grep: support newline separated pattern list

Currently, patterns that contain newline characters don't match anything
when given to git grep.  Regular grep(1) interprets patterns as lists of
newline separated search strings instead.

Implement this functionality by creating and inserting extra grep_pat
structures for patterns consisting of multiple lines when appending to
the pattern lists.  For simplicity, all pattern strings are duplicated.
The original pattern is truncated in place to make it contain only the
first line.

Requested-by: Torne (Richard Coles) <torne@google.com>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2012-05-20 16:33:07 +02:00
committed by Junio C Hamano
parent 2b3873ff34
commit 526a858a99
4 changed files with 41 additions and 3 deletions

2
grep.h
View File

@ -35,7 +35,7 @@ struct grep_pat {
const char *origin;
int no;
enum grep_pat_token token;
const char *pattern;
char *pattern;
size_t patternlen;
enum grep_header_field field;
regex_t regexp;