summaryrefslogtreecommitdiff
path: root/object.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2014-04-01 12:13:37 +0200
committerCarlos Martín Nieto <[email protected]>2014-04-01 12:36:44 +0200
commita06f4a030a90129db76e5a741a73bba5b27cda29 (patch)
tree436e57b23c5bdfb36054f843e2fc4e55b66d8aef /object.go
parent286ff62b14f2471e58ed3dd93df50d2bbd4fc028 (diff)
Adjust to Go tip changes
It does not like breaking aliasing rules, so let's keep a casted pointer for when libgit2 wants that.
Diffstat (limited to 'object.go')
-rw-r--r--object.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/object.go b/object.go
index 090be1f..101d15e 100644
--- a/object.go
+++ b/object.go
@@ -48,7 +48,7 @@ func (t ObjectType) String() (string) {
}
func (o gitObject) Id() *Oid {
- return newOidFromC(C.git_commit_id(o.ptr))
+ return newOidFromC(C.git_object_id(o.ptr))
}
func (o gitObject) Type() ObjectType {
@@ -57,24 +57,33 @@ func (o gitObject) Type() ObjectType {
func (o *gitObject) Free() {
runtime.SetFinalizer(o, nil)
- C.git_commit_free(o.ptr)
+ C.git_object_free(o.ptr)
}
func allocObject(cobj *C.git_object) Object {
switch ObjectType(C.git_object_type(cobj)) {
case ObjectCommit:
- commit := &Commit{gitObject{cobj}}
+ commit := &Commit{
+ gitObject: gitObject{cobj},
+ cast_ptr: (*C.git_commit)(cobj),
+ }
runtime.SetFinalizer(commit, (*Commit).Free)
return commit
case ObjectTree:
- tree := &Tree{gitObject{cobj}}
+ tree := &Tree{
+ gitObject: gitObject{cobj},
+ cast_ptr: (*C.git_tree)(cobj),
+ }
runtime.SetFinalizer(tree, (*Tree).Free)
return tree
case ObjectBlob:
- blob := &Blob{gitObject{cobj}}
+ blob := &Blob{
+ gitObject: gitObject{cobj},
+ cast_ptr: (*C.git_blob)(cobj),
+ }
runtime.SetFinalizer(blob, (*Blob).Free)
return blob
}