grep: -L should show empty files
The -L (--files-without-match) option is supposed to show paths that produced no matches. When running the internal grep on work tree files, however, we had an optimization to just return on zero-sized files, without doing anything. This optimization doesn't matter too much in practice (a tracked empty file must be rare, or there is something wrong with your project); to produce results consistent with GNU grep, we should stop the optimization and show empty files as not having the given pattern. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jan 12, 2010 at 00:22 UTC
fbb9971aca1fef66e622d64418121f6077f05c57
1 file changed
-2
builtin-grep.c
-2
@@ -191,8 +191,6 @@ static int grep_file(struct grep_opt *opt, const char *filename)
191
error("'%s': %s", filename, strerror(errno));
192
return 0;
193
}
194
- if (!st.st_size)
195
- return 0; /* empty file -- no grep hit */
194
if (!S_ISREG(st.st_mode))
195
return 0;
196
sz = xsize_t(st.st_size);