Fix inconsistent function call in Submodule. #167

Merged
calavera merged 4 commits from fix_git_submodules into master 2015-01-09 03:21:20 -06:00
2 changed files with 43 additions and 7 deletions

View File

@ -11,6 +11,14 @@ import (
"unsafe" "unsafe"
) )
// SubmoduleUpdateOptions
type SubmoduleUpdateOptions struct {
*CheckoutOpts
*RemoteCallbacks
CloneCheckoutStrategy CheckoutStrategy
Signature *Signature
}
// Submodule // Submodule
type Submodule struct { type Submodule struct {
ptr *C.git_submodule ptr *C.git_submodule
@ -226,8 +234,8 @@ func (sub *Submodule) SetIgnore(ignore SubmoduleIgnore) SubmoduleIgnore {
return SubmoduleIgnore(o) return SubmoduleIgnore(o)
} }
func (sub *Submodule) Update() SubmoduleUpdate { func (sub *Submodule) UpdateStrategy() SubmoduleUpdate {
o := C.git_submodule_update(sub.ptr) o := C.git_submodule_update_strategy(sub.ptr)
return SubmoduleUpdate(o) return SubmoduleUpdate(o)
} }
@ -307,3 +315,31 @@ func (repo *Repository) ReloadAllSubmodules(force bool) error {
} }
return nil 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)
ptr.signature = opts.Signature.toC()
}

2
vendor/libgit2 vendored

@ -1 +1 @@
Subproject commit 55d9c29aa0c69cdd766c5100fc012d8e0b486e23 Subproject commit 1646412d8fc9e1532a194df2515e9a5fde4da988