threads / discuss / 43349

Re: git-rev-list: --objects list inconsistency

Subject: Re: git-rev-list: --objects list inconsistency

## tl;dr

3 messages between Nov 14, 2006 and Nov 14, 2006.

replies: 2people: 3as markdown or json

Johannes Sixt· Nov 14, 2006, 15:54 UTC · lore

git-rev-list: --objects list inconsistency

I observed a puzzling behavior of git-rev-list:
$ git-rev-list master^^..master 
f3364ca9405e17772fecea1d06c40b9965b8e6e4
bb3bfda219a85d2d49e62c261b9c8f6795ebdc22
$ git-rev-list --max-count=2 master 
f3364ca9405e17772fecea1d06c40b9965b8e6e4
bb3bfda219a85d2d49e62c261b9c8f6795ebdc22
$ git-rev-list --objects master^^..master |wc -l
     10
$ git-rev-list --objects --max-count=2 master |wc -l
   2376

As you can see, without --objects, master^^..master and --max-count=2 list the same two commits.

But with --objects I get different object lists. I don't even know which one is the one to expect, but I certainly would not have expected the lists to be different. What's wrong here?

BTW, the objects listed with --objects --max-count=2 are basically the entire tree at master plus the few objects that changed since master^^.

$ git --version git version 1.4.4.rc2.gc8641

-- Hannes
Junio C Hamano· Nov 14, 2006, 17:58 UTC · re: Johannes Sixt · lore
Johannes Sixt <J.Sixt@eudaptics.com> writes:
Show 10 quoted lines
> I observed a puzzling behavior of git-rev-list:
>
> $ git-rev-list master^^..master 
> f3364ca9405e17772fecea1d06c40b9965b8e6e4
> bb3bfda219a85d2d49e62c261b9c8f6795ebdc22
> $ git-rev-list --max-count=2 master 
> f3364ca9405e17772fecea1d06c40b9965b8e6e4
> bb3bfda219a85d2d49e62c261b9c8f6795ebdc22
> $ git-rev-list --objects master^^..master |wc -l
>      10

You are asking to get objects reachable from master but exclude objects reachable from master^^.

> $ git-rev-list --objects --max-count=2 master |wc -l
>    2376
You are asking to get objects reachable from master and master^.

You have 2300+ objects that are common in trees of master, master^ and master^^.

Linus Torvalds· Nov 14, 2006, 18:26 UTC · re: Johannes Sixt · lore
On Tue, 14 Nov 2006, Johannes Sixt wrote:
> 
> As you can see, without --objects, master^^..master and --max-count=2
> list the same two commits.
"--max-count=X" and "master^^..master" are two TOTALLY different things.

The fact that they happened to give the same results without "--objects" is a random thing, and not at all guaranteed. For example, if "master" (or its parent) had been a merge, it probably wouldn't have given the same result even _without_ "--objects".

> But with --objects I get different object lists. I don't even know which
> one is the one to expect, but I certainly would not have expected the
> lists to be different. What's wrong here?
Nothing is wrong. You're asking for two totally different things.

With "--max-count=2", you're saying "I want the first two commits", and then the "--objects" part extends that to all the other object types too.

So you get two commits _and_ every single object reachable from those two commits.

In contrast, with "master^^..master", you're saying "I want everything that is reachable from "master", but _not_ reachable from it's grand-parent. And the "--objects" flag extends that to all the other object types too.

So you get (in this case) two commits _and_ all the objects that are reachable from those two commits but that are _not_ reachable from the grandparent.

That's a totally different thing, obviously. There's likely to be a lot of objects in common between "master" and its grandparent, and you literally asked to not be shown those objects. In the first case, you didn't ask for the exclusion of the grandparent.

So you should expect a big difference in almost all cases. In one case, you ask for an exclusion, in the other case, you just say "just the first two commits, please". Not at all equivalent.

← back to recent threads