Revert the provided commit leaving the index updated with the results of the revert
(commit *Commit, revertOptions *RevertOptions)
| 60 | |
| 61 | // Revert the provided commit leaving the index updated with the results of the revert |
| 62 | func (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 |