aboutsummaryrefslogtreecommitdiff
path: root/commitquery/query_is_ancestor.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-04-02 06:23:30 +0000
committerGravatar Runxi Yu2026-04-02 06:28:39 +0000
commita041d523de389b65b98a5373a8034041db2a8d83 (patch)
tree7b423dc735f463be616045f2c3c2095a7737aca7 /commitquery/query_is_ancestor.go
parentresearch: Add dynamic pack resources (diff)
signatureNo signature
*: Remove
Diffstat (limited to 'commitquery/query_is_ancestor.go')
-rw-r--r--commitquery/query_is_ancestor.go49
1 files changed, 0 insertions, 49 deletions
diff --git a/commitquery/query_is_ancestor.go b/commitquery/query_is_ancestor.go
deleted file mode 100644
index c21892c8..00000000
--- a/commitquery/query_is_ancestor.go
+++ /dev/null
@@ -1,49 +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)
-}
-
-// isAncestor answers one ancestry query between two resolved internal nodes.
-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
-}