summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Thomas Rast <trast@student.ethz.ch>2010-02-15 17:05:46 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-02-15 21:46:27 -0800
commit460ccd0e19774fd5e4f69de5a454068c686ac5a6 (patch)
treef507de18c02dedc3c2bbebab7856df5ee3b51467
parentdiff: make sure --output=/bad/path is caught (diff)
downloadtgif-460ccd0e19774fd5e4f69de5a454068c686ac5a6.tar.xz
stash pop: remove 'apply' options during 'drop' invocation
The 'git stash pop' option parsing used to remove the first argument in --index mode. At the time this was implemented, this first argument was always --index. However, since the invention of the -q option in fcdd0e9 (stash: teach quiet option, 2009-06-17) you can cause an internal invocation of git stash drop --index by running git stash pop -q --index which then of course fails because drop doesn't know --index. To handle this, instead let 'git stash apply' decide what the future argument to 'drop' should be. Warning: this means that 'git stash apply' must parse all options that 'drop' can take, and deal with them in the same way. This is currently true for its only option -q. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Acked-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgit-stash.sh7
-rwxr-xr-xt/t3903-stash.sh9
2 files changed, 14 insertions, 2 deletions
diff --git a/git-stash.sh b/git-stash.sh
index 4febbbfa5d..79b2771099 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -222,6 +222,7 @@ show_stash () {
}
apply_stash () {
+ applied_stash=
unstash_index=
while test $# != 0
@@ -243,6 +244,9 @@ apply_stash () {
if test $# = 0
then
have_stash || die 'Nothing to apply'
+ applied_stash="$ref_stash@{0}"
+ else
+ applied_stash="$*"
fi
# stash records the work tree, and is a merge between the
@@ -421,8 +425,7 @@ pop)
shift
if apply_stash "$@"
then
- test -z "$unstash_index" || shift
- drop_stash "$@"
+ drop_stash "$applied_stash"
fi
;;
branch)
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 5514f74b30..476e5ec038 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -194,6 +194,15 @@ test_expect_success 'pop -q is quiet' '
test ! -s output.out
'
+test_expect_success 'pop -q --index works and is quiet' '
+ echo foo > file &&
+ git add file &&
+ git stash save --quiet &&
+ git stash pop -q --index > output.out 2>&1 &&
+ test foo = "$(git show :file)" &&
+ test ! -s output.out
+'
+
test_expect_success 'drop -q is quiet' '
git stash &&
git stash drop -q > output.out 2>&1 &&