diff-parseopt: convert --exit-code
[git/raj.git] / t / t7061-wtstatus-ignore.sh
blob0c394cf995cbcf17b1ebd8f38e73a0740e3e00b7
1 #!/bin/sh
3 test_description='git-status ignored files'
5 . ./test-lib.sh
7 cat >expected <<\EOF
8 ?? .gitignore
9 ?? actual
10 ?? expected
11 ?? untracked/
12 !! untracked/ignored
13 EOF
15 test_expect_success 'status untracked directory with --ignored' '
16 echo "ignored" >.gitignore &&
17 mkdir untracked &&
18 : >untracked/ignored &&
19 : >untracked/uncommitted &&
20 git status --porcelain --ignored >actual &&
21 test_cmp expected actual
24 test_expect_success 'same with gitignore starting with BOM' '
25 printf "\357\273\277ignored\n" >.gitignore &&
26 mkdir -p untracked &&
27 : >untracked/ignored &&
28 : >untracked/uncommitted &&
29 git status --porcelain --ignored >actual &&
30 test_cmp expected actual
33 cat >expected <<\EOF
34 ?? .gitignore
35 ?? actual
36 ?? expected
37 ?? untracked/uncommitted
38 !! untracked/ignored
39 EOF
41 test_expect_success 'status untracked directory with --ignored -u' '
42 git status --porcelain --ignored -u >actual &&
43 test_cmp expected actual
45 cat >expected <<\EOF
46 ?? untracked/uncommitted
47 !! untracked/ignored
48 EOF
50 test_expect_success 'status prefixed untracked directory with --ignored' '
51 git status --porcelain --ignored untracked/ >actual &&
52 test_cmp expected actual
55 cat >expected <<\EOF
56 ?? untracked/uncommitted
57 !! untracked/ignored
58 EOF
60 test_expect_success 'status prefixed untracked sub-directory with --ignored -u' '
61 git status --porcelain --ignored -u untracked/ >actual &&
62 test_cmp expected actual
65 cat >expected <<\EOF
66 ?? .gitignore
67 ?? actual
68 ?? expected
69 !! ignored/
70 EOF
72 test_expect_success 'status ignored directory with --ignore' '
73 rm -rf untracked &&
74 mkdir ignored &&
75 : >ignored/uncommitted &&
76 git status --porcelain --ignored >actual &&
77 test_cmp expected actual
80 cat >expected <<\EOF
81 ?? .gitignore
82 ?? actual
83 ?? expected
84 !! ignored/uncommitted
85 EOF
87 test_expect_success 'status ignored directory with --ignore -u' '
88 git status --porcelain --ignored -u >actual &&
89 test_cmp expected actual
92 cat >expected <<\EOF
93 ?? .gitignore
94 ?? actual
95 ?? expected
96 EOF
98 test_expect_success 'status empty untracked directory with --ignore' '
99 rm -rf ignored &&
100 mkdir untracked-ignored &&
101 mkdir untracked-ignored/test &&
102 git status --porcelain --ignored >actual &&
103 test_cmp expected actual
106 cat >expected <<\EOF
107 ?? .gitignore
108 ?? actual
109 ?? expected
112 test_expect_success 'status empty untracked directory with --ignore -u' '
113 git status --porcelain --ignored -u >actual &&
114 test_cmp expected actual
117 cat >expected <<\EOF
118 ?? .gitignore
119 ?? actual
120 ?? expected
121 !! untracked-ignored/
124 test_expect_success 'status untracked directory with ignored files with --ignore' '
125 : >untracked-ignored/ignored &&
126 : >untracked-ignored/test/ignored &&
127 git status --porcelain --ignored >actual &&
128 test_cmp expected actual
131 cat >expected <<\EOF
132 ?? .gitignore
133 ?? actual
134 ?? expected
135 !! untracked-ignored/ignored
136 !! untracked-ignored/test/ignored
139 test_expect_success 'status untracked directory with ignored files with --ignore -u' '
140 git status --porcelain --ignored -u >actual &&
141 test_cmp expected actual
144 cat >expected <<\EOF
145 ?? .gitignore
146 ?? actual
147 ?? expected
150 test_expect_success 'status ignored tracked directory with --ignore' '
151 rm -rf untracked-ignored &&
152 mkdir tracked &&
153 : >tracked/committed &&
154 git add tracked/committed &&
155 git commit -m. &&
156 echo "tracked" >.gitignore &&
157 git status --porcelain --ignored >actual &&
158 test_cmp expected actual
161 cat >expected <<\EOF
162 ?? .gitignore
163 ?? actual
164 ?? expected
167 test_expect_success 'status ignored tracked directory with --ignore -u' '
168 git status --porcelain --ignored -u >actual &&
169 test_cmp expected actual
172 cat >expected <<\EOF
173 ?? .gitignore
174 ?? actual
175 ?? expected
178 test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
179 echo "committed" >>.gitignore &&
180 git status --porcelain --ignored >actual &&
181 test_cmp expected actual
184 cat >expected <<\EOF
185 ?? .gitignore
186 ?? actual
187 ?? expected
190 test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
191 git status --porcelain --ignored -u >actual &&
192 test_cmp expected actual
195 cat >expected <<\EOF
196 ?? .gitignore
197 ?? actual
198 ?? expected
199 !! tracked/uncommitted
202 test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
203 echo "tracked" >.gitignore &&
204 : >tracked/uncommitted &&
205 git status --porcelain --ignored >actual &&
206 test_cmp expected actual
209 cat >expected <<\EOF
210 ?? .gitignore
211 ?? actual
212 ?? expected
213 !! tracked/uncommitted
216 test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
217 git status --porcelain --ignored -u >actual &&
218 test_cmp expected actual
221 cat >expected <<\EOF
222 ?? .gitignore
223 ?? actual
224 ?? expected
225 !! tracked/ignored/
228 test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore' '
229 rm -rf tracked/uncommitted &&
230 mkdir tracked/ignored &&
231 : >tracked/ignored/uncommitted &&
232 git status --porcelain --ignored >actual &&
233 test_cmp expected actual
236 cat >expected <<\EOF
237 ?? .gitignore
238 ?? actual
239 ?? expected
240 !! tracked/ignored/uncommitted
243 test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' '
244 git status --porcelain --ignored -u >actual &&
245 test_cmp expected actual
248 cat >expected <<\EOF
249 ?? .gitignore
250 ?? actual
251 ?? expected
252 !! tracked/ignored/uncommitted
255 test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore' '
256 : >tracked/ignored/committed &&
257 git add -f tracked/ignored/committed &&
258 git commit -m. &&
259 git status --porcelain --ignored >actual &&
260 test_cmp expected actual
263 cat >expected <<\EOF
264 ?? .gitignore
265 ?? actual
266 ?? expected
267 !! tracked/ignored/uncommitted
270 test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' '
271 git status --porcelain --ignored -u >actual &&
272 test_cmp expected actual
275 cat >expected <<\EOF
276 !! tracked/submodule/
279 test_expect_success 'status ignores submodule in excluded directory' '
280 git init tracked/submodule &&
281 test_commit -C tracked/submodule initial &&
282 git status --porcelain --ignored -u tracked/submodule >actual &&
283 test_cmp expected actual
286 test_done