Code

Merge branch 'jc/pickaxe-ignore-case'
[git.git] / t / t3001-ls-files-others-exclude.sh
index 1caeacafa7ae70506e626498d274dbfa25f1b036..c8fe9782672c0e6ba2f0fd0c1b708fc980263182 100755 (executable)
@@ -19,6 +19,9 @@ do
     >$dir/a.$i
   done
 done
+>"#ignore1"
+>"#ignore2"
+>"#hidden"
 
 cat >expect <<EOF
 a.2
@@ -42,6 +45,9 @@ three/a.8
 EOF
 
 echo '.gitignore
+\#ignore1
+\#ignore2*
+\#hid*n
 output
 expect
 .gitignore
@@ -58,6 +64,8 @@ two/*.4
 echo '!*.2
 !*.8' >one/two/.gitignore
 
+allignores='.gitignore one/.gitignore one/two/.gitignore'
+
 test_expect_success \
     'git ls-files --others with various exclude options.' \
     'git ls-files --others \
@@ -79,9 +87,30 @@ test_expect_success \
        >output &&
      test_cmp expect output'
 
-cat > excludes-file << EOF
+test_expect_success 'setup skip-worktree gitignore' '
+       git add $allignores &&
+       git update-index --skip-worktree $allignores &&
+       rm $allignores
+'
+
+test_expect_success \
+    'git ls-files --others with various exclude options.' \
+    'git ls-files --others \
+       --exclude=\*.6 \
+       --exclude-per-directory=.gitignore \
+       --exclude-from=.git/ignore \
+       >output &&
+     test_cmp expect output'
+
+test_expect_success 'restore gitignore' '
+       git checkout $allignores &&
+       rm .git/index
+'
+
+cat > excludes-file <<\EOF
 *.[1-8]
 e*
+\#*
 EOF
 
 git config core.excludesFile excludes-file
@@ -96,7 +125,7 @@ cat > expect << EOF
 #      three/
 EOF
 
-test_expect_success 'git-status honours core.excludesfile' \
+test_expect_success 'git status honors core.excludesfile' \
        'test_cmp expect output'
 
 test_expect_success 'trailing slash in exclude allows directory match(1)' '
@@ -127,7 +156,7 @@ test_expect_success 'trailing slash in exclude allows directory match (2)' '
 
 test_expect_success 'trailing slash in exclude forces directory match (1)' '
 
-       >two
+       >two &&
        git ls-files --others --exclude=two/ >output &&
        grep "^two" output
 
@@ -140,4 +169,49 @@ test_expect_success 'trailing slash in exclude forces directory match (2)' '
 
 '
 
+test_expect_success 'negated exclude matches can override previous ones' '
+
+       git ls-files --others --exclude="a.*" --exclude="!a.1" >output &&
+       grep "^a.1" output
+'
+
+test_expect_success 'subdirectory ignore (setup)' '
+       mkdir -p top/l1/l2 &&
+       (
+               cd top &&
+               git init &&
+               echo /.gitignore >.gitignore &&
+               echo l1 >>.gitignore &&
+               echo l2 >l1/.gitignore &&
+               >l1/l2/l1
+       )
+'
+
+test_expect_success 'subdirectory ignore (toplevel)' '
+       (
+               cd top &&
+               git ls-files -o --exclude-standard
+       ) >actual &&
+       >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'subdirectory ignore (l1/l2)' '
+       (
+               cd top/l1/l2 &&
+               git ls-files -o --exclude-standard
+       ) >actual &&
+       >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'subdirectory ignore (l1)' '
+       (
+               cd top/l1 &&
+               git ls-files -o --exclude-standard
+       ) >actual &&
+       >expect &&
+       test_cmp expect actual
+'
+
 test_done