Merge branch 'dl/cache-tree-fully-valid-fix'

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
main
Junio C Hamano 2026-05-11 10:05:52 +09:00
commit ab0691db4e
2 changed files with 10 additions and 2 deletions

View File

@ -238,7 +238,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
if (!it)
return 0;
if (it->entry_count < 0 ||
odb_has_object(the_repository->objects, &it->oid,
!odb_has_object(the_repository->objects, &it->oid,
ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return 0;
for (i = 0; i < it->subtree_nr; i++) {

View File

@ -278,4 +278,12 @@ test_expect_success 'switching trees does not invalidate shared index' '
)
'

test_expect_success 'cache-tree is used by write-tree when valid' '
test_commit use-valid &&

# write-tree with a valid cache-tree should skip cache_tree_update
GIT_TRACE2_PERF="$(pwd)/trace.output" git write-tree &&
test_grep ! region_enter.*cache_tree.*update trace.output
'

test_done