diff options
author | Ayman Bagabas <ayman.bagabas@gmail.com> | 2023-03-29 23:26:53 -0400 |
---|---|---|
committer | Ayman Bagabas <ayman.bagabas@gmail.com> | 2023-04-26 09:07:37 -0400 |
commit | 3aa7575a4d660a250edd06864d6401a302951fab (patch) | |
tree | 5f4767d4b986989ed208314113f4d36bb1de105c /options.go | |
parent | b154dcce7059e4e02f8798db158b6a76ffc4a63e (diff) | |
download | go-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.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 } |