summaryrefslogtreecommitdiff
path: root/builtin-grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-07-04 02:43:40 -0700
committerJunio C Hamano <junkio@cox.net>2006-07-04 03:15:46 -0700
commitfcfe34b5ace3e75d37c462712c7103e39cdb1fbc (patch)
treed0c966fe452f50210e8f33d27893e358e65a75d7 /builtin-grep.c
parent5390590f6d72ffb80da74ed4cbc8648400ea3481 (diff)
downloadgit-fcfe34b5ace3e75d37c462712c7103e39cdb1fbc.tar.gz
git-grep: fix exit code when we use external grep.
Upon hit, we should exit with status 0. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-grep.c')
-rw-r--r--builtin-grep.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/builtin-grep.c b/builtin-grep.c
index a8bec72f82..bc53546dc7 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)