Merge branch 'rr/push-head'
[gitweb.git] / t / t3001-ls-files-others-exclude.sh
index 2d274bf8ff2b143e11382586966915dcb0d99d25..f0421c09c700bc1203d2ef563c54157e94c83b33 100755 (executable)
@@ -175,6 +175,24 @@ test_expect_success 'negated exclude matches can override previous ones' '
        grep "^a.1" output
 '
 
+test_expect_success 'excluded directory overrides content patterns' '
+
+       git ls-files --others --exclude="one" --exclude="!one/a.1" >output &&
+       if grep "^one/a.1" output
+       then
+               false
+       fi
+'
+
+test_expect_success 'negated directory doesn'\''t affect content patterns' '
+
+       git ls-files --others --exclude="!one" --exclude="one/a.1" >output &&
+       if grep "^one/a.1" output
+       then
+               false
+       fi
+'
+
 test_expect_success 'subdirectory ignore (setup)' '
        mkdir -p top/l1/l2 &&
        (
@@ -214,6 +232,55 @@ test_expect_success 'subdirectory ignore (l1)' '
        test_cmp expect actual
 '
 
+test_expect_success 'show/hide empty ignored directory (setup)' '
+       rm top/l1/l2/l1 &&
+       rm top/l1/.gitignore
+'
+
+test_expect_success 'show empty ignored directory with --directory' '
+       (
+               cd top &&
+               git ls-files -o -i --exclude l1 --directory
+       ) >actual &&
+       echo l1/ >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'hide empty ignored 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 '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 &&