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

Re: [PATCH/RFC] rebase -p: do not redo the merge, but cherry-pick first-parent changes

From
Junio C Hamano <gitster@pobox.com>
Date
May 23, 2012, 18:53 UTC
Message-ID
<7vzk8yzq35.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAOeW2eE9EW3gER7ZDThGABtZ0doNuUb70DnKrnzD+OeWYLO7cQ@mail.gmail.com>
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:
Show 13 quoted lines
> On Mon, May 21, 2012 at 1:19 PM, Johannes Sixt <j6t@kdbg.org> wrote:
>> Replace the 'git merge' by a cherry-pick that picks the changes that the
>> merge introduces with respect to the first parent.
>
> Just a reminder of what I said in [1] (the same thread that you referenced):
>
> I think this will break "git rebase -p --onto g b f" on  the below history.
>
>           .-e-.
>          /     \
>       .-c---d---f
>      /
> a---b---g
... where the replayed history would look like this:
                  .-e'.
                 /     \
    a---b---g---c'--d'--f'

and e' and e, even though being "moral equivalent", may have different degrees of change since c' and c respectively depending on how changes between b and c and changes between b and g are related to each other.

If the change in the dag b..f does not have much to do with the change between b and g, then the change from c to e would be the same as the change from c' to e', and if the original merge at f resolved conflicts between e and d (or added an evil change), replaying the difference from e to f on top of e' may give a better result.

I think your original point was that the above clean picture would not hold if e-b and g-b has interactions. g-b may contain some change that e-b has independently done, in which case e'-g would be made smaller than e-b when the conflict is resolved while replaying e to produce e' on top of c' (the same applies if you replace e with any commit in the dag "rev-list ^b e d"). The merge to produce f' may result in conflicts, whether you merge e' and d' or replay f-e on top of e'.

A better way to keep potential "evil merges" at f while replaying to produce f' may *not* be by applying the difference f-e on top of e'. Instead, you can learn from what 'rerere' does. That is, to attempt a mechanical merge between e and d and call the result (with possible conflict markers and all) pre-f. If you compare pre-f and f, that is the resolution and evil change made at f. When reproducing f', mechanically merge e' and d', call the result (again, with possible conflict markers and all) pre-f', and try reproducing f' by a 3-way merge between pre-f, pre-f' and f.

Previous: Martin von ZweigbergkNext: Martin von Zweigbergk
Message 6 of 16 in “rebase -p: do not redo the merge, but cherry-pick first-parent changes”
  1. rebase -p: do not redo the merge, but cherry-pick first-parent changesJohannes Sixt, May 21, 2012
  2. Junio C HamanoMay 22, 2012
  3. Johannes SixtMay 22, 2012
  4. Jonathan NiederMay 22, 2012
  5. Martin von ZweigbergkMay 23, 2012
  6. Junio C HamanoMay 23, 2012
  7. Martin von ZweigbergkMay 23, 2012
  8. Junio C HamanoMay 24, 2012
  9. Martin von ZweigbergkMay 24, 2012
  10. Junio C HamanoMay 24, 2012
  11. Johannes SixtMay 24, 2012
  12. Junio C HamanoMay 24, 2012
  13. Johannes SixtMay 25, 2012
  14. Junio C HamanoMay 25, 2012
  15. Johannes SixtMay 25, 2012
  16. Johannes SixtMay 23, 2012

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.