aboutsummaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorNick Golden <blindmansion@gmail.com>2026-04-01 15:00:33 -0400
committerJunio C Hamano <gitster@pobox.com>2026-04-01 12:45:06 -0700
commitc0ce43376b178d876bce2073b81737ce49657def (patch)
tree50ea30354c34da6c85778f9c78172d34ff970f74 /read-cache.c
parent67ad42147a7acc2af6074753ebd03d904476118f (diff)
downloadgit-c0ce43376b178d876bce2073b81737ce49657def.tar.xz
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 <blindmansion@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c1
1 files changed, 1 insertions, 0 deletions
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 */
/*