diff options
| author | Carlos Martín Nieto <[email protected]> | 2014-03-11 03:30:56 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2014-03-11 03:30:56 +0100 |
| commit | 263884a908873803cb8a37f80ba89e7b98001f1e (patch) | |
| tree | cd591420af070efc3f617322a582d890eea76022 /checkout.go | |
| parent | b09c6d8bbe874d6a08e0c91ad3f11bceb74414b2 (diff) | |
CheckoutIndex: allow for index to be nil
Allow for the index to be nil and pass that to the library to use the
repository's index.
Diffstat (limited to 'checkout.go')
| -rw-r--r-- | checkout.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/checkout.go b/checkout.go index 5753b09..5b72b9a 100644 --- a/checkout.go +++ b/checkout.go @@ -74,15 +74,21 @@ func (v *Repository) CheckoutHead(opts *CheckoutOpts) error { } // Updates files in the working tree to match the content of the given -// index. opts may be nil. +// index. If index is nil, the repository's index will be used. opts +// may be nil. func (v *Repository) CheckoutIndex(index *Index, opts *CheckoutOpts) error { var copts C.git_checkout_options ptr := populateCheckoutOpts(&copts, opts) + var iptr *C.git_index = nil + if index != nil { + iptr = index.ptr + } + runtime.LockOSThread() defer runtime.UnlockOSThread() - ret := C.git_checkout_index(v.ptr, index.ptr, ptr) + ret := C.git_checkout_index(v.ptr, iptr, ptr) if ret < 0 { return MakeGitError(ret) } |
