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

Re: A question about git-rev-list

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 16, 2007, 20:05 UTC
Message-ID
<alpine.LFD.0.999.0707161258560.20061@woody.linux-foundation.org>
In-Reply-To
<86wsx0wwvs.fsf@lola.quinscape.zz>
On Mon, 16 Jul 2007, David Kastrup wrote:
Show 7 quoted lines
> 
> if I do
> 
> git-rev-list --remove-empty HEAD --not some-commit -- filename | tail -1
> 
> do I have any guarantee that the commit id I get (if any) is a direct
> descendant of some-commit?
No. You get the guarantee that
 - it's some kind of parent of HEAD
 - it's *not* a parent of some-commit
But the trivial case is a simple history like
	 /-B-\
	A     D
         \-C-/

(where "A" is the root commit, and "D" is the current HEAD, and there are two development lines from A to D).

If you now do
	git-rev-list HEAD --not C

you would generally see B on the list of commits, even though it's obviously not a direct descendant of C.

No amount of flags will change that. Of course, B might not show up for _other_ reasons (ie simply because it doesn't change "filename" at all), but generally you must always think of git-rev-list (and git log) as a _set_ operation.

There are no git operations that will look for "chain of commits from C to D" if that is what you want. No such chain necessarily even exists, and quite often it is ambiguous when it *does* exist (ie there is not a single chain from A to D, there are two chains).

You could add some kind of function that looks for the "shortest chain of commits from X to Y", but that would really be something fundamentally different from what git-rev-list gives you.

			Linus
Previous: David KastrupNext: David Kastrup
Message 2 of 4 in “A question about git-rev-list”
  1. David KastrupJul 16, 2007
  2. Linus TorvaldsJul 16, 2007
  3. David KastrupJul 16, 2007
  4. Junio C HamanoJul 17, 2007

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.