Re: [PATCH 7/7] xdiff: make diff3 the default conflictStyle

4 messages, 3 authors, 2021-06-11 · open the first message on its own page

Re: [PATCH 7/7] xdiff: make diff3 the default conflictStyle

From: Sergey Organov <hidden>
Date: 2021-06-11 11:52:39

Junio C Hamano [off-list ref] writes:
Johannes Sixt [off-list ref] writes:
quoted
The case that inner conflicts are presented sub-optimally under diff3
remains, though.
I agree that until that happens (necessary but not sufficient
condition), it is premature to recommend diff3 style to be the
default.
Yep. A work-around could be to fix diff3 to rather produce RCS merge
style in such situations?
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.

Thanks,
-- Sergey Organov

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

Re: [PATCH 7/7] xdiff: make diff3 the default conflictStyle

From: Johannes Sixt <hidden>
Date: 2021-06-11 16:41:36

Am 11.06.21 um 13:51 schrieb Sergey Organov:
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.
There is an important case where RCS style is not inferior: When the base is

 123456

then our side makes it

 12ABC56

and their side makes it

 12AXC56

then diff3 must display the conflict as

 12<ABC|34=AXC>56

to be technically correct. RCS style can coalesce A and C outside of the
conflict and display it as

 12A<B=X>C34

and *that* is the helpful part of this simpler style. You encounter
these kinds of conflicts *a lot* when you juggle fixups in a rebase
--interactive session.

The thread mentioned earlier upthread explores whether diff3 can do a
similar simplification.

-- Hannes

Re: [PATCH 7/7] xdiff: make diff3 the default conflictStyle

From: Felipe Contreras <hidden>
Date: 2021-06-11 17:23:19

Johannes Sixt wrote:
then diff3 must display the conflict as

 12<ABC|34=AXC>56

to be technically correct. RCS style can coalesce A and C outside of the
conflict and display it as

 12A<B=X>C34

and *that* is the helpful part of this simpler style.
I have trouble translating the above to what I'm familiar with in my
mind, so...

diff2:

  1
  2
  A
  <<<<<<< l
  B
  =======
  X
  >>>>>>> r
  C
  5
  6

diff3:

  1
  2
  <<<<<<< l
  A
  B
  C
  ||||||| b
  3
  4
  =======
  A
  X
  C
  >>>>>>> r
  5
  6

I personally don't mind at all having a few extra lines in order to
visualize what actually happened.

But of course there's zdiff3:

  1
  2
  A
  <<<<<<< l
  B
  ||||||| b
  3
  4
  =======
  X
  >>>>>>> r
  C
  5
  6

Which is the best of both worlds, even if not technically accurate.

Cheers.

-- 
Felipe Contreras
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help