aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-04-26 18:28:51 +0100
committerGitHub <noreply@github.com>2023-04-26 18:28:51 +0100
commit0542a302c2be7ed7de276411f7e20b87309734b9 (patch)
treead051d5540425a2df69e5fdee07ddd32b6d64316 /options.go
parentcd1fd6b5da926e8dedd776b319455e499e35618b (diff)
parent3aa7575a4d660a250edd06864d6401a302951fab (diff)
downloadgo-git-0542a302c2be7ed7de276411f7e20b87309734b9.tar.gz
Merge pull request #728 from aymanbagabas/grep-bare
fix: git grep bare repositories
Diffstat (limited to 'options.go')
-rw-r--r--options.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/options.go b/options.go
index 6a38ad9..e79cf9d 100644
--- a/options.go
+++ b/options.go
@@ -650,7 +650,13 @@ var (
)
// Validate validates the fields and sets the default values.
+//
+// TODO: deprecate in favor of Validate(r *Repository) in v6.
func (o *GrepOptions) Validate(w *Worktree) error {
+ return o.validate(w.r)
+}
+
+func (o *GrepOptions) validate(r *Repository) error {
if !o.CommitHash.IsZero() && o.ReferenceName != "" {
return ErrHashOrReference
}
@@ -658,7 +664,7 @@ func (o *GrepOptions) Validate(w *Worktree) error {
// If none of CommitHash and ReferenceName are provided, set commit hash of
// the repository's head.
if o.CommitHash.IsZero() && o.ReferenceName == "" {
- ref, err := w.r.Head()
+ ref, err := r.Head()
if err != nil {
return err
}