merge: add two missing AnnotatedCommit methods

This commit is contained in:
Josh Bleecher Snyder 2018-01-25 16:00:39 -08:00
parent 432a164805
commit 03339f731a
1 changed files with 25 additions and 0 deletions

View File

@ -27,6 +27,15 @@ func newAnnotatedCommitFromC(ptr *C.git_annotated_commit, r *Repository) *Annota
return mh
}
func (mh *AnnotatedCommit) Id() *Oid {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := newOidFromC(C.git_annotated_commit_id(mh.ptr))
runtime.KeepAlive(mh)
return ret
}
func (mh *AnnotatedCommit) Free() {
runtime.SetFinalizer(mh, nil)
C.git_annotated_commit_free(mh.ptr)
@ -79,6 +88,22 @@ func (r *Repository) AnnotatedCommitFromRef(ref *Reference) (*AnnotatedCommit, e
return newAnnotatedCommitFromC(ptr, r), nil
}
func (r *Repository) AnnotatedCommitFromRevspec(spec string) (*AnnotatedCommit, error) {
crevspec := C.CString(spec)
defer C.free(unsafe.Pointer(crevspec))
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var ptr *C.git_annotated_commit
ret := C.git_annotated_commit_from_revspec(&ptr, r.ptr, crevspec)
runtime.KeepAlive(r)
if ret < 0 {
return nil, MakeGitError(ret)
}
return newAnnotatedCommitFromC(ptr, r), nil
}
type MergeTreeFlag int
const (