@@ -131,6 +131,127 @@ test_expect_success 'status -s' '
131
131
132
132
'
133
133
134
+ test_expect_success ' status with gitignore' '
135
+ {
136
+ echo ".gitignore" &&
137
+ echo "expect" &&
138
+ echo "output" &&
139
+ echo "untracked"
140
+ } >.gitignore &&
141
+
142
+ cat >expect <<-\EOF &&
143
+ M dir1/modified
144
+ A dir2/added
145
+ ?? dir2/modified
146
+ EOF
147
+ git status -s >output &&
148
+ test_cmp expect output &&
149
+
150
+ cat >expect <<-\EOF &&
151
+ M dir1/modified
152
+ A dir2/added
153
+ ?? dir2/modified
154
+ !! .gitignore
155
+ !! dir1/untracked
156
+ !! dir2/untracked
157
+ !! expect
158
+ !! output
159
+ !! untracked
160
+ EOF
161
+ git status -s --ignored >output &&
162
+ test_cmp expect output &&
163
+
164
+ cat >expect <<-\EOF &&
165
+ # On branch master
166
+ # Changes to be committed:
167
+ # (use "git reset HEAD <file>..." to unstage)
168
+ #
169
+ # new file: dir2/added
170
+ #
171
+ # Changes not staged for commit:
172
+ # (use "git add <file>..." to update what will be committed)
173
+ # (use "git checkout -- <file>..." to discard changes in working directory)
174
+ #
175
+ # modified: dir1/modified
176
+ #
177
+ # Untracked files:
178
+ # (use "git add <file>..." to include in what will be committed)
179
+ #
180
+ # dir2/modified
181
+ # Ignored files:
182
+ # (use "git add -f <file>..." to include in what will be committed)
183
+ #
184
+ # .gitignore
185
+ # dir1/untracked
186
+ # dir2/untracked
187
+ # expect
188
+ # output
189
+ # untracked
190
+ EOF
191
+ git status --ignored >output &&
192
+ test_cmp expect output
193
+ '
194
+
195
+ test_expect_success ' status with gitignore (nothing untracked)' '
196
+ {
197
+ echo ".gitignore" &&
198
+ echo "expect" &&
199
+ echo "dir2/modified" &&
200
+ echo "output" &&
201
+ echo "untracked"
202
+ } >.gitignore &&
203
+
204
+ cat >expect <<-\EOF &&
205
+ M dir1/modified
206
+ A dir2/added
207
+ EOF
208
+ git status -s >output &&
209
+ test_cmp expect output &&
210
+
211
+ cat >expect <<-\EOF &&
212
+ M dir1/modified
213
+ A dir2/added
214
+ !! .gitignore
215
+ !! dir1/untracked
216
+ !! dir2/modified
217
+ !! dir2/untracked
218
+ !! expect
219
+ !! output
220
+ !! untracked
221
+ EOF
222
+ git status -s --ignored >output &&
223
+ test_cmp expect output &&
224
+
225
+ cat >expect <<-\EOF &&
226
+ # On branch master
227
+ # Changes to be committed:
228
+ # (use "git reset HEAD <file>..." to unstage)
229
+ #
230
+ # new file: dir2/added
231
+ #
232
+ # Changes not staged for commit:
233
+ # (use "git add <file>..." to update what will be committed)
234
+ # (use "git checkout -- <file>..." to discard changes in working directory)
235
+ #
236
+ # modified: dir1/modified
237
+ #
238
+ # Ignored files:
239
+ # (use "git add -f <file>..." to include in what will be committed)
240
+ #
241
+ # .gitignore
242
+ # dir1/untracked
243
+ # dir2/modified
244
+ # dir2/untracked
245
+ # expect
246
+ # output
247
+ # untracked
248
+ EOF
249
+ git status --ignored >output &&
250
+ test_cmp expect output
251
+ '
252
+
253
+ rm -f .gitignore
254
+
134
255
cat > expect << \EOF
135
256
## master
136
257
M dir1/modified
0 commit comments