Skip to content

Commit d95932c

Browse files
committed
handles: panic when we cannot retrieve handle data
1 parent a843b72 commit d95932c

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

index.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,10 @@ func (v *Index) RemoveAll(pathspecs []string, callback IndexMatchedPathCallback)
234234

235235
//export indexMatchedPathCallback
236236
func indexMatchedPathCallback(cPath, cMatchedPathspec *C.char, payload unsafe.Pointer) int {
237-
if payload == nil {
238-
return 0
239-
} else if callback, ok := pointerHandles.Get(payload).(IndexMatchedPathCallback); ok {
237+
if callback, ok := pointerHandles.Get(payload).(IndexMatchedPathCallback); ok {
240238
return callback(C.GoString(cPath), C.GoString(cMatchedPathspec))
241239
} else {
242-
return -1
240+
panic("invalid matched path callback")
243241
}
244242
}
245243

submodule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func SubmoduleVisitor(csub unsafe.Pointer, name *C.char, handle unsafe.Pointer)
103103
if callback, ok := pointerHandles.Get(handle).(SubmoduleCbk); ok {
104104
return (C.int)(callback(sub, C.GoString(name)))
105105
} else {
106-
return -1
106+
panic("invalid submodule visitor callback")
107107
}
108108
}
109109

tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func CallbackGitTreeWalk(_root unsafe.Pointer, _entry unsafe.Pointer, ptr unsafe
9797
if callback, ok := pointerHandles.Get(ptr).(TreeWalkCallback); ok {
9898
return C.int(callback(root, newTreeEntry(entry)))
9999
} else {
100-
return C.int(-1)
100+
panic("invalid treewalk callback")
101101
}
102102
}
103103

0 commit comments

Comments
 (0)