X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fgrep.c;h=d0a73da07a0d7d8d4b01adcfcda88a98130910a0;hb=2d4fef9b86f41ad929f533e0e52dc1a6048cc2a3;hp=8e928e217041a159f4a962f0883d740aa84536d7;hpb=371276bf29314af04b804cfd877abcac62674a58;p=git.git diff --git a/builtin/grep.c b/builtin/grep.c index 8e928e217..d0a73da07 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -17,8 +17,8 @@ #include "dir.h" #ifndef NO_PTHREADS -#include "thread-utils.h" #include +#include "thread-utils.h" #endif static char const * const grep_usage[] = { @@ -724,11 +724,15 @@ 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; - append_grep_pattern(grep_opt, strbuf_detach(&sb, NULL), arg, - ++lno, GREP_PATTERN); + + s = strbuf_detach(&sb, &len); + append_grep_pat(grep_opt, s, len, arg, ++lno, GREP_PATTERN); } fclose(patterns); strbuf_release(&sb);