Make it possible to use a git2go error as a return value from a diff callback and have it propagate

This commit is contained in:
Michael Boulton 2020-08-17 08:20:36 +01:00
parent fff6c9d8ae
commit 7f3d112fbe
No known key found for this signature in database
GPG Key ID: 8A62CA0BE2E0197E
1 changed files with 6 additions and 0 deletions

View File

@ -878,6 +878,9 @@ func hunkApplyCallback(_hunk *C.git_diff_hunk, _payload unsafe.Pointer) C.int {
apply, err := opts.ApplyHunkCallback(&hunk)
if err != nil {
if gitError, ok := err.(*GitError); ok {
return C.int(gitError.Code)
}
return -1
} else if apply {
return 0
@ -901,6 +904,9 @@ func deltaApplyCallback(_delta *C.git_diff_delta, _payload unsafe.Pointer) C.int
apply, err := opts.ApplyDeltaCallback(&delta)
if err != nil {
if gitError, ok := err.(*GitError); ok {
return C.int(gitError.Code)
}
return -1
} else if apply {
return 0