aboutsummaryrefslogtreecommitdiff
path: root/builtin-grep.c
diff options
context:
space:
mode:
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 1df25b07b..01be9bf7f 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;