]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t1005: modernize "! test -f" to "test_path_is_missing"
authorTian Yuchen <a3205153416@gmail.com>
Sat, 17 Jan 2026 06:25:15 +0000 (14:25 +0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 17 Jan 2026 18:01:14 +0000 (10:01 -0800)
Replace instances of "! test -f <file>" with "test_path_is_missing <file>".
This macro provides better diagnostics when the test fails (it prints
"Path exists:" instead of silently failing).

Signed-off-by: Tian Yuchen <a3205153416@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1005-read-tree-reset.sh

index 6b5033d0ce3b3489598f0f1fba5b047bd3e5b43a..1bf384dd0f8c4d165b19026d1a46e0caa0a661f8 100755 (executable)
@@ -40,7 +40,7 @@ test_expect_success 'reset should remove remnants from a failed merge' '
        git ls-files -s &&
        read_tree_u_must_succeed --reset -u HEAD &&
        git ls-files -s >actual &&
-       ! test -f old &&
+       test_path_is_missing old &&
        test_cmp expect actual
 '
 
@@ -56,7 +56,7 @@ test_expect_success 'two-way reset should remove remnants too' '
        git ls-files -s &&
        read_tree_u_must_succeed --reset -u HEAD HEAD &&
        git ls-files -s >actual &&
-       ! test -f old &&
+       test_path_is_missing old &&
        test_cmp expect actual
 '
 
@@ -72,7 +72,7 @@ test_expect_success 'Porcelain reset should remove remnants too' '
        git ls-files -s &&
        git reset --hard &&
        git ls-files -s >actual &&
-       ! test -f old &&
+       test_path_is_missing old &&
        test_cmp expect actual
 '
 
@@ -88,7 +88,7 @@ test_expect_success 'Porcelain checkout -f should remove remnants too' '
        git ls-files -s &&
        git checkout -f &&
        git ls-files -s >actual &&
-       ! test -f old &&
+       test_path_is_missing old &&
        test_cmp expect actual
 '
 
@@ -104,7 +104,7 @@ test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' '
        git ls-files -s &&
        git checkout -f HEAD &&
        git ls-files -s >actual &&
-       ! test -f old &&
+       test_path_is_missing old &&
        test_cmp expect actual
 '