From 10c67474a89c298172a6703b91980ea37c60d5e5 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Thu, 10 Dec 2020 07:19:41 -0800 Subject: More callback refactoring (#713) This change: * Gets rid of the `.toC()` functions for Options objects, since they were redundant with the `populateXxxOptions()`. * Adds support for `errorTarget` to the `RemoteOptions`, since they are used in the same stack for some functions (like `Fetch()`). Now for those cases, the error returned by the callback will be preserved as-is. --- submodule.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'submodule.go') diff --git a/submodule.go b/submodule.go index 01474f6..2042125 100644 --- a/submodule.go +++ b/submodule.go @@ -383,22 +383,22 @@ func (sub *Submodule) Update(init bool, opts *SubmoduleUpdateOptions) error { return nil } -func populateSubmoduleUpdateOptions(ptr *C.git_submodule_update_options, opts *SubmoduleUpdateOptions, errorTarget *error) *C.git_submodule_update_options { - C.git_submodule_update_options_init(ptr, C.GIT_SUBMODULE_UPDATE_OPTIONS_VERSION) - +func populateSubmoduleUpdateOptions(copts *C.git_submodule_update_options, opts *SubmoduleUpdateOptions, errorTarget *error) *C.git_submodule_update_options { + C.git_submodule_update_options_init(copts, C.GIT_SUBMODULE_UPDATE_OPTIONS_VERSION) if opts == nil { return nil } - populateCheckoutOptions(&ptr.checkout_opts, opts.CheckoutOpts, errorTarget) - populateFetchOptions(&ptr.fetch_opts, opts.FetchOptions) + populateCheckoutOptions(&copts.checkout_opts, opts.CheckoutOpts, errorTarget) + populateFetchOptions(&copts.fetch_opts, opts.FetchOptions, errorTarget) - return ptr + return copts } -func freeSubmoduleUpdateOptions(ptr *C.git_submodule_update_options) { - if ptr == nil { +func freeSubmoduleUpdateOptions(copts *C.git_submodule_update_options) { + if copts == nil { return } - freeCheckoutOptions(&ptr.checkout_opts) + freeCheckoutOptions(&copts.checkout_opts) + freeFetchOptions(&copts.fetch_opts) } -- cgit v1.2.3