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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package reachability
import (
"errors"
commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read"
"codeberg.org/lindenii/furgit/objectid"
"codeberg.org/lindenii/furgit/objecttype"
)
func (walk *Walk) expandCommitsFromGraph(id objectid.ObjectID) ([]walkItem, bool, error) {
pos, err := walk.reachability.graph.Lookup(id)
if err != nil {
if _, ok := errors.AsType[*commitgraphread.NotFoundError](err); ok {
return nil, false, nil
}
return nil, true, err
}
commit, err := walk.reachability.graph.CommitAt(pos)
if err != nil {
return nil, true, err
}
next := make([]walkItem, 0, 2+len(commit.ExtraParents))
if commit.Parent1.Valid {
parentOID, err := walk.reachability.graph.OIDAt(commit.Parent1.Pos)
if err != nil {
return nil, true, err
}
next = append(next, walkItem{id: parentOID, want: objecttype.TypeInvalid})
}
if commit.Parent2.Valid {
parentOID, err := walk.reachability.graph.OIDAt(commit.Parent2.Pos)
if err != nil {
return nil, true, err
}
next = append(next, walkItem{id: parentOID, want: objecttype.TypeInvalid})
}
for _, parentPos := range commit.ExtraParents {
parentOID, err := walk.reachability.graph.OIDAt(parentPos)
if err != nil {
return nil, true, err
}
next = append(next, walkItem{id: parentOID, want: objecttype.TypeInvalid})
}
return next, true, nil
}
|