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 16, 2015, 22:17 UTC
Message-ID
<20151216221716.GD1581@serenity.lan>
In-Reply-To
<877fkf9j5h.fsf@waller.obbligato.org>
On Tue, Dec 15, 2015 at 09:17:30PM -0600, David A. Greene wrote:
Show 19 quoted lines
> According to the rebase man page, rebase gathers commits as in "git log
> <upstream>..HEAD."  However, that is not what happens in the tests
> below.  Some of the commits disappear.
> 
> The test basically does this:
> 
> - Setup a master project and a subproject, merged via a subtree-like
>   merge (this is how git-subtree does it).
> 
> - Add some commits to the subproject directory after the subtree merge,
>   to create some history not in the original subproject.
> 
> - filter-branch --subdirectory-filter to extract commits from the
>   subproject directory.
> 
> - Rebase those commits back on to the original subproject repository.
> 
> The above loses all commits made after the subproject is merged into
> the main project.
[snip]
Show 6 quoted lines
> # Does not preserve master4 and master5.
> test_expect_success 'Rebase default' '
> 	git checkout -b rebase-default master &&
> 	git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
> 	git commit -m "Empty commit" --allow-empty &&
> 	git rebase -Xsubtree=files_subtree  --preserve-merges --onto files-master master &&

It seems that the problem is introduces by --preserve-merges (and -Xsubtree causes something interesting to happen as well). I see the following behaviour:

git rebase --onto files-master master
	Works (master4 and master5 preserved).
git rebase --preserve-merges --onto files-master master
	Behaves as described above (master4 and master5 are lost).
git rebase -Xsubtree=files_subtree --onto files-master master
	fatal: Could not parse object 'b15c4133fc3146e1330c84159886f0f7a09fbf43^'
	Unknown exit code (128) from command: git-merge-recursive b15c4133fc3146e1330c84159886f0f7a09fbf43^ -- HEAD b15c4133fc3146e1330c84159886f0f7a09fbf43 
git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master
	Same as the version with only --preserve-merges.
Previous: David A. GreeneNext: David A. Greene
Message 2 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.