mirror of
https://github.com/go-gitea/gitea
synced 2024-11-15 14:31:41 +01:00
Add -F to commit search to treat keywords as strings (#28744)
Fixes #28269 The [default behavior](https://git-scm.com/docs/git-log#Documentation/git-log.txt---basic-regexp) of --grep in git log is to interpret the keyword as a regular expression. This causes the search to fail in the cases where the search keyword contains a `[`, since `[` is a special character used in grep. If we want our keywords to be interpreted as 'strings', we should use [-F flag](https://git-scm.com/docs/git-log#Documentation/git-log.txt---basic-regexp).
This commit is contained in:
parent
2df7563f31
commit
839cd26b1a
1 changed files with 3 additions and 0 deletions
|
@ -142,6 +142,9 @@ func (repo *Repository) searchCommits(id ObjectID, opts SearchCommitsOptions) ([
|
||||||
cmd.AddArguments("--all")
|
cmd.AddArguments("--all")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// interpret search string keywords as string instead of regex
|
||||||
|
cmd.AddArguments("-F")
|
||||||
|
|
||||||
// add remaining keywords from search string
|
// add remaining keywords from search string
|
||||||
// note this is done only for command created above
|
// note this is done only for command created above
|
||||||
for _, v := range opts.Keywords {
|
for _, v := range opts.Keywords {
|
||||||
|
|
Loading…
Reference in a new issue