Skip to content

Commit a3f5d02

Browse files
author
Junio C Hamano
committed
grep: fix --fixed-strings combined with expression.
"git grep --fixed-strings -e GIT --and -e VERSION .gitignore" misbehaved because we did not notice this needs to grab lines that have the given two fixed strings at the same time. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent b48fb5b commit a3f5d02

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

grep.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,13 @@ void compile_grep_patterns(struct grep_opt *opt)
138138
{
139139
struct grep_pat *p;
140140

141-
if (opt->fixed)
142-
return;
143-
144-
/* First compile regexps */
145141
for (p = opt->pattern_list; p; p = p->next) {
146142
switch (p->token) {
147143
case GREP_PATTERN: /* atom */
148144
case GREP_PATTERN_HEAD:
149145
case GREP_PATTERN_BODY:
150-
compile_regexp(p, opt);
146+
if (!opt->fixed)
147+
compile_regexp(p, opt);
151148
break;
152149
default:
153150
opt->extended = 1;

0 commit comments

Comments
 (0)