File tree Expand file tree Collapse file tree 3 files changed +55
-3
lines changed
Expand file tree Collapse file tree 3 files changed +55
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ SYNOPSIS
1515'git stash' branch <branchname> [<stash>]
1616'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
1717 [-u|--include-untracked] [-a|--all] [<message>]]
18+ 'git stash' push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
19+ [-u|--include-untracked] [-a|--all] [-m|--message <message>]]
1820'git stash' clear
1921'git stash' create [<message>]
2022'git stash' store [-m|--message <message>] [-q|--quiet] <commit>
@@ -46,6 +48,7 @@ OPTIONS
4648-------
4749
4850save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]::
51+ push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>]::
4952
5053 Save your local modifications to a new 'stash' and roll them
5154 back to HEAD (in the working tree and in the index).
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ USAGE="list [<options>]
99 or: $dashless branch <branchname> [<stash>]
1010 or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
1111 [-u|--include-untracked] [-a|--all] [<message>]]
12+ or: $dashless push [--patch] [-k|--[no-]keep-index] [-q|--quiet]
13+ [-u|--include-untracked] [-a|--all] [-m <message>]
1214 or: $dashless clear"
1315
1416SUBDIRECTORY_OK=Yes
@@ -189,10 +191,11 @@ store_stash () {
189191 return $ret
190192}
191193
192- save_stash () {
194+ push_stash () {
193195 keep_index=
194196 patch_mode=
195197 untracked=
198+ stash_msg=
196199 while test $# ! = 0
197200 do
198201 case " $1 " in
@@ -216,6 +219,11 @@ save_stash () {
216219 -a|--all)
217220 untracked=all
218221 ;;
222+ -m|--message)
223+ shift
224+ test -z ${1+x} && usage
225+ stash_msg=$1
226+ ;;
219227 --help)
220228 show_help
221229 ;;
@@ -251,8 +259,6 @@ save_stash () {
251259 die " $( gettext " Can't use --patch and --include-untracked or --all at the same time" ) "
252260 fi
253261
254- stash_msg=" $* "
255-
256262 git update-index -q --refresh
257263 if no_changes
258264 then
@@ -291,6 +297,36 @@ save_stash () {
291297 fi
292298}
293299
300+ save_stash () {
301+ push_options=
302+ while test $# ! = 0
303+ do
304+ case " $1 " in
305+ --)
306+ shift
307+ break
308+ ;;
309+ -* )
310+ # pass all options through to push_stash
311+ push_options=" $push_options $1 "
312+ ;;
313+ * )
314+ break
315+ ;;
316+ esac
317+ shift
318+ done
319+
320+ stash_msg=" $* "
321+
322+ if test -z " $stash_msg "
323+ then
324+ push_stash $push_options
325+ else
326+ push_stash $push_options -m " $stash_msg "
327+ fi
328+ }
329+
294330have_stash () {
295331 git rev-parse --verify --quiet $ref_stash > /dev/null
296332}
@@ -617,6 +653,10 @@ save)
617653 shift
618654 save_stash " $@ "
619655 ;;
656+ push)
657+ shift
658+ push_stash " $@ "
659+ ;;
620660apply)
621661 shift
622662 apply_stash " $@ "
Original file line number Diff line number Diff line change @@ -775,4 +775,13 @@ test_expect_success 'stash is not confused by partial renames' '
775775 test_path_is_missing file
776776'
777777
778+ test_expect_success ' push -m shows right message' '
779+ >foo &&
780+ git add foo &&
781+ git stash push -m "test message" &&
782+ echo "stash@{0}: On master: test message" >expect &&
783+ git stash list -1 >actual &&
784+ test_cmp expect actual
785+ '
786+
778787test_done
You can’t perform that action at this time.
0 commit comments