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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 20, 2015 at 14:17 UTC 5ba28313f29bcc2e8571c4b325646fecfbe238df
1 file changed +11
git-stash.sh
+11
@@ -219,6 +219,9 @@ save_stash () {
219 -a|--all)
220 untracked=all
221 ;;
222 + --help)
223 + show_help
224 + ;;
225 --)
226 shift
227 break
@@ -307,6 +310,11 @@ show_stash () {
310 git diff ${FLAGS:---stat} $b_commit $w_commit
311 }
312
313 +show_help () {
314 + exec git help stash
315 + exit 1
316 +}
317 +
318 #
319 # Parses the remaining options looking for flags and
320 # at most one revision defaulting to ${ref_stash}@{0}
@@ -373,6 +381,9 @@ parse_flags_and_rev()
381 --index)
382 INDEX_OPTION=--index
383 ;;
384 + --help)
385 + show_help
386 + ;;
387 -*)
388 test "$ALLOW_UNKNOWN_FLAGS" = t ||
389 die "$(eval_gettext "unknown option: \$opt")"