On Fri, Sep 14, 2007 at 08:40:57AM +0000, Junio C Hamano wrote: > Pierre Habouzit <madcoder@xxxxxxxxxx> writes: > - after finishing to iterate over the cache, we call flush() > with kept == NULL. > > - If count is small, then we may add /dev/null; otherwise we > do not have to (the code would add it when count == 2 if we > change the test as you suggested, which is not necessary, > but would not hurt); Okay I wanted to avoid that fully instead of trying to support it anyways, because I think it's an overkill to do so, but with the <= 2 indeed I don't see problems anymore. I agree this patch fixes all issues I can see. > builtin-grep.c | 5 +++-- > 1 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/builtin-grep.c b/builtin-grep.c > index 4ef30ea..c7b45c4 100644 > --- a/builtin-grep.c > +++ b/builtin-grep.c > @@ -202,7 +202,7 @@ static int flush_grep(struct grep_opt *opt, > int count = argc - arg0; > const char *kept_0 = NULL; > > - if (count < 2) { > + if (count <= 2) { > /* > * Because we keep at least 2 paths in the call from > * the main loop (i.e. kept != NULL), and MAXARGS is > @@ -221,7 +221,8 @@ static int flush_grep(struct grep_opt *opt, > * get "-H" behaviour of GNU grep portably but when we > * are not doing "-l" nor "-L" nor "-c". > */ > - if (!opt->name_only && > + if (count == 1 && > + !opt->name_only && > !opt->unmatch_name_only && > !opt->count) { > argv[argc++] = "/dev/null"; -- ·O· Pierre Habouzit ··O madcoder@xxxxxxxxxx OOO http://www.madism.org
Attachment:
pgpe43FubnIcs.pgp
Description: PGP signature