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

Re: [PATCH] pull: conflict hint pull.rebase suggestion should offer "merges" vs "true"

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Feb 20, 2023, 16:45 UTC
Message-ID
<55818a65-046d-4f96-312b-1b5cae6e210f@dunelm.org.uk>
In-Reply-To
<CAPMMpogi_QoGKD824JW+85v_Sgaf5d3TAd_P55YyT5NF6AUJ=w@mail.gmail.com>
Hi Tao
On 20/02/2023 08:03, Tao Klerks wrote:
Show 33 quoted lines
> On Sat, Feb 18, 2023 at 5:39 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
>>
>> On 18/02/2023 03:17, Elijah Newren wrote:
>>>
>>> One concern I have is that "--rebase-merges" itself has negative user
>>> surprises in store.  In particular, "--rebase-merges", despite its
>>> name, does not rebase merges.  It uses the existing author & commit
>>> message info, but otherwise just discards the existing merge and
>>> creates a new one.  Any information it contained about fixing
>>> conflicts, or making adjustments to make the two branches work
>>> together, is summarily and silently discarded.
>>
>> That's a good point. Another potentially surprising behavior is that
>> when I'm rebasing an integration branch with -rno-rebase-cousins then if
>> one of the topic branches merged into the integration branch happens to
>> share the same base as the integration branch itself the topic branch
>> gets rebased as well.
> 
> I've been trying to understand how this behavior is (potentially)
> surprising - I imagine it's been discussed elsewhere but I'm having a
> hard time understanding, sorry.
> 
> The situation you described is a boundary condition between two others, right?
> * The topic branch could be branched from the integration branch
> (potentially *after* some other change were made to the integration
> branch, but not in this case) - in which case rebasing is what you
> would expect
> * The topic branch could be branched from the main branch (potentially
> *before* the integration branch branched, but not in this case) - in
> which case not rebasing is what you would expect.
> 
> If topic branched from main (at around the same time as integration),
> it might be surprising that it rebases;

Yes that's what I was referring to, on the one hand it isn't surprising at all because both the topic and integration branch have the same base but on the other hand using no-rebase-cousins is supposed to stop the topic branches being rebased.

> if it branched from
> integration (before that had any changes), then it is expected.
Yes
Show 12 quoted lines
>> -rno-rebase-cousins is also slower that it needs
>> to be because it creates a todo list that contains all the commits on
>> the topic branches merged into the integration branch rather than just
>> the merges. The commits on the topic branches are fast-forwarded rather
>> than rewritten so long as they don't share the same base as the
>> integration branch but it noticeably slower than using a todo list with
>> just the merge commands.
> 
> This seems improvable, but no worse than a plain legacy rebase (as
> Alex's new patch would have it, "rebase-merges=drop"), right? Insofar
> as we're discussing why it might make sense to avoid promoting this
> over a plain rebase, I don't understand the concern.

My concern is to have a good understanding of the issues around --rebase-merges before we start promoting it over a plain rebase. It is not a reason not to make the change but it does show --rebase-merges would benefit from some additional polish.

Show 23 quoted lines
>>> My personal opinion would be adding such a capability should be step
>>> 2.5 in your list, though I suspect that would make Tao unhappy (it's a
>>> non-trivial amount of work, unlike the other steps in your list).
>>
>> I've got a couple of patches[1] that cherry-pick the merge if only one
>> of the parents has changed. I've never tried upstreaming them as it is
>> only a partial solution to the problem of rebasing merges but that
>> approach should work well with "git pull --rebase=merges" as only the
>> upstream side will have changed (when rebasing my git integration branch
>> with that patch the merges are cherry-picked). They might make a useful
>> starting point if anyone wants to try and improve the rebasing of merges.
>>
> 
> This is awesome!
> 
> It feels like the first step towards the general strategy that was (I
> believe) best described by Buga at
> https://public-inbox.org/git/a0cc88d2-bfed-ce7b-1b3f-3c447d2b32da@gmail.com/
> !
> 
> (unless I'm missing something, the result of this is exactly the same
> as the result of that strategy, in these "simple" cases where it kicks
> in)
Yes
> The one concern I have with this is that, *if I understand correctly*,
> it sometimes throws away the existing merge information, and sometimes
> doesn't, and there's no easy way to know which it is at runtime.
Right, there are two ways the existing merge can be thrown away.
  (i) The existing merge has conflicts when being cherry picked
      and so we redo the merge (that is a choice, we could present
      the user with the conflicts from the cherry-pick). It is
      possible that the merge succeeds where the cherry-pick failed
      but most of the time we'd stop because if the cherry-pick has
      conflicts the merge will probably have conflicts as well.
(ii) More than one parent has changed and so we redo the merge
> Would
> adding a warning on stderr when a both-parents merge is encountered
> (and any merge resolutions or related changes are still discarded) be
> enough to make this shippable?

I'm not sure. It works well enough for what I use it for (which is essentially "git pull --rebase") but sometimes cherry-picking and sometimes remerging does make it more complicated for users. If we printed a warning what is the user going to do? An experienced user can use the reflog to get back to the original state and redo the rebase with some break statements added in to let them fix up the merges. A less experienced user is going to think git lost their work.

> Are there *any* circumstances where the new cherry-picking behavior
> introduced here wouldn't be the right thing to have happen?
Not that I can think of
Best Wishes
Phillip
Previous: Tao KlerksNext: Elijah Newren
Message 11 of 34 in “pull: conflict hint pull.rebase suggestion should offer "merges" vs "true"”
  1. pull: conflict hint pull.rebase suggestion should offer "merges" vs "true"Tao Klerks via GitGitGadget, Feb 5, 2023
  2. Alex HenrieFeb 16, 2023
  3. Tao KlerksFeb 16, 2023
  4. Alex HenrieFeb 17, 2023
  5. Tao KlerksFeb 17, 2023
  6. Alex HenrieFeb 17, 2023
  7. Junio C HamanoFeb 17, 2023
  8. Elijah NewrenFeb 18, 2023
  9. Phillip WoodFeb 18, 2023
  10. Tao KlerksFeb 20, 2023
  11. Phillip WoodFeb 20, 2023
  12. Elijah NewrenFeb 20, 2023
  13. Tao KlerksFeb 21, 2023
  14. Sergey OrganovFeb 22, 2023
  15. Elijah NewrenFeb 24, 2023
  16. Sergey OrganovFeb 24, 2023
  17. Elijah NewrenFeb 24, 2023
  18. Sergey OrganovFeb 25, 2023
  19. Elijah NewrenFeb 25, 2023
  20. Sergey OrganovFeb 26, 2023
  21. Elijah NewrenFeb 27, 2023
  22. Sergey OrganovFeb 27, 2023
  23. Elijah NewrenFeb 28, 2023
  24. Elijah NewrenFeb 20, 2023
  25. Tao KlerksFeb 20, 2023
  26. Elijah NewrenFeb 20, 2023
  27. Alex HenrieFeb 20, 2023
  28. Tao KlerksFeb 21, 2023
  29. Alex HenrieFeb 21, 2023
  30. Tao KlerksFeb 21, 2023
  31. Elijah NewrenFeb 24, 2023
  32. Felipe ContrerasFeb 28, 2023
  33. Alex HenrieFeb 28, 2023
  34. Felipe ContrerasMar 1, 2023

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.