threads / patch / 11065

patchgit-stash: Display help message if git-stash is run without sub-commands

Subject: [PATCH] git-stash: Display help message if git-stash is run without sub-commands

## tl;dr

7 messages between Nov 30, 2007 and Nov 30, 2007. Diffs are folded; open one to read it.

replies: 6people: 6as markdown or json

Kevin Leung· Nov 30, 2007, 08:16 UTC · lore

The current git-stash behaviour is very error prone to typos. For example, if you typed "git-stash llist", git-stash would thought that you wanted to save to a stash named "llist", but in fact, you meant "git-stash list".

Signed-off-by: Kevin Leung <kevinlsk@gmail.com>
---
 git-stash.sh |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
Show changes to git-stash.sh +6 −9
diff --git a/git-stash.sh b/git-stash.sh
index 77c9421..dbb8894 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Copyright (c) 2007, Nanako Shiraishi

-USAGE='[ | list | show | apply | clear]'
+USAGE='[ save | list | show | apply | clear ]'

 SUBDIRECTORY_OK=Yes
 . git-sh-setup
@@ -195,6 +195,10 @@ show)
        shift
        show_stash "$@"
        ;;
+save)
+       shift
+       save_stash "$@" && git-reset --hard
+       ;;
 apply)
        shift
        apply_stash "$@"
@@ -202,14 +206,7 @@ apply)
 clear)
        clear_stash
        ;;
-help | usage)
-       usage
-       ;;
 *)
-       if test $# -gt 0 && test "$1" = save
-       then
-               shift
-       fi
-       save_stash "$*" && git-reset --hard
+       usage
        ;;
 esac
-- 
1.5.3.6.36.g38762
Mike Hommey· Nov 30, 2007, 08:41 UTC · re: Kevin Leung · lore

Re: [PATCH] git-stash: Display help message if git-stash is run without sub-commands

On Fri, Nov 30, 2007 at 04:16:34PM +0800, Kevin Leung <kevinlsk@gmail.com> wrote:
> The current git-stash behaviour is very error prone to typos. For example,
> if you typed "git-stash llist", git-stash would thought that you wanted to
> save to a stash named "llist", but in fact, you meant "git-stash list".
Still, 'git stash' alone should *do* the stash.
Mike
Kevin Leung· Nov 30, 2007, 09:09 UTC · re: Mike Hommey · lore

Re: [PATCH] git-stash: Display help message if git-stash is run without sub-commands

On Nov 30, 2007 4:41 PM, Mike Hommey <mh@glandium.org> wrote:
> Still, 'git stash' alone should *do* the stash.
>

How about `git stash' still does the stash, and `git stash llist' exits with usage message? And if you want to save the stash with name, you can only do it with `git stash save name_of_stash'.

Kevin Leung
Wincent Colaiuta· Nov 30, 2007, 09:19 UTC · re: Kevin Leung · lore

Re: [PATCH] git-stash: Display help message if git-stash is run without sub-commands

El 30/11/2007, a las 10:09, Kevin Leung escribió:
Show 6 quoted lines
> On Nov 30, 2007 4:41 PM, Mike Hommey <mh@glandium.org> wrote:
>> Still, 'git stash' alone should *do* the stash.
>
> How about `git stash' still does the stash, and `git stash llist'
> exits with usage message? And if you want to save the stash with name,
> you can only do it with `git stash save name_of_stash'.
That's probably the way it should have been all along.
>

Cheers, Wincent

Junio C Hamano· Nov 30, 2007, 20:02 UTC · re: Kevin Leung · lore

Re: [PATCH] git-stash: Display help message if git-stash is run without sub-commands

"Kevin Leung" <kevinlsk@gmail.com> writes:
Show 7 quoted lines
> On Nov 30, 2007 4:41 PM, Mike Hommey <mh@glandium.org> wrote:
>> Still, 'git stash' alone should *do* the stash.
>>
>
> How about `git stash' still does the stash, and `git stash llist'
> exits with usage message? And if you want to save the stash with name,
> you can only do it with `git stash save name_of_stash'.
Sounds like a sensible thing to do.
David Kastrup· Nov 30, 2007, 20:11 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-stash: Display help message if git-stash is run without sub-commands

Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> "Kevin Leung" <kevinlsk@gmail.com> writes:
>
>> On Nov 30, 2007 4:41 PM, Mike Hommey <mh@glandium.org> wrote:
>>> Still, 'git stash' alone should *do* the stash.
>>>
>>
>> How about `git stash' still does the stash, and `git stash llist'
>> exits with usage message? And if you want to save the stash with name,
>> you can only do it with `git stash save name_of_stash'.
>
> Sounds like a sensible thing to do.

Instead of "save", one could use "stash" since that is what it is supposed to do. Then

git stash stash stash
would create a stash called "stash".
-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Johannes Schindelin· Nov 30, 2007, 11:50 UTC · re: Kevin Leung · lore

Re: [PATCH] git-stash: Display help message if git-stash is run without sub-commands

Hi,
On Fri, 30 Nov 2007, Kevin Leung wrote:
> The current git-stash behaviour is very error prone to typos. For 
> example, if you typed "git-stash llist", git-stash would thought that 
> you wanted to save to a stash named "llist", but in fact, you meant 
> "git-stash list".

I am fine with your patch. I would be equally fine with "git stash" still choosing a default message and stashing.

And yes, I agree that the "git stash <whatever>" might be a little too error-prone.

Ciao, Dscho

← back to recent threads