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

Method MergeBases

merge.go:326–352  ·  view source on GitHub ↗

MergeBases retrieves the list of merge bases between two commits. If none are found, an empty slice is returned and the error is set approprately

(one, two *Oid)

Source from the content-addressed store, hash-verified

324// If none are found, an empty slice is returned and the error is set
325// approprately
326func (r *Repository) MergeBases(one, two *Oid) ([]*Oid, error) {
327 runtime.LockOSThread()
328 defer runtime.UnlockOSThread()
329
330 var coids C.git_oidarray
331 ret := C.git_merge_bases(&coids, r.ptr, one.toC(), two.toC())
332 runtime.KeepAlive(one)
333 runtime.KeepAlive(two)
334 if ret < 0 {
335 return nil, MakeGitError(ret)
336 }
337
338 oids := make([]*Oid, coids.count)
339 hdr := reflect.SliceHeader{
340 Data: uintptr(unsafe.Pointer(coids.ids)),
341 Len: int(coids.count),
342 Cap: int(coids.count),
343 }
344
345 goSlice := *(*[]C.git_oid)(unsafe.Pointer(&hdr))
346
347 for i, cid := range goSlice {
348 oids[i] = newOidFromC(&cid)
349 }
350
351 return oids, nil
352}
353
354// MergeBaseMany finds a merge base given a list of commits.
355func (r *Repository) MergeBaseMany(oids []*Oid) (*Oid, error) {

Callers 1

TestMergeBasesFunction · 0.80

Calls 3

MakeGitErrorFunction · 0.85
newOidFromCFunction · 0.85
toCMethod · 0.45

Tested by 1

TestMergeBasesFunction · 0.64