From: Johannes Schindelin Date: Mon, 27 Jul 2009 18:37:10 +0000 (+0200) Subject: Make 'git stash -k' a short form for 'git stash save --keep-index' X-Git-Tag: v1.6.5-rc0~5^2~4^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ea41cfc4f54f884582dbda307287f12bb1fc15e9;p=git.git Make 'git stash -k' a short form for 'git stash save --keep-index' To save me from the carpal tunnel syndrome, make 'git stash' accept the short option '-k' instead of '--keep-index', and for even more convenience, let's DWIM when this developer forgot to type the 'save' command. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 1c64a02fe..a031836a2 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -13,7 +13,8 @@ SYNOPSIS 'git stash' drop [-q|--quiet] [] 'git stash' ( pop | apply ) [--index] [-q|--quiet] [] 'git stash' branch [] -'git stash' [save [--keep-index] [-q|--quiet] []] +'git stash' [save [-k|--keep-index] [-q|--quiet] []] +'git stash' [-k|--keep-index] 'git stash' clear 'git stash' create diff --git a/git-stash.sh b/git-stash.sh index 03e589f76..13edc0eef 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -7,7 +7,8 @@ USAGE="list [] or: $dashless drop [-q|--quiet] [] or: $dashless ( pop | apply ) [--index] [-q|--quiet] [] or: $dashless branch [] - or: $dashless [save [--keep-index] [-q|--quiet] []] + or: $dashless [save [-k|--keep-index] [-q|--quiet] []] + or: $dashless [-k|--keep-index] or: $dashless clear" SUBDIRECTORY_OK=Yes @@ -98,7 +99,7 @@ save_stash () { while test $# != 0 do case "$1" in - --keep-index) + -k|--keep-index) keep_index=t ;; -q|--quiet) @@ -353,12 +354,13 @@ branch) apply_to_branch "$@" ;; *) - if test $# -eq 0 - then - save_stash && + case $#,"$1" in + 0,|1,-k|1,--keep-index) + save_stash "$@" && say '(To restore them type "git stash apply")' - else + ;; + *) usage - fi + esac ;; esac diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 7a3fb6795..e16ad93d2 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -200,4 +200,12 @@ test_expect_success 'drop -q is quiet' ' test ! -s output.out ' +test_expect_success 'stash -k' ' + echo bar3 > file && + echo bar4 > file2 && + git add file2 && + git stash -k && + test bar,bar4 = $(cat file),$(cat file2) +' + test_done