From fb3f8b3bd3aecf46816e8d8d6dc31cbc62a10719 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Tue, 6 Jun 2023 15:35:05 -0700 Subject: [PATCH] merge_tools: check complexity of conflict before reading content We can know before we read the content if the conflict is too complex for a merge tool to resolve. --- src/merge_tools.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/merge_tools.rs b/src/merge_tools.rs index 56155c2cb..d85009a73 100644 --- a/src/merge_tools.rs +++ b/src/merge_tools.rs @@ -173,14 +173,14 @@ pub fn run_mergetool( )); } }; - let mut content = extract_file_conflict_as_single_hunk(tree.store(), repo_path, &file_conflict); // We only support conflicts with 2 sides (3-way conflicts) - if content.adds.len() > 2 { + if file_conflict.adds().len() > 2 { return Err(ConflictResolveError::ConflictTooComplicatedError { path: repo_path.clone(), - sides: content.adds.len(), + sides: file_conflict.adds().len(), }); }; + let mut content = extract_file_conflict_as_single_hunk(tree.store(), repo_path, &file_conflict); let editor = get_merge_tool_from_settings(ui, settings)?; let initial_output_content: Vec = if editor.merge_tool_edits_conflict_markers {