Updates files in the working tree to match the content of the given index. If index is nil, the repository's index will be used. opts may be nil.
(index *Index, opts *CheckoutOptions)
| 221 | // index. If index is nil, the repository's index will be used. opts |
| 222 | // may be nil. |
| 223 | func (v *Repository) CheckoutIndex(index *Index, opts *CheckoutOptions) error { |
| 224 | var iptr *C.git_index = nil |
| 225 | if index != nil { |
| 226 | iptr = index.ptr |
| 227 | } |
| 228 | |
| 229 | runtime.LockOSThread() |
| 230 | defer runtime.UnlockOSThread() |
| 231 | |
| 232 | var err error |
| 233 | cOpts := populateCheckoutOptions(&C.git_checkout_options{}, opts, &err) |
| 234 | defer freeCheckoutOptions(cOpts) |
| 235 | |
| 236 | ret := C.git_checkout_index(v.ptr, iptr, cOpts) |
| 237 | runtime.KeepAlive(v) |
| 238 | if ret == C.int(ErrorCodeUser) && err != nil { |
| 239 | return err |
| 240 | } |
| 241 | if ret < 0 { |
| 242 | return MakeGitError(ret) |
| 243 | } |
| 244 | |
| 245 | return nil |
| 246 | } |
| 247 | |
| 248 | func (v *Repository) CheckoutTree(tree *Tree, opts *CheckoutOptions) error { |
| 249 | runtime.LockOSThread() |