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

Method CheckoutIndex

checkout.go:223–246  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

221// index. If index is nil, the repository's index will be used. opts
222// may be nil.
223func (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
248func (v *Repository) CheckoutTree(tree *Tree, opts *CheckoutOptions) error {
249 runtime.LockOSThread()

Callers 2

TestRevertCommitFunction · 0.80
commitSomethingFunction · 0.80

Calls 3

populateCheckoutOptionsFunction · 0.85
freeCheckoutOptionsFunction · 0.85
MakeGitErrorFunction · 0.85

Tested by 2

TestRevertCommitFunction · 0.64
commitSomethingFunction · 0.64