Skip to content

Commit fbb9971

Browse files
committed
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 <[email protected]>
1 parent 2b77029 commit fbb9971

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

builtin-grep.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ static int grep_file(struct grep_opt *opt, const char *filename)
191191
error("'%s': %s", filename, strerror(errno));
192192
return 0;
193193
}
194-
if (!st.st_size)
195-
return 0; /* empty file -- no grep hit */
196194
if (!S_ISREG(st.st_mode))
197195
return 0;
198196
sz = xsize_t(st.st_size);

0 commit comments

Comments
 (0)