Commit 869fb8f7 authored by Thomas Gummerer's avatar Thomas Gummerer Committed by Junio C Hamano

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 --
Signed-off-by: default avatarThomas Gummerer <[email protected]>
Reviewed-by: default avatarJeff King <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent 1790f4fe
...@@ -322,7 +322,7 @@ push_stash () { ...@@ -322,7 +322,7 @@ push_stash () {
if test "$keep_index" != "t" if test "$keep_index" != "t"
then then
git reset -q git reset -q -- "[email protected]"
fi fi
fi fi
} }
...@@ -77,6 +77,14 @@ test_expect_success 'git stash --no-keep-index -p' ' ...@@ -77,6 +77,14 @@ test_expect_success 'git stash --no-keep-index -p' '
verify_state dir/foo work index verify_state dir/foo work index
' '
test_expect_success 'stash -p --no-keep-index -- <pathspec> does not unstage other files' '
set_state HEAD HEADfile_work HEADfile_index &&
set_state dir/foo work index &&
echo y | git stash push -p --no-keep-index -- HEAD &&
verify_state HEAD committed committed &&
verify_state dir/foo work index
test_expect_success 'none of this moved HEAD' ' test_expect_success 'none of this moved HEAD' '
verify_saved_head verify_saved_head
' '
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment