aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--options.go5
-rw-r--r--options_test.go6
2 files changed, 11 insertions, 0 deletions
diff --git a/options.go b/options.go
index 02248ad..d7776da 100644
--- a/options.go
+++ b/options.go
@@ -427,6 +427,11 @@ func (o *ResetOptions) Validate(r *Repository) error {
}
o.Commit = ref.Hash()
+ } else {
+ _, err := r.CommitObject(o.Commit)
+ if err != nil {
+ return fmt.Errorf("invalid reset option: %w", err)
+ }
}
return nil
diff --git a/options_test.go b/options_test.go
index 171222c..677c317 100644
--- a/options_test.go
+++ b/options_test.go
@@ -23,6 +23,12 @@ func (s *OptionsSuite) TestCommitOptionsParentsFromHEAD(c *C) {
c.Assert(o.Parents, HasLen, 1)
}
+func (s *OptionsSuite) TestResetOptionsCommitNotFound(c *C) {
+ o := ResetOptions{Commit: plumbing.NewHash("ab1b15c6f6487b4db16f10d8ec69bb8bf91dcabd")}
+ err := o.Validate(s.Repository)
+ c.Assert(err, NotNil)
+}
+
func (s *OptionsSuite) TestCommitOptionsCommitter(c *C) {
sig := &object.Signature{}