Skip to content

Commit b3487cc

Browse files
Samuel Lijingitster
authored andcommitted
t7300: clean -d should skip dirs with ignored files
If git sees a directory which contains only untracked and ignored files, clean -d should not remove that directory. It was recently discovered that this is *not* true of git clean -d, and it's possible that this has never worked correctly; this test and its accompanying patch series aims to fix that. Signed-off-by: Samuel Lijin <sxlijin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 95d6787 commit b3487cc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

t/t7300-clean.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,4 +653,20 @@ test_expect_success 'git clean -d respects pathspecs (pathspec is prefix of dir)
653653
test_path_is_dir foobar
654654
'
655655

656+
test_expect_failure 'git clean -d skips untracked dirs containing ignored files' '
657+
echo /foo/bar >.gitignore &&
658+
echo ignoreme >>.gitignore &&
659+
rm -rf foo &&
660+
mkdir -p foo/a/aa/aaa foo/b/bb/bbb &&
661+
touch foo/bar foo/baz foo/a/aa/ignoreme foo/b/ignoreme foo/b/bb/1 foo/b/bb/2 &&
662+
git clean -df &&
663+
test_path_is_dir foo &&
664+
test_path_is_file foo/bar &&
665+
test_path_is_missing foo/baz &&
666+
test_path_is_file foo/a/aa/ignoreme &&
667+
test_path_is_missing foo/a/aa/aaa &&
668+
test_path_is_file foo/b/ignoreme &&
669+
test_path_is_missing foo/b/bb
670+
'
671+
656672
test_done

0 commit comments

Comments
 (0)