summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-07-14 13:12:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-07-14 20:42:48 (GMT)
commit17a1bb570bcd165a3dc1c28c441bee45a941bb12 (patch)
tree8321006978fae884df42ec3acc57ea7b09d72166 /unpack-trees.c
parentbf26c06f126219498a10ae9f8923cfb0bcbad823 (diff)
downloadgit-17a1bb570bcd165a3dc1c28c441bee45a941bb12.zip
git-17a1bb570bcd165a3dc1c28c441bee45a941bb12.tar.gz
git-17a1bb570bcd165a3dc1c28c441bee45a941bb12.tar.bz2
unpack-trees: preserve cache_bottom
The cache_bottom member of 'struct unpack_trees_options' is used to track the range of index entries corresponding to a node of the cache tree. While recursing with traverse_by_cache_tree(), this value is preserved on the call stack using a local and then restored as that method returns. The mark_ce_used() method normally modifies the cache_bottom member when it refers to the marked cache entry. However, sparse directory entries are stored as nodes in the cache-tree data structure as of 2de37c53 (cache-tree: integrate with sparse directory entries, 2021-03-30). Thus, the cache_bottom will be modified as the cache-tree walk advances. Do not update it as well within mark_ce_used(). Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index f88a69f..87c1ed2 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -600,6 +600,13 @@ static void mark_ce_used(struct cache_entry *ce, struct unpack_trees_options *o)
{
ce->ce_flags |= CE_UNPACKED;
+ /*
+ * If this is a sparse directory, don't advance cache_bottom.
+ * That will be advanced later using the cache-tree data.
+ */
+ if (S_ISSPARSEDIR(ce->ce_mode))
+ return;
+
if (o->cache_bottom < o->src_index->cache_nr &&
o->src_index->cache[o->cache_bottom] == ce) {
int bottom = o->cache_bottom;