threads / discuss / 29495

logging disjoint sets of commits in a single command

Subject: logging disjoint sets of commits in a single command

## tl;dr

8 messages between Feb 1, 2012 and Feb 1, 2012.

replies: 7people: 4as markdown or json

Bryan O'Sullivan· Feb 1, 2012, 00:27 UTC · re: Bryan O'Sullivan · lore

Re: logging disjoint sets of commits in a single command

On 2012-01-31 16:15 , "Bryan O'Sullivan" <bryano@fb.com> wrote:
>I'm trying to use "git log" to display only a handful of commits, where
>the commits are not necessarily linearly related to each other.
And I beautifully fat-fingered the "send" key. Oops.

What I was *going* to say was that it looks like revision.c:limit_list is (whether intentionally or not) getting in the way of this.

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?
Carlos Martín Nieto· Feb 1, 2012, 00:39 UTC · re: Bryan O'Sullivan · lore

Re: logging disjoint sets of commits in a single command

On Wed, 2012-02-01 at 00:27 +0000, Bryan O'Sullivan wrote:
Show 19 quoted lines
> On 2012-01-31 16:15 , "Bryan O'Sullivan" <bryano@fb.com> wrote:
> 
> >I'm trying to use "git log" to display only a handful of commits, where
> >the commits are not necessarily linearly related to each other.
> 
> And I beautifully fat-fingered the "send" key. Oops.
> 
> What I was *going* to say was that it looks like revision.c:limit_list is
> (whether intentionally or not) getting in the way of this.
> 
> 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.

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.
   cmn
Jeff King· Feb 1, 2012, 00:53 UTC · re: Carlos Martín Nieto · lore

Re: logging disjoint sets of commits in a single command

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
Bryan O'Sullivan· Feb 1, 2012, 01:02 UTC · re: Jeff King · lore

Re: logging disjoint sets of commits in a single command

On 2012-01-31, "Jeff King" <peff@peff.net> wrote:
>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.

That's totally sensible. I hadn't been able to tell from inspection whether the behaviour was deliberate or not.

Show 5 quoted lines
>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
Oh, nice! I hadn't seen that option.

By the way, the reason I'm even interested in this in the first place is that the performance of commands like "git blame" and "git log" on files and subtrees has become a problem for us (> 10 seconds per invocation, forecast to get much worse), and I wanted to see whether I could feed "git log" a specific list of revisions, and if so, whether that could yield good performance.

I have it in mind to build a secondary index (maintained externally) so that I can supply these git commands with precise lists of revisions for much faster response times.

Thanks, guys!
Jeff King· Feb 1, 2012, 03:03 UTC · re: Bryan O'Sullivan · lore

Re: logging disjoint sets of commits in a single command

On Wed, Feb 01, 2012 at 01:02:57AM +0000, Bryan O'Sullivan wrote:
Show 6 quoted lines
> By the way, the reason I'm even interested in this in the first place is
> that the performance of commands like "git blame" and "git log" on files
> and subtrees has become a problem for us (> 10 seconds per invocation,
> forecast to get much worse), and I wanted to see whether I could feed "git
> log" a specific list of revisions, and if so, whether that could yield
> good performance.

That sounds kind of slow. Is your repository really gigantic? Have you packed everything? I'm just curious if there's some other way to make things faster. Is the repository publicly available?

-Peff
Bryan O'Sullivan· Feb 1, 2012, 22:01 UTC · re: Jeff King · lore

Re: logging disjoint sets of commits in a single command

On 2012-01-31 19:03 , "Jeff King" <peff@peff.net> wrote:
>
>That sounds kind of slow. Is your repository really gigantic?
Bigger than a kernel tree, but not as many commits. Beyond that, can't say.
> Have you packed
>everything?
Yep.
> I'm just curious if there's some other way to make things
>faster.

It would be nice if there was, but the fundamental problem is the lack of an index from filename to commit. Walking every commit is the limiting factor, I believe.

> Is the repository publicly available?
No, sorry.
Junio C Hamano· Feb 1, 2012, 00:48 UTC · re: Bryan O'Sullivan · lore

Re: logging disjoint sets of commits in a single command

"Bryan O'Sullivan" <bryano@fb.com> writes:
> Here's a sample command line against a kernel tree:
>
> git log 373af0c^..373af0c 590dfe2^..590dfe2
This command line is _defined_ to be the same as this.
	git log ^373af0c^ 373af0c ^590dfe2^ 590dfe2
Hence,
> Is there some way around this, or would a patch to fix it be acceptable?

the answer to the second question is "no, that is not a fix but is a breakage for the *current* Git users".

The answer to the first question is that you may be able to do something like this:

        (
            git rev-list 373af0c^..373af0c
            git rev-list 590dfe2^..590dfe2
        ) |
        sort -u |
        xargs git show

Having said all that, for users of Git 2.0, giving richer meaning to the explicit range notation to make your original command line work just like the above scripted way would be more intuitive. While an unconditional change to break the current users would totally be unacceptable, we would want to see somebody come up with a clean migration path toward that goal without hurting existing users in the longer term.

← back to recent threads