summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lijin <sxlijin@gmail.com>2017-05-18 04:21:49 -0400
committerJunio C Hamano <gitster@pobox.com>2017-05-22 12:06:52 +0900
commitb3487ccc0bffc28e134333b164d0d84fdd15d9f4 (patch)
treeb52b4b552852a39bc80b4f6bbdec30e2f11e1cb6
parent95d67879735cfecfdd85f89e59d993c5b4de8835 (diff)
downloadgit-b3487ccc0bffc28e134333b164d0d84fdd15d9f4.tar.gz
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>
-rwxr-xr-xt/t7300-clean.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index b89fd2a6ad..3a2d709c29 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -653,4 +653,20 @@ test_expect_success 'git clean -d respects pathspecs (pathspec is prefix of dir)
test_path_is_dir foobar
'
+test_expect_failure 'git clean -d skips untracked dirs containing ignored files' '
+ echo /foo/bar >.gitignore &&
+ echo ignoreme >>.gitignore &&
+ rm -rf foo &&
+ mkdir -p foo/a/aa/aaa foo/b/bb/bbb &&
+ touch foo/bar foo/baz foo/a/aa/ignoreme foo/b/ignoreme foo/b/bb/1 foo/b/bb/2 &&
+ git clean -df &&
+ test_path_is_dir foo &&
+ test_path_is_file foo/bar &&
+ test_path_is_missing foo/baz &&
+ test_path_is_file foo/a/aa/ignoreme &&
+ test_path_is_missing foo/a/aa/aaa &&
+ test_path_is_file foo/b/ignoreme &&
+ test_path_is_missing foo/b/bb
+'
+
test_done