summaryrefslogtreecommitdiff
path: root/checkout.go
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-12-01 19:11:41 -0800
committerlhchavez <[email protected]>2021-09-05 18:52:01 -0700
commit5def02a589a2c1653f4bb515fdec290361a222be (patch)
treeb99d3a8204c27c902f711bc4f8f8b48baa8352bb /checkout.go
parent70e5e419cf0cab31553b106267a0296f3cd672d9 (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 'checkout.go')
-rw-r--r--checkout.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/checkout.go b/checkout.go
index ebf7c31..89841a8 100644
--- a/checkout.go
+++ b/checkout.go
@@ -7,7 +7,6 @@ extern void _go_git_populate_checkout_callbacks(git_checkout_options *opts);
*/
import "C"
import (
- "errors"
"os"
"runtime"
"unsafe"
@@ -49,8 +48,8 @@ const (
CheckoutUpdateSubmodulesIfChanged CheckoutStrategy = C.GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED // Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED)
)
-type CheckoutNotifyCallback func(why CheckoutNotifyType, path string, baseline, target, workdir DiffFile) ErrorCode
-type CheckoutProgressCallback func(path string, completed, total uint) ErrorCode
+type CheckoutNotifyCallback func(why CheckoutNotifyType, path string, baseline, target, workdir DiffFile) error
+type CheckoutProgressCallback func(path string, completed, total uint)
type CheckoutOptions struct {
Strategy CheckoutStrategy // Default will be a dry run
@@ -116,9 +115,9 @@ func checkoutNotifyCallback(
if data.options.NotifyCallback == nil {
return C.int(ErrorCodeOK)
}
- ret := data.options.NotifyCallback(CheckoutNotifyType(why), path, baseline, target, workdir)
- if ret < 0 {
- *data.errorTarget = errors.New(ErrorCode(ret).String())
+ err := data.options.NotifyCallback(CheckoutNotifyType(why), path, baseline, target, workdir)
+ if err != nil {
+ *data.errorTarget = err
return C.int(ErrorCodeUser)
}
return C.int(ErrorCodeOK)