stash: pass the pathspec argument to git reset

For "git stash -p --no-keep-index", the pathspec argument is currently not passed to "git reset". This means that changes that are staged but that are excluded from the pathspec still get unstaged by git stash -p. Make sure that doesn't happen by passing the pathspec argument to the git reset in question, bringing the behaviour in line with "git stash -- <pathspec>". Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Gummerer committed Mar 21, 2017 at 22:12 UTC 869fb8f729a4e3486ea3c37820e97548223fac6a
2 files changed +9 -1
git-stash.sh
+1 -1
@@ -322,7 +322,7 @@ push_stash () {
322
323 if test "$keep_index" != "t"
324 then
325 - git reset -q
325 + git reset -q -- "$@"
326 fi
327 fi
328 }
t/t3904-stash-patch.sh
+8
@@ -77,6 +77,14 @@ test_expect_success 'git stash --no-keep-index -p' '
77 verify_state dir/foo work index
78 '
79
80 +test_expect_success 'stash -p --no-keep-index -- <pathspec> does not unstage other files' '
81 + set_state HEAD HEADfile_work HEADfile_index &&
82 + set_state dir/foo work index &&
83 + echo y | git stash push -p --no-keep-index -- HEAD &&
84 + verify_state HEAD committed committed &&
85 + verify_state dir/foo work index
86 +'
87 +
88 test_expect_success 'none of this moved HEAD' '
89 verify_saved_head
90 '