{"thread":{"id":"26690","subject":"how to list commits on branch since last merge","startedAt":"2011-03-08T07:24:44Z","lastAt":"2011-03-08T21:03:12Z","messageCount":13,"participants":["Jay Soffian","Michael J Gruber","Jeff King","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162961","messageId":"AANLkTi=zW9hOhnddw6HsjQwV2qLf_R_qeNna+XeN6U6x@mail.gmail.com","threadId":"26690","inReplyTo":null,"subject":"how to list commits on branch since last merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-03-08T07:24:44Z","receivedAt":"2011-03-08T07:24:44Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Given this history:\n\no---o---x---o---...    foo\n \\       \\\n  o---o---m---o---...  bar\n\nI want to list the commits on bar newer than merge m (the last merge\nfrom foo). merge-base returns x.\n\nI feel like I'm going to face-palm upon reply, but the only way I see\nto do it is:\n\n  $ git rev-list --ancestry-path $(git merge-base foo bar)..bar\n\nOr by greping the output of rev-list --merges --parents foo..bar\nlooking for the merge base.\n\nI must be missing something obvious, since this feels like it should\nbe a common operation. :-)\n\nj.\n"},{"id":"162974","messageId":"4D75ED72.8030203@drmicha.warpmail.net","threadId":"26690","inReplyTo":"AANLkTi=zW9hOhnddw6HsjQwV2qLf_R_qeNna+XeN6U6x@mail.gmail.com","subject":"Re: how to list commits on branch since last merge","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-03-08T08:48:50Z","receivedAt":"2011-03-08T08:48:50Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jay Soffian venit, vidit, dixit 08.03.2011 08:24:\n> Given this history:\n> \n> o---o---x---o---...    foo\n>  \\       \\\n>   o---o---m---o---...  bar\n> \n> I want to list the commits on bar newer than merge m (the last merge\n> from foo). merge-base returns x.\n> \n> I feel like I'm going to face-palm upon reply, but the only way I see\n> to do it is:\n> \n>   $ git rev-list --ancestry-path $(git merge-base foo bar)..bar\n> \n> Or by greping the output of rev-list --merges --parents foo..bar\n> looking for the merge base.\n> \n> I must be missing something obvious, since this feels like it should\n> be a common operation. :-)\n\nHave you tried:\n\ngit rev-list --ancestry-path --left-right foo...bar\n\nIf the \">\" commits are the ones that you want you only have to wait for\nthe \"--right-only\" option which is cooking in pu. And grep '^>' for now ;)\n\nMichael\n"},{"id":"162976","messageId":"AANLkTinOEutM92k4SUGEXbfTpzGcQitpW4CZbcQbg0R4@mail.gmail.com","threadId":"26690","inReplyTo":"4D75ED72.8030203@drmicha.warpmail.net","subject":"Re: how to list commits on branch since last merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-03-08T09:35:16Z","receivedAt":"2011-03-08T09:35:16Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Tue, Mar 8, 2011 at 3:48 AM, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n> Have you tried:\n>\n> git rev-list --ancestry-path --left-right foo...bar\n>\n> If the \">\" commits are the ones that you want you only have to wait for\n> the \"--right-only\" option which is cooking in pu. And grep '^>' for now ;)\n\nAh. The rev-list man page entry on --ancestry-path only talks about\nusing it with '..', so I didn't even try it with the symmetric diff\noperator ('...').\n\nThat said, seems it would be useful to have an easy way to get to the\nmerge which has a merge-base as one of its parents. Maybe even a\ngeneric way to find all commits which have a particular parent. I\nthink rev-list --parents | grep is the only way to do that today.\n\nThanks,\n\nj.\n"},{"id":"162977","messageId":"4D75F96B.7000707@drmicha.warpmail.net","threadId":"26690","inReplyTo":"AANLkTinOEutM92k4SUGEXbfTpzGcQitpW4CZbcQbg0R4@mail.gmail.com","subject":"Re: how to list commits on branch since last merge","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-03-08T09:39:55Z","receivedAt":"2011-03-08T09:39:55Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jay Soffian venit, vidit, dixit 08.03.2011 10:35:\n> On Tue, Mar 8, 2011 at 3:48 AM, Michael J Gruber\n> <git@drmicha.warpmail.net> wrote:\n>> Have you tried:\n>>\n>> git rev-list --ancestry-path --left-right foo...bar\n>>\n>> If the \">\" commits are the ones that you want you only have to wait for\n>> the \"--right-only\" option which is cooking in pu. And grep '^>' for now ;)\n> \n> Ah. The rev-list man page entry on --ancestry-path only talks about\n> using it with '..', so I didn't even try it with the symmetric diff\n> operator ('...').\n\nI understood --ancestry-path only after looking at revision.c, where\nthere's talk about \"bottom commits\", which gave me the right hint\n(because I've been messing with the walker lately).\n\n> \n> That said, seems it would be useful to have an easy way to get to the\n> merge which has a merge-base as one of its parents. Maybe even a\n> generic way to find all commits which have a particular parent. I\n> think rev-list --parents | grep is the only way to do that today.\n\nI had a patch for that but it was shot down because of the \"grep\"\nworkaround:\n\nhttp://permalink.gmane.org/gmane.comp.version-control.git/157636\n\nMaybe I should try again...\n\nMichael\n"},{"id":"162978","messageId":"AANLkTikK8Uc8=wKROYWWxZ_6OtQtqBmFCZN760M1LO+c@mail.gmail.com","threadId":"26690","inReplyTo":"AANLkTinOEutM92k4SUGEXbfTpzGcQitpW4CZbcQbg0R4@mail.gmail.com","subject":"Re: how to list commits on branch since last merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-03-08T09:43:26Z","receivedAt":"2011-03-08T09:43:26Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Tue, Mar 8, 2011 at 4:35 AM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> On Tue, Mar 8, 2011 at 3:48 AM, Michael J Gruber\n> <git@drmicha.warpmail.net> wrote:\n>> Have you tried:\n>>\n>> git rev-list --ancestry-path --left-right foo...bar\n>>\n>> If the \">\" commits are the ones that you want you only have to wait for\n>> the \"--right-only\" option which is cooking in pu. And grep '^>' for now ;)\n>\n> Ah. The rev-list man page entry on --ancestry-path only talks about\n> using it with '..', so I didn't even try it with the symmetric diff\n> operator ('...').\n\nAnd with the clue to use '...', it's easy:\n\n  $ git log --ancestry-path foo...bar ^foo\n\nStill want an easy way for merge-base to report the merge which\ncontains the merge-base. That will wait for another day.\n\nj.\n"},{"id":"162979","messageId":"4D75FB7B.70403@drmicha.warpmail.net","threadId":"26690","inReplyTo":"AANLkTikK8Uc8=wKROYWWxZ_6OtQtqBmFCZN760M1LO+c@mail.gmail.com","subject":"Re: how to list commits on branch since last merge","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-03-08T09:48:43Z","receivedAt":"2011-03-08T09:48:43Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jay Soffian venit, vidit, dixit 08.03.2011 10:43:\n> On Tue, Mar 8, 2011 at 4:35 AM, Jay Soffian <jaysoffian@gmail.com> wrote:\n>> On Tue, Mar 8, 2011 at 3:48 AM, Michael J Gruber\n>> <git@drmicha.warpmail.net> wrote:\n>>> Have you tried:\n>>>\n>>> git rev-list --ancestry-path --left-right foo...bar\n>>>\n>>> If the \">\" commits are the ones that you want you only have to wait for\n>>> the \"--right-only\" option which is cooking in pu. And grep '^>' for now ;)\n>>\n>> Ah. The rev-list man page entry on --ancestry-path only talks about\n>> using it with '..', so I didn't even try it with the symmetric diff\n>> operator ('...').\n> \n> And with the clue to use '...', it's easy:\n> \n>   $ git log --ancestry-path foo...bar ^foo\n> \n> Still want an easy way for merge-base to report the merge which\n> contains the merge-base. That will wait for another day.\n\nYou mean shorter than:\n\ngit rev-list --merges -1 $(git merge-base foo bar)\n\nOr maybe I'm misunderstanding \"contain\".\n\nMichael\n"},{"id":"162980","messageId":"AANLkTim_h6vbvnmy7oUNYmV82vCzLLfWKq=3_UY9kPYw@mail.gmail.com","threadId":"26690","inReplyTo":"4D75FB7B.70403@drmicha.warpmail.net","subject":"Re: how to list commits on branch since last merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-03-08T10:11:16Z","receivedAt":"2011-03-08T10:11:16Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Tue, Mar 8, 2011 at 4:48 AM, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n> You mean shorter than:\n>\n> git rev-list --merges -1 $(git merge-base foo bar)\n>\n> Or maybe I'm misunderstanding \"contain\".\n\nGoing back to my original picture, I mean commit m:\n\n  o---o---x---o---...    foo\n   \\       \\\n    o---o---m---o---...  bar\n\nmerge-base foo bar gives me x; to get m I then need to grep the output\nof rev-list --parents for x.\n\nj.\n"},{"id":"162981","messageId":"4D76042B.70005@drmicha.warpmail.net","threadId":"26690","inReplyTo":"AANLkTim_h6vbvnmy7oUNYmV82vCzLLfWKq=3_UY9kPYw@mail.gmail.com","subject":"Re: how to list commits on branch since last merge","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-03-08T10:25:47Z","receivedAt":"2011-03-08T10:25:47Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jay Soffian venit, vidit, dixit 08.03.2011 11:11:\n> On Tue, Mar 8, 2011 at 4:48 AM, Michael J Gruber\n> <git@drmicha.warpmail.net> wrote:\n>> You mean shorter than:\n>>\n>> git rev-list --merges -1 $(git merge-base foo bar)\n>>\n>> Or maybe I'm misunderstanding \"contain\".\n> \n> Going back to my original picture, I mean commit m:\n> \n>   o---o---x---o---...    foo\n>    \\       \\\n>     o---o---m---o---...  bar\n> \n> merge-base foo bar gives me x; to get m I then need to grep the output\n> of rev-list --parents for x.\n> \n> j.\n\nMaybe\n\ngit rev-list --ancestry-path --merges $(git merge-base foo bar)..bar\n\nor, with the patch in pu\n\ngit rev-list --ancestry-path --merges --right-only foo...bar\n\neach piped into tail -1 ?\n\nMichael\n"},{"id":"162994","messageId":"20110308171251.GA1823@sigill.intra.peff.net","threadId":"26690","inReplyTo":"AANLkTim_h6vbvnmy7oUNYmV82vCzLLfWKq=3_UY9kPYw@mail.gmail.com","subject":"Re: how to list commits on branch since last merge","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-08T17:12:51Z","receivedAt":"2011-03-08T17:12:51Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Mar 08, 2011 at 05:11:16AM -0500, Jay Soffian wrote:\n\n> Going back to my original picture, I mean commit m:\n> \n>   o---o---x---o---...    foo\n>    \\       \\\n>     o---o---m---o---...  bar\n> \n> merge-base foo bar gives me x; to get m I then need to grep the output\n> of rev-list --parents for x.\n\nIsn't the merge the first commit in bar that is not in foo? IOW:\n\n  git rev-list foo..bar | tail -n 1\n\n?\n\nI admit it's not particularly elegant, though. And I haven't given\nenough thought to decide whether that happens to work in your case, or\nif it is more general. :)\n\n-Peff\n"},{"id":"162995","messageId":"AANLkTimE52XWMtpuyaU7MbnyYVszKqNbTPSV=QxLyij3@mail.gmail.com","threadId":"26690","inReplyTo":"20110308171251.GA1823@sigill.intra.peff.net","subject":"Re: how to list commits on branch since last merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-03-08T17:39:10Z","receivedAt":"2011-03-08T17:39:10Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Tue, Mar 8, 2011 at 12:12 PM, Jeff King <peff@peff.net> wrote:\n> On Tue, Mar 08, 2011 at 05:11:16AM -0500, Jay Soffian wrote:\n>\n>> Going back to my original picture, I mean commit m:\n>>\n>>   o---o---x---o---...    foo\n>>    \\       \\\n>>     o---o---m---o---...  bar\n>>\n>> merge-base foo bar gives me x; to get m I then need to grep the output\n>> of rev-list --parents for x.\n>\n> Isn't the merge the first commit in bar that is not in foo? IOW:\n\nNo, because bar is never merged to foo. Let me relabel the picture:\n\n   o---o---x---o---...    foo\n    \\       \\\n     a---b---c---d---...  bar\n\n>  git rev-list foo..bar | tail -n 1\n\nThat would return 'a'. merge-base foo bar returns x. I want 'c'. So\nagain, I can do either:\n\n  $ git rev-list foo bar --merges --parents | grep \" $(git merge-base foo bar)\"\n\nOr:\n\n  $ git rev-list --ancestry-path foo...bar ^foo | tail -n 1\n\nI guess this is not at all a common thing, since it seems to be\nconfounding the list. :-)\n\nMy use case is that I maintain a downstream project, so bar never\nmerges back to foo, but sometimes I ask the question \"what have we\ndone on bar since we last merged in foo\". I think --ancestry-path\nreally is the answer:\n\n  $ git log --reverse --ancestry-path foo...bar ^foo\n\nIs actually quite nice.\n\nj.\n"},{"id":"162996","messageId":"20110308180533.GB1823@sigill.intra.peff.net","threadId":"26690","inReplyTo":"AANLkTimE52XWMtpuyaU7MbnyYVszKqNbTPSV=QxLyij3@mail.gmail.com","subject":"Re: how to list commits on branch since last merge","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-08T18:05:33Z","receivedAt":"2011-03-08T18:05:33Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Mar 08, 2011 at 12:39:10PM -0500, Jay Soffian wrote:\n\n> >> Going back to my original picture, I mean commit m:\n> >>\n> >>   o---o---x---o---...    foo\n> >>    \\       \\\n> >>     o---o---m---o---...  bar\n> >>\n> >> merge-base foo bar gives me x; to get m I then need to grep the output\n> >> of rev-list --parents for x.\n> >\n> > Isn't the merge the first commit in bar that is not in foo? IOW:\n> \n> No, because bar is never merged to foo. Let me relabel the picture:\n\nOh, of course. Sorry for the misdirection. Too little sleep. :)\n\n> I guess this is not at all a common thing, since it seems to be\n> confounding the list. :-)\n\nYeah, I think in many cases when \"foo\" and \"bar\" are merged, they both\nend up getting the merge commit, and \"foo..bar\" and \"foo...bar\" becomes\na lot more useful.\n\nYours is more of a long-running maintenance branch scenario. Which is\nnot all that uncommon, of course, but I can't remember a time when I\nwanted to ask for what you're looking for.\n\n-Peff\n"},{"id":"163002","messageId":"m2r5ahqvjs.fsf@igel.home","threadId":"26690","inReplyTo":"20110308171251.GA1823@sigill.intra.peff.net","subject":"Re: how to list commits on branch since last merge","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2011-03-08T19:08:55Z","receivedAt":"2011-03-08T19:08:55Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Mar 08, 2011 at 05:11:16AM -0500, Jay Soffian wrote:\n>\n>> Going back to my original picture, I mean commit m:\n>> \n>>   o---o---x---o---...    foo\n>>    \\       \\\n>>     o---o---m---o---...  bar\n      b1\n>> \n>> merge-base foo bar gives me x; to get m I then need to grep the output\n>> of rev-list --parents for x.\n>\n> Isn't the merge the first commit in bar that is not in foo? IOW:\n>\n>   git rev-list foo..bar | tail -n 1\n\nThat would show the commit marked b1 above, wouldn't it?  ^foo cuts only\nx and its parents, but not the other parent of m.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"163019","messageId":"20110308210312.GA4594@sigill.intra.peff.net","threadId":"26690","inReplyTo":"m2r5ahqvjs.fsf@igel.home","subject":"Re: how to list commits on branch since last merge","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-08T21:03:12Z","receivedAt":"2011-03-08T21:03:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Mar 08, 2011 at 08:08:55PM +0100, Andreas Schwab wrote:\n\n> > Isn't the merge the first commit in bar that is not in foo? IOW:\n> >\n> >   git rev-list foo..bar | tail -n 1\n> \n> That would show the commit marked b1 above, wouldn't it?  ^foo cuts only\n> x and its parents, but not the other parent of m.\n\nYes, just me being dumb. See the other subthread.\n\n-Peff\n"}]}