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

Method Revert

revert.go:62–82  ·  view source on GitHub ↗

Revert the provided commit leaving the index updated with the results of the revert

(commit *Commit, revertOptions *RevertOptions)

Source from the content-addressed store, hash-verified

60
61// Revert the provided commit leaving the index updated with the results of the revert
62func (r *Repository) Revert(commit *Commit, revertOptions *RevertOptions) error {
63 runtime.LockOSThread()
64 defer runtime.UnlockOSThread()
65
66 var err error
67 cOpts := populateRevertOptions(&C.git_revert_options{}, revertOptions, &err)
68 defer freeRevertOptions(cOpts)
69
70 ret := C.git_revert(r.ptr, commit.cast_ptr, cOpts)
71 runtime.KeepAlive(r)
72 runtime.KeepAlive(commit)
73
74 if ret == C.int(ErrorCodeUser) && err != nil {
75 return err
76 }
77 if ret < 0 {
78 return MakeGitError(ret)
79 }
80
81 return nil
82}
83
84// RevertCommit reverts the provided commit against "ourCommit"
85// The returned index contains the result of the revert and should be freed

Callers 1

TestRevertFunction · 0.80

Calls 3

populateRevertOptionsFunction · 0.85
freeRevertOptionsFunction · 0.85
MakeGitErrorFunction · 0.85

Tested by 1

TestRevertFunction · 0.64