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

Re: Listing commits that are _exclusively_ available on a given branch

From
Jeff King <peff@peff.net>
Date
Mar 23, 2012, 17:06 UTC
Message-ID
<20120323170640.GA12881@sigill.intra.peff.net>
In-Reply-To
<CALKQrge-=XExhwxuC14uynpuuO3W+f4YO4=X7kFUx33F3HtnyQ@mail.gmail.com>
On Fri, Mar 23, 2012 at 03:36:33PM +0100, Johan Herland wrote:
Show 11 quoted lines
> I'm trying to figure out how to list commits on a given branch that
> are not available on any other branch, i.e. the commits that are
> exclusive to my branch.
> 
> So far I only have this somewhat brute-force alternative:
> 
>   git rev-list refs/heads/mybranch --not $(git show-ref --heads | grep
> -v refs/heads/mybranch)
> 
> Is it possible to phrase this query in a simpler manner? Preferably by
> not having to list all refs and then run grep on it...

No, I think that is the only way to do it. The algorithm run by rev-list in that case should be optimal, so there is nothing to improve there. Syntactically, it's a little bit of a pain because there is no way to tell rev-list "--all, except for this one branch" short of using grep. We could add a new syntax for that, but I'm not sure what it would look like (or if it would be any easier on the eyes than what you have).

You might consider using "git rev-list --stdin" to avoid running into limits on the command-line length.

-Peff
Previous: Johan HerlandNext: Junio C Hamano
Message 2 of 5 in “Listing commits that are _exclusively_ available on a given branch”
  1. Johan HerlandMar 23, 2012
  2. Jeff KingMar 23, 2012
  3. Junio C HamanoMar 23, 2012
  4. Jeff KingMar 23, 2012
  5. Junio C HamanoMar 23, 2012

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.