Skip to content

Commit 17a1bb5

Browse files
derrickstoleegitster
authored andcommitted
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 2de37c5 (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 <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bf26c06 commit 17a1bb5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

unpack-trees.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,13 @@ static void mark_ce_used(struct cache_entry *ce, struct unpack_trees_options *o)
600600
{
601601
ce->ce_flags |= CE_UNPACKED;
602602

603+
/*
604+
* If this is a sparse directory, don't advance cache_bottom.
605+
* That will be advanced later using the cache-tree data.
606+
*/
607+
if (S_ISSPARSEDIR(ce->ce_mode))
608+
return;
609+
603610
if (o->cache_bottom < o->src_index->cache_nr &&
604611
o->src_index->cache[o->cache_bottom] == ce) {
605612
int bottom = o->cache_bottom;

0 commit comments

Comments
 (0)