From 1790f4fea04c2401feda0c96e35a3b50b1ba4fe3 Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Tue, 21 Mar 2017 22:12:17 +0000 Subject: stash: don't show internal implementation details git stash push uses other git commands internally. Currently it only passes the -q flag to those if the -q flag is passed to git stash. when using 'git stash push -p -q --no-keep-index', it doesn't even pass the flag on to the internal reset at all. It really is enough for the user to know that the stash is created, without bothering them with the internal details of what's happening. Always pass the -q flag to the internal git clean and git reset commands, to avoid unnecessary and potentially confusing output. Reported-by: Jeff King Signed-off-by: Thomas Gummerer Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3903-stash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 89877e4b52..6e15f3d266 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -663,7 +663,7 @@ test_expect_success 'stash apply shows status same as git status (relative to cu sane_unset GIT_MERGE_VERBOSITY && git stash apply ) | - sed -e 1,2d >actual && # drop "Saved..." and "HEAD is now..." + sed -e 1d >actual && # drop "Saved..." test_i18ncmp expect actual ' -- cgit v1.2.3 From 869fb8f729a4e3486ea3c37820e97548223fac6a Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Tue, 21 Mar 2017 22:12:18 +0000 Subject: 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: Thomas Gummerer Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3904-stash-patch.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't') diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh index 38e730090f..83744f8c93 100755 --- a/t/t3904-stash-patch.sh +++ b/t/t3904-stash-patch.sh @@ -77,6 +77,14 @@ test_expect_success 'git stash --no-keep-index -p' ' verify_state dir/foo work index ' +test_expect_success 'stash -p --no-keep-index -- 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' ' verify_saved_head ' -- cgit v1.2.3 From e0e7f99ea400808cd11af72425c721c8b44193ca Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Tue, 21 Mar 2017 22:12:19 +0000 Subject: stash: keep untracked files intact in stash -k Currently when there are untracked changes in a file "one" and in a file "two" in the repository and the user uses: git stash push -k one all changes in "two" are wiped out completely. That is clearly not the intended result. Make sure that only the files given in the pathspec are changed when git stash push -k is used. Reported-by: Jeff King Signed-off-by: Thomas Gummerer Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3903-stash.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't') diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 6e15f3d266..b71d1e659e 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -907,4 +907,18 @@ test_expect_success 'stash without verb with pathspec' ' test_path_is_file bar ' +test_expect_success 'stash -k -- leaves unstaged files intact' ' + git reset && + >foo && + >bar && + git add foo bar && + git commit -m "test" && + echo "foo" >foo && + echo "bar" >bar && + git stash -k -- foo && + test "",bar = $(cat foo),$(cat bar) && + git stash pop && + test foo,bar = $(cat foo),$(cat bar) +' + test_done -- cgit v1.2.3