git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] `git stash drop --help` removes stash
@ 2012-05-22  7:29 Alexander Daniel
  2012-05-22 17:58 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Daniel @ 2012-05-22  7:29 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [BUG] `git stash drop --help` removes stash
  2012-05-22  7:29 [BUG] `git stash drop --help` removes stash Alexander Daniel
@ 2012-05-22 17:58 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2012-05-22 17:58 UTC (permalink / raw)
  To: Alexander Daniel; +Cc: git

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-22 17:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-22  7:29 [BUG] `git stash drop --help` removes stash Alexander Daniel
2012-05-22 17:58 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).