blob: 78149c6a49d5c36da2dd2520ecd50877632a2fe7 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package commitquery
// IsAncestor reports whether ancestor is reachable from descendant through
// commit parent edges.
func IsAncestor(ctx *Context, ancestor, descendant NodeIndex) (bool, error) {
if ancestor == descendant {
return true, nil
}
ancestorGeneration := ctx.EffectiveGeneration(ancestor)
descendantGeneration := ctx.EffectiveGeneration(descendant)
if ancestorGeneration != generationInfinity &&
descendantGeneration != generationInfinity &&
ancestorGeneration > descendantGeneration {
return false, nil
}
minGeneration := uint64(0)
if ancestorGeneration != generationInfinity {
minGeneration = ancestorGeneration
}
_, err := paintDownToCommon(ctx, ancestor, []NodeIndex{descendant}, minGeneration)
if err != nil {
return false, err
}
return ctx.HasAnyMarks(ancestor, markRight), nil
}
|