git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH/RFC 06/24] Show usage string for 'git show-ref -h'
Date: Mon,  9 Nov 2009 09:04:46 -0600	[thread overview]
Message-ID: <1257779104-23884-6-git-send-email-jrnieder@gmail.com> (raw)
In-Reply-To: <20091109150235.GA23871@progeny.tock>

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>
---
 Documentation/git-show-ref.txt |    3 +--
 builtin-show-ref.c             |   10 ++++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt
index f4429bd..70f400b 100644
--- a/Documentation/git-show-ref.txt
+++ b/Documentation/git-show-ref.txt
@@ -8,7 +8,7 @@ git-show-ref - List references in a local repository
 SYNOPSIS
 --------
 [verse]
-'git show-ref' [-q|--quiet] [--verify] [-h|--head] [-d|--dereference]
+'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]
 	     [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
 	     [--heads] [--] <pattern>...
 'git show-ref' --exclude-existing[=<pattern>] < ref-list
@@ -30,7 +30,6 @@ the `.git` directory.
 OPTIONS
 -------
 
--h::
 --head::
 
 	Show the HEAD reference.
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index c46550c..17ada88 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -7,7 +7,7 @@
 #include "parse-options.h"
 
 static const char * const show_ref_usage[] = {
-	"git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [pattern*] ",
+	"git show-ref [-q|--quiet] [--verify] [--head] [-d|--dereference] [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [pattern*] ",
 	"git show-ref --exclude-existing[=pattern] < ref-list",
 	NULL
 };
@@ -183,7 +183,10 @@ static const struct option show_ref_options[] = {
 	OPT_BOOLEAN(0, "heads", &heads_only, "only show heads (can be combined with tags)"),
 	OPT_BOOLEAN(0, "verify", &verify, "stricter reference checking, "
 		    "requires exact ref path"),
-	OPT_BOOLEAN('h', "head", &show_head, "show the HEAD reference"),
+	{ OPTION_BOOLEAN, 'h', NULL, &show_head, NULL,
+	  "show the HEAD reference",
+	  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+	OPT_BOOLEAN(0, "head", &show_head, "show the HEAD reference"),
 	OPT_BOOLEAN('d', "dereference", &deref_tags,
 		    "dereference tags into object IDs"),
 	{ OPTION_CALLBACK, 's', "hash", &abbrev, "n",
@@ -201,6 +204,9 @@ static const struct option show_ref_options[] = {
 
 int cmd_show_ref(int argc, const char **argv, const char *prefix)
 {
+	if (argc == 2 && !strcmp(argv[1], "-h"))
+		usage_with_options(show_ref_usage, show_ref_options);
+
 	argc = parse_options(argc, argv, prefix, show_ref_options,
 			     show_ref_usage, PARSE_OPT_NO_INTERNAL_HELP);
 
-- 
1.6.5.2

  parent reply	other threads:[~2009-11-09 14:56 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080125173149.GA10287@edna.gwendoline.at>
2009-11-08  7:11 ` [PATCH] Let 'git <command> -h' show usage without a git dir Jonathan Nieder
2009-11-08  7:26   ` [PATCH] Show usage string for 'git http-push -h' Jonathan Nieder
2009-11-09  8:52     ` Tay Ray Chuan
2009-11-09 10:47       ` [PATCH v2] " Jonathan Nieder
2009-11-09 13:56         ` Tay Ray Chuan
2009-11-08  9:21   ` [PATCH] Let 'git <command> -h' show usage without a git dir Junio C Hamano
2009-11-08 11:03     ` Jonathan Nieder
2009-11-09 15:02       ` [PATCH 00/24] " Jonathan Nieder
2009-11-09 15:04         ` [PATCH 01/24] Retire fetch--tool helper to contrib/examples Jonathan Nieder
2009-11-09 15:04         ` [PATCH 02/24] Show usage string for 'git grep -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 03/24] Show usage string for 'git cherry -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 04/24] Show usage string for 'git commit-tree -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 05/24] Show usage string for 'git merge-ours -h' Jonathan Nieder
2009-11-09 15:04         ` Jonathan Nieder [this message]
2009-11-09 15:04         ` [PATCH 07/24] check-ref-format: update usage string Jonathan Nieder
2009-11-10 20:11           ` Junio C Hamano
2009-11-09 15:04         ` [PATCH 08/24] Show usage string for 'git check-ref-format -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 09/24] Show usage string for 'git fast-import -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 10/24] Show usage string for 'git get-tar-commit-id -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 11/24] Show usage string for 'git imap-send -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 12/24] Show usage string for 'git mailsplit -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 13/24] Show usage string for 'git merge-one-file -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 14/24] Show usage string for 'git rev-parse -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 15/24] Show usage string for 'git show-index -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 16/24] Show usage string for 'git unpack-file -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 17/24] Show usage string for 'git stripspace -h' Jonathan Nieder
2009-11-09 15:04         ` [PATCH 18/24] merge: do not setup worktree twice Jonathan Nieder
2009-11-10 20:11           ` Junio C Hamano
2009-11-11  1:58             ` Jonathan Nieder
2009-11-09 15:04         ` [PATCH 19/24] Let 'git http-fetch -h' show usage outside any git repository Jonathan Nieder
2009-11-09 15:05         ` [PATCH 20/24] http-fetch: add missing initialization of argv0_path Jonathan Nieder
2009-11-10 20:12           ` Junio C Hamano
2009-11-10 21:56             ` Johannes Sixt
2009-11-11  1:52             ` Jonathan Nieder
2009-11-09 15:05         ` [PATCH 21/24] Let 'git <command> -h' show usage without a git dir Jonathan Nieder
2009-11-09 15:05         ` [PATCH 22/24] Let usage() take a printf-style format Jonathan Nieder
2009-11-10 20:16           ` Junio C Hamano
2009-11-09 15:05         ` [PATCH 23/24] merge-{recursive,subtree}: use usage() to print usage Jonathan Nieder
2009-11-09 15:05         ` [PATCH 24/24] diff --no-index: make the usage string less scary Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1257779104-23884-6-git-send-email-jrnieder@gmail.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).