Fix ForeachSubmodule panicing.
As the SubmoduleVisitor function is called from inside libgit2 we cannot use Go types in its signature. Fix by using C types instead.
This commit is contained in:
parent
1107c6824f
commit
2e481dbc79
|
@ -97,10 +97,10 @@ func (repo *Repository) LookupSubmodule(name string) (*Submodule, error) {
|
||||||
type SubmoduleCbk func(sub *Submodule, name string) int
|
type SubmoduleCbk func(sub *Submodule, name string) int
|
||||||
|
|
||||||
//export SubmoduleVisitor
|
//export SubmoduleVisitor
|
||||||
func SubmoduleVisitor(csub unsafe.Pointer, name string, cfct unsafe.Pointer) int {
|
func SubmoduleVisitor(csub unsafe.Pointer, name *C.char, cfct unsafe.Pointer) C.int {
|
||||||
sub := &Submodule{(*C.git_submodule)(csub)}
|
sub := &Submodule{(*C.git_submodule)(csub)}
|
||||||
fct := *(*SubmoduleCbk)(cfct)
|
fct := *(*SubmoduleCbk)(cfct)
|
||||||
return fct(sub, name)
|
return (C.int)(fct(sub, C.GoString(name)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) ForeachSubmodule(cbk SubmoduleCbk) error {
|
func (repo *Repository) ForeachSubmodule(cbk SubmoduleCbk) error {
|
||||||
|
|
Loading…
Reference in New Issue