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

Re: Beyond Merge and Rebase: The Upstream Import Approach in Git

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2023, 20:27 UTC
Message-ID
<xmqqpm4wswny.fsf@gitster.g>
In-Reply-To
<xmqq7cr5uonp.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
>> So I switched to a different scheme instead that I dub "merging rebase".
>> Instead of finishing the rebase with a merge, I start it with that merge.
>> In your example, it would look like this:
>>
>>    o---o---o---o---o  upstream/main
>>         \           \
>>          o---o---o---M---o'---o'---o' main
> ...
>> This strategy is not without problems, though, which becomes quite clear
>> when you accept PRs that are based on commits prior to the most recent
>> merging rebase (or rebasing merge, both strategies suffer from the same
>> problem): the _next_ merging rebase will not necessarily find the most
>> appropriate base commit, in particular when rebasing with
>> `--rebase-merges`, causing unnecessary merge conflicts.

In Git, any commit, be it a single parent commit or a merge, makes this statement:

    I considered all the parents of this commit, and it is my belief
    that it suits the purpose of the branch I am growing better than
    all of them.

This is the foundation of the correctness of three-way merges. Coming from a common ancestor, because M suits the purpose of the branch better than M^1 or M^2, when merging anything forked from M^1 (or M^2) into a decendant of M (say, 'main'), as long as the descendant of M still shares the same purpose of the branch, it does not need to consider what the commits before M^1 (or M^2) did.

M in the "merging rebase", however, claims that M, i.e. the recent upstream, fits the purpose of the branch better than the earlier three commits did, which is not quite right. In contrast, rebasing merge does not have such a problem, i.e.

    o---o---o---o---o  upstream/main
         \           \
          \           a'---b'---c'
           \                     \
            a---b---c-------------M main

The commit c, a parent of M, implemented the features the topic wanted to, and the commit c', another parent of M, implements the same on top of a newer upstream. The tree of M is the same as c' and it matches the purpose, which presumably is to implement whatever (a,b,c) or (a',b',c') wanted to on top of reasonably recent upstream, of the branch.

Anyway, I do not think building on top of M would help from this state, so let's stop seeing if there is a way to make rebasing merge a bit more useful.

Thanks.
Previous: Junio C HamanoNext: Aleksander Korzyński
Message 6 of 9 in “Beyond Merge and Rebase: The Upstream Import Approach in Git”
  1. Aleksander KorzyńskiJul 11, 2023
  2. Junio C HamanoJul 11, 2023
  3. Aleksander KorzyńskiJul 13, 2023
  4. Johannes SchindelinJul 12, 2023
  5. Junio C HamanoJul 12, 2023
  6. Junio C HamanoJul 12, 2023
  7. Aleksander KorzyńskiJul 14, 2023
  8. Aleksander KorzyńskiAug 1, 2023
  9. Aleksander KorzyńskiJul 14, 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.