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

Method ResetToCommit

reset.go:17–33  ·  view source on GitHub ↗
(commit *Commit, resetType ResetType, opts *CheckoutOptions)

Source from the content-addressed store, hash-verified

15)
16
17func (r *Repository) ResetToCommit(commit *Commit, resetType ResetType, opts *CheckoutOptions) error {
18 runtime.LockOSThread()
19 defer runtime.UnlockOSThread()
20
21 var err error
22 cOpts := populateCheckoutOptions(&C.git_checkout_options{}, opts, &err)
23 defer freeCheckoutOptions(cOpts)
24
25 ret := C.git_reset(r.ptr, commit.ptr, C.git_reset_t(resetType), cOpts)
26 if ret == C.int(ErrorCodeUser) && err != nil {
27 return err
28 }
29 if ret < 0 {
30 return MakeGitError(ret)
31 }
32 return nil
33}
34
35func (r *Repository) ResetDefaultToCommit(commit *Commit, pathspecs []string) error {
36 cpathspecs := C.git_strarray{}

Callers 2

TestResetToCommitFunction · 0.80
TestApplyDiffAddfileFunction · 0.80

Calls 3

populateCheckoutOptionsFunction · 0.85
freeCheckoutOptionsFunction · 0.85
MakeGitErrorFunction · 0.85

Tested by 2

TestResetToCommitFunction · 0.64
TestApplyDiffAddfileFunction · 0.64