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

Re: [PATCH] Detect renames in diff family.

From
Linus Torvalds <torvalds@osdl.org>
Date
May 19, 2005, 16:19 UTC
Message-ID
<Pine.LNX.4.58.0505190901340.2322@ppc970.osdl.org>
In-Reply-To
<7vu0kz1p6k.fsf@assigned-by-dhcp.cox.net>
On Thu, 19 May 2005, Junio C Hamano wrote:
Show 6 quoted lines
> 
> Special request for Linus is to check if I did not screw up the
> various calls into the diff core from diff-tree.  Essentially
> the idea is to start one patchset session with diff_setup() and
> close it with diff_flush() before you start another patchset
> session.
It all looks ok from a quick setup, and with this I can now do
	git-whatchanged -M
in the kernel, and searching for renames I find:
	diff --git a/arch/um/kernel/sys_call_table.c b/arch/um/sys-x86_64/sys_call_table.c
	rename old arch/um/kernel/sys_call_table.c
	rename new arch/um/sys-x86_64/sys_call_table.c
	--- a/arch/um/kernel/sys_call_table.c
	+++ b/arch/um/sys-x86_64/sys_call_table.c
	@@ -1,4 +1,4 @@
	-/* 
	+/*
	  * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
	  * Copyright 2003 PathScale, Inc.
	  * Licensed under the GPL
	@@ -14,6 +14,12 @@
	 #include "sysdep/syscalls.h"
	 #include "kern_util.h"
	 
	+#ifdef CONFIG_NFSD
	....
which looks quite correct.

I notice that you left some debugging output in there ("**score **" stuff), and I'll remove it, but it's merged and pushed out and passed my trivial tests.

[ rambling mode on: ]

One thing that struck me is that there is nothing wrong with having the same old file marked twice for a rename, or considering new files to be copies of old files. So if we ever allow that, then "rename" may be the wrong name for this, since the logic certainly allows the old file to still exist (or be removed and show up multiple times in a new guise).

In other words, let's say that we create a new architecture or a new filesystem, and we have tons of _new_ files, but not a lot of removed files. It would literally be very cool to see that the new files are based on contents of old files, and that it would thus potentially be very interesting to see a diff like

	diff --git a/arch/i386/kernel/irq.c b/arch/x86-64/kernel/irq.c
	based-on old arch/i386/kernel/irq.c
	creates new arch/x86-64/kernel/irq.c
	--- arch/i386/kernel/irq.c
	+++ arch/x86_64/kernel/irq.c
	@@ -1,205 +1,31 @@
	 /*
	- *     linux/arch/i386/kernel/irq.c
	+ *     linux/arch/x86_64/kernel/irq.c
	  *
	  *     Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
	  *
	...
(the above is a made-up example, but it's at least _half-way_ valid).

I'm not suggesting you actually do this, if only because it's quite expensive: it means that any newly added file would have to be compared with _all_ files in the previous archive, which is just too damn expensive. But I'd like people to kind of keep this in mind as a possibility, because maybe wasting CPU time in a big way might actually be acceptable in some cases, and having a separate flag to enable this kind of thing might be interesting, no?

		Linus
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 43 in “Detect renames in diff family.”
  1. Detect renames in diff family.Junio C Hamano, May 19, 2005
  2. Linus TorvaldsMay 19, 2005
  3. Junio C HamanoMay 19, 2005
  4. Linus TorvaldsMay 19, 2005
  5. Nicolas PitreMay 19, 2005
  6. Junio C HamanoMay 19, 2005
  7. Nicolas PitreMay 19, 2005
  8. Junio C HamanoMay 19, 2005
  9. Nicolas PitreMay 19, 2005
  10. Junio C HamanoMay 19, 2005
  11. Linus TorvaldsMay 19, 2005
  12. Junio C HamanoMay 19, 2005
  13. Linus TorvaldsMay 20, 2005
  14. Junio C HamanoMay 20, 2005
  15. Junio C HamanoMay 19, 2005
  16. Junio C HamanoMay 19, 2005
  17. Linus TorvaldsMay 19, 2005
  18. Junio C HamanoMay 19, 2005
  19. H. Peter AnvinMay 19, 2005
  20. Joel BeckerMay 19, 2005
  21. Junio C HamanoMay 21, 2005
  22. 1/3 Diff overhaul, adding half of copy detection.Junio C Hamano, May 21, 2005
  23. 2/3 Introducing software archaeologist's tool "pickaxe".Junio C Hamano, May 21, 2005
  24. Constness fix for pickaxe option.Junio C Hamano, May 21, 2005
  25. Linus TorvaldsMay 21, 2005
  26. 3/3 Diff overhaul, adding the other half of copy detection.Junio C Hamano, May 21, 2005
  27. Teach diff-tree to report unmodified paths for -C option.Junio C Hamano, May 21, 2005
  28. Junio C HamanoMay 21, 2005
  29. Linus TorvaldsMay 21, 2005
  30. Junio C HamanoMay 21, 2005
  31. Linus TorvaldsMay 21, 2005
  32. Linus TorvaldsMay 21, 2005
  33. Linus TorvaldsMay 21, 2005
  34. Junio C HamanoMay 21, 2005
  35. Junio C HamanoMay 24, 2005
  36. Linus TorvaldsMay 24, 2005
  37. Junio C HamanoMay 24, 2005
  38. Linus TorvaldsMay 24, 2005
  39. Junio C HamanoMay 24, 2005
  40. Detect copies harder in diff-tree.Junio C Hamano, May 26, 2005
  41. Junio C HamanoMay 21, 2005
  42. Tweak diffcore-rename heuristics.Junio C Hamano, May 21, 2005
  43. Now I think I am done with diff...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.