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

Re: Odd rebase behavior

From
John Keeping <john@keeping.me.uk>
Date
Dec 19, 2015, 16:09 UTC
Message-ID
<20151219160906.GB14056@serenity.lan>
In-Reply-To
<20151218180549.GA14056@serenity.lan>
On Fri, Dec 18, 2015 at 06:05:49PM +0000, John Keeping wrote:
Show 16 quoted lines
> On Fri, Dec 18, 2015 at 11:43:16AM -0600, David A. Greene wrote:
> > John Keeping <john@keeping.me.uk> writes:
> > 
> > > It seems that the problem is introduces by --preserve-merges (and
> > > -Xsubtree causes something interesting to happen as well).  I see the
> > > following behaviour:
> > 
> > Thanks for narrowing this down!  Is it possible this is actually a
> > cherry-pick problem since --preserve-merges forces rebase to use
> > cherry-pick?
> 
> I'm pretty sure this a result of the code in git-rebase--interactive.sh
> just below the comment "Watch for commits that have been dropped by
> cherry-pick", which filters out certain commits.  However, I'm not at
> all familiar with the --preserve-merges code in git-rebase so I could be
> completely wrong.

I've traced through git-rebase--interactive.sh and I can see what's happening here now. The problematic code is around the handling of the "rewritten" directory.

In --preserve-merges mode, we write the SHA1 of the "onto" commit into rewritten and then add any commits descended from it along the first-parent path that we have identified as candidates for being rebased. This allows us to identify commits that have been merged in and remove them from the rebase instruction list.

Because the right-hand commit in this case is disjoint from "onto", we end up dropping everything at this point. The --root option fixes this because instead of preserving just "onto", it adds all of the commits given by:

	git merge-base --all $orig_head $upstream

Since the disjoint history causes the root commit to be rewritten, I think requiring --root for this case to work is reasonable. However, I'm not sure we should add it automatically. It may be better to detect that there is no common history and die if --root has not been given.

Previous: Johannes Sixt
Message 6 of 6 in “Odd rebase behavior”
  1. David A. GreeneDec 16, 2015
  2. John KeepingDec 16, 2015
  3. David A. GreeneDec 18, 2015
  4. John KeepingDec 18, 2015
  5. Johannes SixtDec 18, 2015
  6. John KeepingDec 19, 2015

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.