aboutsummaryrefslogtreecommitdiffstats
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-02-17 16:25:05 -0800
committerJunio C Hamano <gitster@pobox.com>2022-02-17 16:25:05 -0800
commit2f45f3e2bc859e5d5d29ede28de14f073c2dc227 (patch)
tree5ee746acec3fe482534dbb4c7c8b21c251b47115 /read-cache.c
parent708cbef33a2c905c920e94b70d0946f9f4ff3a4e (diff)
parentb9ca5e26579ceb820103b49648c01187a4a0dddd (diff)
downloadgit-2f45f3e2bc859e5d5d29ede28de14f073c2dc227.tar.gz
Merge branch 'vd/sparse-clean-etc'
"git update-index", "git checkout-index", and "git clean" are taught to work better with the sparse checkout feature. * vd/sparse-clean-etc: update-index: reduce scope of index expansion in do_reupdate update-index: integrate with sparse index update-index: add tests for sparse-checkout compatibility checkout-index: integrate with sparse index checkout-index: add --ignore-skip-worktree-bits option checkout-index: expand sparse checkout compatibility tests clean: integrate with sparse index reset: reorder wildcard pathspec conditions reset: fix validation in sparse index test
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/read-cache.c b/read-cache.c
index 63a792e578..79b9b99ebf 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1340,9 +1340,6 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
int skip_df_check = option & ADD_CACHE_SKIP_DFCHECK;
int new_only = option & ADD_CACHE_NEW_ONLY;
- if (!(option & ADD_CACHE_KEEP_CACHE_TREE))
- cache_tree_invalidate_path(istate, ce->name);
-
/*
* If this entry's path sorts after the last entry in the index,
* we can avoid searching for it.
@@ -1353,6 +1350,13 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
else
pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce), EXPAND_SPARSE);
+ /*
+ * Cache tree path should be invalidated only after index_name_stage_pos,
+ * in case it expands a sparse index.
+ */
+ if (!(option & ADD_CACHE_KEEP_CACHE_TREE))
+ cache_tree_invalidate_path(istate, ce->name);
+
/* existing match? Just replace it. */
if (pos >= 0) {
if (!new_only)