]> git.ipfire.org Git - thirdparty/git.git/commitdiff
status tests: filter `.gitconfig` from status output
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sun, 26 Apr 2026 14:38:35 +0000 (14:38 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Apr 2026 05:50:54 +0000 (14:50 +0900)
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>
t/t7060-wtstatus.sh
t/t7061-wtstatus-ignore.sh
t/t7064-wtstatus-pv2.sh
t/t7508-status.sh
t/t7521-ignored-mode.sh

index 0f4344c55e6421d605ab7364bc2fedfe9165b02b..942ddbbf0eca9e1ca90e1c09fff1995677a9e7a4 100755 (executable)
@@ -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
index 2f9bea9793cec8b2900c35b3add315b67192a882..14ddaba2f3e7ea70c9b15b4ddd3ad39fe3744db2 100755 (executable)
@@ -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
 '
 
index 8bbc5ce6d9886cb1fbe2506df2259e284ca5598e..be6c931a9624bcf99c32c18b3a000c4d59bb7486 100755 (executable)
@@ -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
 '
 
index a5e21bf8bffb4512c8d9bb0858b0f94805aecd64..5f76ec62d8dc476a617cd1b637b4a6ef0d05dbff 100755 (executable)
@@ -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
 '
 
index a88b02b06ed34234abfb3aa3131dd31a7d364141..7ea0b0d2f2a9888374fda47ce26078badbeabe63 100755 (executable)
@@ -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
 '