Skip to contentSkip to conversation

logging disjoint sets of commits in a single command

DISCUSSION Bryan O'Sullivan 4 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw
Quoted 2 lines · Bryan O'Sullivan

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?

#2 lore raw
Quoted 12 lines · Bryan O'Sullivan
Quoted 2 lines · Bryan O'Sullivan

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:

Quoted 7 lines

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

#3 lore raw
Quoted 4 lines · Carlos Martín Nieto
Quoted 4 lines

Here's a sample command line against a kernel tree:

git log 373af0c^..373af0c 590dfe2^..590dfe2

Quoted 8 lines
Quoted 5 lines

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
Quoted 6 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

#4 lore raw
Quoted 4 lines · Jeff King

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.

Quoted 5 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!

#5 lore raw
Quoted 6 lines · Bryan O'Sullivan

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

#6 lore raw
Quoted 2 lines · Jeff King

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.

Quoted 2 lines

Have you packed
everything?

Yep.

Quoted 2 lines

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.

Quoted 1 line

Is the repository publicly available?

No, sorry.

#7 lore raw
In reply to Bryan O'Sullivan
Quoted 3 lines · Bryan O'Sullivan

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,

Quoted 1 line

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.