Re: What's the difference between `git show branch:file | diff -u - file` vs `git diff branch file`?
- From
Michael J Gruber <git@drmicha.warpmail.net>
- Date
- Aug 23, 2011, 15:34 UTC
- Message-ID
- <4E53C89A.9000604@drmicha.warpmail.net>
- In-Reply-To
- <1314096731.15017.2.camel@n900.home.ru>
Marat Radchenko venit, vidit, dixit 23.08.2011 12:52:
Show 7 quoted lines
>> Is that a very large tree or a very slow file system? > Tree is large (500k files), file system is irrelevant since all time is spend on CPU. > >> Do we enumerate all >> differing files and only then limit diff output by path?? > > Dunno, that's why I am asking why it is so slow.
Well, we have to read the full tree before diffing. But I can't reproduce the extreme difference which you observed (0.003s vs. 30s), only a factor of ten or so for a repo with 100k files:
git init seq 0 100000|while read n ; do echo a > a$n;done git add . git commit -m m echo b > a0
On a ramdisk, I get:
time git diff > /dev/null
real 0m0.160s user 0m0.064s sys 0m0.190s
time git diff -- a0 > /dev/null
real 0m0.070s user 0m0.051s sys 0m0.021s
time git diff HEAD > /dev/null
real 0m0.266s user 0m0.145s sys 0m0.212s
time git diff HEAD -- a0 > /dev/null
real 0m0.171s user 0m0.136s sys 0m0.033s
time git show HEAD:a0 > /dev/null
real 0m0.018s user 0m0.009s sys 0m0.007s
time git show HEAD:a0 | diff -u - a0 > /dev/null
real 0m0.019s user 0m0.010s sys 0m0.008s
Stumped.
In your case, do you have a lot of differing files besides the one you are limitting to? Anyway, that does not seem to make a huge difference in my timings. (Just tried.) Still Stumped.
Michael