From 37e56c28a8756a4b532168b1c39344a5d6ee9b0f Mon Sep 17 00:00:00 2001 From: Michael Boulton Date: Mon, 17 Aug 2020 08:36:02 +0100 Subject: [PATCH] Remove C wrapper for initialising apply opptions --- diff.go | 9 +++++++-- wrapper.c | 6 ------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/diff.go b/diff.go index b03a475..2e9bf58 100644 --- a/diff.go +++ b/diff.go @@ -4,7 +4,6 @@ package git #include extern void _go_git_populate_apply_cb(git_apply_options *options); -extern void _go_git_apply_init_options(git_apply_options *options); extern int _go_git_diff_foreach(git_diff *diff, int eachFile, int eachHunk, int eachLine, void *payload); extern void _go_git_setup_diff_notify_callbacks(git_diff_options* opts); extern int _go_git_diff_blobs(git_blob *old, const char *old_path, git_blob *new, const char *new_path, git_diff_options *opts, int eachFile, int eachHunk, int eachLine, void *payload); @@ -918,7 +917,13 @@ func deltaApplyCallback(_delta *C.git_diff_delta, _payload unsafe.Pointer) C.int func DefaultApplyOptions() (*ApplyOptions, error) { opts := C.git_apply_options{} - C._go_git_apply_init_options(&opts) + ecode := C.git_apply_options_init(&opts, C.GIT_APPLY_OPTIONS_VERSION) + if int(ecode) != 0 { + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + return nil, MakeGitError(ecode) + } return applyOptionsFromC(&opts), nil } diff --git a/wrapper.c b/wrapper.c index c19d035..4308ae4 100644 --- a/wrapper.c +++ b/wrapper.c @@ -6,12 +6,6 @@ typedef int (*gogit_submodule_cbk)(git_submodule *sm, const char *name, void *payload); -void _go_git_apply_init_options(git_apply_options *options) -{ - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; - *options = opts; -} - void _go_git_populate_apply_cb(git_apply_options *options) { options->delta_cb = (git_apply_delta_cb)deltaApplyCallback;