diff options
| author | lhchavez <[email protected]> | 2020-12-01 19:11:41 -0800 |
|---|---|---|
| committer | lhchavez <[email protected]> | 2021-09-05 18:52:01 -0700 |
| commit | 5def02a589a2c1653f4bb515fdec290361a222be (patch) | |
| tree | b99d3a8204c27c902f711bc4f8f8b48baa8352bb /index.go | |
| parent | 70e5e419cf0cab31553b106267a0296f3cd672d9 (diff) | |
The big Callback type adjustment of 2020
This change makes all callbacks that can fail return an `error`. This
makes things a lot more idiomatic.
Diffstat (limited to 'index.go')
| -rw-r--r-- | index.go | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -10,13 +10,12 @@ extern int _go_git_index_remove_all(git_index*, const git_strarray*, void*); */ import "C" import ( - "errors" "fmt" "runtime" "unsafe" ) -type IndexMatchedPathCallback func(string, string) int +type IndexMatchedPathCallback func(string, string) error type indexMatchedPathCallbackData struct { callback IndexMatchedPathCallback errorTarget *error @@ -343,9 +342,9 @@ func indexMatchedPathCallback(cPath, cMatchedPathspec *C.char, payload unsafe.Po panic("invalid matched path callback") } - ret := data.callback(C.GoString(cPath), C.GoString(cMatchedPathspec)) - if ret < 0 { - *data.errorTarget = errors.New(ErrorCode(ret).String()) + err := data.callback(C.GoString(cPath), C.GoString(cMatchedPathspec)) + if err != nil { + *data.errorTarget = err return C.int(ErrorCodeUser) } |
