summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blob.go4
-rw-r--r--commit.go4
-rw-r--r--object.go5
-rw-r--r--tag.go4
-rw-r--r--tree.go4
5 files changed, 21 insertions, 0 deletions
diff --git a/blob.go b/blob.go
index 5235597..227e014 100644
--- a/blob.go
+++ b/blob.go
@@ -20,6 +20,10 @@ type Blob struct {
cast_ptr *C.git_blob
}
+func (b *Blob) AsObject() *Object {
+ return &b.Object
+}
+
func (v *Blob) Size() int64 {
ret := int64(C.git_blob_rawsize(v.cast_ptr))
runtime.KeepAlive(v)
diff --git a/commit.go b/commit.go
index 5aa5f25..223b093 100644
--- a/commit.go
+++ b/commit.go
@@ -18,6 +18,10 @@ type Commit struct {
cast_ptr *C.git_commit
}
+func (c *Commit) AsObject() *Object {
+ return &c.Object
+}
+
func (c *Commit) Message() string {
ret := C.GoString(C.git_commit_message(c.cast_ptr))
runtime.KeepAlive(c)
diff --git a/object.go b/object.go
index f4f1b3e..5505e35 100644
--- a/object.go
+++ b/object.go
@@ -26,6 +26,11 @@ type Object struct {
repo *Repository
}
+// Objecter lets us accept any kind of Git object in functions.
+type Objecter interface {
+ AsObject() *Object
+}
+
func (t ObjectType) String() string {
switch t {
case ObjectAny:
diff --git a/tag.go b/tag.go
index a58b090..9e26174 100644
--- a/tag.go
+++ b/tag.go
@@ -17,6 +17,10 @@ type Tag struct {
cast_ptr *C.git_tag
}
+func (t *Tag) AsObject() *Object {
+ return &t.Object
+}
+
func (t Tag) Message() string {
ret := C.GoString(C.git_tag_message(t.cast_ptr))
runtime.KeepAlive(t)
diff --git a/tree.go b/tree.go
index f5cbd78..ee14ec5 100644
--- a/tree.go
+++ b/tree.go
@@ -27,6 +27,10 @@ type Tree struct {
cast_ptr *C.git_tree
}
+func (t *Tree) AsObject() *Object {
+ return &t.Object
+}
+
type TreeEntry struct {
Name string
Id *Oid