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

Re: Kernel headers git tree

From
Linus Torvalds <torvalds@osdl.org>
Date
Jul 14, 2006, 05:16 UTC
Message-ID
<Pine.LNX.4.64.0607132157370.5623@g5.osdl.org>
In-Reply-To
<1152840456.31372.75.camel@shinybook.infradead.org>
On Fri, 14 Jul 2006, David Woodhouse wrote:
Show 11 quoted lines
> > 
> > The default ordering from git-rev-list (and all other revision listing 
> > things, ie "git log" etc) _does_ guarantee that we never show a child 
> > before _one_ of its parents has been shown (although "parent" in this case 
> > may be the command line).
> 
> Does it? I thought at one point it sorted on some random criterion like
> alphabetically by author, or some other cosmetic information which isn't
> really part of the git structure -- like the timestamp or something?
> We still don't enforce monotonicity, do we? The timestamps are still
> just fluff?
The timestamps are, and always have been, just a heuristic.

The output order of git-rev-list is actually entirely well-defined, but it's the _cheap_ ordering, not the strict and full topological one.

The cheap ordering means that we don't ever look at the whole history, but it's still a real "DAG reachability ordering" in the sense that when we output a commit, we have _always_ output _one_ full path of commits to reach that commit from one of the starting point.

But since you can traverse the DAG in any number of ways, the heuristic is that when there are multiple choices, we pick the one with the most recent commit date.

So to give an example, let's say we have
	HEAD  ->     A
		    / \
		   B   C
		  / \   \
		 D   E   F
		  \ /   / \
		   G   H  I
		  .......
the difference between --topo-order and the default ordering for
	git rev-list HEAD
is most visible for commit 'G'.

For --topo-order, we guarantee that before we show 'G', we _will_ have shown both 'D' and 'E'. In other words, --topo-ordering guarantees that it shows _all_ children before it shows the parent.

That's a _very_ very expensive thing to guarantee, because you can't actually tell that you've seen all children on 'G' before you've basically traversed most of the tree. In the above example, you CANNOT tell whether 'F' is a child of 'G', for exmaple. Think about it. You don't know - maybe the missing piece is 'I' -> 'Z' -> 'G', but without having parsed all the commits, you'll never know.

[ Actually, strictly speaking, you can guarantee it earlier than before 
  you parsed them _all_: you can guarantee it once _every_single_commit_ 
  whose parents you haven't followed yet is a direct ancestor of 'G' - at 
  that point, and not before, do you know that 'G' can have no more 
  children. That's actually very expensive to compute, so we don't do it - 
  we will walk the whole history, and only _then_ do we use one of the 
  algorithms to generate a topological sort from the full DAG.
  If somebody knows of an _incremental_ algorithm that doesn't need the 
  full DAG and can do a topo-ordering, that would be wonderful. But it's 
  basically very very very expensive. ]

So by default, we don't do that at all. By default, we will print out 'G' whenever we have printed out _any_ path leading to 'G', and 'G' is the commit with the most recent commit date.

So we might print things out as A, B, D, G, E ... - notice how we printed out 'E' _after_ we did 'G', but we did have the A->B->D->G path, so G was reachable from the top along the path we printed.

> In this case, I really do have commits in the intermediate tree which
> don't actually change anything, and I want to filter them out -- I
> couldn't see a simple way to do it all in one pass.

Ok, in that case, the "." is correct, but the --topo-order should be unnecessary because you only care about the first entry.

			Linus
Previous: David WoodhouseNext: David Woodhouse
Message 8 of 27 in “Kernel headers git tree”
  1. David WoodhouseJul 13, 2006
  2. Junio C HamanoJul 14, 2006
  3. David WoodhouseJul 14, 2006
  4. Linus TorvaldsJul 14, 2006
  5. Junio C HamanoJul 14, 2006
  6. Linus TorvaldsJul 14, 2006
  7. David WoodhouseJul 14, 2006
  8. Linus TorvaldsJul 14, 2006
  9. David WoodhouseJul 14, 2006
  10. Linus TorvaldsJul 14, 2006
  11. Daniel BarkalowJul 14, 2006
  12. David WoodhouseJul 14, 2006
  13. Daniel BarkalowJul 14, 2006
  14. Linus TorvaldsJul 14, 2006
  15. David WoodhouseJul 14, 2006
  16. Linus TorvaldsJul 14, 2006
  17. Trivial path optimization testAlex Riesen, Jul 17, 2006
  18. Junio C HamanoJul 24, 2006
  19. Alex RiesenJul 24, 2006
  20. Trivial path optimization testAlex Riesen, Jul 24, 2006
  21. Junio C HamanoJul 14, 2006
  22. David WoodhouseJul 14, 2006
  23. Ian CampbellJul 14, 2006
  24. Junio C HamanoJul 14, 2006
  25. Ingo OeserJul 14, 2006
  26. David WoodhouseJul 14, 2006
  27. Ingo OeserJul 18, 2006

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.