{"thread":{"id":"29796","subject":"subtree merges lose prefix after rebase","startedAt":"2012-03-01T15:18:14Z","lastAt":"2012-03-01T18:30:34Z","messageCount":2,"participants":["Zakaria ElQotbi","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"185820","messageId":"CALtv3HqtdUrRaGWvrwo89r3y1RQ4wy1Bzt5=RhQHaJTXS3gk9A@mail.gmail.com","threadId":"29796","inReplyTo":"CALtv3HphaC7d0QyR1DUowHn0Wrmrsw4YGyU4rE8YzhZX3ea6dA@mail.gmail.com","subject":"subtree merges lose prefix after rebase","fromName":"Zakaria ElQotbi","fromEmail":"zakaria@elqotbi.com","sentAt":"2012-03-01T15:18:14Z","receivedAt":"2012-03-01T15:18:14Z","isPatch":false,"sender":{"key":"zakaria@elqotbi.com","avatar":null},"body":"Hi, folks!\nwhy subtree merges lose prefix after an interactive rebase, is it a known\nissue ? or I'am missing somethings:\n\n$ for project in a b c ; do\n    mkdir $project\n    ( cd $project ; git init; touch ${project^} ; git add ${project^}\n; git commit -m \"add ${project^}\" )\n   done\n$ tree\n.\n|-- a\n|   `-- A\n|-- b\n|   `-- B\n`-- c\n    `-- C\n\n$ mkdir tree && cd tree && git init\n$ touch README && git add README && git commit -m \"add readme\"\n$ for project in a b c ; do\n  mkdir -p projects/$project\n  git remote add -f $project ../$project\n  git merge -s ours --no-commit $project/master\n  git read-tree --prefix=projects/$project -u $project/master\n  git commit -m \"merge $project into tree\"\n  git pull -s subtree $project master\n done\n\n$ tree\n.\n|-- projects\n|   |-- a\n|   |   `-- A\n|   |-- b\n|   |   `-- B\n|   `-- c\n|       `-- C\n`-- README\n\n$ git rebase -i -p a6d4e8e # this the hash of \"merge b\" commit\n$ git commit --amend -m \"merge b edit\"\n$ git rebase --continue\n$ tree\n.\n|-- C\n|-- projects\n|   |-- a\n|   |   `-- A\n|   `-- b\n|       `-- B\n`-- README\n\n\nBest regards\n--\nZakaria ElQotbi\n4096R/3DC2241A\n\n\"The secret of creativity is knowing how to hide your sources.\"\n        - Albert Einstein\n"},{"id":"185836","messageId":"7vboognph1.fsf@alter.siamese.dyndns.org","threadId":"29796","inReplyTo":"CALtv3HqtdUrRaGWvrwo89r3y1RQ4wy1Bzt5=RhQHaJTXS3gk9A@mail.gmail.com","subject":"Re: subtree merges lose prefix after rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-01T18:30:34Z","receivedAt":"2012-03-01T18:30:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Zakaria ElQotbi <zakaria@elqotbi.com> writes:\n\n> why subtree merges lose prefix after an interactive rebase, is it a known\n> issue ? or I'am missing somethings:\n> ...\n> $ git rebase -i -p a6d4e8e # this the hash of \"merge b\" commit\n> $ git commit --amend -m \"merge b edit\"\n> $ git rebase --continue\n> $ tree\n> .\n> |-- C\n> |-- projects\n> |   |-- a\n> |   |   `-- A\n> |   `-- b\n> |       `-- B\n> `-- README\n\nRebase essentially is a stepwise cherry-pick, and cherry-pick does not see\nanything but the trees recorded in the commit being rebased and in its\nparent.\n\nYour original history is to merge in projects a, b and c in order,\nrenaming them using subtree merge to their own subdirectory.  You rebase\nthe commits after the one that merges b, i.e. the merge of project c, in\nthat history.  As far as that rebased commit is concerned, the change it\nmakes relative to its parent commit is to add file C at the root level.\nSo you are starting from the state you merged a and b into the whole\nproject, and replaing that commit that adds C at the root level.  That\nmatches the above picture.\n\nIn short, this is expected, because rebase does not know anything about\nevil merges made by 'subtree' (or 'ours' for that matter).  And I do not\nthink there is any plan to make rebase aware of subtree merges.  After\nall, subtree merge was invented merely as a short-term hack to serve as a\nstop gap measure until submodule support becomes mature.\n"}]}