提交 ea41cfc4 编写于 作者: J Johannes Schindelin 提交者: Junio C Hamano

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: NJohannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 6517452d
...@@ -13,7 +13,8 @@ SYNOPSIS ...@@ -13,7 +13,8 @@ SYNOPSIS
'git stash' drop [-q|--quiet] [<stash>] 'git stash' drop [-q|--quiet] [<stash>]
'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>] 'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
'git stash' branch <branchname> [<stash>] 'git stash' branch <branchname> [<stash>]
'git stash' [save [--keep-index] [-q|--quiet] [<message>]] 'git stash' [save [-k|--keep-index] [-q|--quiet] [<message>]]
'git stash' [-k|--keep-index]
'git stash' clear 'git stash' clear
'git stash' create 'git stash' create
......
...@@ -7,7 +7,8 @@ USAGE="list [<options>] ...@@ -7,7 +7,8 @@ USAGE="list [<options>]
or: $dashless drop [-q|--quiet] [<stash>] or: $dashless drop [-q|--quiet] [<stash>]
or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>] or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]
or: $dashless branch <branchname> [<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" or: $dashless clear"
SUBDIRECTORY_OK=Yes SUBDIRECTORY_OK=Yes
...@@ -98,7 +99,7 @@ save_stash () { ...@@ -98,7 +99,7 @@ save_stash () {
while test $# != 0 while test $# != 0
do do
case "$1" in case "$1" in
--keep-index) -k|--keep-index)
keep_index=t keep_index=t
;; ;;
-q|--quiet) -q|--quiet)
...@@ -353,12 +354,13 @@ branch) ...@@ -353,12 +354,13 @@ branch)
apply_to_branch "$@" apply_to_branch "$@"
;; ;;
*) *)
if test $# -eq 0 case $#,"$1" in
then 0,|1,-k|1,--keep-index)
save_stash && save_stash "$@" &&
say '(To restore them type "git stash apply")' say '(To restore them type "git stash apply")'
else ;;
*)
usage usage
fi esac
;; ;;
esac esac
...@@ -200,4 +200,12 @@ test_expect_success 'drop -q is quiet' ' ...@@ -200,4 +200,12 @@ test_expect_success 'drop -q is quiet' '
test ! -s output.out 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 test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册