stash: clean untracked files before reset
authorNicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
Fri, 11 Aug 2017 17:14:43 +0000 (19:14 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 11 Aug 2017 22:11:30 +0000 (15:11 -0700)
commitbbffd87d3223b2f5782918eab2e011931bdffdcc
tree40778074d3005a0839646e54ac5d5c15d220befc
parent4274c698f46a9bc45834c4904e7e113450c042fb
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>
git-stash.sh
t/t3905-stash-include-untracked.sh