Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-29 05:06:11 +01:00

Merge pull request 'git-grep: ensure bounded default for MatchesPerFile' (#4928) from yoctozepto/forgejo:git-grep-limit-matches-per-file into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4928
Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>
Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
Otto 2024-08-12 14:37:43 +00:00
commit 4132b18e59

View file

@ -68,9 +68,8 @@ func GrepSearch(ctx context.Context, repo *Repository, search string, opts GrepO
"-I", "--null", "--break", "--heading", "--column", "-I", "--null", "--break", "--heading", "--column",
"--fixed-strings", "--line-number", "--ignore-case", "--full-name") "--fixed-strings", "--line-number", "--ignore-case", "--full-name")
cmd.AddOptionValues("--context", fmt.Sprint(opts.ContextLineNumber)) cmd.AddOptionValues("--context", fmt.Sprint(opts.ContextLineNumber))
if opts.MatchesPerFile > 0 { opts.MatchesPerFile = cmp.Or(opts.MatchesPerFile, 20)
cmd.AddOptionValues("--max-count", fmt.Sprint(opts.MatchesPerFile)) cmd.AddOptionValues("--max-count", fmt.Sprint(opts.MatchesPerFile))
}
words := []string{search} words := []string{search}
if opts.IsFuzzy { if opts.IsFuzzy {
words = strings.Fields(search) words = strings.Fields(search)