From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 7/8] status tests: filter `.gitconfig` from status output
Date: Fri, 24 Apr 2026 15:01:16 +0000 [thread overview]
Message-ID: <56fe902644452f98b39d2ee4217228416705f14c.1777042877.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2098.git.1777042877.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
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>
---
t/t7060-wtstatus.sh | 3 +--
t/t7061-wtstatus-ignore.sh | 27 +++++++++++++++++++++++++++
t/t7064-wtstatus-pv2.sh | 1 +
t/t7508-status.sh | 4 ++++
t/t7521-ignored-mode.sh | 1 +
5 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh
index 0f4344c55e..942ddbbf0e 100755
--- a/t/t7060-wtstatus.sh
+++ b/t/t7060-wtstatus.sh
@@ -9,6 +9,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
test_expect_success setup '
git config --global advice.statusuoption false &&
+ echo "/.gitconfig" >>.git/info/exclude &&
test_commit A &&
test_commit B oneside added &&
git checkout A^0 &&
@@ -221,7 +222,6 @@ test_expect_success 'status --branch with detached HEAD' '
git status --branch --porcelain >actual &&
cat >expected <<-EOF &&
## HEAD (no branch)
- ?? .gitconfig
?? actual
?? expect
?? expected
@@ -237,7 +237,6 @@ test_expect_success 'status --porcelain=v1 --branch with detached HEAD' '
git status --branch --porcelain=v1 >actual &&
cat >expected <<-EOF &&
## HEAD (no branch)
- ?? .gitconfig
?? actual
?? expect
?? expected
diff --git a/t/t7061-wtstatus-ignore.sh b/t/t7061-wtstatus-ignore.sh
index 2f9bea9793..14ddaba2f3 100755
--- a/t/t7061-wtstatus-ignore.sh
+++ b/t/t7061-wtstatus-ignore.sh
@@ -18,6 +18,7 @@ test_expect_success 'status untracked directory with --ignored' '
: >untracked/ignored &&
: >untracked/uncommitted &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -27,6 +28,7 @@ test_expect_success 'same with gitignore starting with BOM' '
: >untracked/ignored &&
: >untracked/uncommitted &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -40,18 +42,22 @@ test_expect_success 'status untracked files --ignored with pathspec (no match)'
test_expect_success 'status untracked files --ignored with pathspec (literal match)' '
git status --porcelain --ignored -- untracked/ignored >actual &&
echo "!! untracked/ignored" >expected &&
+ test_filter_gitconfig actual &&
test_cmp expected actual &&
git status --porcelain --ignored -- untracked/uncommitted >actual &&
echo "?? untracked/uncommitted" >expected &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
test_expect_success 'status untracked files --ignored with pathspec (glob match)' '
git status --porcelain --ignored -- untracked/i\* >actual &&
echo "!! untracked/ignored" >expected &&
+ test_filter_gitconfig actual &&
test_cmp expected actual &&
git status --porcelain --ignored -- untracked/u\* >actual &&
echo "?? untracked/uncommitted" >expected &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -65,6 +71,7 @@ EOF
test_expect_success 'status untracked directory with --ignored -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
cat >expected <<\EOF
@@ -76,9 +83,11 @@ test_expect_success 'status of untracked directory with --ignored works with or
git status --porcelain --ignored >tmp &&
grep untracked/ tmp >actual &&
rm tmp &&
+ test_filter_gitconfig actual &&
test_cmp expected actual &&
git status --porcelain --ignored untracked/ >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -89,6 +98,7 @@ EOF
test_expect_success 'status prefixed untracked sub-directory with --ignored -u' '
git status --porcelain --ignored -u untracked/ >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -104,6 +114,7 @@ test_expect_success 'status ignored directory with --ignore' '
mkdir ignored &&
: >ignored/uncommitted &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -116,6 +127,7 @@ EOF
test_expect_success 'status ignored directory with --ignore -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -130,6 +142,7 @@ test_expect_success 'status empty untracked directory with --ignore' '
mkdir untracked-ignored &&
mkdir untracked-ignored/test &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -141,6 +154,7 @@ EOF
test_expect_success 'status empty untracked directory with --ignore -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -155,6 +169,7 @@ test_expect_success 'status untracked directory with ignored files with --ignore
: >untracked-ignored/ignored &&
: >untracked-ignored/test/ignored &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -168,6 +183,7 @@ EOF
test_expect_success 'status untracked directory with ignored files with --ignore -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -185,6 +201,7 @@ test_expect_success 'status ignored tracked directory with --ignore' '
git commit -m. &&
echo "tracked" >.gitignore &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -196,6 +213,7 @@ EOF
test_expect_success 'status ignored tracked directory with --ignore -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -208,6 +226,7 @@ EOF
test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
echo "committed" >>.gitignore &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -219,6 +238,7 @@ EOF
test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -233,6 +253,7 @@ test_expect_success 'status ignored tracked directory and uncommitted file with
echo "tracked" >.gitignore &&
: >tracked/uncommitted &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -245,6 +266,7 @@ EOF
test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -260,6 +282,7 @@ test_expect_success 'status ignored tracked directory with uncommitted file in u
mkdir tracked/ignored &&
: >tracked/ignored/uncommitted &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -272,6 +295,7 @@ EOF
test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -287,6 +311,7 @@ test_expect_success 'status ignored tracked directory with uncommitted file in t
git add -f tracked/ignored/committed &&
git commit -m. &&
git status --porcelain --ignored >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -299,6 +324,7 @@ EOF
test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' '
git status --porcelain --ignored -u >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
@@ -310,6 +336,7 @@ test_expect_success 'status ignores submodule in excluded directory' '
git init tracked/submodule &&
test_commit -C tracked/submodule initial &&
git status --porcelain --ignored -u tracked/submodule >actual &&
+ test_filter_gitconfig actual &&
test_cmp expected actual
'
diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh
index 8bbc5ce6d9..be6c931a96 100755
--- a/t/t7064-wtstatus-pv2.sh
+++ b/t/t7064-wtstatus-pv2.sh
@@ -231,6 +231,7 @@ test_expect_success 'ignored files are printed with --ignored' '
EOF
git status --porcelain=v2 --ignored --untracked-files=all >actual &&
+ test_filter_gitconfig actual &&
test_cmp expect actual
'
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index a5e21bf8bf..5f76ec62d8 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -263,6 +263,7 @@ test_expect_success 'status with gitignore' '
!! untracked
EOF
git status -s --ignored >output &&
+ test_filter_gitconfig output &&
test_cmp expect output &&
cat >expect <<\EOF &&
@@ -296,6 +297,7 @@ Ignored files:
EOF
git status --ignored >output &&
+ test_filter_gitconfig output &&
test_cmp expect output
'
@@ -328,6 +330,7 @@ test_expect_success 'status with gitignore (nothing untracked)' '
!! untracked
EOF
git status -s --ignored >output &&
+ test_filter_gitconfig output &&
test_cmp expect output &&
cat >expect <<\EOF &&
@@ -358,6 +361,7 @@ Ignored files:
EOF
git status --ignored >output &&
+ test_filter_gitconfig output &&
test_cmp expect output
'
diff --git a/t/t7521-ignored-mode.sh b/t/t7521-ignored-mode.sh
index a88b02b06e..7ea0b0d2f2 100755
--- a/t/t7521-ignored-mode.sh
+++ b/t/t7521-ignored-mode.sh
@@ -30,6 +30,7 @@ test_expect_success 'Verify behavior of status on directories with ignored files
dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
+ test_filter_gitconfig output &&
test_cmp expect output
'
--
gitgitgadget
next prev parent reply other threads:[~2026-04-24 15:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 15:01 [PATCH 0/8] safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 1/8] test-lib: allow bare repository access when breaking changes are enabled Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 2/8] t7900: do not let `$HOME/.gitconfig` interfere with XDG tests Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 3/8] t1300: remove global config settings injected by test-lib.sh Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 4/8] t1305: use `--git-dir=.` for bare repo in include cycle test Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 5/8] t5601: restore `.gitconfig` after includeIf test Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 6/8] ls-files tests: filter `.gitconfig` from `--others` output Johannes Schindelin via GitGitGadget
2026-04-26 0:44 ` Junio C Hamano
2026-04-24 15:01 ` Johannes Schindelin via GitGitGadget [this message]
2026-04-24 15:01 ` [PATCH 8/8] safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 0/8] " Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 1/8] test-lib: allow bare repository access when breaking changes are enabled Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 2/8] t7900: do not let `$HOME/.gitconfig` interfere with XDG tests Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 3/8] t1300: remove global config settings injected by test-lib.sh Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 4/8] t1305: use `--git-dir=.` for bare repo in include cycle test Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 5/8] t5601: restore `.gitconfig` after includeIf test Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 6/8] ls-files tests: filter `.gitconfig` from `--others` output Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 7/8] status tests: filter `.gitconfig` from status output Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 8/8] safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES Johannes Schindelin via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56fe902644452f98b39d2ee4217228416705f14c.1777042877.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox