git-grep: fix for initial dashes in expressions

There is no reason to reject initial dashes in git-grep
expressions... other than the code not supporting it previously.
A new method is introduced to relax the security checks.
This commit is contained in:
Radosław Piliszek 2024-08-12 14:05:01 +02:00
parent 0d2efa2c4a
commit f4d86b4ab0
4 changed files with 45 additions and 1 deletions

View file

@ -76,7 +76,7 @@ func GrepSearch(ctx context.Context, repo *Repository, search string, opts GrepO
words = strings.Fields(search)
}
for _, word := range words {
cmd.AddOptionValues("-e", strings.TrimLeft(word, "-"))
cmd.AddGitGrepExpression(word)
}
// pathspec