Re: [PATCH 7/7] xdiff: make diff3 the default conflictStyle
From: Felipe Contreras <hidden>
Date: 2021-06-11 15:33:43
Sergey Organov wrote:
Junio C Hamano [off-list ref] writes:
quoted
I notice that "git merge --help" tells what each part separated by conflict markers mean in both output styles, but does not make a specific recommendation as to which one to use in what situation, and it might benefit a few additional sentences to help readers based on what you said, i.e. the "RCS merge" style that hides the original is succinct and easier to work with when you are familiar with what both sides did, while a more verbose "diff3" style helps when you are unfamiliar with what one side (or both sides) did.I don't get it. Once you have diff3 output, and you want something simpler, you just kill the inner section, right? RCS merge output style is simply inferior.
The issue here is not a mere inner section, it's a nested inner section due to a recursive merge. Personally I've never encountered these in real life, but you can trigger them with the following synthetic example, and the output with diff3 is:
--- a/content
+++ b/content@@@ -1,1 -1,1 +1,13 @@@ ++<<<<<<< HEAD +D ++||||||| merged common ancestors ++<<<<<<<<< Temporary merge branch 1 ++B ++||||||||| 2c9519d ++1 ++========= ++A ++>>>>>>>>> Temporary merge branch 2 ++======= + C ++>>>>>>> C While with merge is:
--- a/content
+++ b/content@@@ -1,1 -1,1 +1,5 @@@ ++<<<<<<< HEAD +D ++======= + C ++>>>>>>> C I don't see why diff3 triggers the output of this temporary merge, that is a bug in my book. I would expect the output to simply be:
--- a/content
+++ b/content@@@ -1,1 -1,1 +1,13 @@@ ++<<<<<<< HEAD +D ++||||||| 2c9519d ++1 ++======= + C ++>>>>>>> C Cheers. git init repo && cd repo && echo 1 > content && git add content && git commit -m 1 content && git checkout -b A master && echo A > content && git commit -m A content && git checkout -b B master && echo B > content && git commit -m B content && git checkout -b C A && git rev-parse B >.git/MERGE_HEAD && echo C > content && git commit -m C -a && git checkout -b D A && git rev-parse B >.git/MERGE_HEAD && echo D > content && git commit -m D -a && git -c merge.conflictstyle=diff3 merge -m final C && cat content -- Felipe Contreras