diff options
| author | 2026-03-29 14:42:13 +0000 | |
|---|---|---|
| committer | 2026-03-29 14:47:04 +0000 | |
| commit | df73a4c6f1b58075316ba7449fbfb127b9fbb79d (patch) | |
| tree | 62fee259ec037410b06419ee3ac9c2c189c35ab3 /commitquery/ancestor.go | |
| parent | internal/priorityqueue: Update docs (diff) | |
| signature | No signature | |
commitquery: Reorganize
Diffstat (limited to 'commitquery/ancestor.go')
| -rw-r--r-- | commitquery/ancestor.go | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/commitquery/ancestor.go b/commitquery/ancestor.go deleted file mode 100644 index 6a43babb..00000000 --- a/commitquery/ancestor.go +++ /dev/null @@ -1,48 +0,0 @@ -package commitquery - -import objectid "codeberg.org/lindenii/furgit/object/id" - -// IsAncestor reports whether ancestor is reachable from descendant through -// commit parent edges. -// -// Both inputs are peeled through annotated tags before commit traversal. -func (query *query) IsAncestor(ancestor, descendant objectid.ObjectID) (bool, error) { - ancestorIdx, err := query.resolveCommitish(ancestor) - if err != nil { - return false, err - } - - descendantIdx, err := query.resolveCommitish(descendant) - if err != nil { - return false, err - } - - return query.isAncestor(ancestorIdx, descendantIdx) -} - -func (query *query) isAncestor(ancestor, descendant nodeIndex) (bool, error) { - if ancestor == descendant { - return true, nil - } - - ancestorGeneration := query.effectiveGeneration(ancestor) - descendantGeneration := query.effectiveGeneration(descendant) - - if ancestorGeneration != generationInfinity && - descendantGeneration != generationInfinity && - ancestorGeneration > descendantGeneration { - return false, nil - } - - minGeneration := uint64(0) - if ancestorGeneration != generationInfinity { - minGeneration = ancestorGeneration - } - - err := query.paintDownToCommon(ancestor, []nodeIndex{descendant}, minGeneration) - if err != nil { - return false, err - } - - return query.hasAnyMarks(ancestor, markRight), nil -} |
