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

Method RevertCommit

revert.go:86–104  ·  view source on GitHub ↗

RevertCommit reverts the provided commit against "ourCommit" The returned index contains the result of the revert and should be freed

(revertCommit *Commit, ourCommit *Commit, mainline uint, mergeOptions *MergeOptions)

Source from the content-addressed store, hash-verified

84// RevertCommit reverts the provided commit against "ourCommit"
85// The returned index contains the result of the revert and should be freed
86func (r *Repository) RevertCommit(revertCommit *Commit, ourCommit *Commit, mainline uint, mergeOptions *MergeOptions) (*Index, error) {
87 runtime.LockOSThread()
88 defer runtime.UnlockOSThread()
89
90 cOpts := populateMergeOptions(&C.git_merge_options{}, mergeOptions)
91 defer freeMergeOptions(cOpts)
92
93 var index *C.git_index
94
95 ecode := C.git_revert_commit(&index, r.ptr, revertCommit.cast_ptr, ourCommit.cast_ptr, C.uint(mainline), cOpts)
96 runtime.KeepAlive(revertCommit)
97 runtime.KeepAlive(ourCommit)
98
99 if ecode < 0 {
100 return nil, MakeGitError(ecode)
101 }
102
103 return newIndexFromC(index, r), nil
104}

Callers 1

TestRevertCommitFunction · 0.80

Calls 4

populateMergeOptionsFunction · 0.85
freeMergeOptionsFunction · 0.85
MakeGitErrorFunction · 0.85
newIndexFromCFunction · 0.85

Tested by 1

TestRevertCommitFunction · 0.64