Skip to content

Commit d7f5feb

Browse files
me-heerGiteaBot
authored andcommitted
Add -F to commit search to treat keywords as strings (go-gitea#28744)
Fixes go-gitea#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).
1 parent bce27d0 commit d7f5feb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

modules/git/repo_commit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ func (repo *Repository) searchCommits(id SHA1, opts SearchCommitsOptions) ([]*Co
148148
cmd.AddArguments("--all")
149149
}
150150

151+
// interpret search string keywords as string instead of regex
152+
cmd.AddArguments("-F")
153+
151154
// add remaining keywords from search string
152155
// note this is done only for command created above
153156
if len(opts.Keywords) > 0 {

0 commit comments

Comments
 (0)