ReachableFromAny returns whether a commit is reachable from any of a list of commits by following parent edges.
(commit *Oid, descendants []*Oid)
| 44 | // ReachableFromAny returns whether a commit is reachable from any of a list of |
| 45 | // commits by following parent edges. |
| 46 | func (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 | } |