@matheusbsbs / matheus-bagliano / commits / 9c855c3178
Fork 0

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>

Jonathan Nieder committed Nov 9, 2009 at 09:04 UTC 9c855c31786b9e879ef4cd3b8b5aa97bc4bcf8ec
1 file changed +7
builtin-grep.c
+7
@@ -788,6 +788,13 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
788 OPT_END()
789 };
790
791 + /*
792 + * 'git grep -h', unlike 'git grep -h <pattern>', is a request
793 + * to show usage information and exit.
794 + */
795 + if (argc == 2 && !strcmp(argv[1], "-h"))
796 + usage_with_options(grep_usage, options);
797 +
798 memset(&opt, 0, sizeof(opt));
799 opt.prefix = prefix;
800 opt.prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;