git-stash: remove untracked/ignored directories when stashed

The two new stash options --include-untracked and --all do not remove the
untracked and/or ignored files that are stashed if those files reside in
a subdirectory. e.g. the following sequence fails:

   mkdir untracked &&
   echo hello >untracked/file.txt &&
   git stash --include-untracked &&
   test ! -f untracked/file.txt

Within the git-stash script, git-clean is used to remove the
untracked/ignored files, but since the -d option was not supplied, it does
not remove directories.

So, add -d to the git-clean arguments, and update the tests to test this
functionality.

Reported-by: Hilco Wijbenga <hilco.wijbenga@gmail.com>
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Brandon Casey
2011-08-26 19:59:27 -05:00
committed by Junio C Hamano
parent c995ef49e2
commit 7474b8b452
2 changed files with 24 additions and 4 deletions

View File

@ -228,7 +228,7 @@ save_stash () {
test "$untracked" = "all" && CLEAN_X_OPTION=-x || CLEAN_X_OPTION=
if test -n "$untracked"
then
git clean --force --quiet $CLEAN_X_OPTION
git clean --force --quiet -d $CLEAN_X_OPTION
fi
if test "$keep_index" = "t" && test -n $i_tree