loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'git-grep: refactor defaults' (#4964) from yoctozepto/git-grep-refactor-defaults into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4964
Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>

+9 -3
+9 -3
modules/git/grep.go
··· 36 36 PathSpec []setting.Glob 37 37 } 38 38 39 + func (opts *GrepOptions) ensureDefaults() { 40 + opts.RefName = cmp.Or(opts.RefName, "HEAD") 41 + opts.MaxResultLimit = cmp.Or(opts.MaxResultLimit, 50) 42 + opts.MatchesPerFile = cmp.Or(opts.MatchesPerFile, 20) 43 + } 44 + 39 45 func hasPrefixFold(s, t string) bool { 40 46 if len(s) < len(t) { 41 47 return false ··· 53 59 _ = stdoutWriter.Close() 54 60 }() 55 61 62 + opts.ensureDefaults() 63 + 56 64 /* 57 65 The output is like this ("^@" means \x00; the first number denotes the line, 58 66 the second number denotes the column of the first match in line): ··· 69 77 "-I", "--null", "--break", "--heading", "--column", 70 78 "--fixed-strings", "--line-number", "--ignore-case", "--full-name") 71 79 cmd.AddOptionValues("--context", fmt.Sprint(opts.ContextLineNumber)) 72 - opts.MatchesPerFile = cmp.Or(opts.MatchesPerFile, 20) 73 80 cmd.AddOptionValues("--max-count", fmt.Sprint(opts.MatchesPerFile)) 74 81 words := []string{search} 75 82 if opts.IsFuzzy { ··· 90 97 for _, expr := range setting.Indexer.ExcludePatterns { 91 98 files = append(files, ":^"+expr.Pattern()) 92 99 } 93 - cmd.AddDynamicArguments(cmp.Or(opts.RefName, "HEAD")).AddDashesAndList(files...) 100 + cmd.AddDynamicArguments(opts.RefName).AddDashesAndList(files...) 94 101 95 - opts.MaxResultLimit = cmp.Or(opts.MaxResultLimit, 50) 96 102 stderr := bytes.Buffer{} 97 103 err = cmd.Run(&RunOpts{ 98 104 Timeout: time.Duration(setting.Git.Timeout.Grep) * time.Second,