diff options
| author | 2026-03-06 10:38:46 +0800 | |
|---|---|---|
| committer | 2026-03-06 10:38:46 +0800 | |
| commit | 7987e9350b590a4a9038ad18fe2ff049c0037cb8 (patch) | |
| tree | dafe51aa15701676d52fc07b4b6163207e94e6bd /reachability/reachability.go | |
| parent | reachability: Use commit-graph (diff) | |
| signature | No signature | |
reachability, internal/testgit: Fix lints v0.1.56
Diffstat (limited to 'reachability/reachability.go')
| -rw-r--r-- | reachability/reachability.go | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/reachability/reachability.go b/reachability/reachability.go index 9126ee84..29ac2a93 100644 --- a/reachability/reachability.go +++ b/reachability/reachability.go @@ -71,6 +71,42 @@ func (r *Reachability) IsAncestor(ancestor, descendant objectid.ObjectID) (bool, return false, nil } +// CheckConnected verifies that all objects reachable from wants (under the +// selected domain) can be fully traversed without missing-object/type/parse +// errors, excluding subgraphs rooted at haves. +// +// Even with commit-graph acceleration available, each visited commit is +// still validated against the object store. +func (r *Reachability) CheckConnected(domain Domain, haves, wants map[objectid.ObjectID]struct{}) error { + walk := r.Walk(domain, haves, wants) + + walk.strict = true + for range walk.Seq() { + } + + return walk.Err() +} + +// Walk creates one single-use traversal over the selected domain. +// +// In DomainCommits, when a commit-graph reader is attached, parent expansion +// may use commit-graph metadata for speed. +func (r *Reachability) Walk(domain Domain, haves, wants map[objectid.ObjectID]struct{}) *Walk { + walk := &Walk{ + reachability: r, + domain: domain, + haves: haves, + wants: wants, + } + + err := validateDomain(domain) + if err != nil { + walk.err = err + } + + return walk +} + func (r *Reachability) isAncestorGraph(ancestor, descendant objectid.ObjectID) (bool, bool, error) { if r.graph == nil { return false, false, nil @@ -141,38 +177,3 @@ func (r *Reachability) isAncestorGraph(ancestor, descendant objectid.ObjectID) ( return false, true, nil } - -// CheckConnected verifies that all objects reachable from wants (under the -// selected domain) can be fully traversed without missing-object/type/parse -// errors, excluding subgraphs rooted at haves. -// -// Even with commit-graph acceleration available, each visited commit is -// still validated against the object store. -func (r *Reachability) CheckConnected(domain Domain, haves, wants map[objectid.ObjectID]struct{}) error { - walk := r.Walk(domain, haves, wants) - walk.strict = true - for range walk.Seq() { - } - - return walk.Err() -} - -// Walk creates one single-use traversal over the selected domain. -// -// In DomainCommits, when a commit-graph reader is attached, parent expansion -// may use commit-graph metadata for speed. -func (r *Reachability) Walk(domain Domain, haves, wants map[objectid.ObjectID]struct{}) *Walk { - walk := &Walk{ - reachability: r, - domain: domain, - haves: haves, - wants: wants, - } - - err := validateDomain(domain) - if err != nil { - walk.err = err - } - - return walk -} |
