Expand description
Commit-graph traversal helpers.
This module exposes collect_ancestor_set. Higher-level walks
(is_ancestor, find_merge_base) live in super::merge alongside
the merge algorithm that consumes them.
Bound: at most MAX_ANCESTORS (10_000) commits are visited per
call. Beyond that the walk stops silently — callers asking about
pathologically deep histories get a partial answer rather than an
OOM.
Constants§
- MAX_
ANCESTORS - Hard cap on commits visited per call.
- MAX_
REACHABLE - Hard cap on the total number of objects
reachable_objectswill visit per call. Matches the scale ofMAX_ANCESTORSbut applies to the full object closure (commits + trees + blobs + chunks), so it is intentionally larger. A repo that exceeds this cap has to split pushes — the push-path is the only caller for now.
Functions§
- collect_
ancestor_ set - Collect the set of all ancestor commits of
start, includingstartitself, by DFS overCommit::parents. The walk: - reachable_
closure - Collect every object reachable from any of
roots— the multi-root generalization ofreachable_objects. This is the closuremkit gc(#233) keeps live: seed it with the full retention root set fromsuper::gc::collect_rootsand every object NOT in the result is unreachable. - reachable_
closure_ checked - Like
reachable_closurebut also reports whether theMAX_REACHABLEcap truncated the walk (true= incomplete). A caller that would delete unreachable objects (gc) MUST treattruncated == trueas fatal: beyond the cap the “unreachable” verdict is unsound, so pruning would drop live data. - reachable_
objects - Collect every object reachable from commit
root— the full closure needed to reconstruct the commit on a fresh store. Walks, in order: