summaryrefslogtreecommitdiff
path: root/builtin-grep.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2009-11-09 09:04:42 -0600
committerJunio C Hamano <gitster@pobox.com>2009-11-09 17:08:44 -0800
commit9c855c31786b9e879ef4cd3b8b5aa97bc4bcf8ec (patch)
treee9c65cd83204fca2d7aa0689e1af92aa1c1903f5 /builtin-grep.c
parentfe9a215214acd2cf9132aec70e0758786a6e3e8b (diff)
downloadgit-9c855c31786b9e879ef4cd3b8b5aa97bc4bcf8ec.tar.gz
Show usage string for 'git grep -h'
Clarification: the following description only talks about "git grep -h" without any other options and arguments. Such a change cannot be breaking backward compatibility. "grep -h" cannot be asking for suppressing filenames, as there is no match pattern specified. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-grep.c')
-rw-r--r--builtin-grep.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/builtin-grep.c b/builtin-grep.c
index 1df25b07b5..01be9bf7ff 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -788,6 +788,13 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
OPT_END()
};
+ /*
+ * 'git grep -h', unlike 'git grep -h <pattern>', is a request
+ * to show usage information and exit.
+ */
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage_with_options(grep_usage, options);
+
memset(&opt, 0, sizeof(opt));
opt.prefix = prefix;
opt.prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;