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

Re: git-rev-list: add "--dense" flag

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 22, 2005, 03:30 UTC
Message-ID
<Pine.LNX.4.64.0510212025260.10477@g5.osdl.org>
In-Reply-To
<20051022025638.GQ30889@pasky.or.cz>
On Sat, 22 Oct 2005, Petr Baudis wrote:
Show 7 quoted lines
> 
> > If you're just going to feed them to diff-tree _anyway_, then you might as 
> > well not even do the dense thing, because quite frankly, you're just doing 
> > extra work.
> 
> fork() is awfully expensive for me. fork()ing something (supposedly)
> trivial (it was stat) slowed my (non-trivial) loop about 4 times.
Not fork. More like
	git-rev-list .. | git-diff-tree --stdin

If you do it that way (which is quite common - git-whatchanged, git-log etc), there's no reason to ask for a dense output, because git-diff-tree can handle the non-dense one as fast as git-rev-list can.

But the --dense option is wonderful for "gitk", and for "slow stuff". Where "slow" can indeed be a fork, or just an interpreter loop like a shell/perl script, which would fork/exec git-diff-tree for each commit.

>From a commit-list standpoint
	git-rev-list --dense ... -- paths
is the same as
	git-rev-list -- paths | git-diff-tree -s -r --stdin -- paths

but it's somewhat more efficient, and more importantly, it rewrites the parents. So quite often, you'd want to use "--dense" together with "--parent" so that you get the "rewritten" history. That's how come gitk didn't need any changes, and it "just worked". It's also how my example script did the rename detection without having to traverse unnecessary commits.

		Linus
Previous: Petr BaudisNext: Junio C Hamano
Message 13 of 20 in “git-rev-list: add "--dense" flag”
  1. Linus TorvaldsOct 21, 2005
  2. Linus TorvaldsOct 21, 2005
  3. Linus TorvaldsOct 21, 2005
  4. Petr BaudisOct 22, 2005
  5. Handling renames.Petr Baudis, Oct 22, 2005
  6. Linus TorvaldsOct 22, 2005
  7. Petr BaudisOct 22, 2005
  8. Junio C HamanoOct 22, 2005
  9. Petr BaudisOct 22, 2005
  10. Linus TorvaldsOct 22, 2005
  11. Linus TorvaldsOct 22, 2005
  12. Petr BaudisOct 22, 2005
  13. Linus TorvaldsOct 22, 2005
  14. Junio C HamanoOct 22, 2005
  15. Linus TorvaldsOct 22, 2005
  16. Jonas FonsecaOct 25, 2005
  17. Linus TorvaldsOct 25, 2005
  18. Jonas FonsecaOct 25, 2005
  19. Linus TorvaldsOct 25, 2005
  20. Linus TorvaldsOct 25, 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.