diff options
| author | Vicent Marti <[email protected]> | 2013-03-05 20:53:04 +0100 |
|---|---|---|
| committer | Vicent Marti <[email protected]> | 2013-03-05 20:53:04 +0100 |
| commit | b1d50b70ea8c4be9c19fe91768d6653736660c4c (patch) | |
| tree | 56670245aa3f3379bc2cfd9baec097c9f8231b94 /commit.go | |
Initial commit
Diffstat (limited to 'commit.go')
| -rw-r--r-- | commit.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/commit.go b/commit.go new file mode 100644 index 0000000..bba02e8 --- /dev/null +++ b/commit.go @@ -0,0 +1,52 @@ +package git + +/* +#include <git2.h> +#include <git2/errors.h> + +extern int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr); +*/ +import "C" + +import ( +) + +// Commit +type Commit struct { + ptr *C.git_commit +} + +func (c *Commit) Id() *Oid { + return newOidFromC(C.git_commit_id(c.ptr)) +} + +func (c *Commit) Message() string { + return C.GoString(C.git_commit_message(c.ptr)) +} + +func (c *Commit) Tree() (*Tree, error) { + tree := new(Tree) + + err := C.git_commit_tree(&tree.ptr, c.ptr) + if err < 0 { + return nil, LastError() + } + return tree, nil +} + +func (c *Commit) TreeId() *Oid { + return newOidFromC(C.git_commit_tree_id(c.ptr)) +} + +/* TODO */ +/* +func (c *Commit) Author() *Signature { + ptr := C.git_commit_author(c.ptr) + return &Signature{ptr} +} + +func (c *Commit) Committer() *Signature { + ptr := C.git_commit_committer(c.ptr) + return &Signature{ptr} +} +*/ |
