Skip to content

Commit

Permalink
grep: -L should show empty files
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jan 12, 2010
1 parent 2b77029 commit fbb9971
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions builtin-grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ static int grep_file(struct grep_opt *opt, const char *filename)
error("'%s': %s", filename, strerror(errno));
return 0;
}
if (!st.st_size)
return 0; /* empty file -- no grep hit */
if (!S_ISREG(st.st_mode))
return 0;
sz = xsize_t(st.st_size);
Expand Down

0 comments on commit fbb9971

Please sign in to comment.