From 2bf17ba2f18ad3ae3068568e5754046544b159b7 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 18 Apr 2013 00:54:46 +0200 Subject: Ok, now with shared base object --- commit.go | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'commit.go') diff --git a/commit.go b/commit.go index b1ca6c4..9730a70 100644 --- a/commit.go +++ b/commit.go @@ -9,34 +9,20 @@ extern int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr); import "C" import ( - "runtime" "unsafe" "time" ) // Commit type Commit struct { - ptr *C.git_commit + gitObject } -func (o *Commit) Id() *Oid { - return newOidFromC(C.git_commit_id(o.ptr)) -} - -func (o *Commit) Type() ObjectType { - return OBJ_COMMIT -} - -func (o *Commit) Free() { - runtime.SetFinalizer(o, nil) - C.git_commit_free(o.ptr) -} - -func (c *Commit) Message() string { +func (c Commit) Message() string { return C.GoString(C.git_commit_message(c.ptr)) } -func (c *Commit) Tree() (*Tree, error) { +func (c Commit) Tree() (*Tree, error) { var ptr *C.git_object err := C.git_commit_tree(&ptr, c.ptr) @@ -47,16 +33,16 @@ func (c *Commit) Tree() (*Tree, error) { return allocObject(ptr).(*Tree), nil } -func (c *Commit) TreeId() *Oid { +func (c Commit) TreeId() *Oid { return newOidFromC(C.git_commit_tree_id(c.ptr)) } -func (c *Commit) Author() *Signature { +func (c Commit) Author() *Signature { ptr := C.git_commit_author(c.ptr) return newSignatureFromC(ptr) } -func (c *Commit) Committer() *Signature { +func (c Commit) Committer() *Signature { ptr := C.git_commit_committer(c.ptr) return newSignatureFromC(ptr) } -- cgit v1.2.3