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

[RFC] use typechange as rename source

From
Jeff King <peff@peff.net>
Date
Nov 21, 2007, 17:12 UTC
Message-ID
<20071121171235.GA32233@sigill.intra.peff.net>
Today in one of my repositories I did something like this:
  $ mv foo bar
  $ ln -s bar foo
  $ git add .
and I expected git-status to claim:
  typechange: foo
  renamed:    foo -> bar

but it didn't find the rename (without -C) because the path 'foo' still exists. So there is a disconnect in what git and I think of as "exists". Should typechanges make a file eligible as a rename src?

A quickie patch to implement this is:
diff --git a/diffcore-rename.c b/diffcore-rename.c
index f9ebea5..5a34e8a 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -417,6 +417,10 @@ void diffcore_rename(struct diff_options *options)
 				p->one->rename_used++;
 			register_rename_src(p->one, p->score);
 		}
+		else if (DIFF_PAIR_TYPE_CHANGED(p)) {
+			p->one->rename_used++;
+			register_rename_src(p->one, p->score);
+		}
 		else if (detect_rename == DIFF_DETECT_COPY) {
 			/*
 			 * Increment the "rename_used" score by

There are a few add-on questions:

  - should typechanges in both directions be used, or just file ->
    symlink?

  - this actually produces a 'copied' status rather than a 'renamed'
    since the 'foo' entry does still exist. Is this reasonable?

-Peff
Next: Junio C Hamano
Message 1 of 14 in “[RFC] use typechange as rename source”
  1. Jeff KingNov 21, 2007
  2. Junio C HamanoNov 29, 2007
  3. Jeff KingNov 29, 2007
  4. Junio C HamanoNov 30, 2007
  5. Jeff KingNov 30, 2007
  6. Junio C HamanoDec 1, 2007
  7. Jeff KingDec 1, 2007
  8. Junio C HamanoDec 1, 2007
  9. Junio C HamanoDec 1, 2007
  10. Jeff KingDec 1, 2007
  11. Junio C HamanoDec 1, 2007
  12. Jeff KingDec 1, 2007
  13. Junio C HamanoDec 2, 2007
  14. Jeff KingDec 3, 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.