summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fcfe34b)
raw | patch | inline | side by side (parent: fcfe34b)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 4 Jul 2006 09:44:48 +0000 (02:44 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 4 Jul 2006 10:15:46 +0000 (03:15 -0700) |
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-grep.c | patch | blob | history |
diff --git a/builtin-grep.c b/builtin-grep.c
index bc53546dc713f425e1d35fd3716265a0bdf01702..6973c66704326804def00a22bfdcdb487dcad4c2 100644 (file)
--- a/builtin-grep.c
+++ b/builtin-grep.c
static const char builtin_grep_usage[] =
"git-grep <option>* <rev>* [-e] <pattern> [<path>...]";
+static const char emsg_invalid_context_len[] =
+"%s: invalid context length argument";
+static const char emsg_missing_context_len[] =
+"missing context length argument";
+static const char emsg_missing_argument[] =
+"option requires an argument -%s";
+
int cmd_grep(int argc, const char **argv, char **envp)
{
int hit = 0;
case 'A': case 'B': case 'C':
if (!arg[2]) {
if (argc <= 1)
- usage(builtin_grep_usage);
+ die(emsg_missing_context_len);
scan = *++argv;
argc--;
}
break;
}
if (sscanf(scan, "%u", &num) != 1)
- usage(builtin_grep_usage);
+ die(emsg_invalid_context_len, scan);
switch (arg[1]) {
case 'A':
opt.post_context = num;
int lno = 0;
char buf[1024];
if (argc <= 1)
- usage(builtin_grep_usage);
+ die(emsg_missing_argument, arg);
patterns = fopen(argv[1], "r");
if (!patterns)
die("'%s': %s", argv[1], strerror(errno));
argc--;
continue;
}
- usage(builtin_grep_usage);
+ die(emsg_missing_argument, arg);
}
if (!strcmp("--", arg)) {
/* later processing wants to have this at argv[1] */