MCPcopy Create free account
hub / github.com/libgit2/git2go / ReachableFromAny

Method ReachableFromAny

graph.go:46–69  ·  view source on GitHub ↗

ReachableFromAny returns whether a commit is reachable from any of a list of commits by following parent edges.

(commit *Oid, descendants []*Oid)

Source from the content-addressed store, hash-verified

44// ReachableFromAny returns whether a commit is reachable from any of a list of
45// commits by following parent edges.
46func (repo *Repository) ReachableFromAny(commit *Oid, descendants []*Oid) (bool, error) {
47 if len(descendants) == 0 {
48 return false, nil
49 }
50
51 coids := make([]C.git_oid, len(descendants))
52 for i := 0; i < len(descendants); i++ {
53 coids[i] = *descendants[i].toC()
54 }
55
56 runtime.LockOSThread()
57 defer runtime.UnlockOSThread()
58
59 ret := C.git_graph_reachable_from_any(repo.ptr, commit.toC(), &coids[0], C.size_t(len(descendants)))
60 runtime.KeepAlive(repo)
61 runtime.KeepAlive(commit)
62 runtime.KeepAlive(coids)
63 runtime.KeepAlive(descendants)
64 if ret < 0 {
65 return false, MakeGitError(ret)
66 }
67
68 return (ret > 0), nil
69}

Callers 1

TestReachableFromAnyFunction · 0.80

Calls 2

MakeGitErrorFunction · 0.85
toCMethod · 0.45

Tested by 1

TestReachableFromAnyFunction · 0.64