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

Re: [PATCH, take 2] Linear-time/space rename logic (exact renames only)

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Oct 22, 2007, 19:44 UTC
Message-ID
<alpine.LFD.0.999.0710221241560.30120@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.0.999.0710221207300.30120@woody.linux-foundation.org>
On Mon, 22 Oct 2007, Linus Torvalds wrote:
> 
> I'm sure there's more to come..

One more detail.. The updated comment explains the issue: if we broke a file apart, and rename detection joined it back together, the result is neither a rename nor a copy, it's a regular modification (and all remaining renames will be copies of the original, so don't bother decrementing the "rename_used" count).

		Linus
---
 diff.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/diff.c b/diff.c
index 2e74cb3..e839f59 100644
--- a/diff.c
+++ b/diff.c
@@ -2636,13 +2636,19 @@ static void diff_resolve_rename_copy(void)
 		 * either in-place edit or rename/copy edit.
 		 */
 		else if (DIFF_PAIR_RENAME(p)) {
-			/* See if there is some other filepair that
-			 * copies from the same source as us.  If so
-			 * we are a copy.  Otherwise we are either a
-			 * copy if the path stays, or a rename if it
-			 * does not, but we already handled "stays" case.
+			/*
+			 * A rename might have re-connected a broken
+			 * pair up, causing the pathnames to be the
+			 * same again. If so, that's not a rename at
+			 * all, just a modification..
+			 *
+			 * Otherwise, see if this source was used for
+			 * multiple renames, in which case we decrement
+			 * the count, and call it a copy.
 			 */
-			if (--p->one->rename_used > 0)
+			if (!strcmp(p->one->path, p->two->path))
+				p->status = DIFF_STATUS_MODIFIED;
+			else if (--p->one->rename_used > 0)
 				p->status = DIFF_STATUS_COPIED;
 			else
 				p->status = DIFF_STATUS_RENAMED;
Previous: Linus TorvaldsNext: Alex Riesen
Message 10 of 13 in “Linear-time/space rename logic (exact renames only)”
  1. Linear-time/space rename logic (exact renames only)Linus Torvalds, Oct 21, 2007
  2. David SymondsOct 22, 2007
  3. Linus TorvaldsOct 22, 2007
  4. Jeff KingOct 22, 2007
  5. Sven VerdoolaegeOct 22, 2007
  6. Jeff KingOct 22, 2007
  7. Linus TorvaldsOct 22, 2007
  8. Linear-time/space rename logic (exact renames only)Linus Torvalds, Oct 22, 2007
  9. Linus TorvaldsOct 22, 2007
  10. Linus TorvaldsOct 22, 2007
  11. Alex RiesenOct 22, 2007
  12. Linus TorvaldsOct 22, 2007
  13. Alex RiesenOct 22, 2007

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.