summaryrefslogtreecommitdiff
path: root/object.go
diff options
context:
space:
mode:
authorAnkur Mittal <[email protected]>2017-04-19 18:36:00 -0700
committerAnkur Mittal <[email protected]>2017-04-19 18:42:13 -0700
commit7caac1fa7b52eb30df29aa3b460f6511993fafd0 (patch)
treef9fef9a44fbd7429eccc940d02abf6df8a5d42d8 /object.go
parent7cd5a4e731e982391b9274e17c7f32050d8e5b15 (diff)
Add support for getting short object Id
Diffstat (limited to 'object.go')
-rw-r--r--object.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/object.go b/object.go
index 1981980..b365a3f 100644
--- a/object.go
+++ b/object.go
@@ -49,6 +49,20 @@ func (o *Object) Id() *Oid {
return newOidFromC(C.git_object_id(o.ptr))
}
+func (o *Object) ShortId() (string, error) {
+ resultBuf := C.git_buf{}
+
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ ecode := C.git_object_short_id(&resultBuf, o.ptr)
+ if ecode < 0 {
+ return "", MakeGitError(ecode)
+ }
+ defer C.git_buf_free(&resultBuf)
+ return C.GoString(resultBuf.ptr), nil
+}
+
func (o *Object) Type() ObjectType {
return ObjectType(C.git_object_type(o.ptr))
}