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
This commit is contained in:
Junio C Hamano
2026-04-09 11:22:18 -07:00
2 changed files with 10 additions and 2 deletions

View File

@@ -238,8 +238,8 @@ 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_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
!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++) {
if (!cache_tree_fully_valid(it->down[i]->cache_tree))

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