Fast implementation of Git in pure Go codeberg.org/lindenii/furgit
git go
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

reachability: Peel root to commit

Runxi Yu 04e1b6bf 46f66e8e

+5 -9
+2 -2
reachability/ancestor.go
··· 12 12 // 13 13 // Both inputs are peeled through annotated tags before commit traversal. 14 14 func (r *Reachability) IsAncestor(ancestor, descendant objectid.ObjectID) (bool, error) { 15 - ancestorCommit, err := r.peelRootToDomain(ancestor, DomainCommits) 15 + ancestorCommit, err := r.peelRootToCommit(ancestor) 16 16 if err != nil { 17 17 return false, err 18 18 } 19 19 20 - descendantCommit, err := r.peelRootToDomain(descendant, DomainCommits) 20 + descendantCommit, err := r.peelRootToCommit(descendant) 21 21 if err != nil { 22 22 return false, err 23 23 }
+3 -7
reachability/peel.go
··· 6 6 "codeberg.org/lindenii/furgit/objecttype" 7 7 ) 8 8 9 - func (r *Reachability) peelRootToDomain(id objectid.ObjectID, domain Domain) (objectid.ObjectID, error) { 10 - err := validateDomain(domain) 11 - if err != nil { 12 - return objectid.ObjectID{}, err 13 - } 14 - 9 + // peelRootToCommit peels annotated tags transitively until a commit is reached. 10 + func (r *Reachability) peelRootToCommit(id objectid.ObjectID) (objectid.ObjectID, error) { 15 11 for { 16 12 ty, err := r.readHeaderType(id) 17 13 if err != nil { ··· 19 15 } 20 16 21 17 if ty != objecttype.TypeTag { 22 - if domain == DomainCommits && ty != objecttype.TypeCommit { 18 + if ty != objecttype.TypeCommit { 23 19 return objectid.ObjectID{}, &ObjectTypeError{OID: id, Got: ty, Want: objecttype.TypeCommit} 24 20 } 25 21