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

Re: [PATCH v2 0/7] Drop support for git rebase --preserve-merges

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Sep 10, 2021, 12:08 UTC
Message-ID
<nycvar.QRO.7.76.6.2109101325410.59@tvgsbejvaqbjf.bet>
In-Reply-To
<CABPp-BFZfa7cchRTycdyMbnwb_f=vHxQYLA5QswuM0ExfxeMAQ@mail.gmail.com>
Hi Elijah,
On Tue, 7 Sep 2021, Elijah Newren wrote:
Show 76 quoted lines
> On Tue, Sep 7, 2021 at 11:51 AM Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> >
> > On Thu, 2 Sep 2021, Johannes Sixt wrote:
> >
> > > Am 02.09.21 um 16:18 schrieb Johannes Schindelin:
> > > > On Wed, 1 Sep 2021, Junio C Hamano wrote:
> > > >> A good goal.  There is no remaining use case where (a fictitious and
> > > >> properly working version of) "--preserve-merges" option cannot be
> > > >> replaced by "--rebase-merges", is it?  I somehow had a feeling that
> > > >> the other Johannes (sorry if it weren't you, j6t) had cases that the
> > > >> former worked better, but perhaps I am mis-remembering things.
> > > >
> > > > I think that I managed to address whatever concerns there were about the
> > > > `--rebase-merges` backend in the meantime.
> > >
> > > That was either my suggestion/desire to make no-rebase-cousins the
> > > default. That has been settled.
> > >
> > > Or my wish not to redo the merge, but to replay the first-parent
> > > difference. The idea never got traction, and I've long since abandoned
> > > my implementation of it.
> >
> > Thank you for clarifying.
> >
> > Yes, I remember how that idea came up, and I even tried that strategy for
> > a couple of merging rebases of Git for Windows' branch thicket. Sadly, it
> > did not work half as well as I had hoped.
> >
> > The best idea I had back then still is in want of being implemented: sort
> > of a "four-way merge". It is basically the same as a three-way merge, but
> > allows for the pre-images to differ in the context (and yes, this cannot
> > be represented using the current conflict markers). Definitely not
> > trivial.
>
> merge-ort opens a new possibility (since it does merges without
> touching the index or working tree): Take the merge commit, M, that
> you are trying to transplant.  Hold on to it for a minute.  Do what
> rebase-merges does now; namely, do a simple merge of the desired new
> branches that otherwise ignores M to get your new merge commit N.
> Hang on to N too for a minute.  Now use merge-ort to auto-remerge M
> (much like AUTO_MERGE or --remerge-diff does) to get a new merge
> commit that we'll call pre-M.  If M was a clean merge that the user
> didn't amend, then pre-M will match M.  If M wasn't a clean merge or
> was amended, then pre-M will otherwise differ from M by not including
> any manual changes the user made when they originally created M --
> such as removing conflict markers, fixing semantic conflicts, evil
> changes, etc.
>
> Now we've got three merge commits: pre-M, M, and N.  (Technically,
> pre-M and N might be toplevel trees rather than full commits, but
> whatever.)  The difference between pre-M and M represent the manual
> work the user did in order to create M.  Now, do a three-way
> (non-recursive) merge of those commits, to get the rebased result, R.
> This operation has the affect of applying the changes from pre-M to M
> on top of N.
>
> There's obviously some edge cases (e.g. nested conflict markers), but
> I think they're better than the edge cases presented by the
> alternatives:
>   * the first-parent difference idea silently discards intermediate
> changes from reapplying other patches (especially if other patches are
> added or dropped), which to me feels _very_ dangerous
>   * the current rebase-merges idea silently discards manual user
> changes within the original merge commit (i.e. it hopes that there is
> no difference between pre-M and M), which can also be lossy
>   * I don't think this idea drops any data, but it does run the risk
> of conflicts that are difficult to understand.  But I suspect less so
> than your five-way merge would entail.
>
> If the difficulty of conflicts in this scheme is too high, we could do
> a few things like providing multiple versions (e.g. if either
> pre-M:file or N:file had conflicts, or maybe if R:file has nested
> conflicts, then place both R:file and N:file in the working tree
> somewhere) or pointing at special commands that help users figure out
> what went on (e.g. 'git log -1 --remerge-diff M -- file').

While I agree that `merge-ort` makes a lot of things much better, I think in this context we need to keep in mind that those nested merge conflicts can really hurt.

In my tests (I tried to implement a strategy where a 3-way merge is done with M and N^, using the parent commits of M as merge parents successively, see https://lore.kernel.org/git/nycvar.QRO.7.76.6.1804130002090.65@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz/ for the nitty gritty), I ran into _nasty_ nested merge conflicts, even with trivial examples. And I came to the conviction that treating the merge conflict markers as Just Another Line was the main culprit.

I wish I had the time to try out your proposed strategy with the conconcted example I presented in that mail I linked above. Because now I am curious what it would do...

Ciao, Dscho

Previous: Elijah NewrenNext: Elijah Newren
Message 52 of 78 in “Drop support for git rebase --preserve-merges”
  1. 0/8 Drop support for git rebase --preserve-mergesJohannes Schindelin via GitGitGadget, Nov 23, 2019
  2. 1/8 t5520: do not use `pull.rebase=preserve`Johannes Schindelin via GitGitGadget, Nov 23, 2019
  3. 2/8 remote: warn about unhandled branch.<name>.rebase valuesJohannes Schindelin via GitGitGadget, Nov 23, 2019
  4. 4/8 pull: remove support for `--rebase=preserve`Johannes Schindelin via GitGitGadget, Nov 23, 2019
  5. 6/8 git-svn: drop support for `--preserve-merges`Johannes Schindelin via GitGitGadget, Nov 23, 2019
  6. Eric WongNov 23, 2019
  7. Johannes SchindelinNov 24, 2019
  8. Eric WongNov 25, 2019
  9. 3/8 tests: stop testing `git rebase --preserve-merges`Johannes Schindelin via GitGitGadget, Nov 23, 2019
  10. 8/8 remote: no longer claim that branch.*.rebase=preserve is a thingJohannes Schindelin via GitGitGadget, Nov 23, 2019
  11. 7/8 rebase: drop the internal `rebase--interactive` commandJohannes Schindelin via GitGitGadget, Nov 23, 2019
  12. 5/8 rebase: drop support for `--preserve-merges`Johannes Schindelin via GitGitGadget, Nov 23, 2019
  13. 0/7 Drop support for git rebase --preserve-mergesJohannes Schindelin via GitGitGadget, Sep 1, 2021
  14. 1/7 t5520: do not use `pull.rebase=preserve`Johannes Schindelin via GitGitGadget, Sep 1, 2021
  15. 2/7 remote: warn about unhandled branch.<name>.rebase valuesJohannes Schindelin via GitGitGadget, Sep 1, 2021
  16. 4/7 pull: remove support for `--rebase=preserve`Johannes Schindelin via GitGitGadget, Sep 1, 2021
  17. 3/7 tests: stop testing `git rebase --preserve-merges`Johannes Schindelin via GitGitGadget, Sep 1, 2021
  18. Ævar Arnfjörð BjarmasonSep 1, 2021
  19. 6/7 git-svn: drop support for `--preserve-merges`Johannes Schindelin via GitGitGadget, Sep 1, 2021
  20. Ævar Arnfjörð BjarmasonSep 1, 2021
  21. Johannes SchindelinSep 2, 2021
  22. Johannes SchindelinSep 2, 2021
  23. 5/7 rebase: drop support for `--preserve-merges`Johannes Schindelin via GitGitGadget, Sep 1, 2021
  24. Ævar Arnfjörð BjarmasonSep 1, 2021
  25. Johannes SchindelinSep 2, 2021
  26. Ævar Arnfjörð BjarmasonSep 2, 2021
  27. Ævar Arnfjörð BjarmasonSep 1, 2021
  28. Johannes SchindelinSep 2, 2021
  29. Ævar Arnfjörð BjarmasonSep 2, 2021
  30. Ævar Arnfjörð BjarmasonSep 2, 2021
  31. Ævar Arnfjörð BjarmasonSep 2, 2021
  32. Ævar Arnfjörð BjarmasonSep 2, 2021
  33. Ævar Arnfjörð BjarmasonSep 2, 2021
  34. Johannes SchindelinSep 4, 2021
  35. Ævar Arnfjörð BjarmasonSep 5, 2021
  36. Junio C HamanoSep 5, 2021
  37. Phillip WoodSep 6, 2021
  38. Johannes SchindelinSep 7, 2021
  39. Phillip WoodSep 7, 2021
  40. Johannes SchindelinSep 7, 2021
  41. 7/7 rebase: drop the internal `rebase--interactive` commandJohannes Schindelin via GitGitGadget, Sep 1, 2021
  42. Phillip WoodSep 6, 2021
  43. Johannes SchindelinSep 7, 2021
  44. Ævar Arnfjörð BjarmasonSep 1, 2021
  45. Johannes SchindelinSep 2, 2021
  46. Ævar Arnfjörð BjarmasonSep 2, 2021
  47. Junio C HamanoSep 1, 2021
  48. Johannes SchindelinSep 2, 2021
  49. Johannes SixtSep 2, 2021
  50. Johannes SchindelinSep 7, 2021
  51. Elijah NewrenSep 7, 2021
  52. Johannes SchindelinSep 10, 2021
  53. Elijah NewrenSep 10, 2021
  54. merge-ort and --rebase-merges, was Re: [PATCH v2 0/7] Drop support for git rebase --preserve-mergesJohannes Schindelin, Sep 13, 2021
  55. Elijah NewrenSep 13, 2021
  56. Ævar Arnfjörð BjarmasonSep 6, 2021
  57. Junio C HamanoSep 7, 2021
  58. Ævar Arnfjörð BjarmasonSep 7, 2021
  59. Alban GruinSep 4, 2021
  60. Phillip WoodSep 6, 2021
  61. Johannes SchindelinSep 7, 2021
  62. 00/11 Drop support for git rebase --preserve-mergesJohannes Schindelin via GitGitGadget, Sep 7, 2021
  63. 01/11 t5520: do not use `pull.rebase=preserve`Johannes Schindelin via GitGitGadget, Sep 7, 2021
  64. 02/11 remote: warn about unhandled branch.<name>.rebase valuesJohannes Schindelin via GitGitGadget, Sep 7, 2021
  65. 03/11 tests: stop testing `git rebase --preserve-merges`Johannes Schindelin via GitGitGadget, Sep 7, 2021
  66. 04/11 pull: remove support for `--rebase=preserve`Johannes Schindelin via GitGitGadget, Sep 7, 2021
  67. 06/11 git-svn: drop support for `--preserve-merges`Johannes Schindelin via GitGitGadget, Sep 7, 2021
  68. 05/11 rebase: drop support for `--preserve-merges`Johannes Schindelin via GitGitGadget, Sep 7, 2021
  69. Ævar Arnfjörð BjarmasonSep 10, 2021
  70. re-mentioning --preserve-merges in the docs (was: [PATCH v3 05/11] rebase: drop support for `--preserve-merges`)Ævar Arnfjörð Bjarmason, Jul 21, 2022
  71. Junio C HamanoJul 21, 2022
  72. Johannes SchindelinJul 29, 2022
  73. 07/11 rebase: drop the internal `rebase--interactive` commandJohannes Schindelin via GitGitGadget, Sep 7, 2021
  74. 08/11 rebase: remove obsolete code commentJohannes Schindelin via GitGitGadget, Sep 7, 2021
  75. 09/11 rebase: stop mentioning the -p option in commentsJohannes Schindelin via GitGitGadget, Sep 7, 2021
  76. 10/11 rebase: remove a no-longer-used functionJohannes Schindelin via GitGitGadget, Sep 7, 2021
  77. 11/11 sequencer: restrict scope of a formerly public functionJohannes Schindelin via GitGitGadget, Sep 7, 2021
  78. Ævar Arnfjörð BjarmasonSep 8, 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.