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

Re: git-diff-tree rename detection for single file

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 19, 2005, 03:12 UTC
Message-ID
<Pine.LNX.4.64.0510182004100.3369@g5.osdl.org>
In-Reply-To
<7virvujkcw.fsf@assigned-by-dhcp.cox.net>
On Tue, 18 Oct 2005, Junio C Hamano wrote:
> 
> Having said that, I think we *could* introduce a new flag to
> git-diff-* brothers, --late-pathspec

Gaah. Why? It's really not possible to do it efficiently inside git-diff-xyz, so whatever implementation would basically boil down to something you can already do with some trivial scripting, basically boiling down to:

	git-diff-tree -r -M | grep pathnamelist | git-diff-helper

Now, several reasons why it's much better to do this kind of "--late-pathspec" at a higher level (instead of inside the git-diff-xyz family):

 (a) git-diff-xyz is already some of the more complex core parts. It's not 
     likely a good idea to make them any more complex, unless there's some 
     very fundamental reason for it.
 (b) without pathname limits, git-diff-tree is very slow. Well, it's 
     actually very fast compared to something braindead like CVS, but if 
     you want to track a single file over a thousand releases, it's MUCH 
     MUCH faster to do the pathname limit at the beginning. Otherwise 
     you'll spend all your time reading and comparing big trees with tens 
     of thousands of entries.
 (c) with a higher-level thing, what you can do is have a TWO-phase thing: 
     use the fast pathname limiter in git-diff-tree to figure out when 
     that file changes in history, and then _only_ for those commits do 
     you go back and then do the much more expensive "git-diff-tree -r -M" 
     followed by the pathname-limiting post-processing.

See what I'm saying? You really can do the post-processing outside of git-diff-tree, and you will in fact be much better off if you do so.

The performance impact of pruning the pathnames _before_ diffing them was absolutely staggering. You couldn't reasonably do a "git-whatchanged -p" on the kernel for a single file if you didn't do it the way we do it now.

			Linus
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “git-diff-tree rename detection for single file”
  1. David HoOct 18, 2005
  2. Junio C HamanoOct 18, 2005
  3. Junio C HamanoOct 19, 2005
  4. Linus TorvaldsOct 19, 2005
  5. Junio C HamanoOct 19, 2005
  6. Nicolas PitreOct 19, 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.