From 8acbfe348f8e3732f3dddc1e1e40eace121e1eec Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Wed, 7 Aug 2024 14:26:18 -0700 Subject: [PATCH] Show simple conflicts simply --- cli/src/diff_util.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cli/src/diff_util.rs b/cli/src/diff_util.rs index 517181a2df..22167e92c3 100644 --- a/cli/src/diff_util.rs +++ b/cli/src/diff_util.rs @@ -1043,6 +1043,27 @@ fn show_structured_conflict_diff_hunks( text = BString::new(print_context(formatter, text.into(), false)?); } last_hunk_unmodified_text = Some(Some(text.into())); + } else if let [DiffExplanationAtom::ChangedConflictAdd { + left_version, + right_version, + }] = explained_hunk.as_slice() + { + // This is a simple diff + if let Some(Some(text)) = last_hunk_unmodified_text { + print_context(formatter, text, true)?; + } + last_hunk_unmodified_text = Some(None); + // TODO: These headers would not be necessary if we could indent both the + // context before the diff *and* the context after by a space. + writeln!( + formatter.labeled("hunk_header"), + "<<<<<<<<<<<<< Unconflicted diff BEGIN" + )?; + show_diff(formatter, left_version, right_version)?; + writeln!( + formatter.labeled("hunk_header"), + ">>>>>>>>>>>>> Unconflicted diff END" + )?; } else { if let Some(Some(text)) = last_hunk_unmodified_text { print_context(formatter, text, true)?;