Skip to main content

reachable_objects

Function reachable_objects 

Source
pub fn reachable_objects(
    store: &ObjectStore,
    root: &Hash,
) -> Result<BTreeSet<Hash>, StoreError>
Expand description

Collect every object reachable from commit root — the full closure needed to reconstruct the commit on a fresh store. Walks, in order:

  1. root commit → its tree_hash + every parent.
  2. each tree → every entry’s object_hash (blob / tree / chunked-blob).
  3. nested trees → recurse.
  4. chunked-blob manifests → every chunks[i] hash.

Deltas are not produced by any path the push code drives, and remix objects are walked like commits (tree + parents) per SPEC-OBJECTS §6.

Returns a BTreeSet so iteration order is deterministic — the push code uses that to build reproducible packfiles. Deduplication happens naturally via the set.

§Errors

  • StoreError::ObjectNotFound if root itself is missing from the store. Missing referenced objects (e.g. a tree listing a blob that got pruned) are a harder failure and propagate via the same variant — callers pushing partial repos should fix their store before pushing.
  • Other StoreError variants propagate as-is.