fc6013ba3c83aa7243f15595bc7b6ddd8b8f46dc
[git/git.git] / t / t7061-wtstatus-ignore.sh
1 #!/bin/sh
2
3 test_description='git-status ignored files'
4
5 . ./test-lib.sh
6
7 cat >expected <<\EOF
8 ?? .gitignore
9 ?? actual
10 ?? expected
11 ?? untracked/
12 !! untracked/ignored
13 EOF
14
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
22 '
23
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
31 '
32
33 cat >expected <<\EOF
34 ?? .gitignore
35 ?? actual
36 ?? expected
37 ?? untracked/uncommitted
38 !! untracked/ignored
39 EOF
40
41 test_expect_success 'status untracked directory with --ignored -u' '
42 git status --porcelain --ignored -u >actual &&
43 test_cmp expected actual
44 '
45 cat >expected <<\EOF
46 ?? untracked/uncommitted
47 !! untracked/ignored
48 EOF
49
50 test_expect_success 'status prefixed untracked directory with --ignored' '
51 git status --porcelain --ignored untracked/ >actual &&
52 test_cmp expected actual
53 '
54
55 cat >expected <<\EOF
56 ?? untracked/uncommitted
57 !! untracked/ignored
58 EOF
59
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
63 '
64
65 cat >expected <<\EOF
66 ?? .gitignore
67 ?? actual
68 ?? expected
69 !! ignored/
70 EOF
71
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
78 '
79
80 cat >expected <<\EOF
81 ?? .gitignore
82 ?? actual
83 ?? expected
84 !! ignored/uncommitted
85 EOF
86
87 test_expect_success 'status ignored directory with --ignore -u' '
88 git status --porcelain --ignored -u >actual &&
89 test_cmp expected actual
90 '
91
92 cat >expected <<\EOF
93 ?? .gitignore
94 ?? actual
95 ?? expected
96 EOF
97
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
104 '
105
106 cat >expected <<\EOF
107 ?? .gitignore
108 ?? actual
109 ?? expected
110 EOF
111
112 test_expect_success 'status empty untracked directory with --ignore -u' '
113 git status --porcelain --ignored -u >actual &&
114 test_cmp expected actual
115 '
116
117 cat >expected <<\EOF
118 ?? .gitignore
119 ?? actual
120 ?? expected
121 !! untracked-ignored/
122 EOF
123
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
129 '
130
131 cat >expected <<\EOF
132 ?? .gitignore
133 ?? actual
134 ?? expected
135 !! untracked-ignored/ignored
136 !! untracked-ignored/test/ignored
137 EOF
138
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
142 '
143
144 cat >expected <<\EOF
145 ?? .gitignore
146 ?? actual
147 ?? expected
148 EOF
149
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
159 '
160
161 cat >expected <<\EOF
162 ?? .gitignore
163 ?? actual
164 ?? expected
165 EOF
166
167 test_expect_success 'status ignored tracked directory with --ignore -u' '
168 git status --porcelain --ignored -u >actual &&
169 test_cmp expected actual
170 '
171
172 cat >expected <<\EOF
173 ?? .gitignore
174 ?? actual
175 ?? expected
176 EOF
177
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
182 '
183
184 cat >expected <<\EOF
185 ?? .gitignore
186 ?? actual
187 ?? expected
188 EOF
189
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
193 '
194
195 cat >expected <<\EOF
196 ?? .gitignore
197 ?? actual
198 ?? expected
199 !! tracked/uncommitted
200 EOF
201
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
207 '
208
209 cat >expected <<\EOF
210 ?? .gitignore
211 ?? actual
212 ?? expected
213 !! tracked/uncommitted
214 EOF
215
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
219 '
220
221 cat >expected <<\EOF
222 ?? .gitignore
223 ?? actual
224 ?? expected
225 !! tracked/ignored/
226 EOF
227
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
234 '
235
236 cat >expected <<\EOF
237 ?? .gitignore
238 ?? actual
239 ?? expected
240 !! tracked/ignored/uncommitted
241 EOF
242
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
246 '
247
248 cat >expected <<\EOF
249 ?? .gitignore
250 ?? actual
251 ?? expected
252 !! tracked/ignored/uncommitted
253 EOF
254
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
261 '
262
263 cat >expected <<\EOF
264 ?? .gitignore
265 ?? actual
266 ?? expected
267 !! tracked/ignored/uncommitted
268 EOF
269
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
273 '
274
275 test_done