Updates files in the index and the working tree to match the content of the commit pointed at by HEAD. opts may be nil.
(opts *CheckoutOptions)
| 197 | // Updates files in the index and the working tree to match the content of |
| 198 | // the commit pointed at by HEAD. opts may be nil. |
| 199 | func (v *Repository) CheckoutHead(opts *CheckoutOptions) error { |
| 200 | runtime.LockOSThread() |
| 201 | defer runtime.UnlockOSThread() |
| 202 | |
| 203 | var err error |
| 204 | cOpts := populateCheckoutOptions(&C.git_checkout_options{}, opts, &err) |
| 205 | defer freeCheckoutOptions(cOpts) |
| 206 | |
| 207 | ret := C.git_checkout_head(v.ptr, cOpts) |
| 208 | runtime.KeepAlive(v) |
| 209 | |
| 210 | if ret == C.int(ErrorCodeUser) && err != nil { |
| 211 | return err |
| 212 | } |
| 213 | if ret < 0 { |
| 214 | return MakeGitError(ret) |
| 215 | } |
| 216 | |
| 217 | return nil |
| 218 | } |
| 219 | |
| 220 | // Updates files in the working tree to match the content of the given |
| 221 | // index. If index is nil, the repository's index will be used. opts |
nothing calls this directly
no test coverage detected