@matheusbsbs / matheus-bagliano / commits / e62b393505
Fork 0

Show usage string for 'git show-ref -h'

This only changes the behavior of "git show-ref -h" without any other options and arguments. "show-ref -h" currently is short for "show-ref --head", which shows all the refs/* and HEAD, as opposed to "show-ref" that shows all the refs/* and not HEAD. Does anybody use "show-ref -h"? It was in Linus's original, most likely only because "it might be handy", not because "the command should not show the HEAD by default for such and such reasons". So I think it is okay if "show-ref -h" (but not "show-ref --head") gives help and exits. If a current script uses "git show-ref -h" without any other arguments, it would have to be adapted by changing "-h" to "--head". 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 e62b393505616c3ce313f6dac5060d9e1cde8e42
2 files changed +9 -4
Documentation/git-show-ref.txt
+1 -2
@@ -8,7 +8,7 @@ git-show-ref - List references in a local repository
8 SYNOPSIS
9 --------
10 [verse]
11 -'git show-ref' [-q|--quiet] [--verify] [-h|--head] [-d|--dereference]
11 +'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]
12 [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
13 [--heads] [--] <pattern>...
14 'git show-ref' --exclude-existing[=<pattern>] < ref-list
@@ -30,7 +30,6 @@ the `.git` directory.
30 OPTIONS
31 -------
32
33 --h::
33 --head::
34
35 Show the HEAD reference.
builtin-show-ref.c
+8 -2
@@ -7,7 +7,7 @@
7 #include "parse-options.h"
8
9 static const char * const show_ref_usage[] = {
10 - "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [pattern*] ",
10 + "git show-ref [-q|--quiet] [--verify] [--head] [-d|--dereference] [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [pattern*] ",
11 "git show-ref --exclude-existing[=pattern] < ref-list",
12 NULL
13 };
@@ -183,7 +183,10 @@ static const struct option show_ref_options[] = {
183 OPT_BOOLEAN(0, "heads", &heads_only, "only show heads (can be combined with tags)"),
184 OPT_BOOLEAN(0, "verify", &verify, "stricter reference checking, "
185 "requires exact ref path"),
186 - OPT_BOOLEAN('h', "head", &show_head, "show the HEAD reference"),
186 + { OPTION_BOOLEAN, 'h', NULL, &show_head, NULL,
187 + "show the HEAD reference",
188 + PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
189 + OPT_BOOLEAN(0, "head", &show_head, "show the HEAD reference"),
190 OPT_BOOLEAN('d', "dereference", &deref_tags,
191 "dereference tags into object IDs"),
192 { OPTION_CALLBACK, 's', "hash", &abbrev, "n",
@@ -201,6 +204,9 @@ static const struct option show_ref_options[] = {
204
205 int cmd_show_ref(int argc, const char **argv, const char *prefix)
206 {
207 + if (argc == 2 && !strcmp(argv[1], "-h"))
208 + usage_with_options(show_ref_usage, show_ref_options);
209 +
210 argc = parse_options(argc, argv, prefix, show_ref_options,
211 show_ref_usage, PARSE_OPT_NO_INTERNAL_HELP);
212