git-stash: add new 'pop' subcommand
This combines the existing stash subcommands 'apply' and 'drop' to allow a single stash entry to be applied and then dropped, in other words 'popped', from the stash list. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Casey committed
Feb 22, 2008 at 16:52 UTC
bd56ff54f710d463a6858bdc7ef6245f9ef30f42
2 files changed
+16
-2
Documentation/git-stash.txt
+7
-1
@@ -8,7 +8,7 @@ git-stash - Stash the changes in a dirty working directory away
8
SYNOPSIS
9
--------
10
[verse]
11
-'git-stash' (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>])
11
+'git-stash' (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>] | pop [<stash>])
12
'git-stash' [save [<message>]]
13
14
DESCRIPTION
@@ -90,6 +90,12 @@ drop [<stash>]::
90
Remove a single stashed state from the stash list. When no `<stash>`
91
is given, it removes the latest one. i.e. `stash@\{0}`
92
93
+pop [<stash>]::
94
+
95
+ Remove a single stashed state from the stash list and apply on top
96
+ of the current working tree state. When no `<stash>` is given,
97
+ `stash@\{0}` is assumed. See also `apply`.
98
+
99
100
DISCUSSION
101
----------
git-stash.sh
+9
-1
@@ -1,7 +1,7 @@
1
#!/bin/sh
2
# Copyright (c) 2007, Nanako Shiraishi
3
4
-USAGE='[ | save | list | show | apply | clear | drop | create ]'
4
+USAGE='[ | save | list | show | apply | clear | drop | pop | create ]'
5
6
SUBDIRECTORY_OK=Yes
7
OPTIONS_SPEC=
@@ -256,6 +256,14 @@ drop)
256
shift
257
drop_stash "$@"
258
;;
259
+pop)
260
+ shift
261
+ if apply_stash "$@"
262
+ then
263
+ test -z "$unstash_index" || shift
264
+ drop_stash "$@"
265
+ fi
266
+ ;;
267
*)
268
if test $# -eq 0
269
then