Merge pull request #526 from dbolkensteyn/v27
Fixes #513 - Segfault during tree walk
This commit is contained in:
commit
6cc7d3dc6a
12
tag.go
12
tag.go
|
@ -21,26 +21,26 @@ func (t *Tag) AsObject() *Object {
|
||||||
return &t.Object
|
return &t.Object
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Tag) Message() string {
|
func (t *Tag) Message() string {
|
||||||
ret := C.GoString(C.git_tag_message(t.cast_ptr))
|
ret := C.GoString(C.git_tag_message(t.cast_ptr))
|
||||||
runtime.KeepAlive(t)
|
runtime.KeepAlive(t)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Tag) Name() string {
|
func (t *Tag) Name() string {
|
||||||
ret := C.GoString(C.git_tag_name(t.cast_ptr))
|
ret := C.GoString(C.git_tag_name(t.cast_ptr))
|
||||||
runtime.KeepAlive(t)
|
runtime.KeepAlive(t)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Tag) Tagger() *Signature {
|
func (t *Tag) Tagger() *Signature {
|
||||||
cast_ptr := C.git_tag_tagger(t.cast_ptr)
|
cast_ptr := C.git_tag_tagger(t.cast_ptr)
|
||||||
ret := newSignatureFromC(cast_ptr)
|
ret := newSignatureFromC(cast_ptr)
|
||||||
runtime.KeepAlive(t)
|
runtime.KeepAlive(t)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Tag) Target() *Object {
|
func (t *Tag) Target() *Object {
|
||||||
var ptr *C.git_object
|
var ptr *C.git_object
|
||||||
ret := C.git_tag_target(&ptr, t.cast_ptr)
|
ret := C.git_tag_target(&ptr, t.cast_ptr)
|
||||||
runtime.KeepAlive(t)
|
runtime.KeepAlive(t)
|
||||||
|
@ -51,13 +51,13 @@ func (t Tag) Target() *Object {
|
||||||
return allocObject(ptr, t.repo)
|
return allocObject(ptr, t.repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Tag) TargetId() *Oid {
|
func (t *Tag) TargetId() *Oid {
|
||||||
ret := newOidFromC(C.git_tag_target_id(t.cast_ptr))
|
ret := newOidFromC(C.git_tag_target_id(t.cast_ptr))
|
||||||
runtime.KeepAlive(t)
|
runtime.KeepAlive(t)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Tag) TargetType() ObjectType {
|
func (t *Tag) TargetType() ObjectType {
|
||||||
ret := ObjectType(C.git_tag_target_type(t.cast_ptr))
|
ret := ObjectType(C.git_tag_target_type(t.cast_ptr))
|
||||||
runtime.KeepAlive(t)
|
runtime.KeepAlive(t)
|
||||||
return ret
|
return ret
|
||||||
|
|
15
tree.go
15
tree.go
|
@ -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)
|
cname := C.CString(filename)
|
||||||
defer C.free(unsafe.Pointer(cname))
|
defer C.free(unsafe.Pointer(cname))
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func (t Tree) EntryByName(filename string) *TreeEntry {
|
||||||
// free it, but you must not use it after the Tree is freed.
|
// 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.
|
// 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()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ func (t Tree) EntryById(id *Oid) *TreeEntry {
|
||||||
|
|
||||||
// EntryByPath looks up an entry by its full path, recursing into
|
// EntryByPath looks up an entry by its full path, recursing into
|
||||||
// deeper trees if necessary (i.e. if there are slashes in the path)
|
// 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)
|
cpath := C.CString(path)
|
||||||
defer C.free(unsafe.Pointer(cpath))
|
defer C.free(unsafe.Pointer(cpath))
|
||||||
var entry *C.git_tree_entry
|
var entry *C.git_tree_entry
|
||||||
|
@ -102,7 +102,7 @@ func (t Tree) EntryByPath(path string) (*TreeEntry, error) {
|
||||||
return newTreeEntry(entry), nil
|
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))
|
entry := C.git_tree_entry_byindex(t.cast_ptr, C.size_t(index))
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -113,7 +113,7 @@ func (t Tree) EntryByIndex(index uint64) *TreeEntry {
|
||||||
return goEntry
|
return goEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Tree) EntryCount() uint64 {
|
func (t *Tree) EntryCount() uint64 {
|
||||||
num := C.git_tree_entrycount(t.cast_ptr)
|
num := C.git_tree_entrycount(t.cast_ptr)
|
||||||
runtime.KeepAlive(t)
|
runtime.KeepAlive(t)
|
||||||
return uint64(num)
|
return uint64(num)
|
||||||
|
@ -122,9 +122,8 @@ func (t Tree) EntryCount() uint64 {
|
||||||
type TreeWalkCallback func(string, *TreeEntry) int
|
type TreeWalkCallback func(string, *TreeEntry) int
|
||||||
|
|
||||||
//export CallbackGitTreeWalk
|
//export CallbackGitTreeWalk
|
||||||
func CallbackGitTreeWalk(_root *C.char, _entry unsafe.Pointer, ptr unsafe.Pointer) C.int {
|
func CallbackGitTreeWalk(_root *C.char, entry *C.git_tree_entry, ptr unsafe.Pointer) C.int {
|
||||||
root := C.GoString(_root)
|
root := C.GoString(_root)
|
||||||
entry := (*C.git_tree_entry)(_entry)
|
|
||||||
|
|
||||||
if callback, ok := pointerHandles.Get(ptr).(TreeWalkCallback); ok {
|
if callback, ok := pointerHandles.Get(ptr).(TreeWalkCallback); ok {
|
||||||
return C.int(callback(root, newTreeEntry(entry)))
|
return C.int(callback(root, newTreeEntry(entry)))
|
||||||
|
@ -133,7 +132,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()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue