[PATCH 2/1] stash: recognize "--help" for subcommands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]