diff options
| author | David Calavera <[email protected]> | 2015-01-08 13:44:58 -0800 |
|---|---|---|
| committer | David Calavera <[email protected]> | 2015-01-08 13:44:58 -0800 |
| commit | 9b914e07cc314daa42e61807b23350b2571f643f (patch) | |
| tree | 3ede7ec1abc1ca07f51095116cfb567298645619 /submodule.go | |
| parent | 8adbc08d70642e2d281654a9122b6c5ecfe1d2a7 (diff) | |
Add Submodule.Update method.
Update libgit2 to a version that includes https://github.com/libgit2/libgit2/pull/2804.
Diffstat (limited to 'submodule.go')
| -rw-r--r-- | submodule.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/submodule.go b/submodule.go index bb86a0a..67e4fab 100644 --- a/submodule.go +++ b/submodule.go @@ -316,3 +316,33 @@ func (repo *Repository) ReloadAllSubmodules(force bool) error { } return nil } + +func (sub *Submodule) Update(init bool, opts *SubmoduleUpdateOptions) error { + var copts C.git_submodule_update_options + populateSubmoduleUpdateOptions(&copts, opts) + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + ret := C.git_submodule_update(sub.ptr, cbool(init), &copts) + if ret < 0 { + return MakeGitError(ret) + } + + return nil +} + +func populateSubmoduleUpdateOptions(ptr *C.git_submodule_update_options, opts *SubmoduleUpdateOptions) { + C.git_submodule_update_init_options(ptr, C.GIT_SUBMODULE_UPDATE_OPTIONS_VERSION) + + if opts == nil { + return + } + + populateCheckoutOpts(&ptr.checkout_opts, opts.CheckoutOpts) + populateRemoteCallbacks(&ptr.remote_callbacks, opts.RemoteCallbacks) + ptr.clone_checkout_strategy = C.uint(opts.CloneCheckoutStrategy) + if opts.Signature != nil { + ptr.signature = opts.Signature.toC() + } +} |
