summaryrefslogtreecommitdiff
path: root/repository.go
diff options
context:
space:
mode:
authorVicent Marti <[email protected]>2013-03-06 16:59:45 +0100
committerVicent Marti <[email protected]>2013-03-06 16:59:45 +0100
commit20e2528478b0154aa63606645e67f7260ff3c2b3 (patch)
tree879cf8c83f2122f76dd26bbe135e1185938b52a3 /repository.go
parentbdfd8736bc8c119c4a841fd8b1c8202f5d5ceb9a (diff)
Repository.CreateCommit
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/repository.go b/repository.go
index 5313af3..0f5eff5 100644
--- a/repository.go
+++ b/repository.go
@@ -104,19 +104,22 @@ func (v *Repository) Walk() (*RevWalk, error) {
return walk, nil
}
-/* TODO
-func (v *Repository) Commit(
+func (v *Repository) CreateCommit(
refname string, author, committer *Signature,
message string, tree *Tree, parents ...*Commit) (*Oid, error) {
oid := new(Oid)
+
cref := C.CString(refname)
defer C.free(unsafe.Pointer(cref))
+
cmsg := C.CString(message)
defer C.free(unsafe.Pointer(cmsg))
- nparents := len(parents)
+
var cparents []*C.git_commit = nil
var parentsarg **C.git_commit = nil
+
+ nparents:= len(parents)
if nparents > 0 {
cparents = make([]*C.git_commit, nparents)
for i, v := range parents {
@@ -125,18 +128,23 @@ func (v *Repository) Commit(
parentsarg = &cparents[0]
}
+ authorSig := author.toC()
+ defer C.git_signature_free(authorSig)
+
+ committerSig := committer.toC()
+ defer C.git_signature_free(committerSig)
+
ret := C.git_commit_create(
oid.toC(), v.ptr, cref,
- author.git_signature, committer.git_signature,
+ authorSig, committerSig,
nil, cmsg, tree.ptr, C.int(nparents), parentsarg)
- if ret < GIT_SUCCESS {
+ if ret < 0 {
return nil, LastError()
}
return oid, nil
}
-*/
func (v *Odb) Free() {
runtime.SetFinalizer(v, nil)