Merge branch 'js/stash-dwim' into tr/reset-checkout-patch
authorJunio C Hamano <gitster@pobox.com>
Sat, 15 Aug 2009 22:20:28 +0000 (15:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 15 Aug 2009 22:20:28 +0000 (15:20 -0700)
* commit 'tr/reset-checkout-patch^^2':
Make 'git stash -k' a short form for 'git stash save --keep-index'

Documentation/git-stash.txt
git-stash.sh
t/t3903-stash.sh
index 4b15459c8374c1a83d4ffa9e0fd1a984aada7621..3dc16a108a15bdb4ea7a86d30dbaa6822969229a 100644 (file)
@@ -13,7 +13,8 @@ SYNOPSIS
 'git stash' drop [-q|--quiet] [<stash>]
 'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
 'git stash' branch <branchname> [<stash>]
-'git stash' [save [--patch] [--[no-]keep-index] [-q|--quiet] [<message>]]
+'git stash' [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] [<message>]]
+'git stash' [-k|--keep-index]
 'git stash' clear
 'git stash' create
 
index 567aa5d725e38750b860b01a43ba01914e180ea1..81a72f68cc47aed881b618f893d49c776fe52ae8 100755 (executable)
@@ -7,7 +7,8 @@ USAGE="list [<options>]
    or: $dashless drop [-q|--quiet] [<stash>]
    or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]
    or: $dashless branch <branchname> [<stash>]
-   or: $dashless [save [--keep-index] [-q|--quiet] [<message>]]
+   or: $dashless [save [-k|--keep-index] [-q|--quiet] [<message>]]
+   or: $dashless [-k|--keep-index]
    or: $dashless clear"
 
 SUBDIRECTORY_OK=Yes
@@ -132,7 +133,7 @@ save_stash () {
        while test $# != 0
        do
                case "$1" in
-               --keep-index)
+               -k|--keep-index)
                        keep_index=t
                        ;;
                --no-keep-index)
@@ -405,12 +406,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
index 7a3fb679571a9fc79135f8b9495462f723b663af..e16ad93d2c2718baf62ad90e9fc07187106d9ee4 100755 (executable)
@@ -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