summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-06-29 04:13:05 +0200
committerJunio C Hamano <gitster@pobox.com>2021-07-15 00:05:53 +0200
commitf934f1b47fb56d18b2b81d9288590e03e9a0ed23 (patch)
tree68edab13b65236d75b315b29165521b6363e3c17
parentcommit: integrate with sparse-index (diff)
downloadgit-f934f1b47fb56d18b2b81d9288590e03e9a0ed23.tar.xz
git-f934f1b47fb56d18b2b81d9288590e03e9a0ed23.zip
sparse-index: recompute cache-tree
When some commands run with command_requires_full_index=1, then the index can get in a state where the in-memory cache tree is actually equal to the sparse index's cache tree instead of the full one. This results in incorrect entry_count values. By clearing the cache tree before converting to sparse, we avoid this issue. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sparse-index.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sparse-index.c b/sparse-index.c
index 53c8f711cc..c6b4feec41 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -170,6 +170,8 @@ int convert_to_sparse(struct index_state *istate)
if (index_has_unmerged_entries(istate))
return 0;
+ /* Clear and recompute the cache-tree */
+ cache_tree_free(&istate->cache_tree);
if (cache_tree_update(istate, 0)) {
warning(_("unable to update cache-tree, staying full"));
return -1;