# [BUG] `git stash drop --help` removes stash

2 messages from 2012-05-22 to 2012-05-22. Participants: Alexander Daniel, Junio C Hamano.
Thread: https://gitlist.dev/t/30588

## Alexander Daniel, 2012-05-22 07:29

Subject: [BUG] `git stash drop --help` removes stash
Message-ID: <95877607-FED0-41C0-9F12-B91FE9DE7871@openforce.com>
URL: https://gitlist.dev/e/95877607-FED0-41C0-9F12-B91FE9DE7871%40openforce.com

```
SUMMARY
`git stash drop --help` removes stash@{0}

VERSION
$ git --version
git version 1.7.10.2

STEPS TO REPRODUCE
- put something on the stash with `git stash`
- Naively try to show help for `git stash drop` with `git stash drop --help`
- `git stash drop --help` actually removes stash@{0}:

  $ git stash drop --help
  Dropped refs/stash@{0} (bfee7acd94b85e2b0bb5ef172893872140ba0520)

EXPECTED BEHAVIOR:
Invalid parameter error message is displayed (no modification of the stash)

Alex

```

## Junio C Hamano, 2012-05-22 17:58

Subject: Re: [BUG] `git stash drop --help` removes stash
Message-ID: <7vwr443xp3.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwr443xp3.fsf%40alter.siamese.dyndns.org
In-Reply-To: <95877607-FED0-41C0-9F12-B91FE9DE7871@openforce.com>

```
Alexander Daniel <alexander.daniel@openforce.com> writes:

> SUMMARY
> `git stash drop --help` removes stash@{0}

Thanks.

Unfortunately there is no subcommand specific help text, so a quick fix
would be along the lines of the attached patch.

The right fix would be to instead add support for subcommand specific help
text.  Such a change would tweak assert_stash_like and assert_stash_ref
not to die when --help is given even if there is no stash (or an explicit
command line argument did not name a stash), and then make all subcommand
implementations in the script (e.g. find places where these two functions
are called) notice that the user asked for --help and give subcommand
specific help text from there.


 git-stash.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/git-stash.sh b/git-stash.sh
index 4e2c7f8..487e2b5 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -339,6 +339,9 @@ parse_flags_and_rev()
 			--index)
 				INDEX_OPTION=--index
 			;;
+			--help)
+				usage
+			;;
 			-*)
 				FLAGS="${FLAGS}${FLAGS:+ }$opt"
 			;;

```
