handles: panic when we cannot retrieve handle data

This commit is contained in:
Patrick Steinhardt 2015-05-22 08:58:21 +02:00
parent a843b7247f
commit d95932c84a
3 changed files with 4 additions and 6 deletions

View File

@ -234,12 +234,10 @@ func (v *Index) RemoveAll(pathspecs []string, callback IndexMatchedPathCallback)
//export indexMatchedPathCallback
func indexMatchedPathCallback(cPath, cMatchedPathspec *C.char, payload unsafe.Pointer) int {
if payload == nil {
return 0
} else if callback, ok := pointerHandles.Get(payload).(IndexMatchedPathCallback); ok {
if callback, ok := pointerHandles.Get(payload).(IndexMatchedPathCallback); ok {
return callback(C.GoString(cPath), C.GoString(cMatchedPathspec))
} else {
return -1
panic("invalid matched path callback")
}
}

View File

@ -103,7 +103,7 @@ func SubmoduleVisitor(csub unsafe.Pointer, name *C.char, handle unsafe.Pointer)
if callback, ok := pointerHandles.Get(handle).(SubmoduleCbk); ok {
return (C.int)(callback(sub, C.GoString(name)))
} else {
return -1
panic("invalid submodule visitor callback")
}
}

View File

@ -97,7 +97,7 @@ func CallbackGitTreeWalk(_root unsafe.Pointer, _entry unsafe.Pointer, ptr unsafe
if callback, ok := pointerHandles.Get(ptr).(TreeWalkCallback); ok {
return C.int(callback(root, newTreeEntry(entry)))
} else {
return C.int(-1)
panic("invalid treewalk callback")
}
}