Re: git-rev-list: add "--dense" flag
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:09
On Sat, 22 Oct 2005, Petr Baudis wrote:
quoted
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