threads / bug / 30588

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

Subject: [BUG] `git stash drop --help` removes stash

## tl;dr

2 messages between May 22, 2012 and May 22, 2012.

replies: 1people: 2as markdown or json

Alexander Daniel· May 22, 2012, 07:29 UTC · lore

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· May 22, 2012, 17:58 UTC · re: Alexander Daniel · lore

Re: [BUG] `git stash drop --help` removes stash

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"
 			;;

← back to recent threads