{"thread":{"id":"17099","subject":"Removing a commit from a local branch","startedAt":"2009-01-11T22:42:24Z","lastAt":"2009-01-12T01:20:26Z","messageCount":5,"participants":["Chris Packham","Jakub Narebski","Björn Steinbrink","Sitaram Chamarty"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"100023","messageId":"a038bef50901111442y16695664y4fed7cdd9d8af27@mail.gmail.com","threadId":"17099","inReplyTo":"a038bef50901111441w21959397tc41922656a25027c@mail.gmail.com","subject":"Removing a commit from a local branch","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2009-01-11T22:42:24Z","receivedAt":"2009-01-11T22:42:24Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"Hi List,\n\nI'm part of a development team using git. We use a maintainer model\nwhere developers send patches/pull requests to a maintainer who\napplies the patches to a local branch, decides if they're good or not\nand pushes the good patches to the public repository.\n\nWhat I want to do is script the removal of a bad patch so that the\nmaintainer identifies a patch in his local branch, sends an email to\nthe author telling them why their patch is being rejected then removes\nthe commit for that patch. Using git log a script can extract the\nauthor email address, hash and headline of each commit. Based on that\ninformation scripting the email is easy enough. Now I come to using\ngit rebase to remove the bad commit based on its hash which leads me\nto my question - How do I refer to a commit based on the hash of its\nparent?\n\nConsider the following example. The maintainer has the following branch locally\n\n  todeliver: A-B-C-D\n\nHe is happy with commits A, C and D but wants to reject B. Ideally I\nwant to be able to say\n  git rebase --onto <parent of B> <child of B> todelvier\n\nand get\n  todeliver: A-C'-D'\n\nI know that <parent of B> can be referred to as B~1 but what about\n<child of B>? I've read through the man page for git-rev-parse and\nnothing stands out as child of commit X.\n\nIs there a better what do achieve what I'm after?\n\nThanks,\nChris\n"},{"id":"100025","messageId":"m3hc45zcgq.fsf@localhost.localdomain","threadId":"17099","inReplyTo":"a038bef50901111442y16695664y4fed7cdd9d8af27@mail.gmail.com","subject":"Re: Removing a commit from a local branch","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-01-11T22:48:07Z","receivedAt":"2009-01-11T22:48:07Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Chris Packham\" <judge.packham@gmail.com> writes:\n\n> Consider the following example. The maintainer has the following\n> branch locally\n> \n>   todeliver: A-B-C-D\n> \n> He is happy with commits A, C and D but wants to reject B. Ideally I\n> want to be able to say\n>   git rebase --onto <parent of B> <child of B> todelvier\n> \n> and get\n>   todeliver: A-C'-D'\n> \n> I know that <parent of B> can be referred to as B~1 but what about\n> <child of B>? I've read through the man page for git-rev-parse and\n> nothing stands out as child of commit X.\n> \n> Is there a better what do achieve what I'm after?\n\nYes, I think it would be easier to either use \"git rebase --interactive\"\n(with some script taking place of EDITOR, or something), or prod Stephan\nBeyer (CC-ed) to finish git-sequencer...\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"100026","messageId":"20090111225220.GB15533@atjola.homenet","threadId":"17099","inReplyTo":"a038bef50901111442y16695664y4fed7cdd9d8af27@mail.gmail.com","subject":"Re: Removing a commit from a local branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-01-11T22:52:20Z","receivedAt":"2009-01-11T22:52:20Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.01.12 11:42:24 +1300, Chris Packham wrote:\n> Hi List,\n> \n> I'm part of a development team using git. We use a maintainer model\n> where developers send patches/pull requests to a maintainer who\n> applies the patches to a local branch, decides if they're good or not\n> and pushes the good patches to the public repository.\n> \n> What I want to do is script the removal of a bad patch so that the\n> maintainer identifies a patch in his local branch, sends an email to\n> the author telling them why their patch is being rejected then removes\n> the commit for that patch. Using git log a script can extract the\n> author email address, hash and headline of each commit. Based on that\n> information scripting the email is easy enough. Now I come to using\n> git rebase to remove the bad commit based on its hash which leads me\n> to my question - How do I refer to a commit based on the hash of its\n> parent?\n> \n> Consider the following example. The maintainer has the following branch locally\n> \n>   todeliver: A-B-C-D\n> \n> He is happy with commits A, C and D but wants to reject B. Ideally I\n> want to be able to say\n>   git rebase --onto <parent of B> <child of B> todelvier\n\nYou don't want <child of B> there, just B.\n\ngit rebase --onto <onto> <upstream> <branch>\n\nRebases the commits from the range <upstream>..<branch>, and that\n_excludes_ the commit (referenced by) <upstream>.\n\nSo:\ngit rebase --onto B^ B todeliver\n\nWorks on: B..todeliver == todeliver --not B\nAnd that range contains commits C and D.\n\nBjörn\n"},{"id":"100038","messageId":"a038bef50901111612v44a18cc2v1c66dd537b07715f@mail.gmail.com","threadId":"17099","inReplyTo":"20090111225220.GB15533@atjola.homenet","subject":"Re: Removing a commit from a local branch","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2009-01-12T00:12:32Z","receivedAt":"2009-01-12T00:12:32Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"Thanks thats exactly what I was after.\n\nOn Mon, Jan 12, 2009 at 11:52 AM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n> On 2009.01.12 11:42:24 +1300, Chris Packham wrote:\n>> Hi List,\n>>\n>> I'm part of a development team using git. We use a maintainer model\n>> where developers send patches/pull requests to a maintainer who\n>> applies the patches to a local branch, decides if they're good or not\n>> and pushes the good patches to the public repository.\n>>\n>> What I want to do is script the removal of a bad patch so that the\n>> maintainer identifies a patch in his local branch, sends an email to\n>> the author telling them why their patch is being rejected then removes\n>> the commit for that patch. Using git log a script can extract the\n>> author email address, hash and headline of each commit. Based on that\n>> information scripting the email is easy enough. Now I come to using\n>> git rebase to remove the bad commit based on its hash which leads me\n>> to my question - How do I refer to a commit based on the hash of its\n>> parent?\n>>\n>> Consider the following example. The maintainer has the following branch locally\n>>\n>>   todeliver: A-B-C-D\n>>\n>> He is happy with commits A, C and D but wants to reject B. Ideally I\n>> want to be able to say\n>>   git rebase --onto <parent of B> <child of B> todelvier\n>\n> You don't want <child of B> there, just B.\n>\n> git rebase --onto <onto> <upstream> <branch>\n>\n> Rebases the commits from the range <upstream>..<branch>, and that\n> _excludes_ the commit (referenced by) <upstream>.\n>\n> So:\n> git rebase --onto B^ B todeliver\n>\n> Works on: B..todeliver == todeliver --not B\n> And that range contains commits C and D.\n>\n> Björn\n>\n"},{"id":"100044","messageId":"slrngml6mq.d1r.sitaramc@sitaramc.homelinux.net","threadId":"17099","inReplyTo":"a038bef50901111442y16695664y4fed7cdd9d8af27@mail.gmail.com","subject":"Re: Removing a commit from a local branch","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2009-01-12T01:20:26Z","receivedAt":"2009-01-12T01:20:26Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On 2009-01-11, Chris Packham <judge.packham@gmail.com> wrote:\n> Consider the following example. The maintainer has the\n> following branch locally\n>\n>   todeliver: A-B-C-D\n>\n> He is happy with commits A, C and D but wants to reject B. Ideally I\n> want to be able to say\n>   git rebase --onto <parent of B> <child of B> todelvier\n>\n> and get\n>   todeliver: A-C'-D'\n\nyou have an off-by-one error here.  You need B, not child of\nB.  Problem solved :-)\n"}]}