MCPcopy Create free account
hub / github.com/libgit2/git2go / CheckoutHead

Method CheckoutHead

checkout.go:199–218  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
199func (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

Callers

nothing calls this directly

Calls 3

populateCheckoutOptionsFunction · 0.85
freeCheckoutOptionsFunction · 0.85
MakeGitErrorFunction · 0.85

Tested by

no test coverage detected