summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2021-11-29 15:52:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-11-29 20:51:26 (GMT)
commitc01b1cbd473c05e29fe0c1a31b8f6539e82c4559 (patch)
tree38bbe77ece24553f0a77d05401135a35ca77853e /cache-tree.c
parent291d77eb3e28aee42821d500bf61211f09b4297a (diff)
downloadgit-c01b1cbd473c05e29fe0c1a31b8f6539e82c4559.zip
git-c01b1cbd473c05e29fe0c1a31b8f6539e82c4559.tar.gz
git-c01b1cbd473c05e29fe0c1a31b8f6539e82c4559.tar.bz2
reset: integrate with sparse index
Disable `command_requires_full_index` repo setting and add `ensure_full_index` guards around code paths that cannot yet use sparse directory index entries. `reset --soft` does not modify the index, so no compatibility changes are needed for it to function without expanding the index. For all other reset modes (`--mixed`, `--hard`, `--keep`, `--merge`), the full index is expanded to prevent cache tree corruption and invalid variable accesses. Additionally, the `read_cache()` check verifying an uncorrupted index is moved after argument parsing and preparing the repo settings. The index is not used by the preceding argument handling, but `read_cache()` must be run *after* enabling sparse index for the command (so that the index is not expanded unnecessarily) and *before* using the index for reset (so that it is verified as uncorrupted). Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 90919f9..9be19c8 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -776,6 +776,7 @@ void prime_cache_tree(struct repository *r,
cache_tree_free(&istate->cache_tree);
istate->cache_tree = cache_tree();
+ ensure_full_index(istate);
prime_cache_tree_rec(r, istate->cache_tree, tree);
istate->cache_changed |= CACHE_TREE_CHANGED;
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);