git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] xdiff: implement a zealous diff3, or "zdiff3"

From
Elijah Newren <newren@gmail.com>
Date
Jun 15, 2021, 18:12 UTC
Message-ID
<CABPp-BHjXf88MQYX8Fd3WGw2WfbMKAdAD-MEViiB7oTtQbfTyw@mail.gmail.com>
In-Reply-To
<60c8758c80e13_e633208f7@natae.notmuch>

On Tue, Jun 15, 2021 at 2:40 AM Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 96 quoted lines
>
> Elijah Newren via GitGitGadget wrote:
> > From: Elijah Newren <newren@gmail.com>
> >
> > "zdiff3" is identical to ordinary diff3 except that it allows compaction
> > of common lines on the two sides of history at the beginning or end of
> > the conflict hunk.
>
> That was not the main reason behind zdiff3.
>
> The whole point of zdiff3 was to have something closer to the "merge"
> style, even if not technically correct.
>
> Your proposal is better than diff3 in that respect, but worse than Uwe's
> zdiff3.
>
> If you have this:
>
>   l  b  r
>   =  =  =
>   A  A  A
>
>   B     b
>   C     C
>   D     D
>   E     E
>   F     F
>   I     i
>
> merge will output this:
>
>   A
>
>   <<<<<<< l
>   B
>   =======
>   b
>   >>>>>>> r
>   C
>   D
>   E
>   F
>   <<<<<<< l
>   I
>   =======
>   i
>   >>>>>>> r
>
> This is simple, and useful.
>
> diff3 will output this:
>
>   A
>   <<<<<<< l
>
>   B
>   C
>   D
>   E
>   F
>   I
>   ||||||| b
>   =======
>
>   b
>   C
>   D
>   E
>   F
>   i
>   >>>>>>> r
>
> Not very friendly.
>
> Your zdiff3:
>
>   A
>
>   <<<<<<< l
>   B
>   C
>   D
>   E
>   F
>   I
>   ||||||| b
>   =======
>   b
>   C
>   D
>   E
>   F
>   i
>   >>>>>>> r
>
> Just marginally better.

Your example here is one where diff3 has no original text in the conflicted region. Empty text is trivially easy to split, making it a somewhat uninteresting testcase for zdiff3. The interesting question is what do you do when that region is non-empty? When it's non-empty, it's not going to match the two sides (i.e. it won't have "C D E F" lines for your example) -- we know that because when the original also matches the two sides, the xdiff code will start with multiple separate conflicts instead of one big one. So, in such a case, do you still decide to split the conflict regions, and if so, how do you split the non-matching original text?

Previous: Felipe ContrerasNext: Sergey Organov
Message 5 of 39 in “RFC: implement new zdiff3 conflict style”
  1. 0/2 RFC: implement new zdiff3 conflict styleElijah Newren via GitGitGadget, Jun 15, 2021
  2. 1/2 xdiff: implement a zealous diff3, or "zdiff3"Elijah Newren via GitGitGadget, Jun 15, 2021
  3. Junio C HamanoJun 15, 2021
  4. Felipe ContrerasJun 15, 2021
  5. Elijah NewrenJun 15, 2021
  6. Sergey OrganovJun 15, 2021
  7. 2/2 update documentation for new zdiff3 conflictStyleElijah Newren via GitGitGadget, Jun 15, 2021
  8. Junio C HamanoJun 15, 2021
  9. Jeff KingJun 15, 2021
  10. Elijah NewrenJun 15, 2021
  11. Phillip WoodJun 16, 2021
  12. Jeff KingJun 16, 2021
  13. Phillip WoodJun 23, 2021
  14. Jeff KingJun 23, 2021
  15. Elijah NewrenJun 17, 2021
  16. Johannes SixtJun 15, 2021
  17. Elijah NewrenJun 15, 2021
  18. Johannes SixtJun 16, 2021
  19. Elijah NewrenJun 16, 2021
  20. 0/2 RFC: implement new zdiff3 conflict styleElijah Newren via GitGitGadget, Sep 11, 2021
  21. 1/2 xdiff: implement a zealous diff3, or "zdiff3"Elijah Newren via GitGitGadget, Sep 11, 2021
  22. Phillip WoodSep 15, 2021
  23. Phillip WoodSep 15, 2021
  24. Elijah NewrenSep 18, 2021
  25. Phillip WoodSep 24, 2021
  26. Elijah NewrenSep 18, 2021
  27. Phillip WoodSep 24, 2021
  28. 2/2 update documentation for new zdiff3 conflictStyleElijah Newren via GitGitGadget, Sep 11, 2021
  29. 0/2 RFC: implement new zdiff3 conflict styleElijah Newren via GitGitGadget, Sep 18, 2021
  30. 1/2 xdiff: implement a zealous diff3, or "zdiff3"Elijah Newren via GitGitGadget, Sep 18, 2021
  31. 2/2 update documentation for new zdiff3 conflictStyleElijah Newren via GitGitGadget, Sep 18, 2021
  32. 0/2 Implement new zdiff3 conflict styleElijah Newren via GitGitGadget, Nov 16, 2021
  33. 1/2 xdiff: implement a zealous diff3, or "zdiff3"Phillip Wood via GitGitGadget, Nov 16, 2021
  34. 2/2 update documentation for new zdiff3 conflictStyleElijah Newren via GitGitGadget, Nov 16, 2021
  35. 0/2 Implement new zdiff3 conflict styleElijah Newren via GitGitGadget, Dec 1, 2021
  36. 1/2 xdiff: implement a zealous diff3, or "zdiff3"Phillip Wood via GitGitGadget, Dec 1, 2021
  37. 2/2 update documentation for new zdiff3 conflictStyleElijah Newren via GitGitGadget, Dec 1, 2021
  38. Bagas SanjayaDec 2, 2021
  39. Eric SunshineDec 2, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.