File tree Expand file tree Collapse file tree 5 files changed +21
-0
lines changed
Expand file tree Collapse file tree 5 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ type Blob struct {
2020 cast_ptr * C.git_blob
2121}
2222
23+ func (b * Blob ) AsObject () * Object {
24+ return & b .Object
25+ }
26+
2327func (v * Blob ) Size () int64 {
2428 ret := int64 (C .git_blob_rawsize (v .cast_ptr ))
2529 runtime .KeepAlive (v )
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ type Commit struct {
1818 cast_ptr * C.git_commit
1919}
2020
21+ func (c * Commit ) AsObject () * Object {
22+ return & c .Object
23+ }
24+
2125func (c * Commit ) Message () string {
2226 ret := C .GoString (C .git_commit_message (c .cast_ptr ))
2327 runtime .KeepAlive (c )
Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ type Object struct {
2626 repo * Repository
2727}
2828
29+ // Objecter lets us accept any kind of Git object in functions.
30+ type Objecter interface {
31+ AsObject () * Object
32+ }
33+
2934func (t ObjectType ) String () string {
3035 switch t {
3136 case ObjectAny :
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ type Tag struct {
1717 cast_ptr * C.git_tag
1818}
1919
20+ func (t * Tag ) AsObject () * Object {
21+ return & t .Object
22+ }
23+
2024func (t Tag ) Message () string {
2125 ret := C .GoString (C .git_tag_message (t .cast_ptr ))
2226 runtime .KeepAlive (t )
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ type Tree struct {
2727 cast_ptr * C.git_tree
2828}
2929
30+ func (t * Tree ) AsObject () * Object {
31+ return & t .Object
32+ }
33+
3034type TreeEntry struct {
3135 Name string
3236 Id * Oid
You can’t perform that action at this time.
0 commit comments