All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Vincent Legoll <vincent.legoll@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/1] stash: recognize "--help" for subcommands
Date: Wed, 20 May 2015 14:17:46 -0400	[thread overview]
Message-ID: <20150520181746.GC14561@peff.net> (raw)
In-Reply-To: <20150520180132.GB14561@peff.net>

On Wed, May 20, 2015 at 02:01:32PM -0400, Jeff King wrote:

> This takes away the immediate pain. We may also want to
> teach "--help" to the option. I guess we cannot do better
> than just having it run "git help stash" in all cases (i.e.,
> we have no way to get the help for a specific subcommand).

That actually turns out to be pretty painless...

-- >* --
Subject: stash: recognize "--help" for subcommands

If you run "git stash --help", you get the help for stash
(this magic is done by the git wrapper itself). But if you
run "git stash drop --help", you get an error. We
cannot show help specific to "stash drop", of course, but we
can at least give the user the normal stash manpage.

Signed-off-by: Jeff King <peff@peff.net>
---
 git-stash.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/git-stash.sh b/git-stash.sh
index c6f492c..1f5ea87 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -219,6 +219,9 @@ save_stash () {
 		-a|--all)
 			untracked=all
 			;;
+		--help)
+			show_help
+			;;
 		--)
 			shift
 			break
@@ -307,6 +310,11 @@ show_stash () {
 	git diff ${FLAGS:---stat} $b_commit $w_commit
 }
 
+show_help () {
+	exec git help stash
+	exit 1
+}
+
 #
 # Parses the remaining options looking for flags and
 # at most one revision defaulting to ${ref_stash}@{0}
@@ -373,6 +381,9 @@ parse_flags_and_rev()
 			--index)
 				INDEX_OPTION=--index
 			;;
+			--help)
+				show_help
+			;;
 			-*)
 				test "$ALLOW_UNKNOWN_FLAGS" = t ||
 					die "$(eval_gettext "unknown option: \$opt")"
-- 
2.4.1.396.g7ba6d7b

  reply	other threads:[~2015-05-20 18:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20 17:14 [BUG, RFC] git stash drop --help Vincent Legoll
2015-05-20 18:01 ` [PATCH] stash: complain about unknown flags Jeff King
2015-05-20 18:17   ` Jeff King [this message]
2015-11-01  8:17     ` [PATCH 2/1] stash: recognize "--help" for subcommands Vincent Legoll
2015-11-01  8:16   ` [PATCH] stash: complain about unknown flags Vincent Legoll

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=20150520181746.GC14561@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=vincent.legoll@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.