summaryrefslogtreecommitdiff
path: root/sparse-index.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-03-30 13:11:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-03-30 19:57:48 (GMT)
commit2de37c536d54a28a032491ad4ef97632ef6ab836 (patch)
treee9eb29e598eb4cbb34ac3609ad9fe1189642fb61 /sparse-index.c
parentdcc5fd5fd26b71d75f9e70abd0e09e553b5f40ca (diff)
downloadgit-2de37c536d54a28a032491ad4ef97632ef6ab836.zip
git-2de37c536d54a28a032491ad4ef97632ef6ab836.tar.gz
git-2de37c536d54a28a032491ad4ef97632ef6ab836.tar.bz2
cache-tree: integrate with sparse directory entries
The cache-tree extension was previously disabled with sparse indexes. However, the cache-tree is an important performance feature for commands like 'git status' and 'git add'. Integrate it with sparse directory entries. When writing a sparse index, completely clear and recalculate the cache tree. By starting from scratch, the only integration necessary is to check if we hit a sparse directory entry and create a leaf of the cache-tree that has an entry_count of one and no subtrees. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sparse-index.c')
-rw-r--r--sparse-index.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sparse-index.c b/sparse-index.c
index 4c73772..95ea171 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -172,7 +172,11 @@ int convert_to_sparse(struct index_state *istate)
istate->cache_nr = convert_to_sparse_rec(istate,
0, 0, istate->cache_nr,
"", 0, istate->cache_tree);
- istate->drop_cache_tree = 1;
+
+ /* Clear and recompute the cache-tree */
+ cache_tree_free(&istate->cache_tree);
+ cache_tree_update(istate, 0);
+
istate->sparse_index = 1;
trace2_region_leave("index", "convert_to_sparse", istate->repo);
return 0;
@@ -273,5 +277,9 @@ void ensure_full_index(struct index_state *istate)
strbuf_release(&base);
free(full);
+ /* Clear and recompute the cache-tree */
+ cache_tree_free(&istate->cache_tree);
+ cache_tree_update(istate, 0);
+
trace2_region_leave("index", "ensure_full_index", istate->repo);
}