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

Re: logging disjoint sets of commits in a single command

From
Jeff King <peff@peff.net>
Date
Feb 1, 2012, 00:53 UTC
Message-ID
<20120201005332.GC30969@sigill.intra.peff.net>
In-Reply-To
<1328056769.31804.217.camel@centaur.lab.cmartin.tk>
On Wed, Feb 01, 2012 at 01:39:29AM +0100, Carlos Martín Nieto wrote:
Show 12 quoted lines
> > Here's a sample command line against a kernel tree:
> > 
> > git log 373af0c^..373af0c 590dfe2^..590dfe2
> > 
> > I want git to log those two specific commits, but in fact it looks like
> > limit_list is marking 590dfe2 as UNINTERESTING while processing 373af0c,
> > and so it gets pruned.
> > 
> > Is there some way around this, or would a patch to fix it be acceptable?
> 
> From my reading of the manpage (and the way most git commands work) log
> accepts one range of commits. They all get bunched up together.
Right. That command is equivalent to:
  373af0c 590dfe2 --not 373af0c^ 590dfe2^

So the limiting for one range you're interested in ends up marking part of the other as uninteresting, and that's by design. This topic came up recently, and I think the general consensus is that it would be cool to be able to do totally independent ranges, but that would be backwards incompatible with the current behavior.

In the general case, you can emulate this with:
  { git log 373af0c^..373af0c
    git log 590dfe2^..590dfe2
  } | $PAGER

which is of course slightly more annoying to type. If you're just interested in _single_ commits, though, you can just give the commits and turn off walking:

  git log --no-walk 373af0c 590dfe2
Show 6 quoted lines
> You might find cat-file's --batch mode interesting.
> 
>     git rev-list 373af0c^..373af0c | git cat-file --batch
>     git rev-list 590dfe2^..590dfe2 | git cat-file --batch
> 
> looks a lot like what you're looking for.

I think you could even drop the rev-lists in this case, since he just wants a single commit. However, cat-file lacks the niceties of "log", like fancy --pretty formatting and automatic diffing against parents.

-Peff
Previous: Carlos Martín NietoNext: Bryan O'Sullivan
Message 4 of 8 in “logging disjoint sets of commits in a single command”
  1. Bryan O'SullivanFeb 1, 2012
  2. Bryan O'SullivanFeb 1, 2012
  3. Carlos Martín NietoFeb 1, 2012
  4. Jeff KingFeb 1, 2012
  5. Bryan O'SullivanFeb 1, 2012
  6. Jeff KingFeb 1, 2012
  7. Bryan O'SullivanFeb 1, 2012
  8. Junio C HamanoFeb 1, 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.