aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorMihir Joshi <mihir67mj@gmail.com>2024-01-10 16:58:20 +0530
committerGitHub <noreply@github.com>2024-01-10 11:28:20 +0000
commit839cd26b1acc3926918fb5755294dcc355db5ad8 (patch)
treeaa3fc6a7f38d2af1fe8b68b4f920095565b724d6 /modules/git
parent2df7563f3176aa8c7dcb070f660d53da4bb66e78 (diff)
downloadgitea-839cd26b1acc3926918fb5755294dcc355db5ad8.tar.gz
gitea-839cd26b1acc3926918fb5755294dcc355db5ad8.zip
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).
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/repo_commit.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go
index ccb3eb4ade..a69229055f 100644
--- a/modules/git/repo_commit.go
+++ b/modules/git/repo_commit.go
@@ -142,6 +142,9 @@ func (repo *Repository) searchCommits(id ObjectID, opts SearchCommitsOptions) ([
cmd.AddArguments("--all")
}
+ // interpret search string keywords as string instead of regex
+ cmd.AddArguments("-F")
+
// add remaining keywords from search string
// note this is done only for command created above
for _, v := range opts.Keywords {