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)
| 324 | // If none are found, an empty slice is returned and the error is set |
| 325 | // approprately |
| 326 | func (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. |
| 355 | func (r *Repository) MergeBaseMany(oids []*Oid) (*Oid, error) { |