@matheusbsbs / matheus-bagliano / commits / ea41cfc4f5
Fork 0

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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 27, 2009 at 20:37 UTC ea41cfc4f54f884582dbda307287f12bb1fc15e9
3 files changed +19 -8
Documentation/git-stash.txt
+2 -1
@@ -13,7 +13,8 @@ SYNOPSIS
13 'git stash' drop [-q|--quiet] [<stash>]
14 'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
15 'git stash' branch <branchname> [<stash>]
16 -'git stash' [save [--keep-index] [-q|--quiet] [<message>]]
16 +'git stash' [save [-k|--keep-index] [-q|--quiet] [<message>]]
17 +'git stash' [-k|--keep-index]
18 'git stash' clear
19 'git stash' create
20
git-stash.sh
+9 -7
@@ -7,7 +7,8 @@ USAGE="list [<options>]
7 or: $dashless drop [-q|--quiet] [<stash>]
8 or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]
9 or: $dashless branch <branchname> [<stash>]
10 - or: $dashless [save [--keep-index] [-q|--quiet] [<message>]]
10 + or: $dashless [save [-k|--keep-index] [-q|--quiet] [<message>]]
11 + or: $dashless [-k|--keep-index]
12 or: $dashless clear"
13
14 SUBDIRECTORY_OK=Yes
@@ -98,7 +99,7 @@ save_stash () {
99 while test $# != 0
100 do
101 case "$1" in
101 - --keep-index)
102 + -k|--keep-index)
103 keep_index=t
104 ;;
105 -q|--quiet)
@@ -353,12 +354,13 @@ branch)
354 apply_to_branch "$@"
355 ;;
356 *)
356 - if test $# -eq 0
357 - then
358 - save_stash &&
357 + case $#,"$1" in
358 + 0,|1,-k|1,--keep-index)
359 + save_stash "$@" &&
360 say '(To restore them type "git stash apply")'
360 - else
361 + ;;
362 + *)
363 usage
362 - fi
364 + esac
365 ;;
366 esac
t/t3903-stash.sh
+8
@@ -200,4 +200,12 @@ test_expect_success 'drop -q is quiet' '
200 test ! -s output.out
201 '
202
203 +test_expect_success 'stash -k' '
204 + echo bar3 > file &&
205 + echo bar4 > file2 &&
206 + git add file2 &&
207 + git stash -k &&
208 + test bar,bar4 = $(cat file),$(cat file2)
209 +'
210 +
211 test_done