status tests: filter `.gitconfig` from status output

Since test-lib.sh creates `$HOME/.gitconfig` when `WITH_BREAKING_CHANGES` is in effect, the file appears in `git status` output as either untracked (`?? .gitconfig`) or ignored (`!! .gitconfig` / `! .gitconfig`, depending on porcelain version), because the `.git/info/exclude` entry causes git to treat it as an ignored file rather than hiding it entirely. In t7061 and t7521, which are pervasively affected, introduce a `filter_gitconfig` helper that strips all status-prefix variants of `.gitconfig` from the output before comparison. In the remaining scripts (t7060, t7064, t7508), apply targeted adjustments. Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Apr 26, 2026 at 14:38 UTC a09d2b27ff9331d03a629b5ffcf81cb16bbe6544
5 files changed +34 -2
t/t7060-wtstatus.sh
+1 -2
@@ -9,6 +9,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9
10 test_expect_success setup '
11 git config --global advice.statusuoption false &&
12 + echo "/.gitconfig" >>.git/info/exclude &&
13 test_commit A &&
14 test_commit B oneside added &&
15 git checkout A^0 &&
@@ -221,7 +222,6 @@ test_expect_success 'status --branch with detached HEAD' '
222 git status --branch --porcelain >actual &&
223 cat >expected <<-EOF &&
224 ## HEAD (no branch)
224 - ?? .gitconfig
225 ?? actual
226 ?? expect
227 ?? expected
@@ -237,7 +237,6 @@ test_expect_success 'status --porcelain=v1 --branch with detached HEAD' '
237 git status --branch --porcelain=v1 >actual &&
238 cat >expected <<-EOF &&
239 ## HEAD (no branch)
240 - ?? .gitconfig
240 ?? actual
241 ?? expect
242 ?? expected
t/t7061-wtstatus-ignore.sh
+27
@@ -18,6 +18,7 @@ test_expect_success 'status untracked directory with --ignored' '
18 : >untracked/ignored &&
19 : >untracked/uncommitted &&
20 git status --porcelain --ignored >actual &&
21 + test_filter_gitconfig actual &&
22 test_cmp expected actual
23 '
24
@@ -27,6 +28,7 @@ test_expect_success 'same with gitignore starting with BOM' '
28 : >untracked/ignored &&
29 : >untracked/uncommitted &&
30 git status --porcelain --ignored >actual &&
31 + test_filter_gitconfig actual &&
32 test_cmp expected actual
33 '
34
@@ -40,18 +42,22 @@ test_expect_success 'status untracked files --ignored with pathspec (no match)'
42 test_expect_success 'status untracked files --ignored with pathspec (literal match)' '
43 git status --porcelain --ignored -- untracked/ignored >actual &&
44 echo "!! untracked/ignored" >expected &&
45 + test_filter_gitconfig actual &&
46 test_cmp expected actual &&
47 git status --porcelain --ignored -- untracked/uncommitted >actual &&
48 echo "?? untracked/uncommitted" >expected &&
49 + test_filter_gitconfig actual &&
50 test_cmp expected actual
51 '
52
53 test_expect_success 'status untracked files --ignored with pathspec (glob match)' '
54 git status --porcelain --ignored -- untracked/i\* >actual &&
55 echo "!! untracked/ignored" >expected &&
56 + test_filter_gitconfig actual &&
57 test_cmp expected actual &&
58 git status --porcelain --ignored -- untracked/u\* >actual &&
59 echo "?? untracked/uncommitted" >expected &&
60 + test_filter_gitconfig actual &&
61 test_cmp expected actual
62 '
63
@@ -65,6 +71,7 @@ EOF
71
72 test_expect_success 'status untracked directory with --ignored -u' '
73 git status --porcelain --ignored -u >actual &&
74 + test_filter_gitconfig actual &&
75 test_cmp expected actual
76 '
77 cat >expected <<\EOF
@@ -76,9 +83,11 @@ test_expect_success 'status of untracked directory with --ignored works with or
83 git status --porcelain --ignored >tmp &&
84 grep untracked/ tmp >actual &&
85 rm tmp &&
86 + test_filter_gitconfig actual &&
87 test_cmp expected actual &&
88
89 git status --porcelain --ignored untracked/ >actual &&
90 + test_filter_gitconfig actual &&
91 test_cmp expected actual
92 '
93
@@ -89,6 +98,7 @@ EOF
98
99 test_expect_success 'status prefixed untracked sub-directory with --ignored -u' '
100 git status --porcelain --ignored -u untracked/ >actual &&
101 + test_filter_gitconfig actual &&
102 test_cmp expected actual
103 '
104
@@ -104,6 +114,7 @@ test_expect_success 'status ignored directory with --ignore' '
114 mkdir ignored &&
115 : >ignored/uncommitted &&
116 git status --porcelain --ignored >actual &&
117 + test_filter_gitconfig actual &&
118 test_cmp expected actual
119 '
120
@@ -116,6 +127,7 @@ EOF
127
128 test_expect_success 'status ignored directory with --ignore -u' '
129 git status --porcelain --ignored -u >actual &&
130 + test_filter_gitconfig actual &&
131 test_cmp expected actual
132 '
133
@@ -130,6 +142,7 @@ test_expect_success 'status empty untracked directory with --ignore' '
142 mkdir untracked-ignored &&
143 mkdir untracked-ignored/test &&
144 git status --porcelain --ignored >actual &&
145 + test_filter_gitconfig actual &&
146 test_cmp expected actual
147 '
148
@@ -141,6 +154,7 @@ EOF
154
155 test_expect_success 'status empty untracked directory with --ignore -u' '
156 git status --porcelain --ignored -u >actual &&
157 + test_filter_gitconfig actual &&
158 test_cmp expected actual
159 '
160
@@ -155,6 +169,7 @@ test_expect_success 'status untracked directory with ignored files with --ignore
169 : >untracked-ignored/ignored &&
170 : >untracked-ignored/test/ignored &&
171 git status --porcelain --ignored >actual &&
172 + test_filter_gitconfig actual &&
173 test_cmp expected actual
174 '
175
@@ -168,6 +183,7 @@ EOF
183
184 test_expect_success 'status untracked directory with ignored files with --ignore -u' '
185 git status --porcelain --ignored -u >actual &&
186 + test_filter_gitconfig actual &&
187 test_cmp expected actual
188 '
189
@@ -185,6 +201,7 @@ test_expect_success 'status ignored tracked directory with --ignore' '
201 git commit -m. &&
202 echo "tracked" >.gitignore &&
203 git status --porcelain --ignored >actual &&
204 + test_filter_gitconfig actual &&
205 test_cmp expected actual
206 '
207
@@ -196,6 +213,7 @@ EOF
213
214 test_expect_success 'status ignored tracked directory with --ignore -u' '
215 git status --porcelain --ignored -u >actual &&
216 + test_filter_gitconfig actual &&
217 test_cmp expected actual
218 '
219
@@ -208,6 +226,7 @@ EOF
226 test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
227 echo "committed" >>.gitignore &&
228 git status --porcelain --ignored >actual &&
229 + test_filter_gitconfig actual &&
230 test_cmp expected actual
231 '
232
@@ -219,6 +238,7 @@ EOF
238
239 test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
240 git status --porcelain --ignored -u >actual &&
241 + test_filter_gitconfig actual &&
242 test_cmp expected actual
243 '
244
@@ -233,6 +253,7 @@ test_expect_success 'status ignored tracked directory and uncommitted file with
253 echo "tracked" >.gitignore &&
254 : >tracked/uncommitted &&
255 git status --porcelain --ignored >actual &&
256 + test_filter_gitconfig actual &&
257 test_cmp expected actual
258 '
259
@@ -245,6 +266,7 @@ EOF
266
267 test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
268 git status --porcelain --ignored -u >actual &&
269 + test_filter_gitconfig actual &&
270 test_cmp expected actual
271 '
272
@@ -260,6 +282,7 @@ test_expect_success 'status ignored tracked directory with uncommitted file in u
282 mkdir tracked/ignored &&
283 : >tracked/ignored/uncommitted &&
284 git status --porcelain --ignored >actual &&
285 + test_filter_gitconfig actual &&
286 test_cmp expected actual
287 '
288
@@ -272,6 +295,7 @@ EOF
295
296 test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' '
297 git status --porcelain --ignored -u >actual &&
298 + test_filter_gitconfig actual &&
299 test_cmp expected actual
300 '
301
@@ -287,6 +311,7 @@ test_expect_success 'status ignored tracked directory with uncommitted file in t
311 git add -f tracked/ignored/committed &&
312 git commit -m. &&
313 git status --porcelain --ignored >actual &&
314 + test_filter_gitconfig actual &&
315 test_cmp expected actual
316 '
317
@@ -299,6 +324,7 @@ EOF
324
325 test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' '
326 git status --porcelain --ignored -u >actual &&
327 + test_filter_gitconfig actual &&
328 test_cmp expected actual
329 '
330
@@ -310,6 +336,7 @@ test_expect_success 'status ignores submodule in excluded directory' '
336 git init tracked/submodule &&
337 test_commit -C tracked/submodule initial &&
338 git status --porcelain --ignored -u tracked/submodule >actual &&
339 + test_filter_gitconfig actual &&
340 test_cmp expected actual
341 '
342
t/t7064-wtstatus-pv2.sh
+1
@@ -231,6 +231,7 @@ test_expect_success 'ignored files are printed with --ignored' '
231 EOF
232
233 git status --porcelain=v2 --ignored --untracked-files=all >actual &&
234 + test_filter_gitconfig actual &&
235 test_cmp expect actual
236 '
237
t/t7508-status.sh
+4
@@ -263,6 +263,7 @@ test_expect_success 'status with gitignore' '
263 !! untracked
264 EOF
265 git status -s --ignored >output &&
266 + test_filter_gitconfig output &&
267 test_cmp expect output &&
268
269 cat >expect <<\EOF &&
@@ -296,6 +297,7 @@ Ignored files:
297
298 EOF
299 git status --ignored >output &&
300 + test_filter_gitconfig output &&
301 test_cmp expect output
302 '
303
@@ -328,6 +330,7 @@ test_expect_success 'status with gitignore (nothing untracked)' '
330 !! untracked
331 EOF
332 git status -s --ignored >output &&
333 + test_filter_gitconfig output &&
334 test_cmp expect output &&
335
336 cat >expect <<\EOF &&
@@ -358,6 +361,7 @@ Ignored files:
361
362 EOF
363 git status --ignored >output &&
364 + test_filter_gitconfig output &&
365 test_cmp expect output
366 '
367
t/t7521-ignored-mode.sh
+1
@@ -30,6 +30,7 @@ test_expect_success 'Verify behavior of status on directories with ignored files
30 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
31
32 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
33 + test_filter_gitconfig output &&
34 test_cmp expect output
35 '
36