git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to list commits on branch since last merge

From
Jay Soffian <jaysoffian@gmail.com>
Date
Mar 8, 2011, 17:39 UTC
Message-ID
<AANLkTimE52XWMtpuyaU7MbnyYVszKqNbTPSV=QxLyij3@mail.gmail.com>
In-Reply-To
<20110308171251.GA1823@sigill.intra.peff.net>
On Tue, Mar 8, 2011 at 12:12 PM, Jeff King <peff@peff.net> wrote:
Show 12 quoted lines
> 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.
Previous: Jeff KingNext: Jeff King
Message 10 of 13 in “how to list commits on branch since last merge”
  1. Jay SoffianMar 8, 2011
  2. Michael J GruberMar 8, 2011
  3. Jay SoffianMar 8, 2011
  4. Michael J GruberMar 8, 2011
  5. Jay SoffianMar 8, 2011
  6. Michael J GruberMar 8, 2011
  7. Jay SoffianMar 8, 2011
  8. Michael J GruberMar 8, 2011
  9. Jeff KingMar 8, 2011
  10. Jay SoffianMar 8, 2011
  11. Jeff KingMar 8, 2011
  12. Andreas SchwabMar 8, 2011
  13. Jeff KingMar 8, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.