summaryrefslogtreecommitdiff
path: root/t/t3905-stash-include-untracked.sh
diff options
context:
space:
mode:
authorNicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>2017-08-11 17:14:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-08-11 22:11:30 (GMT)
commitbbffd87d3223b2f5782918eab2e011931bdffdcc (patch)
tree40778074d3005a0839646e54ac5d5c15d220befc /t/t3905-stash-include-untracked.sh
parent4274c698f46a9bc45834c4904e7e113450c042fb (diff)
downloadgit-bbffd87d3223b2f5782918eab2e011931bdffdcc.zip
git-bbffd87d3223b2f5782918eab2e011931bdffdcc.tar.gz
git-bbffd87d3223b2f5782918eab2e011931bdffdcc.tar.bz2
stash: clean untracked files before reset
If calling git stash -u on a repo that contains a file that is not ignored any more due to a current modification of the gitignore file, this file is stashed but not remove from the working tree. This is due to git-stash first doing a reset --hard which clears the .gitignore file modification and the call git clean, leaving the file untouched. This causes git stash pop to fail due to the file existing. This patch simply switches the order between cleaning and resetting and adds a test for this usecase. Reported-by: Sam Partington <sam@whiteoctober.co.uk> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3905-stash-include-untracked.sh')
-rwxr-xr-xt/t3905-stash-include-untracked.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 193adc7..bfde405 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -211,4 +211,21 @@ test_expect_success 'stash push with $IFS character' '
test_path_is_file bar
'
+cat > .gitignore <<EOF
+ignored
+ignored.d/*
+EOF
+
+test_expect_success 'stash previously ignored file' '
+ git reset HEAD &&
+ git add .gitignore &&
+ git commit -m "Add .gitignore" &&
+ >ignored.d/foo &&
+ echo "!ignored.d/foo" >> .gitignore &&
+ git stash save --include-untracked &&
+ test_path_is_missing ignored.d/foo &&
+ git stash pop &&
+ test_path_is_file ignored.d/foo
+'
+
test_done