summaryrefslogtreecommitdiff
path: root/reset.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-08-31 19:58:29 +0200
committerCarlos Martín Nieto <[email protected]>2015-08-31 19:58:29 +0200
commit6d3a3499f1639a6272e334f9f74b1e0cf6b0bb49 (patch)
tree04b27dfdf1faadcaff6ca40fa27d8edd690045d1 /reset.go
parent157593f38da780c4f6cb6dc61275b9b36a3327bf (diff)
parent4090c401c8bf3f062e898f75bde01e2ef27b3911 (diff)
Merge branch 'master-v23'
Diffstat (limited to 'reset.go')
-rw-r--r--reset.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/reset.go b/reset.go
new file mode 100644
index 0000000..b5b7435
--- /dev/null
+++ b/reset.go
@@ -0,0 +1,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.gitObject.ptr, C.git_reset_t(resetType), opts.toC())
+
+ if ret < 0 {
+ return MakeGitError(ret)
+ }
+ return nil
+}