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

Re: [PATCH] The diff-raw format updates.

From
Linus Torvalds <torvalds@osdl.org>
Date
May 22, 2005, 20:24 UTC
Message-ID
<Pine.LNX.4.58.0505221259110.2307@ppc970.osdl.org>
In-Reply-To
<7vy8a7cavf.fsf@assigned-by-dhcp.cox.net>
On Sun, 22 May 2005, Junio C Hamano wrote:
Show 5 quoted lines
>
> I deliberatly chose not to record rename/copy distinction in diff-raw
> --- it is to be inferred from which entry touches the src _last_.  
> Everything but the last one to touch the same path is copy, and the last
> one is rename.
My counter-example: there is no rename at all, just a copy.

The current raw-diff output simply _cannot_ distinguish this from the case where there is a rename, as far as I can tell.

Basically, imagine doing something like this:
	mkdir test-copy
	cd test-copy
	git-init-db 
	cp ~/v2.6/linux/kernel/sched.c .
	git-update-cache --add sched.c 
	echo duh | git-commit-tree $(git-write-tree) > .git/HEAD
	sed 's/sched\.c/other\.c/g' < sched.c > other.c
	git-update-cache --add other.c 
	echo duh2 | git-commit-tree $(git-write-tree) -p HEAD

and dammit, if "other.c" doesn't show up as a copy (with small differences) of sched.c, then the whole diff algorithm is broken and clearly isn't doing copy-diffs right at all (right now it doesn't do it since diff-tree doesn't even do the "check copies against old", but that's a different issue).

In other words, how do you propose to _describe_ that copy?

The whole point to the "raw diff" format is that you should be able to get the same output with

	git-diff-tree -C HEAD | git-diff-helper
	git-diff-tree -C -p HEAD

and right now I don't see how you can do that.. And if you can't do that, then the raw diff format is pointless. It's not "raw diff" at all, it's a "less capable diff" format.

THAT is why I think the raw diff output is broken right now. All the rest was about just trying to also make it a bit more readable while at it.

Try it. I added in the "&& detect_rename < 2" thing to diff-tree.c, and I get:

	git-whatchanged -C --root | git-diff-helper | less -S
resulting in:
	diff-tree eb773598aa29bb642d6016a0d5961c80628ce490 (from 8c63fcad1f27ceed6825110aa806349dad99d89f)
	Author: Linus Torvalds <torvalds@ppc970.osdl.org>
	Date:   Sun May 22 13:17:40 2005 -0700
	    
	    duh2
	
	diff --git a/sched.c b/other.c
	--- a/sched.c
	+++ b/other.c
	@@ -1,5 +1,5 @@
	 /*
	- *  kernel/sched.c
	+ *  kernel/other.c
	  *
	  *  Kernel scheduler and related syscalls
	  *

ie it does NOT say it is a copy, because it _cannot_ say it is a copy. It just doesn't know. A copy and a rename look exactly the same in the raw diff output, and that's a BUG.

		Linus
Previous: Junio C HamanoNext: Junio C Hamano
Message 20 of 33 in “updated design for the diff-raw format.”
  1. Junio C HamanoMay 21, 2005
  2. Junio C HamanoMay 21, 2005
  3. Junio C HamanoMay 21, 2005
  4. Junio C HamanoMay 21, 2005
  5. Junio C HamanoMay 21, 2005
  6. Prepare diffcore interface for diff-tree header supression.Junio C Hamano, May 22, 2005
  7. The diff-raw format updates.Junio C Hamano, May 22, 2005
  8. Linus TorvaldsMay 22, 2005
  9. Junio C HamanoMay 22, 2005
  10. Junio C HamanoMay 22, 2005
  11. Fix tweak in similarity estimator.Junio C Hamano, May 22, 2005
  12. Linus TorvaldsMay 22, 2005
  13. Niklas HoglundMay 22, 2005
  14. Junio C HamanoMay 22, 2005
  15. Thomas GlanzmannMay 22, 2005
  16. Linus TorvaldsMay 22, 2005
  17. Thomas GlanzmannMay 22, 2005
  18. Junio C HamanoMay 22, 2005
  19. Junio C HamanoMay 22, 2005
  20. Linus TorvaldsMay 22, 2005
  21. Junio C HamanoMay 22, 2005
  22. Linus TorvaldsMay 22, 2005
  23. Junio C HamanoMay 23, 2005
  24. Linus TorvaldsMay 23, 2005
  25. Junio C HamanoMay 23, 2005
  26. Rename/copy detection fix.Junio C Hamano, May 23, 2005
  27. Comments on "Rename/copy detection fix."Junio C Hamano, May 23, 2005
  28. Junio C HamanoMay 22, 2005
  29. Diffcore updates.Junio C Hamano, May 22, 2005
  30. Linus TorvaldsMay 22, 2005
  31. Junio C HamanoMay 22, 2005
  32. Diffcore updates.Junio C Hamano, May 22, 2005
  33. Be careful with symlinks when detecting renames and copies.Junio C Hamano, May 23, 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.