Skip to content

Fix receivers to Blob and Tree methods #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ 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)
func (b *Blob) Size() int64 {
ret := int64(C.git_blob_rawsize(b.cast_ptr))
runtime.KeepAlive(b)
return ret
}

func (v *Blob) Contents() []byte {
size := C.int(C.git_blob_rawsize(v.cast_ptr))
buffer := unsafe.Pointer(C.git_blob_rawcontent(v.cast_ptr))
func (b *Blob) Contents() []byte {
size := C.int(C.git_blob_rawsize(b.cast_ptr))
buffer := unsafe.Pointer(C.git_blob_rawcontent(b.cast_ptr))

goBytes := C.GoBytes(buffer, size)
runtime.KeepAlive(v)
runtime.KeepAlive(b)

return goBytes
}
Expand Down
12 changes: 6 additions & 6 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func newTreeEntry(entry *C.git_tree_entry) *TreeEntry {
}
}

func (t Tree) EntryByName(filename string) *TreeEntry {
func (t *Tree) EntryByName(filename string) *TreeEntry {
cname := C.CString(filename)
defer C.free(unsafe.Pointer(cname))

Expand All @@ -67,7 +67,7 @@ func (t Tree) EntryByName(filename string) *TreeEntry {
// free it, but you must not use it after the Tree is freed.
//
// Warning: this must examine every entry in the tree, so it is not fast.
func (t Tree) EntryById(id *Oid) *TreeEntry {
func (t *Tree) EntryById(id *Oid) *TreeEntry {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

Expand All @@ -84,7 +84,7 @@ func (t Tree) EntryById(id *Oid) *TreeEntry {

// EntryByPath looks up an entry by its full path, recursing into
// deeper trees if necessary (i.e. if there are slashes in the path)
func (t Tree) EntryByPath(path string) (*TreeEntry, error) {
func (t *Tree) EntryByPath(path string) (*TreeEntry, error) {
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
var entry *C.git_tree_entry
Expand All @@ -102,7 +102,7 @@ func (t Tree) EntryByPath(path string) (*TreeEntry, error) {
return newTreeEntry(entry), nil
}

func (t Tree) EntryByIndex(index uint64) *TreeEntry {
func (t *Tree) EntryByIndex(index uint64) *TreeEntry {
entry := C.git_tree_entry_byindex(t.cast_ptr, C.size_t(index))
if entry == nil {
return nil
Expand All @@ -113,7 +113,7 @@ func (t Tree) EntryByIndex(index uint64) *TreeEntry {
return goEntry
}

func (t Tree) EntryCount() uint64 {
func (t *Tree) EntryCount() uint64 {
num := C.git_tree_entrycount(t.cast_ptr)
runtime.KeepAlive(t)
return uint64(num)
Expand All @@ -133,7 +133,7 @@ func CallbackGitTreeWalk(_root *C.char, _entry unsafe.Pointer, ptr unsafe.Pointe
}
}

func (t Tree) Walk(callback TreeWalkCallback) error {
func (t *Tree) Walk(callback TreeWalkCallback) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

Expand Down