Skip to content

Commit ac4da79

Browse files
committed
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>
1 parent 556db0e commit ac4da79

5 files changed

Lines changed: 34 additions & 2 deletions

File tree

t/t7060-wtstatus.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
99

1010
test_expect_success setup '
1111
git config --global advice.statusuoption false &&
12+
echo "/.gitconfig" >>.git/info/exclude &&
1213
test_commit A &&
1314
test_commit B oneside added &&
1415
git checkout A^0 &&
@@ -221,7 +222,6 @@ test_expect_success 'status --branch with detached HEAD' '
221222
git status --branch --porcelain >actual &&
222223
cat >expected <<-EOF &&
223224
## HEAD (no branch)
224-
?? .gitconfig
225225
?? actual
226226
?? expect
227227
?? expected
@@ -237,7 +237,6 @@ test_expect_success 'status --porcelain=v1 --branch with detached HEAD' '
237237
git status --branch --porcelain=v1 >actual &&
238238
cat >expected <<-EOF &&
239239
## HEAD (no branch)
240-
?? .gitconfig
241240
?? actual
242241
?? expect
243242
?? expected

t/t7061-wtstatus-ignore.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ test_expect_success 'status untracked directory with --ignored' '
1818
: >untracked/ignored &&
1919
: >untracked/uncommitted &&
2020
git status --porcelain --ignored >actual &&
21+
test_filter_gitconfig actual &&
2122
test_cmp expected actual
2223
'
2324

@@ -27,6 +28,7 @@ test_expect_success 'same with gitignore starting with BOM' '
2728
: >untracked/ignored &&
2829
: >untracked/uncommitted &&
2930
git status --porcelain --ignored >actual &&
31+
test_filter_gitconfig actual &&
3032
test_cmp expected actual
3133
'
3234

@@ -40,18 +42,22 @@ test_expect_success 'status untracked files --ignored with pathspec (no match)'
4042
test_expect_success 'status untracked files --ignored with pathspec (literal match)' '
4143
git status --porcelain --ignored -- untracked/ignored >actual &&
4244
echo "!! untracked/ignored" >expected &&
45+
test_filter_gitconfig actual &&
4346
test_cmp expected actual &&
4447
git status --porcelain --ignored -- untracked/uncommitted >actual &&
4548
echo "?? untracked/uncommitted" >expected &&
49+
test_filter_gitconfig actual &&
4650
test_cmp expected actual
4751
'
4852

4953
test_expect_success 'status untracked files --ignored with pathspec (glob match)' '
5054
git status --porcelain --ignored -- untracked/i\* >actual &&
5155
echo "!! untracked/ignored" >expected &&
56+
test_filter_gitconfig actual &&
5257
test_cmp expected actual &&
5358
git status --porcelain --ignored -- untracked/u\* >actual &&
5459
echo "?? untracked/uncommitted" >expected &&
60+
test_filter_gitconfig actual &&
5561
test_cmp expected actual
5662
'
5763

@@ -65,6 +71,7 @@ EOF
6571

6672
test_expect_success 'status untracked directory with --ignored -u' '
6773
git status --porcelain --ignored -u >actual &&
74+
test_filter_gitconfig actual &&
6875
test_cmp expected actual
6976
'
7077
cat >expected <<\EOF
@@ -76,9 +83,11 @@ test_expect_success 'status of untracked directory with --ignored works with or
7683
git status --porcelain --ignored >tmp &&
7784
grep untracked/ tmp >actual &&
7885
rm tmp &&
86+
test_filter_gitconfig actual &&
7987
test_cmp expected actual &&
8088
8189
git status --porcelain --ignored untracked/ >actual &&
90+
test_filter_gitconfig actual &&
8291
test_cmp expected actual
8392
'
8493

@@ -89,6 +98,7 @@ EOF
8998

9099
test_expect_success 'status prefixed untracked sub-directory with --ignored -u' '
91100
git status --porcelain --ignored -u untracked/ >actual &&
101+
test_filter_gitconfig actual &&
92102
test_cmp expected actual
93103
'
94104

@@ -104,6 +114,7 @@ test_expect_success 'status ignored directory with --ignore' '
104114
mkdir ignored &&
105115
: >ignored/uncommitted &&
106116
git status --porcelain --ignored >actual &&
117+
test_filter_gitconfig actual &&
107118
test_cmp expected actual
108119
'
109120

@@ -116,6 +127,7 @@ EOF
116127

117128
test_expect_success 'status ignored directory with --ignore -u' '
118129
git status --porcelain --ignored -u >actual &&
130+
test_filter_gitconfig actual &&
119131
test_cmp expected actual
120132
'
121133

@@ -130,6 +142,7 @@ test_expect_success 'status empty untracked directory with --ignore' '
130142
mkdir untracked-ignored &&
131143
mkdir untracked-ignored/test &&
132144
git status --porcelain --ignored >actual &&
145+
test_filter_gitconfig actual &&
133146
test_cmp expected actual
134147
'
135148

@@ -141,6 +154,7 @@ EOF
141154

142155
test_expect_success 'status empty untracked directory with --ignore -u' '
143156
git status --porcelain --ignored -u >actual &&
157+
test_filter_gitconfig actual &&
144158
test_cmp expected actual
145159
'
146160

@@ -155,6 +169,7 @@ test_expect_success 'status untracked directory with ignored files with --ignore
155169
: >untracked-ignored/ignored &&
156170
: >untracked-ignored/test/ignored &&
157171
git status --porcelain --ignored >actual &&
172+
test_filter_gitconfig actual &&
158173
test_cmp expected actual
159174
'
160175

@@ -168,6 +183,7 @@ EOF
168183

169184
test_expect_success 'status untracked directory with ignored files with --ignore -u' '
170185
git status --porcelain --ignored -u >actual &&
186+
test_filter_gitconfig actual &&
171187
test_cmp expected actual
172188
'
173189

@@ -185,6 +201,7 @@ test_expect_success 'status ignored tracked directory with --ignore' '
185201
git commit -m. &&
186202
echo "tracked" >.gitignore &&
187203
git status --porcelain --ignored >actual &&
204+
test_filter_gitconfig actual &&
188205
test_cmp expected actual
189206
'
190207

@@ -196,6 +213,7 @@ EOF
196213

197214
test_expect_success 'status ignored tracked directory with --ignore -u' '
198215
git status --porcelain --ignored -u >actual &&
216+
test_filter_gitconfig actual &&
199217
test_cmp expected actual
200218
'
201219

@@ -208,6 +226,7 @@ EOF
208226
test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
209227
echo "committed" >>.gitignore &&
210228
git status --porcelain --ignored >actual &&
229+
test_filter_gitconfig actual &&
211230
test_cmp expected actual
212231
'
213232

@@ -219,6 +238,7 @@ EOF
219238

220239
test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
221240
git status --porcelain --ignored -u >actual &&
241+
test_filter_gitconfig actual &&
222242
test_cmp expected actual
223243
'
224244

@@ -233,6 +253,7 @@ test_expect_success 'status ignored tracked directory and uncommitted file with
233253
echo "tracked" >.gitignore &&
234254
: >tracked/uncommitted &&
235255
git status --porcelain --ignored >actual &&
256+
test_filter_gitconfig actual &&
236257
test_cmp expected actual
237258
'
238259

@@ -245,6 +266,7 @@ EOF
245266

246267
test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
247268
git status --porcelain --ignored -u >actual &&
269+
test_filter_gitconfig actual &&
248270
test_cmp expected actual
249271
'
250272

@@ -260,6 +282,7 @@ test_expect_success 'status ignored tracked directory with uncommitted file in u
260282
mkdir tracked/ignored &&
261283
: >tracked/ignored/uncommitted &&
262284
git status --porcelain --ignored >actual &&
285+
test_filter_gitconfig actual &&
263286
test_cmp expected actual
264287
'
265288

@@ -272,6 +295,7 @@ EOF
272295

273296
test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' '
274297
git status --porcelain --ignored -u >actual &&
298+
test_filter_gitconfig actual &&
275299
test_cmp expected actual
276300
'
277301

@@ -287,6 +311,7 @@ test_expect_success 'status ignored tracked directory with uncommitted file in t
287311
git add -f tracked/ignored/committed &&
288312
git commit -m. &&
289313
git status --porcelain --ignored >actual &&
314+
test_filter_gitconfig actual &&
290315
test_cmp expected actual
291316
'
292317

@@ -299,6 +324,7 @@ EOF
299324

300325
test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' '
301326
git status --porcelain --ignored -u >actual &&
327+
test_filter_gitconfig actual &&
302328
test_cmp expected actual
303329
'
304330

@@ -310,6 +336,7 @@ test_expect_success 'status ignores submodule in excluded directory' '
310336
git init tracked/submodule &&
311337
test_commit -C tracked/submodule initial &&
312338
git status --porcelain --ignored -u tracked/submodule >actual &&
339+
test_filter_gitconfig actual &&
313340
test_cmp expected actual
314341
'
315342

t/t7064-wtstatus-pv2.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ test_expect_success 'ignored files are printed with --ignored' '
231231
EOF
232232
233233
git status --porcelain=v2 --ignored --untracked-files=all >actual &&
234+
test_filter_gitconfig actual &&
234235
test_cmp expect actual
235236
'
236237

t/t7508-status.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ test_expect_success 'status with gitignore' '
263263
!! untracked
264264
EOF
265265
git status -s --ignored >output &&
266+
test_filter_gitconfig output &&
266267
test_cmp expect output &&
267268
268269
cat >expect <<\EOF &&
@@ -296,6 +297,7 @@ Ignored files:
296297
297298
EOF
298299
git status --ignored >output &&
300+
test_filter_gitconfig output &&
299301
test_cmp expect output
300302
'
301303

@@ -328,6 +330,7 @@ test_expect_success 'status with gitignore (nothing untracked)' '
328330
!! untracked
329331
EOF
330332
git status -s --ignored >output &&
333+
test_filter_gitconfig output &&
331334
test_cmp expect output &&
332335
333336
cat >expect <<\EOF &&
@@ -358,6 +361,7 @@ Ignored files:
358361
359362
EOF
360363
git status --ignored >output &&
364+
test_filter_gitconfig output &&
361365
test_cmp expect output
362366
'
363367

t/t7521-ignored-mode.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ test_expect_success 'Verify behavior of status on directories with ignored files
3030
dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
3131
3232
git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
33+
test_filter_gitconfig output &&
3334
test_cmp expect output
3435
'
3536

0 commit comments

Comments
 (0)