Skip to main content

build_cache_tree_from_tree

Function build_cache_tree_from_tree 

Source
pub fn build_cache_tree_from_tree(
    odb: &Odb,
    tree_oid: &ObjectId,
) -> Result<CacheTreeNode>
Expand description

Build a cache-tree directly from a tree object, preserving Git’s raw entry_count semantics. Unlike build_cache_tree_from_index, the per-node entry_count is the recursive number of non-tree entries as recorded in the tree — duplicate path entries are counted separately, exactly as upstream Git’s cache-tree does after reading such a tree into the index.

This is the cache-tree real Git attaches after read-tree/reset/checkout populate the index from a tree. For a tree with duplicate entries (t4058-diff-duplicates) the resulting entry_count exceeds the number of (deduplicated) index entries, so verify_cache_tree later reports “corrupted cache-tree has entries not present in index”.