782
783
revs->commit_format = CMIT_FMT_DEFAULT;
784
785
+ revs->grep_filter.status_only = 1;
786
+ revs->grep_filter.pattern_tail = &(revs->grep_filter.pattern_list);
787
+ revs->grep_filter.regflags = REG_NEWLINE;
788
+
789
diff_setup(&revs->diffopt);
790
if (prefix && !revs->diffopt.prefix) {
791
revs->diffopt.prefix = prefix;
950
951
static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)
952
{
949
- if (!revs->grep_filter) {
950
- struct grep_opt *opt = xcalloc(1, sizeof(*opt));
951
- opt->status_only = 1;
952
- opt->pattern_tail = &(opt->pattern_list);
953
- opt->regflags = REG_NEWLINE;
954
- revs->grep_filter = opt;
955
- }
956
- append_grep_pattern(revs->grep_filter, ptn,
957
- "command line", 0, what);
953
+ append_grep_pattern(&revs->grep_filter, ptn, "command line", 0, what);
954
}
955
956
static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern)
1160
} else if (!prefixcmp(arg, "--grep=")) {
1161
add_message_grep(revs, arg+7);
1162
} else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
1167
- if (revs->grep_filter)
1168
- revs->grep_filter->regflags |= REG_EXTENDED;
1163
+ revs->grep_filter.regflags |= REG_EXTENDED;
1164
} else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
1170
- if (revs->grep_filter)
1171
- revs->grep_filter->regflags |= REG_ICASE;
1165
+ revs->grep_filter.regflags |= REG_ICASE;
1166
} else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
1173
- if (revs->grep_filter)
1174
- revs->grep_filter->fixed = 1;
1167
+ revs->grep_filter.fixed = 1;
1168
} else if (!strcmp(arg, "--all-match")) {
1176
- if (revs->grep_filter)
1177
- revs->grep_filter->all_match = 1;
1169
+ revs->grep_filter.all_match = 1;
1170
} else if (!prefixcmp(arg, "--encoding=")) {
1171
arg += 11;
1172
if (strcmp(arg, "none"))
1341
if (diff_setup_done(&revs->diffopt) < 0)
1342
die("diff_setup_done failed");
1343
1352
- if (revs->grep_filter) {
1353
- compile_grep_patterns(revs->grep_filter);
1354
- }
1344
+ compile_grep_patterns(&revs->grep_filter);
1345
1346
if (revs->reverse && revs->reflog_info)
1347
die("cannot combine --reverse with --walk-reflogs");
1482
1483
static int commit_match(struct commit *commit, struct rev_info *opt)
1484
{
1495
- if (!opt->grep_filter)
1485
+ if (!opt->grep_filter.pattern_list)
1486
return 1;
1497
- return grep_buffer(opt->grep_filter,
1487
+ return grep_buffer(&opt->grep_filter,
1488
NULL, /* we say nothing, not even filename */
1489
commit->buffer, strlen(commit->buffer));
1490
}