Reference: expose Peel()

Peel a reference to a particular type of object, returning an Object,
which you then perform a type assertion on.
This commit is contained in:
Carlos Martín Nieto 2014-05-23 11:37:00 +02:00
parent f5e1252d6e
commit 22bcd7decf
1 changed files with 13 additions and 0 deletions

View File

@ -148,6 +148,19 @@ func (v *Reference) Delete() error {
return nil return nil
} }
func (v *Reference) Peel(t ObjectType) (Object, error) {
var cobj *C.git_object
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := C.git_reference_peel(&cobj, v.ptr, C.git_otype(t)); err < 0 {
return nil, MakeGitError(err)
}
return allocObject(cobj), nil
}
// Cmp compares both references, retursn 0 on equality, otherwise a // Cmp compares both references, retursn 0 on equality, otherwise a
// stable sorting. // stable sorting.
func (v *Reference) Cmp(ref2 *Reference) int { func (v *Reference) Cmp(ref2 *Reference) int {