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

Re: [BUG] 'git mv a/fileA b/fileB' causes 'c/fileC' to be deleted

From
Junio C Hamano <junkio@cox.net>
Date
Oct 2, 2006, 05:20 UTC
Message-ID
<7vmz8fxpiq.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vven3xq7l.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
> Thanks.  I see it reproduces.
>
> It is a bug in git-mv that fails to update cache-tree data
> structure properly.  This patch should fix it.

The previous patch was safer but unnecessarily was a bit heavy handed. This should fix it nicer.

-- >8 -- git-mv: invalidate the removed path properly in cache-tree

The command updated the cache without invalidating the cache tree entries while removing an existing entry.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/builtin-mv.c b/builtin-mv.c
index 4d21d88..54dd3bf 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -278,6 +278,7 @@ int cmd_mv(int argc, const char **argv, 
 		for (i = 0; i < deleted.nr; i++) {
 			const char *path = deleted.items[i].path;
 			remove_file_from_cache(path);
+			cache_tree_invalidate_path(active_cache_tree, path);
 		}
 
 		if (active_cache_changed) {
Previous: Junio C Hamano
Message 5 of 5 in “[BUG] 'git mv a/fileA b/fileB' causes 'c/fileC' to be deleted”
  1. Michael CassarOct 1, 2006
  2. Junio C HamanoOct 1, 2006
  3. Michael CassarOct 2, 2006
  4. Junio C HamanoOct 2, 2006
  5. Junio C HamanoOct 2, 2006

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.