3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git ls-files --others --exclude
8 This test runs git ls-files --others and tests --exclude patterns.
14 for dir in . one one/two three
17 for i in 1 2 3 4 5 6 7 8
65 !*.8' >one/two/.gitignore
67 allignores='.gitignore one/.gitignore one/two/.gitignore'
70 'git ls-files --others with various exclude options.' \
71 'git ls-files --others \
73 --exclude-per-directory=.gitignore \
74 --exclude-from=.git/ignore \
76 test_cmp expect output'
78 # Test \r\n (MSDOS-like systems)
79 printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore
82 'git ls-files --others with \r\n line endings.' \
83 'git ls-files --others \
85 --exclude-per-directory=.gitignore \
86 --exclude-from=.git/ignore \
88 test_cmp expect output'
90 test_expect_success 'setup skip-worktree gitignore' '
91 git add $allignores &&
92 git update-index --skip-worktree $allignores &&
97 'git ls-files --others with various exclude options.' \
98 'git ls-files --others \
100 --exclude-per-directory=.gitignore \
101 --exclude-from=.git/ignore \
103 test_cmp expect output'
105 test_expect_success 'restore gitignore' '
106 git checkout $allignores &&
110 cat > excludes-file <<\EOF
116 git config core.excludesFile excludes-file
118 git status | grep "^# " > output
128 test_expect_success 'git status honors core.excludesfile' \
129 'test_cmp expect output'
131 test_expect_success 'trailing slash in exclude allows directory match(1)' '
133 git ls-files --others --exclude=one/ >output &&
134 if grep "^one/" output
144 test_expect_success 'trailing slash in exclude allows directory match (2)' '
146 git ls-files --others --exclude=one/two/ >output &&
147 if grep "^one/two/" output
157 test_expect_success 'trailing slash in exclude forces directory match (1)' '
160 git ls-files --others --exclude=two/ >output &&
165 test_expect_success 'trailing slash in exclude forces directory match (2)' '
167 git ls-files --others --exclude=one/a.1/ >output &&
168 grep "^one/a.1" output
172 test_expect_success 'negated exclude matches can override previous ones' '
174 git ls-files --others --exclude="a.*" --exclude="!a.1" >output &&