From: Michael J Gruber Date: Tue, 23 Aug 2011 20:07:43 GMT Subject: Re: What's the difference between `git show branch:file | diff -u - file` vs `git diff branch file`? Message-ID: <4E54088F.7050700@drmicha.warpmail.net> In-Reply-To: <7vk4a4rqvb.fsf@alter.siamese.dyndns.org> Junio C Hamano venit, vidit, dixit 23.08.2011 19:15: > Michael J Gruber writes: > >> Marat Radchenko venit, vidit, dixit 23.08.2011 12:52: >>>> 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. > > Not necessarily, especially when pathspec is given like the original post, > i.e. "git diff $tree_ish -- $path". We would need to open tree objects > that lead to the leaf of the $path and a blob, but other objects won't be > needed. I meant: The way "git diff" is now, it does that. > > The default diff backend tries to come up with minimal changes by spending > extra cycles, so it is not so surprising if the file compared is large-ish > and/or has very many similar lines in itself (in which case there are many > potential matching line pairs between the preimage and the postimage to be > examined to produce a minimal diff). But the file in this case is not that large, and "git diff" spends 30s! Michael