Skip to content

Commit 65e79b8

Browse files
committed
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 <[email protected]>
1 parent cd94f82 commit 65e79b8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sparse-index.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ int convert_to_sparse(struct index_state *istate)
170170
if (index_has_unmerged_entries(istate))
171171
return 0;
172172

173+
/* Clear and recompute the cache-tree */
174+
cache_tree_free(&istate->cache_tree);
173175
if (cache_tree_update(istate, 0)) {
174176
warning(_("unable to update cache-tree, staying full"));
175177
return -1;

0 commit comments

Comments
 (0)