]> asedeno.scripts.mit.edu Git - git.git/blobdiff - t/t3001-ls-files-others-exclude.sh
Read .gitignore from index if it is skip-worktree
[git.git] / t / t3001-ls-files-others-exclude.sh
index 85aef12a113fed8164a085a19ce5c794ab96ff6f..132c4765cbe8ffc8b92deb5d3e6ca05c012d7c37 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