diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-06-02 00:01:41 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-06-02 00:01:41 +0400 |
commit | 2147cb2762c67d0ec2101ab13a4c1b0ef8cab599 (patch) | |
tree | 7dccda03b60264e9922edc9bbcad3d4942d77f10 /builtin/grep.c | |
parent | e2d484c47a3445a288f4e45ee8365c912eebb26f (diff) | |
parent | ec83061156e18ce600384d3c57f90729a9295488 (diff) |
Merge branch 'rs/maint-grep-F' into maint
"git grep -e '$pattern'", unlike the case where the patterns are read from
a file, did not treat individual lines in the given pattern argument as
separate regular expressions as it should.
By René Scharfe
* rs/maint-grep-F:
grep: stop leaking line strings with -f
grep: support newline separated pattern list
grep: factor out do_append_grep_pat()
grep: factor out create_grep_pat()
Diffstat (limited to 'builtin/grep.c')
-rw-r--r-- | builtin/grep.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 643938d905..fe1726f5ef 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -600,15 +600,12 @@ static int file_callback(const struct option *opt, const char *arg, int unset) if (!patterns) die_errno(_("cannot open '%s'"), arg); while (strbuf_getline(&sb, patterns, '\n') == 0) { - char *s; - size_t len; - /* ignore empty line like grep does */ if (sb.len == 0) continue; - s = strbuf_detach(&sb, &len); - append_grep_pat(grep_opt, s, len, arg, ++lno, GREP_PATTERN); + append_grep_pat(grep_opt, sb.buf, sb.len, arg, ++lno, + GREP_PATTERN); } if (!from_stdin) fclose(patterns); |