summaryrefslogtreecommitdiff
path: root/commit.go
diff options
context:
space:
mode:
Diffstat (limited to 'commit.go')
-rw-r--r--commit.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/commit.go b/commit.go
index cacaa33..0c64c76 100644
--- a/commit.go
+++ b/commit.go
@@ -9,8 +9,9 @@ extern int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr);
import "C"
import (
- "unsafe"
+ "runtime"
"time"
+ "unsafe"
)
// Commit
@@ -25,6 +26,9 @@ func (c Commit) Message() string {
func (c Commit) Tree() (*Tree, error) {
var ptr *C.git_object
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
err := C.git_commit_tree(&ptr, c.ptr)
if err < 0 {
return nil, LastError()
@@ -48,12 +52,13 @@ func (c Commit) Committer() *Signature {
}
func (c *Commit) Parent(n uint) *Commit {
- par := &Commit{}
- ret := C.git_commit_parent(&par.ptr, c.ptr, C.uint(n))
+ var cobj *C.git_object
+ ret := C.git_commit_parent(&cobj, c.ptr, C.uint(n))
if ret != 0 {
return nil
}
- return par
+
+ return allocObject(cobj).(*Commit)
}
func (c *Commit) ParentId(n uint) *Oid {
@@ -85,10 +90,15 @@ func newSignatureFromC(sig *C.git_signature) *Signature {
// the offset in mintes, which is what git wants
func (v *Signature) Offset() int {
_, offset := v.When.Zone()
- return offset/60
+ return offset / 60
}
-func (sig *Signature) toC() (*C.git_signature) {
+func (sig *Signature) toC() *C.git_signature {
+
+ if sig == nil {
+ return nil
+ }
+
var out *C.git_signature
name := C.CString(sig.Name)