| 246 | } |
| 247 | |
| 248 | func (v *Repository) CheckoutTree(tree *Tree, opts *CheckoutOptions) error { |
| 249 | runtime.LockOSThread() |
| 250 | defer runtime.UnlockOSThread() |
| 251 | |
| 252 | var err error |
| 253 | cOpts := populateCheckoutOptions(&C.git_checkout_options{}, opts, &err) |
| 254 | defer freeCheckoutOptions(cOpts) |
| 255 | |
| 256 | ret := C.git_checkout_tree(v.ptr, tree.ptr, cOpts) |
| 257 | runtime.KeepAlive(v) |
| 258 | runtime.KeepAlive(tree) |
| 259 | if ret == C.int(ErrorCodeUser) && err != nil { |
| 260 | return err |
| 261 | } |
| 262 | if ret < 0 { |
| 263 | return MakeGitError(ret) |
| 264 | } |
| 265 | |
| 266 | return nil |
| 267 | } |