Skip to content

Commit 3d6167f

Browse files
committed
Merge branch 'dl/cache-tree-fully-valid-fix' into jch
The check that implements the logic to see if an in-core cache-tree is fully ready to write out a tree object was broken, which has been corrected. * dl/cache-tree-fully-valid-fix: cache-tree: fix inverted object existence check in cache_tree_fully_valid
2 parents ff72455 + 5217312 commit 3d6167f

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

cache-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ int cache_tree_fully_valid(struct cache_tree *it)
238238
if (!it)
239239
return 0;
240240
if (it->entry_count < 0 ||
241-
odb_has_object(the_repository->objects, &it->oid,
242-
ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
241+
!odb_has_object(the_repository->objects, &it->oid,
242+
ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
243243
return 0;
244244
for (i = 0; i < it->subtree_nr; i++) {
245245
if (!cache_tree_fully_valid(it->down[i]->cache_tree))

t/t0090-cache-tree.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,12 @@ test_expect_success 'switching trees does not invalidate shared index' '
278278
)
279279
'
280280

281+
test_expect_success 'cache-tree is used by write-tree when valid' '
282+
test_commit use-valid &&
283+
284+
# write-tree with a valid cache-tree should skip cache_tree_update
285+
GIT_TRACE2_PERF="$(pwd)/trace.output" git write-tree &&
286+
test_grep ! region_enter.*cache_tree.*update trace.output
287+
'
288+
281289
test_done

0 commit comments

Comments
 (0)