Re: [PATCH] grep: fix exit status if external_grep() returns error
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 7, 2009, 18:13 UTC
- Message-ID
- <7vskeyvd0c.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20090907084801.GB10797@localhost>
Clemens Buchacher <drizzd@aon.at> writes:
Show 14 quoted lines
> diff --git a/builtin-grep.c b/builtin-grep.c
> index ad0e0a5..b577738 100644
> --- a/builtin-grep.c
> +++ b/builtin-grep.c
> @@ -500,9 +500,9 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached,
> * be a lot more optimized
> */
> if (!cached && external_grep_allowed) {
> - hit = external_grep(opt, paths, cached);
> - if (hit >= 0)
> - return hit;
> + int ret = external_grep(opt, paths, cached);
> + if (ret >= 0)
> + return ret;Well caught, and this deserves to go to maint.
An alternative would be to reset hit to zero if we decide to use the internal one after this conditional.
Thanks.