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

Re: git-rev-list: proper lazy reachability

From
Linus Torvalds <torvalds@osdl.org>
Date
May 31, 2005, 15:13 UTC
Message-ID
<Pine.LNX.4.58.0505310758270.1876@ppc970.osdl.org>
In-Reply-To
<2cfc4032050531005820979ca7@mail.gmail.com>
On Tue, 31 May 2005, Jon Seymour wrote:
Show 11 quoted lines
> 
>      A 
>   /  |  \ 
> B    C   D
> |  /   /
> E
> | \ 
> F G
> 
> and searching for git-rev-list A ^B it would actually be better to stop
> at E (printing A,B,C,D,E)

Btw, you probably looked at the actual code, so you know this, but maybe it wasn't clear to everybody else: the code obviously _will_ look at all of ABCDE before it can even decide that it should print out ACD, since it really needs to.

What happens is that it walks the tree "time-first" (not depth-first or breadth-first, but "most-recent-first"), which tends to approximate what we want, and when it sees "B" it will mark all of its children as uninteresting since they were clearly seen. So it will actually have gotten all the way to E before it can tell that it has seen enough.

The thing that makes git-rev-list preferred over git-rev-tree is that it can avoid looking at F and G and older parents, since it's clear by E that walking the tree any further would be pointless, and all the commits we could look at are already marked uninteresting.

But if somebody wanted to actually show this as a _graph_, what you would probably want is actually all of ABCDE, except you'd get the "interesting" bit separately (ie ACD would be tagged some way). Then you could show a sane graph that is colored by whether something is new or not, for example. That's absolutely trivial to do wiyth the new rev-list algorithm, in case somebody really cares - it's literally just changing the printout to show the entries marked "ignored" with some extra marking.

(Well, slightly more too: you'd have to add the uninteresting commits to the list, and mark the end object itself as being ignored, but that's two more trivial lines. Right now the code knows that it won't even add some objects to the output list, so..).

		Linus
Previous: Linus TorvaldsNext: Jon Seymour
Message 4 of 16 in “git-rev-list: proper lazy reachability”
  1. Linus TorvaldsMay 31, 2005
  2. Jon SeymourMay 31, 2005
  3. Linus TorvaldsMay 31, 2005
  4. Linus TorvaldsMay 31, 2005
  5. Jon SeymourJun 1, 2005
  6. Paul MackerrasMay 31, 2005
  7. Linus TorvaldsMay 31, 2005
  8. Linus TorvaldsMay 31, 2005
  9. Matthias UrlichsJun 1, 2005
  10. Junio C HamanoJun 4, 2005
  11. Thomas GlanzmannJun 4, 2005
  12. Linus TorvaldsJun 4, 2005
  13. Linus TorvaldsJun 4, 2005
  14. Junio C HamanoJun 4, 2005
  15. Petr BaudisJun 4, 2005
  16. Junio C HamanoJun 4, 2005

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.