git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
KLKevin Leung <kevinlsk@gmail.com>
Date
Dec 3, 2007, 03:36 UTC
Message-ID
<e66701d40712021936p10ee73ddj9696d3a8b4092127@mail.gmail.com>
In-Reply-To
<7vwsrwqysf.fsf@gitster.siamese.dyndns.org>

The current git-stash behaviour is very error prone to typos. For example, if you typed "git-stash llist", git-stash would think 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>
---
 Thanks, Junio. It should be alright now.
 git-stash.sh |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 77c9421..844a3e5 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,12 @@ apply)
 clear)
        clear_stash
        ;;
-help | usage)
-       usage
-       ;;
 *)
-       if test $# -gt 0 && test "$1" = save
+       if test "$#" -eq "0"
        then
-               shift
+               save_stash && git-reset --hard
+       else
+               usage
        fi
-       save_stash "$*" && git-reset --hard
        ;;
 esac
-- 
1.5.3.7-dirty
Previous: Junio C HamanoNext: Wayne Davison
Message 3 of 6 in “git-stash: Display help message if git-stash is run with wrong sub-commands”
  1. git-stash: Display help message if git-stash is run with wrong sub-commandsKevin Leung, Dec 3, 2007
  2. Junio C HamanoDec 3, 2007
  3. Kevin LeungDec 3, 2007
  4. Wayne DavisonDec 3, 2007
  5. Johannes SchindelinDec 3, 2007
  6. Wayne DavisonDec 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.