From c0ce43376b178d876bce2073b81737ce49657def Mon Sep 17 00:00:00 2001 From: Nick Golden Date: Wed, 1 Apr 2026 15:00:33 -0400 Subject: read-cache: disable renames in add_files_to_cache add_files_to_cache() refreshes the index from worktree changes and does not need rename detection. When unmerged entries and a deleted stage-0 path are present together, rename detection can pair them and rewrite an unmerged diff pair to point at the deleted path. That later makes "git commit -a" and "git add -u" try to stat the deleted path and die with "unable to stat". Disable rename detection in this callback-driven staging path and add a regression test covering the crash. Signed-off-by: Nick Golden Signed-off-by: Junio C Hamano --- read-cache.c | 1 + 1 file changed, 1 insertion(+) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index 0c07c3aef7..bacb841a2e 100644 --- a/read-cache.c +++ b/read-cache.c @@ -3975,6 +3975,7 @@ int add_files_to_cache(struct repository *repo, const char *prefix, rev.diffopt.format_callback = update_callback; rev.diffopt.format_callback_data = &data; rev.diffopt.flags.override_submodule_config = 1; + rev.diffopt.detect_rename = 0; /* staging worktree changes does not need renames */ rev.max_count = 0; /* do not compare unmerged paths with stage #2 */ /* -- cgit v1.3