Skip to content

Commit

Permalink
stash: recognize "--help" for subcommands
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 20, 2015
1 parent d6cc2df commit 5ba2831
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions git-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ save_stash () {
-a|--all)
untracked=all
;;
--help)
show_help
;;
--)
shift
break
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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")"
Expand Down

0 comments on commit 5ba2831

Please sign in to comment.