From 20e2528478b0154aa63606645e67f7260ff3c2b3 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Wed, 6 Mar 2013 16:59:45 +0100 Subject: Repository.CreateCommit --- commit.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'commit.go') diff --git a/commit.go b/commit.go index 779ebd7..93160ba 100644 --- a/commit.go +++ b/commit.go @@ -10,6 +10,7 @@ import "C" import ( "runtime" + "unsafe" "time" ) @@ -74,3 +75,20 @@ func (sig *Signature) Time() time.Time { loc := time.FixedZone("", sig.Offset*60) return time.Unix(sig.UnixTime, 0).In(loc) } + +func (sig *Signature) toC() (*C.git_signature) { + var out *C.git_signature + + name := C.CString(sig.Name) + defer C.free(unsafe.Pointer(name)) + + email := C.CString(sig.Email) + defer C.free(unsafe.Pointer(email)) + + ret := C.git_signature_new(&out, name, email, C.git_time_t(sig.UnixTime), C.int(sig.Offset)) + if ret < 0 { + return nil + } + + return out +} -- cgit v1.2.3