aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorAyman Bagabas <ayman.bagabas@gmail.com>2023-03-29 23:26:53 -0400
committerAyman Bagabas <ayman.bagabas@gmail.com>2023-04-26 09:07:37 -0400
commit3aa7575a4d660a250edd06864d6401a302951fab (patch)
tree5f4767d4b986989ed208314113f4d36bb1de105c /options.go
parentb154dcce7059e4e02f8798db158b6a76ffc4a63e (diff)
downloadgo-git-3aa7575a4d660a250edd06864d6401a302951fab.tar.gz
fix: git grep bare repositories
Perform grep on `*Repository` instead of `*Worktree`. Fixes: https://github.com/go-git/go-git/issues/68
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 738c1ce..112d600 100644
--- a/options.go
+++ b/options.go
@@ -642,7 +642,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
}
@@ -650,7 +656,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
}