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

Re: subtree merges lose prefix after rebase

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 1, 2012, 18:30 UTC
Message-ID
<7vboognph1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CALtv3HqtdUrRaGWvrwo89r3y1RQ4wy1Bzt5=RhQHaJTXS3gk9A@mail.gmail.com>
Zakaria ElQotbi <zakaria@elqotbi.com> writes:
Show 15 quoted lines
> why subtree merges lose prefix after an interactive rebase, is it a known
> issue ? or I'am missing somethings:
> ...
> $ git rebase -i -p a6d4e8e # this the hash of "merge b" commit
> $ git commit --amend -m "merge b edit"
> $ git rebase --continue
> $ tree
> .
> |-- C
> |-- projects
> |   |-- a
> |   |   `-- A
> |   `-- b
> |       `-- B
> `-- README

Rebase essentially is a stepwise cherry-pick, and cherry-pick does not see anything but the trees recorded in the commit being rebased and in its parent.

Your original history is to merge in projects a, b and c in order, renaming them using subtree merge to their own subdirectory. You rebase the commits after the one that merges b, i.e. the merge of project c, in that history. As far as that rebased commit is concerned, the change it makes relative to its parent commit is to add file C at the root level. So you are starting from the state you merged a and b into the whole project, and replaing that commit that adds C at the root level. That matches the above picture.

In short, this is expected, because rebase does not know anything about evil merges made by 'subtree' (or 'ours' for that matter). And I do not think there is any plan to make rebase aware of subtree merges. After all, subtree merge was invented merely as a short-term hack to serve as a stop gap measure until submodule support becomes mature.

Previous: Zakaria ElQotbi
Message 2 of 2 in “subtree merges lose prefix after rebase”
  1. Zakaria ElQotbiMar 1, 2012
  2. Junio C HamanoMar 1, 2012

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.