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>
Samuel Lijin committed
May 18, 2017 at 04:21 UTC
b3487ccc0bffc28e134333b164d0d84fdd15d9f4
1 file changed
+16
t/t7300-clean.sh
+16
@@ -653,4 +653,20 @@ test_expect_success 'git clean -d respects pathspecs (pathspec is prefix of dir)
653
test_path_is_dir foobar
654
'
655
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
+
672
test_done