Skip to content

Commit

Permalink
git-stash: add new 'pop' subcommand
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brandon Casey authored and Junio C Hamano committed Feb 23, 2008
1 parent e25d5f9 commit bd56ff5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Documentation/git-stash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git-stash - Stash the changes in a dirty working directory away
SYNOPSIS
--------
[verse]
'git-stash' (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>])
'git-stash' (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>] | pop [<stash>])
'git-stash' [save [<message>]]

DESCRIPTION
Expand Down Expand Up @@ -90,6 +90,12 @@ drop [<stash>]::
Remove a single stashed state from the stash list. When no `<stash>`
is given, it removes the latest one. i.e. `stash@\{0}`

pop [<stash>]::

Remove a single stashed state from the stash list and apply on top
of the current working tree state. When no `<stash>` is given,
`stash@\{0}` is assumed. See also `apply`.


DISCUSSION
----------
Expand Down
10 changes: 9 additions & 1 deletion git-stash.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (c) 2007, Nanako Shiraishi

USAGE='[ | save | list | show | apply | clear | drop | create ]'
USAGE='[ | save | list | show | apply | clear | drop | pop | create ]'

SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
Expand Down Expand Up @@ -256,6 +256,14 @@ drop)
shift
drop_stash "$@"
;;
pop)
shift
if apply_stash "$@"
then
test -z "$unstash_index" || shift
drop_stash "$@"
fi
;;
*)
if test $# -eq 0
then
Expand Down

0 comments on commit bd56ff5

Please sign in to comment.