{"thread":{"id":"65182","subject":"[PATCH] t0004: replace test -e with test_path_exists","startedAt":"2026-03-09T17:56:47Z","lastAt":"2026-03-09T19:30:15Z","messageCount":2,"participants":["PRASHANT S BISHT","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"538306","messageId":"20260309175621.32211-1-prashantjee2025@gmail.com","threadId":"65182","inReplyTo":null,"subject":"[PATCH] t0004: replace test -e with test_path_exists","fromName":"PRASHANT S BISHT","fromEmail":"prashantjee2025@gmail.com","sentAt":"2026-03-09T17:56:21Z","receivedAt":"2026-03-09T17:56:47Z","isPatch":true,"sender":{"key":"prashantjee2025@gmail.com","avatar":"https://avatars.githubusercontent.com/u/213211543?v=4"},"body":"Replace old-style path existence checks with the modern test_path_exists\nhelper function that provides clearer diagnostic messages on failure.\nWhen test -e fails, the output gives no indication of what went wrong.\n\nThese instances were found using:\n\n  git grep \"test -[efd]\" t/ | grep -v \"if test\"\n\nas suggested in the microproject ideas.\n\nSigned-off-by: PRASHANT S BISHT <prashantjee2025@gmail.com>\n---\n t/t0004-unwritable.sh | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh\nindex 3bdafbae0f..2a9fc781b6 100755\n--- a/t/t0004-unwritable.sh\n+++ b/t/t0004-unwritable.sh\n@@ -21,7 +21,7 @@ test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable reposi\n \ttest_must_fail git write-tree 2>out.write-tree\n '\n \n-test_lazy_prereq WRITE_TREE_OUT 'test -e \"$TRASH_DIRECTORY\"/out.write-tree'\n+test_lazy_prereq WRITE_TREE_OUT 'test_path_exists \"$TRASH_DIRECTORY/out.write-tree\"'\n test_expect_success WRITE_TREE_OUT 'write-tree output on unwritable repository' '\n \tcat >expect <<-\\EOF &&\n \terror: insufficient permission for adding an object to repository database .git/objects\n@@ -36,7 +36,7 @@ test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository\n \ttest_must_fail git commit -m second 2>out.commit\n '\n \n-test_lazy_prereq COMMIT_OUT 'test -e \"$TRASH_DIRECTORY\"/out.commit'\n+test_lazy_prereq COMMIT_OUT 'test_path_exists \"$TRASH_DIRECTORY/out.commit\"'\n test_expect_success COMMIT_OUT 'commit output on unwritable repository' '\n \tcat >expect <<-\\EOF &&\n \terror: insufficient permission for adding an object to repository database .git/objects\n@@ -52,7 +52,7 @@ test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repo\n \ttest_must_fail git update-index file 2>out.update-index\n '\n \n-test_lazy_prereq UPDATE_INDEX_OUT 'test -e \"$TRASH_DIRECTORY\"/out.update-index'\n+test_lazy_prereq UPDATE_INDEX_OUT 'test_path_exists \"$TRASH_DIRECTORY/out.update-index\"'\n test_expect_success UPDATE_INDEX_OUT 'update-index output on unwritable repository' '\n \tcat >expect <<-\\EOF &&\n \terror: insufficient permission for adding an object to repository database .git/objects\n@@ -69,7 +69,7 @@ test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' '\n \ttest_must_fail git add file 2>out.add\n '\n \n-test_lazy_prereq ADD_OUT 'test -e \"$TRASH_DIRECTORY\"/out.add'\n+test_lazy_prereq ADD_OUT 'test_path_exists \"$TRASH_DIRECTORY/out.add\"'\n test_expect_success ADD_OUT 'add output on unwritable repository' '\n \tcat >expect <<-\\EOF &&\n \terror: insufficient permission for adding an object to repository database .git/objects\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"538314","messageId":"CAPig+cSp1634HVrj6qVfRodR=J3UubYa_aa32JJSTCe1u2NwDA@mail.gmail.com","threadId":"65182","inReplyTo":"20260309175621.32211-1-prashantjee2025@gmail.com","subject":"Re: [PATCH] t0004: replace test -e with test_path_exists","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2026-03-09T19:30:03Z","receivedAt":"2026-03-09T19:30:15Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Mar 9, 2026 at 2:02 PM PRASHANT S BISHT\n<prashantjee2025@gmail.com> wrote:\n> Replace old-style path existence checks with the modern test_path_exists\n> helper function that provides clearer diagnostic messages on failure.\n> When test -e fails, the output gives no indication of what went wrong.\n>\n> These instances were found using:\n>\n>   git grep \"test -[efd]\" t/ | grep -v \"if test\"\n>\n> as suggested in the microproject ideas.\n>\n> Signed-off-by: PRASHANT S BISHT <prashantjee2025@gmail.com>\n> ---\n> diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh\n> @@ -21,7 +21,7 @@ test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable reposi\n> -test_lazy_prereq WRITE_TREE_OUT 'test -e \"$TRASH_DIRECTORY\"/out.write-tree'\n> +test_lazy_prereq WRITE_TREE_OUT 'test_path_exists \"$TRASH_DIRECTORY/out.write-tree\"'\n> @@ -36,7 +36,7 @@ test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository\n> -test_lazy_prereq COMMIT_OUT 'test -e \"$TRASH_DIRECTORY\"/out.commit'\n> +test_lazy_prereq COMMIT_OUT 'test_path_exists \"$TRASH_DIRECTORY/out.commit\"'\n> @@ -52,7 +52,7 @@ test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repo\n> -test_lazy_prereq UPDATE_INDEX_OUT 'test -e \"$TRASH_DIRECTORY\"/out.update-index'\n> +test_lazy_prereq UPDATE_INDEX_OUT 'test_path_exists \"$TRASH_DIRECTORY/out.update-index\"'\n> @@ -69,7 +69,7 @@ test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' '\n> -test_lazy_prereq ADD_OUT 'test -e \"$TRASH_DIRECTORY\"/out.add'\n> +test_lazy_prereq ADD_OUT 'test_path_exists \"$TRASH_DIRECTORY/out.add\"'\n\nI'm afraid you chose instances of `test -e` which should not be\nconverted to `test_path_exists`.\n\nIf you're not familiar with Git's test \"prereq\" facility, then it is\nnot obvious, but each of these uses of `test -e` is, in fact, used for\ncontrol-flow rather than being used to assert some truth. Hence, these\nchanges run afoul of point #3 under the \"Modernize Test Path Checking\nin Git’s Test Suite\" item on the SoC microproject ideas page[*].\n\nPlease try converting some other cases in some other test script.\n\n[*]: https://git.github.io/SoC-2026-Microprojects/\n"}]}