git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how to list commits on branch since last merge
@ 2011-03-08  7:24 Jay Soffian
  2011-03-08  8:48 ` Michael J Gruber
  0 siblings, 1 reply; 13+ messages in thread
From: Jay Soffian @ 2011-03-08  7:24 UTC (permalink / raw)
  To: git

Given this history:

o---o---x---o---...    foo
 \       \
  o---o---m---o---...  bar

I want to list the commits on bar newer than merge m (the last merge
from foo). merge-base returns x.

I feel like I'm going to face-palm upon reply, but the only way I see
to do it is:

  $ git rev-list --ancestry-path $(git merge-base foo bar)..bar

Or by greping the output of rev-list --merges --parents foo..bar
looking for the merge base.

I must be missing something obvious, since this feels like it should
be a common operation. :-)

j.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08  7:24 how to list commits on branch since last merge Jay Soffian
@ 2011-03-08  8:48 ` Michael J Gruber
  2011-03-08  9:35   ` Jay Soffian
  0 siblings, 1 reply; 13+ messages in thread
From: Michael J Gruber @ 2011-03-08  8:48 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

Jay Soffian venit, vidit, dixit 08.03.2011 08:24:
> Given this history:
> 
> o---o---x---o---...    foo
>  \       \
>   o---o---m---o---...  bar
> 
> I want to list the commits on bar newer than merge m (the last merge
> from foo). merge-base returns x.
> 
> I feel like I'm going to face-palm upon reply, but the only way I see
> to do it is:
> 
>   $ git rev-list --ancestry-path $(git merge-base foo bar)..bar
> 
> Or by greping the output of rev-list --merges --parents foo..bar
> looking for the merge base.
> 
> I must be missing something obvious, since this feels like it should
> be a common operation. :-)

Have you tried:

git rev-list --ancestry-path --left-right foo...bar

If the ">" commits are the ones that you want you only have to wait for
the "--right-only" option which is cooking in pu. And grep '^>' for now ;)

Michael

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08  8:48 ` Michael J Gruber
@ 2011-03-08  9:35   ` Jay Soffian
  2011-03-08  9:39     ` Michael J Gruber
  2011-03-08  9:43     ` Jay Soffian
  0 siblings, 2 replies; 13+ messages in thread
From: Jay Soffian @ 2011-03-08  9:35 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git

On Tue, Mar 8, 2011 at 3:48 AM, Michael J Gruber
<git@drmicha.warpmail.net> wrote:
> Have you tried:
>
> git rev-list --ancestry-path --left-right foo...bar
>
> If the ">" commits are the ones that you want you only have to wait for
> the "--right-only" option which is cooking in pu. And grep '^>' for now ;)

Ah. The rev-list man page entry on --ancestry-path only talks about
using it with '..', so I didn't even try it with the symmetric diff
operator ('...').

That said, seems it would be useful to have an easy way to get to the
merge which has a merge-base as one of its parents. Maybe even a
generic way to find all commits which have a particular parent. I
think rev-list --parents | grep is the only way to do that today.

Thanks,

j.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08  9:35   ` Jay Soffian
@ 2011-03-08  9:39     ` Michael J Gruber
  2011-03-08  9:43     ` Jay Soffian
  1 sibling, 0 replies; 13+ messages in thread
From: Michael J Gruber @ 2011-03-08  9:39 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

Jay Soffian venit, vidit, dixit 08.03.2011 10:35:
> On Tue, Mar 8, 2011 at 3:48 AM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>> Have you tried:
>>
>> git rev-list --ancestry-path --left-right foo...bar
>>
>> If the ">" commits are the ones that you want you only have to wait for
>> the "--right-only" option which is cooking in pu. And grep '^>' for now ;)
> 
> Ah. The rev-list man page entry on --ancestry-path only talks about
> using it with '..', so I didn't even try it with the symmetric diff
> operator ('...').

I understood --ancestry-path only after looking at revision.c, where
there's talk about "bottom commits", which gave me the right hint
(because I've been messing with the walker lately).

> 
> That said, seems it would be useful to have an easy way to get to the
> merge which has a merge-base as one of its parents. Maybe even a
> generic way to find all commits which have a particular parent. I
> think rev-list --parents | grep is the only way to do that today.

I had a patch for that but it was shot down because of the "grep"
workaround:

http://permalink.gmane.org/gmane.comp.version-control.git/157636

Maybe I should try again...

Michael

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08  9:35   ` Jay Soffian
  2011-03-08  9:39     ` Michael J Gruber
@ 2011-03-08  9:43     ` Jay Soffian
  2011-03-08  9:48       ` Michael J Gruber
  1 sibling, 1 reply; 13+ messages in thread
From: Jay Soffian @ 2011-03-08  9:43 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git

On Tue, Mar 8, 2011 at 4:35 AM, Jay Soffian <jaysoffian@gmail.com> wrote:
> On Tue, Mar 8, 2011 at 3:48 AM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>> Have you tried:
>>
>> git rev-list --ancestry-path --left-right foo...bar
>>
>> If the ">" commits are the ones that you want you only have to wait for
>> the "--right-only" option which is cooking in pu. And grep '^>' for now ;)
>
> Ah. The rev-list man page entry on --ancestry-path only talks about
> using it with '..', so I didn't even try it with the symmetric diff
> operator ('...').

And with the clue to use '...', it's easy:

  $ git log --ancestry-path foo...bar ^foo

Still want an easy way for merge-base to report the merge which
contains the merge-base. That will wait for another day.

j.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08  9:43     ` Jay Soffian
@ 2011-03-08  9:48       ` Michael J Gruber
  2011-03-08 10:11         ` Jay Soffian
  0 siblings, 1 reply; 13+ messages in thread
From: Michael J Gruber @ 2011-03-08  9:48 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

Jay Soffian venit, vidit, dixit 08.03.2011 10:43:
> On Tue, Mar 8, 2011 at 4:35 AM, Jay Soffian <jaysoffian@gmail.com> wrote:
>> On Tue, Mar 8, 2011 at 3:48 AM, Michael J Gruber
>> <git@drmicha.warpmail.net> wrote:
>>> Have you tried:
>>>
>>> git rev-list --ancestry-path --left-right foo...bar
>>>
>>> If the ">" commits are the ones that you want you only have to wait for
>>> the "--right-only" option which is cooking in pu. And grep '^>' for now ;)
>>
>> Ah. The rev-list man page entry on --ancestry-path only talks about
>> using it with '..', so I didn't even try it with the symmetric diff
>> operator ('...').
> 
> And with the clue to use '...', it's easy:
> 
>   $ git log --ancestry-path foo...bar ^foo
> 
> Still want an easy way for merge-base to report the merge which
> contains the merge-base. That will wait for another day.

You mean shorter than:

git rev-list --merges -1 $(git merge-base foo bar)

Or maybe I'm misunderstanding "contain".

Michael

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08  9:48       ` Michael J Gruber
@ 2011-03-08 10:11         ` Jay Soffian
  2011-03-08 10:25           ` Michael J Gruber
  2011-03-08 17:12           ` Jeff King
  0 siblings, 2 replies; 13+ messages in thread
From: Jay Soffian @ 2011-03-08 10:11 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git

On Tue, Mar 8, 2011 at 4:48 AM, Michael J Gruber
<git@drmicha.warpmail.net> wrote:
> You mean shorter than:
>
> git rev-list --merges -1 $(git merge-base foo bar)
>
> Or maybe I'm misunderstanding "contain".

Going back to my original picture, I mean commit m:

  o---o---x---o---...    foo
   \       \
    o---o---m---o---...  bar

merge-base foo bar gives me x; to get m I then need to grep the output
of rev-list --parents for x.

j.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08 10:11         ` Jay Soffian
@ 2011-03-08 10:25           ` Michael J Gruber
  2011-03-08 17:12           ` Jeff King
  1 sibling, 0 replies; 13+ messages in thread
From: Michael J Gruber @ 2011-03-08 10:25 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

Jay Soffian venit, vidit, dixit 08.03.2011 11:11:
> On Tue, Mar 8, 2011 at 4:48 AM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>> You mean shorter than:
>>
>> git rev-list --merges -1 $(git merge-base foo bar)
>>
>> Or maybe I'm misunderstanding "contain".
> 
> Going back to my original picture, I mean commit m:
> 
>   o---o---x---o---...    foo
>    \       \
>     o---o---m---o---...  bar
> 
> merge-base foo bar gives me x; to get m I then need to grep the output
> of rev-list --parents for x.
> 
> j.

Maybe

git rev-list --ancestry-path --merges $(git merge-base foo bar)..bar

or, with the patch in pu

git rev-list --ancestry-path --merges --right-only foo...bar

each piped into tail -1 ?

Michael

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08 10:11         ` Jay Soffian
  2011-03-08 10:25           ` Michael J Gruber
@ 2011-03-08 17:12           ` Jeff King
  2011-03-08 17:39             ` Jay Soffian
  2011-03-08 19:08             ` Andreas Schwab
  1 sibling, 2 replies; 13+ messages in thread
From: Jeff King @ 2011-03-08 17:12 UTC (permalink / raw)
  To: Jay Soffian; +Cc: Michael J Gruber, git

On Tue, Mar 08, 2011 at 05:11:16AM -0500, Jay Soffian wrote:

> Going back to my original picture, I mean commit m:
> 
>   o---o---x---o---...    foo
>    \       \
>     o---o---m---o---...  bar
> 
> merge-base foo bar gives me x; to get m I then need to grep the output
> of rev-list --parents for x.

Isn't the merge the first commit in bar that is not in foo? IOW:

  git rev-list foo..bar | tail -n 1

?

I admit it's not particularly elegant, though. And I haven't given
enough thought to decide whether that happens to work in your case, or
if it is more general. :)

-Peff

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08 17:12           ` Jeff King
@ 2011-03-08 17:39             ` Jay Soffian
  2011-03-08 18:05               ` Jeff King
  2011-03-08 19:08             ` Andreas Schwab
  1 sibling, 1 reply; 13+ messages in thread
From: Jay Soffian @ 2011-03-08 17:39 UTC (permalink / raw)
  To: Jeff King; +Cc: Michael J Gruber, git

On Tue, Mar 8, 2011 at 12:12 PM, Jeff King <peff@peff.net> wrote:
> On Tue, Mar 08, 2011 at 05:11:16AM -0500, Jay Soffian wrote:
>
>> Going back to my original picture, I mean commit m:
>>
>>   o---o---x---o---...    foo
>>    \       \
>>     o---o---m---o---...  bar
>>
>> merge-base foo bar gives me x; to get m I then need to grep the output
>> of rev-list --parents for x.
>
> Isn't the merge the first commit in bar that is not in foo? IOW:

No, because bar is never merged to foo. Let me relabel the picture:

   o---o---x---o---...    foo
    \       \
     a---b---c---d---...  bar

>  git rev-list foo..bar | tail -n 1

That would return 'a'. merge-base foo bar returns x. I want 'c'. So
again, I can do either:

  $ git rev-list foo bar --merges --parents | grep " $(git merge-base foo bar)"

Or:

  $ git rev-list --ancestry-path foo...bar ^foo | tail -n 1

I guess this is not at all a common thing, since it seems to be
confounding the list. :-)

My use case is that I maintain a downstream project, so bar never
merges back to foo, but sometimes I ask the question "what have we
done on bar since we last merged in foo". I think --ancestry-path
really is the answer:

  $ git log --reverse --ancestry-path foo...bar ^foo

Is actually quite nice.

j.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08 17:39             ` Jay Soffian
@ 2011-03-08 18:05               ` Jeff King
  0 siblings, 0 replies; 13+ messages in thread
From: Jeff King @ 2011-03-08 18:05 UTC (permalink / raw)
  To: Jay Soffian; +Cc: Michael J Gruber, git

On Tue, Mar 08, 2011 at 12:39:10PM -0500, Jay Soffian wrote:

> >> Going back to my original picture, I mean commit m:
> >>
> >>   o---o---x---o---...    foo
> >>    \       \
> >>     o---o---m---o---...  bar
> >>
> >> merge-base foo bar gives me x; to get m I then need to grep the output
> >> of rev-list --parents for x.
> >
> > Isn't the merge the first commit in bar that is not in foo? IOW:
> 
> No, because bar is never merged to foo. Let me relabel the picture:

Oh, of course. Sorry for the misdirection. Too little sleep. :)

> I guess this is not at all a common thing, since it seems to be
> confounding the list. :-)

Yeah, I think in many cases when "foo" and "bar" are merged, they both
end up getting the merge commit, and "foo..bar" and "foo...bar" becomes
a lot more useful.

Yours is more of a long-running maintenance branch scenario. Which is
not all that uncommon, of course, but I can't remember a time when I
wanted to ask for what you're looking for.

-Peff

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08 17:12           ` Jeff King
  2011-03-08 17:39             ` Jay Soffian
@ 2011-03-08 19:08             ` Andreas Schwab
  2011-03-08 21:03               ` Jeff King
  1 sibling, 1 reply; 13+ messages in thread
From: Andreas Schwab @ 2011-03-08 19:08 UTC (permalink / raw)
  To: Jeff King; +Cc: Jay Soffian, Michael J Gruber, git

Jeff King <peff@peff.net> writes:

> On Tue, Mar 08, 2011 at 05:11:16AM -0500, Jay Soffian wrote:
>
>> Going back to my original picture, I mean commit m:
>> 
>>   o---o---x---o---...    foo
>>    \       \
>>     o---o---m---o---...  bar
      b1
>> 
>> merge-base foo bar gives me x; to get m I then need to grep the output
>> of rev-list --parents for x.
>
> Isn't the merge the first commit in bar that is not in foo? IOW:
>
>   git rev-list foo..bar | tail -n 1

That would show the commit marked b1 above, wouldn't it?  ^foo cuts only
x and its parents, but not the other parent of m.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to list commits on branch since last merge
  2011-03-08 19:08             ` Andreas Schwab
@ 2011-03-08 21:03               ` Jeff King
  0 siblings, 0 replies; 13+ messages in thread
From: Jeff King @ 2011-03-08 21:03 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: git

On Tue, Mar 08, 2011 at 08:08:55PM +0100, Andreas Schwab wrote:

> > Isn't the merge the first commit in bar that is not in foo? IOW:
> >
> >   git rev-list foo..bar | tail -n 1
> 
> That would show the commit marked b1 above, wouldn't it?  ^foo cuts only
> x and its parents, but not the other parent of m.

Yes, just me being dumb. See the other subthread.

-Peff

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-03-08 21:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-08  7:24 how to list commits on branch since last merge Jay Soffian
2011-03-08  8:48 ` Michael J Gruber
2011-03-08  9:35   ` Jay Soffian
2011-03-08  9:39     ` Michael J Gruber
2011-03-08  9:43     ` Jay Soffian
2011-03-08  9:48       ` Michael J Gruber
2011-03-08 10:11         ` Jay Soffian
2011-03-08 10:25           ` Michael J Gruber
2011-03-08 17:12           ` Jeff King
2011-03-08 17:39             ` Jay Soffian
2011-03-08 18:05               ` Jeff King
2011-03-08 19:08             ` Andreas Schwab
2011-03-08 21:03               ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).