diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Search the log literally as intended
setup_revisions compiles the pattern itself, and the literal type cgit set afterwards came too late, so text that was no valid regular expression, such as an unbalanced bracket, ended in a 500.
Diffstat (limited to 'source/ui-log.c')
-rw-r--r--source/ui-log.c10
1 file changed, 4 insertions, 6 deletions
diff --git a/source/ui-log.c b/source/ui-log.c
index 793f145..98efcf6 100644
--- a/source/ui-log.c
+++ b/source/ui-log.c
@@ -489,6 +489,10 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
if (grep && pattern && *pattern) {
pattern = xstrdup(pattern);
if (!strcmp(grep, "grep") || !strcmp(grep, "author") || !strcmp(grep, "committer")) {
+ // The search is literal and ignores case. setup_revisions
+ // compiles the pattern, so the flags go in with it.
+ strvec_push(&rev_argv, "--fixed-strings");
+ strvec_push(&rev_argv, "--regexp-ignore-case");
strvec_pushf(&rev_argv, "--%s=%s", grep, pattern);
} else if (!strcmp(grep, "range")) {
char *arg;
@@ -542,18 +546,12 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
setup_revisions(rev_argv.nr, rev_argv.v, &rev, NULL);
load_ref_decorations(NULL, DECORATE_FULL_REFS);
rev.show_decorations = 1;
- rev.grep_filter.ignore_case = 1;
- // The search is literal. A pattern would run as a regular expression
- // over every message in the history, and one with a backreference
- // takes exponential time to match.
- rev.grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED;
rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = ctx.cfg.renamelimit;
if (ctx.qry.ignorews)
DIFF_XDL_SET(&rev.diffopt, IGNORE_WHITESPACE);
- compile_grep_patterns(&rev.grep_filter);
// A failed setup leaves the walk holding freed commits, so it must
// not be read from.
if (prepare_revision_walk(&rev)) {