{"thread":{"id":"25488","subject":"git rebase and merge commits","startedAt":"2010-10-20T16:45:45Z","lastAt":"2010-10-25T11:23:47Z","messageCount":5,"participants":["Dominique Quatravaux","Jonathan Nieder","Joshua Jensen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"153874","messageId":"AANLkTikroNPehcyBsueCnJ5hR0idd3cBP4m1KNccdRqL@mail.gmail.com","threadId":"25488","inReplyTo":null,"subject":"git rebase and merge commits","fromName":"Dominique Quatravaux","fromEmail":"domq@google.com","sentAt":"2010-10-20T16:45:45Z","receivedAt":"2010-10-20T16:45:45Z","isPatch":false,"sender":{"key":"domq@google.com","avatar":"https://gravatar.com/avatar/121b20f85f75e3366ecd70be7f2777189ed53d0cc5472531cde13e4ed9e4f61e?d=mp&s=160"},"body":"Hi all, I'm trying to write \"git shove\", a wrapper around git rebase\n--interactive that would turn this\n\n\n#        A---B---C---K targetbranch\n#       /         \\\n#  D---E---F---G---H---I--J srcbranch\n\ninto this:\n\n#   A---B---C---I'---K'  targetbranch\n#  /             \\\n# D---E---F---G---H'---J' srcbranch\n#\n\n(ie I has been shoved into targetbranch).\n\nIt seemed to me that the first step should be to simply rebase I, H, and J (in\nthis order) onto C. Unfortunately git rebase --interactive -p C proposes a\ngit-rebase-todo that contains only \"noop\"; if I forcefully put this instead,\n\nedit iiii I\nedit hhhh H\nedit jjjj J\n\nit seems to me that the HEAD jumps backward to the original H on the second\nrebase step, instead of daisy-chaining H behind I.  This is with git 1.7.3.1.\n\nHere are the outputs of git log --graph --pretty=oneline --abbrev-commit at each\nrebase step:\n\n1/3\n\n* a810395 I\n*   1cfccc7 H\n|\\\n| * c477d4e C\n| * 7002290 B\n| * aa9f1d0 A\n* | b614d31 G\n* | 2ad4496 F\n|/\n* 0d512e9 E\n* b6cbc2b D\n\n2/3\n\n*   1cfccc7 H\n|\\\n| * c477d4e C\n| * 7002290 B\n| * aa9f1d0 A\n* | b614d31 G\n* | 2ad4496 F\n|/\n* 0d512e9 E\n* b6cbc2b D\n\n3/3\n\n* 3a41a45 J\n* a810395 I\n*   1cfccc7 H\n|\\\n| * c477d4e C\n| * 7002290 B\n| * aa9f1d0 A\n* | b614d31 G\n* | 2ad4496 F\n|/\n* 0d512e9 E\n* b6cbc2b D\n\n\nIs there a way to do a real rebase of a merge commit?\n\nFWIW, here is the script I use to create my toy environment in the current\ndirectory:\n\nfunction _make_commit() {\n  echo \"$1\" > \"$1\"\n  git add \"$1\"\n  git commit -a -m \"$1\"\n  git tag \"$1\" HEAD\n}\n\nfunction _prepare_merged_history() {\n  git init\n  _make_commit \"D\"\n  git checkout -b targetbranch\n  _make_commit \"E\"\n  _make_commit \"A\"\n  _make_commit \"B\"\n  _make_commit \"C\"\n  _make_commit \"K\"\n  git checkout E\n  git checkout -b srcbranch\n  _make_commit \"F\"\n  _make_commit \"G\"\n  git merge  -m \"H\" C\n  git tag H HEAD\n  _make_commit \"I\"\n  _make_commit \"J\"\n}\n\nfunction _git_rebase_todo_line() {\n  echo -n \"pick \"\n  git rev-list -n 1 --pretty=oneline --abbrev-commit --abbrev=7 \"$1\"\n}\n\nfunction _make_git_rebase_todo() {\n  {\n    _git_rebase_todo_line refs/tags/I\n    _git_rebase_todo_line refs/tags/H\n    _git_rebase_todo_line refs/tags/J\n  } > git-rebase-todo\n}\n\n[ -d \".git\" ] && exit\n_prepare_merged_history\n_make_git_rebase_todo\n\n\nThanks in advance,\n\n-- \n  Dominique Quatravaux\n  +41 79 609 40 72\n"},{"id":"153877","messageId":"20101020173201.GA10537@burratino","threadId":"25488","inReplyTo":"AANLkTikroNPehcyBsueCnJ5hR0idd3cBP4m1KNccdRqL@mail.gmail.com","subject":"Re: git rebase and merge commits","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-20T17:32:01Z","receivedAt":"2010-10-20T17:32:01Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Dominique,\n\nDominique Quatravaux wrote:\n\n> #        A---B---C---K targetbranch\n> #       /         \\\n> #  D---E---F---G---H---I--J srcbranch\n> \n> into this:\n> \n> #   A---B---C---I'---K'  targetbranch\n> #  /             \\\n> # D---E---F---G---H'---J' srcbranch\n> #\n> \n> (ie I has been shoved into targetbranch).\n> \n> It seemed to me that the first step should be to simply rebase I, H, and J (in\n> this order) onto C. Unfortunately git rebase --interactive -p C proposes\n[...]\n\nI'm sorry to break this news, but \"rebase --interactive --preserve-merges\"\n(unlike \"rebase --preserve-merges\" without --interactive) was never\nimplemented completely.  See the BUGS section of the git-rebase man page.\n\nLuckily, there is a roadmap for anyone interested in implementing it.  Maybe\nit could be you?  See [1] and the surrounding thread.\n\nThanks for your interest,\nJonathan\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/148059/focus=148144\n"},{"id":"153878","messageId":"4CBF2A94.1030206@workspacewhiz.com","threadId":"25488","inReplyTo":"20101020173201.GA10537@burratino","subject":"Re: git rebase and merge commits","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-10-20T17:44:52Z","receivedAt":"2010-10-20T17:44:52Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"----- Original Message -----\nFrom: Jonathan Nieder\nDate: 10/20/2010 11:32 AM\n> I'm sorry to break this news, but \"rebase --interactive --preserve-merges\"\n> (unlike \"rebase --preserve-merges\" without --interactive) was never\n> implemented completely.  See the BUGS section of the git-rebase man page.\n>\n> Luckily, there is a roadmap for anyone interested in implementing it.  Maybe\n> it could be you?  See [1] and the surrounding thread.\n>\n> Thanks for your interest,\n> Jonathan\n>\n> [1] http://thread.gmane.org/gmane.comp.version-control.git/148059/focus=148144\nI applied that patch to my git-rebase--interactive, although it did not \ncleanly apply.  I hacked a few bits to get it going again.  I could post \nthe entire file here, if someone wants to clean it up.\n\nIt does properly rebase the first-parent merges fine.\n\nJosh\n"},{"id":"153879","messageId":"4CBF3108.4070300@workspacewhiz.com","threadId":"25488","inReplyTo":"4CBF2A94.1030206@workspacewhiz.com","subject":"Re: git rebase and merge commits","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-10-20T18:12:24Z","receivedAt":"2010-10-20T18:12:24Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"----- Original Message -----\nFrom: Joshua Jensen\nDate: 10/20/2010 11:44 AM\n> ----- Original Message -----\n> From: Jonathan Nieder\n> Date: 10/20/2010 11:32 AM\n>> I'm sorry to break this news, but \"rebase --interactive \n>> --preserve-merges\"\n>> (unlike \"rebase --preserve-merges\" without --interactive) was never\n>> implemented completely.  See the BUGS section of the git-rebase man \n>> page.\n>>\n>> Luckily, there is a roadmap for anyone interested in implementing \n>> it.  Maybe\n>> it could be you?  See [1] and the surrounding thread.\n>>\n>> Thanks for your interest,\n>> Jonathan\n>>\n>> [1] \n>> http://thread.gmane.org/gmane.comp.version-control.git/148059/focus=148144\n> I applied that patch to my git-rebase--interactive, although it did \n> not cleanly apply.  I hacked a few bits to get it going again.  I \n> could post the entire file here, if someone wants to clean it up.\n>\n> It does properly rebase the first-parent merges fine.\n\nNever mind.  I applied this patch: \nhttp://marc.info/?l=git&m=119379735525213&w=2\n\nJosh\n"},{"id":"154401","messageId":"AANLkTinhi=4nUn_anUEuz=m9=E7QJsJFWNBfO2yTtnUi@mail.gmail.com","threadId":"25488","inReplyTo":"20101020173201.GA10537@burratino","subject":"Re: git rebase and merge commits","fromName":"Dominique Quatravaux","fromEmail":"domq@google.com","sentAt":"2010-10-25T11:23:47Z","receivedAt":"2010-10-25T11:23:47Z","isPatch":false,"sender":{"key":"domq@google.com","avatar":"https://gravatar.com/avatar/121b20f85f75e3366ecd70be7f2777189ed53d0cc5472531cde13e4ed9e4f61e?d=mp&s=160"},"body":"On Wed, Oct 20, 2010 at 7:32 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Luckily, there is a roadmap for anyone interested in implementing it.  Maybe\n> it could be you?  See [1] and the surrounding thread.\n>\n> Thanks for your interest,\n> Jonathan\n>\n> [1] http://thread.gmane.org/gmane.comp.version-control.git/148059/focus=148144\n>\n\nI gave it a shot last week, but this is more that I can chew on in my\nspare time. Sorry! Thanks for the information anyway.\n\n\n-- \n  Dominique Quatravaux\n  +41 79 609 40 72\n"}]}