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
15
15
'git stash' branch <branchname> [<stash>]
16
16
'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
17
17
[-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>]]
18
20
'git stash' clear
19
21
'git stash' create [<message>]
20
22
'git stash' store [-m|--message <message>] [-q|--quiet] <commit>
@@ -46,6 +48,7 @@ OPTIONS
46
48
-------
47
49
48
50
save [-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>]::
49
52
50
53
Save your local modifications to a new 'stash' and roll them
51
54
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>]
9
9
or: $dashless branch <branchname> [<stash>]
10
10
or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
11
11
[-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>]
12
14
or: $dashless clear"
13
15
14
16
SUBDIRECTORY_OK=Yes
@@ -189,10 +191,11 @@ store_stash () {
189
191
return $ret
190
192
}
191
193
192
- save_stash () {
194
+ push_stash () {
193
195
keep_index=
194
196
patch_mode=
195
197
untracked=
198
+ stash_msg=
196
199
while test $# ! = 0
197
200
do
198
201
case " $1 " in
@@ -216,6 +219,11 @@ save_stash () {
216
219
-a|--all)
217
220
untracked=all
218
221
;;
222
+ -m|--message)
223
+ shift
224
+ test -z ${1+x} && usage
225
+ stash_msg=$1
226
+ ;;
219
227
--help)
220
228
show_help
221
229
;;
@@ -251,8 +259,6 @@ save_stash () {
251
259
die " $( gettext " Can't use --patch and --include-untracked or --all at the same time" ) "
252
260
fi
253
261
254
- stash_msg=" $* "
255
-
256
262
git update-index -q --refresh
257
263
if no_changes
258
264
then
@@ -291,6 +297,36 @@ save_stash () {
291
297
fi
292
298
}
293
299
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
+
294
330
have_stash () {
295
331
git rev-parse --verify --quiet $ref_stash > /dev/null
296
332
}
@@ -617,6 +653,10 @@ save)
617
653
shift
618
654
save_stash " $@ "
619
655
;;
656
+ push)
657
+ shift
658
+ push_stash " $@ "
659
+ ;;
620
660
apply)
621
661
shift
622
662
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' '
775
775
test_path_is_missing file
776
776
'
777
777
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
+
778
787
test_done
You can’t perform that action at this time.
0 commit comments