[PATCH 02/24] Show usage string for 'git grep -h'
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Nov 9, 2009, 15:04 UTC
- Message-ID
- <1257779104-23884-2-git-send-email-jrnieder@gmail.com>
- In-Reply-To
- <20091109150235.GA23871@progeny.tock>
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> --- builtin-grep.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/builtin-grep.c b/builtin-grep.c index 1df25b0..01be9bf 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;
-- 1.6.5.2