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

Re: Newbie question regarding 3way merge order.

From
Nanako Shiraishi <nanako3@lavabit.com>
Date
Jan 31, 2009, 21:45 UTC
Message-ID
<20090201064543.6117@nanako3.lavabit.com>
In-Reply-To
<87myd7bo8f.fsf@gigli.quasi.internal>
Quoting "Raimund Berger" <raimund.berger@gmail.com> writes:
> I'm myself, especially since a conflicting rebase leaves the index in an
> "unmerged" state. Much like a regular merge does. It's still all
> assumptions though, or maybe I'm missing documentation .... (?)

The rebase command you run with neither -m nor -i option replays your work on top of the upstream by running git-am with the --3way option.

This commit introduced the feature.
commit 7f59dbbb8f8d479c1d31453eac06ec765436a780
Author: Junio C Hamano <junkio@cox.net>
Date:   Mon Nov 14 00:41:53 2005 -0800
    Rewrite rebase to use git-format-patch piped to git-am.
    
    The current rebase implementation finds commits in our tree but
    not in the upstream tree using git-cherry, and tries to apply
    them using git-cherry-pick (i.e. always use 3-way) one by one.
    
    Which is fine, but when some of the changes do not apply
    cleanly, it punts, and punts badly.
    [omitting the rest]

The message talks about what was wrong with the original, what benefit it gives the users, and how to use it, but it doesn't discuss how the magic works in detail.

Junio much later describes how it works, taking a real-world example in this message:

http://thread.gmane.org/gmane.comp.version-control.git/46569/focus=46609

In short, it works by applying your changes as patches but when a patch doesn't apply it falls back to a simplified three-way merge.

http://thread.gmane.org/gmane.comp.version-control.git/100579/focus=100602

I think Junio misremembered the history in his last message in the thread. He says that rebase was originally a format-patch piped to am, but before the commit 7f59dbbb8f8d479c1d31453eac06ec765436a780 it was done by a series of cherry-pick.

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
Previous: Raimund BergerNext: Raimund Berger
Message 7 of 16 in “Newbie question regarding 3way merge order.”
  1. Raimund BergerJan 29, 2009
  2. Raimund BergerJan 30, 2009
  3. Sitaram ChamartyJan 30, 2009
  4. Raimund BergerJan 30, 2009
  5. Sitaram ChamartyJan 31, 2009
  6. Raimund BergerJan 31, 2009
  7. Nanako ShiraishiJan 31, 2009
  8. Raimund BergerFeb 1, 2009
  9. Junio C HamanoFeb 1, 2009
  10. Sitaram ChamartyFeb 2, 2009
  11. Raimund BergerFeb 2, 2009
  12. Johannes SixtFeb 2, 2009
  13. Raimund BergerFeb 2, 2009
  14. Johannes SixtFeb 3, 2009
  15. Nanako ShiraishiJan 31, 2009
  16. Raimund BergerJan 31, 2009

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.