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)
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>
No differences found