summaryrefslogtreecommitdiff
path: root/reset.go
blob: 9da7625b647a322c68a79d5c52146839434b8dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package git

/*
#include <git2.h>
*/
import "C"
import "runtime"

type ResetType int

const (
	ResetSoft  ResetType = C.GIT_RESET_SOFT
	ResetMixed ResetType = C.GIT_RESET_MIXED
	ResetHard  ResetType = C.GIT_RESET_HARD
)

func (r *Repository) ResetToCommit(commit *Commit, resetType ResetType, opts *CheckoutOpts) error {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	ret := C.git_reset(r.ptr, commit.ptr, C.git_reset_t(resetType), opts.toC())

	if ret < 0 {
		return MakeGitError(ret)
	}
	return nil
}