summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dir.c11
-rwxr-xr-xt/t3001-ls-files-others-exclude.sh26
-rwxr-xr-xt/t7061-wtstatus-ignore.sh6
-rwxr-xr-xt/t7300-clean.sh34
4 files changed, 66 insertions, 11 deletions
diff --git a/dir.c b/dir.c
index fd4aeae3e7..7a98e3ac8a 100644
--- a/dir.c
+++ b/dir.c
@@ -941,8 +941,7 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
{
- if (!(dir->flags & DIR_SHOW_IGNORED) &&
- cache_name_exists(pathname, len, ignore_case))
+ if (cache_name_exists(pathname, len, ignore_case))
return NULL;
ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
@@ -1044,9 +1043,8 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
* traversal routine.
*
* Case 1: If we *already* have entries in the index under that
- * directory name, we recurse into the directory to see all the files,
- * unless the directory is excluded and we want to show ignored
- * directories
+ * directory name, we always recurse into the directory to see
+ * all the files.
*
* Case 2: If we *already* have that directory name as a gitlink,
* we always continue to see it as a gitlink, regardless of whether
@@ -1081,9 +1079,6 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
/* The "len-1" is to strip the final '/' */
switch (directory_exists_in_index(dirname, len-1)) {
case index_directory:
- if ((dir->flags & DIR_SHOW_OTHER_DIRECTORIES) && exclude)
- break;
-
return recurse_into_directory;
case index_gitdir:
diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh
index 859da350ab..ec4fae2f39 100755
--- a/t/t3001-ls-files-others-exclude.sh
+++ b/t/t3001-ls-files-others-exclude.sh
@@ -237,6 +237,32 @@ test_expect_success 'hide empty ignored directory with --no-empty-directory' '
test_cmp expect actual
'
+test_expect_success 'show/hide empty ignored sub-directory (setup)' '
+ > top/l1/tracked &&
+ (
+ cd top &&
+ git add -f l1/tracked
+ )
+'
+
+test_expect_success 'show empty ignored sub-directory with --directory' '
+ (
+ cd top &&
+ git ls-files -o -i --exclude l1 --directory
+ ) >actual &&
+ echo l1/l2/ >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'hide empty ignored sub-directory with --no-empty-directory' '
+ (
+ cd top &&
+ git ls-files -o -i --exclude l1 --directory --no-empty-directory
+ ) >actual &&
+ >expect &&
+ test_cmp expect actual
+'
+
test_expect_success 'pattern matches prefix completely' '
: >expect &&
git ls-files -i -o --exclude "/three/a.3[abc]" >actual &&
diff --git a/t/t7061-wtstatus-ignore.sh b/t/t7061-wtstatus-ignore.sh
index 4c6f145d97..460789b4d8 100755
--- a/t/t7061-wtstatus-ignore.sh
+++ b/t/t7061-wtstatus-ignore.sh
@@ -186,7 +186,7 @@ cat >expected <<\EOF
?? .gitignore
?? actual
?? expected
-!! tracked/
+!! tracked/uncommitted
EOF
test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
@@ -212,7 +212,7 @@ cat >expected <<\EOF
?? .gitignore
?? actual
?? expected
-!! tracked/
+!! tracked/ignored/
EOF
test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore' '
@@ -239,7 +239,7 @@ cat >expected <<\EOF
?? .gitignore
?? actual
?? expected
-!! tracked/
+!! tracked/ignored/uncommitted
EOF
test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore' '
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index ccfb54de7a..710be90489 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -298,6 +298,23 @@ test_expect_success 'git clean -d -x' '
'
+test_expect_success 'git clean -d -x with ignored tracked directory' '
+
+ mkdir -p build docs &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ git clean -d -x -e src &&
+ test -f Makefile &&
+ test -f README &&
+ test -f src/part1.c &&
+ test -f src/part2.c &&
+ test ! -f a.out &&
+ test -f src/part3.c &&
+ test ! -d docs &&
+ test ! -f obj.o &&
+ test ! -d build
+
+'
+
test_expect_success 'git clean -X' '
mkdir -p build docs &&
@@ -332,6 +349,23 @@ test_expect_success 'git clean -d -X' '
'
+test_expect_success 'git clean -d -X with ignored tracked directory' '
+
+ mkdir -p build docs &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ git clean -d -X -e src &&
+ test -f Makefile &&
+ test -f README &&
+ test -f src/part1.c &&
+ test -f src/part2.c &&
+ test -f a.out &&
+ test ! -f src/part3.c &&
+ test -f docs/manual.txt &&
+ test ! -f obj.o &&
+ test ! -d build
+
+'
+
test_expect_success 'clean.requireForce defaults to true' '
git config --unset clean.requireForce &&