From: Junio C Hamano Date: Tue, 4 Jul 2006 09:43:40 +0000 (-0700) Subject: git-grep: fix exit code when we use external grep. X-Git-Tag: v1.4.2-rc1~86^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fcfe34b5ace3e75d37c462712c7103e39cdb1fbc;p=git.git git-grep: fix exit code when we use external grep. Upon hit, we should exit with status 0. Signed-off-by: Junio C Hamano --- diff --git a/builtin-grep.c b/builtin-grep.c index a8bec72f8..bc53546dc 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -446,7 +446,7 @@ static int exec_grep(int argc, const char **argv) static int external_grep(struct grep_opt *opt, const char **paths, int cached) { - int i, nr, argc, hit, len; + int i, nr, argc, hit, len, status; const char *argv[MAXARGS+1]; char randarg[ARGBUF]; char *argptr = randarg; @@ -536,12 +536,17 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached) argv[argc++] = name; if (argc < MAXARGS) continue; - hit += exec_grep(argc, argv); + status = exec_grep(argc, argv); + if (0 < status) + hit = 1; argc = nr; } - if (argc > nr) - hit += exec_grep(argc, argv); - return 0; + if (argc > nr) { + status = exec_grep(argc, argv); + if (0 < status) + hit = 1; + } + return hit; } static int grep_cache(struct grep_opt *opt, const char **paths, int cached)