{"thread":{"id":"63657","subject":"[PATCH v4] t2400: replace 'test -[efd]' with 'test_path_is_*'","startedAt":"2025-06-17T00:29:46Z","lastAt":"2025-06-17T13:10:59Z","messageCount":2,"participants":["Rodrigo Michelassi","Junio C Hamano"],"isPatch":true,"patchVersion":4,"patchTotal":null},"messages":[{"id":"520305","messageId":"20250617002939.24478-1-rodmichelassi@gmail.com","threadId":"63657","inReplyTo":null,"subject":"[PATCH v4] t2400: replace 'test -[efd]' with 'test_path_is_*'","fromName":"Rodrigo Michelassi","fromEmail":"rodmichelassi@gmail.com","sentAt":"2025-06-17T00:29:39Z","receivedAt":"2025-06-17T00:29:46Z","isPatch":true,"sender":{"key":"rodmichelassi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/101156335?v=4"},"body":"'test_path_is_file', 'test_path_is_dir' and 'test_file_is_missing'\nare test helpers used in Git's development, that emit useful\ndiagnostic information when they detect a failing condition, while\ntest -[efd] does not.\nReplace the basic shell commands 'test -f', 'test -d' and 'test -e',\nwith this modern path checking approach.\n\nCo-authored-by: Isabella Caselli <icaselli@usp.br>\nSigned-off-by: Isabella Caselli <icaselli@usp.br>\nSigned-off-by: Rodrigo Michelassi <rodmichelassi@gmail.com>\n---\n t/t2400-worktree-add.sh | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh\nindex 90638fa886..023e1301c8 100755\n--- a/t/t2400-worktree-add.sh\n+++ b/t/t2400-worktree-add.sh\n@@ -42,8 +42,8 @@ test_expect_success '\"add\" using - shorthand' '\n \n test_expect_success '\"add\" refuses to checkout locked branch' '\n \ttest_must_fail git worktree add zere main &&\n-\t! test -d zere &&\n-\t! test -d .git/worktrees/zere\n+\ttest_path_is_missing zere &&\n+\ttest_path_is_missing .git/worktrees/zere\n '\n \n test_expect_success 'checking out paths not complaining about linked checkouts' '\n@@ -70,14 +70,14 @@ test_expect_success '\"add\" worktree' '\n test_expect_success '\"add\" worktree with lock' '\n \tgit worktree add --detach --lock here-with-lock main &&\n \ttest_when_finished \"git worktree unlock here-with-lock || :\" &&\n-\ttest -f .git/worktrees/here-with-lock/locked\n+\ttest_path_is_file .git/worktrees/here-with-lock/locked\n '\n \n test_expect_success '\"add\" worktree with lock and reason' '\n \tlock_reason=\"why not\" &&\n \tgit worktree add --detach --lock --reason \"$lock_reason\" here-with-lock-reason main &&\n \ttest_when_finished \"git worktree unlock here-with-lock-reason || :\" &&\n-\ttest -f .git/worktrees/here-with-lock-reason/locked &&\n+\ttest_path_is_file .git/worktrees/here-with-lock-reason/locked &&\n \techo \"$lock_reason\" >expect &&\n \ttest_cmp expect .git/worktrees/here-with-lock-reason/locked\n '\n@@ -412,14 +412,14 @@ test_expect_success '\"add --orphan\" with empty repository' '\n test_expect_success '\"add\" worktree with orphan branch and lock' '\n \tgit worktree add --lock --orphan -b orphanbr orphan-with-lock &&\n \ttest_when_finished \"git worktree unlock orphan-with-lock || :\" &&\n-\ttest -f .git/worktrees/orphan-with-lock/locked\n+\ttest_path_is_file .git/worktrees/orphan-with-lock/locked\n '\n \n test_expect_success '\"add\" worktree with orphan branch, lock, and reason' '\n \tlock_reason=\"why not\" &&\n \tgit worktree add --detach --lock --reason \"$lock_reason\" orphan-with-lock-reason main &&\n \ttest_when_finished \"git worktree unlock orphan-with-lock-reason || :\" &&\n-\ttest -f .git/worktrees/orphan-with-lock-reason/locked &&\n+\ttest_path_is_file .git/worktrees/orphan-with-lock-reason/locked &&\n \techo \"$lock_reason\" >expect &&\n \ttest_cmp expect .git/worktrees/orphan-with-lock-reason/locked\n '\n@@ -474,7 +474,7 @@ test_expect_success 'local clone --shared from linked checkout' '\n \n test_expect_success '\"add\" worktree with --no-checkout' '\n \tgit worktree add --no-checkout -b swamp swamp &&\n-\t! test -e swamp/init.t &&\n+\ttest_path_is_missing swamp/init.t &&\n \tgit -C swamp reset --hard &&\n \ttest_cmp init.t swamp/init.t\n '\n@@ -497,7 +497,7 @@ test_expect_success 'put a worktree under rebase' '\n \n test_expect_success 'add a worktree, checking out a rebased branch' '\n \ttest_must_fail git worktree add new-rebase under-rebase &&\n-\t! test -d new-rebase\n+\ttest_path_is_missing new-rebase\n '\n \n test_expect_success 'checking out a rebased branch from another worktree' '\n@@ -535,7 +535,7 @@ test_expect_success 'checkout a branch under bisect' '\n \t\tgit worktree list >actual &&\n \t\tgrep \"under-bisect.*detached HEAD\" actual &&\n \t\ttest_must_fail git worktree add new-bisect under-bisect &&\n-\t\t! test -d new-bisect\n+\t\ttest_path_is_missing new-bisect\n \t)\n '\n \n@@ -1165,7 +1165,7 @@ test_expect_success '\"add\" not tripped up by magic worktree matching\"' '\n \n test_expect_success FUNNYNAMES 'sanitize generated worktree name' '\n \tgit worktree add --detach \".  weird*..?.lock.lock\" &&\n-\ttest -d .git/worktrees/---weird-.-\n+\ttest_path_is_dir .git/worktrees/---weird-.-\n '\n \n test_expect_success '\"add\" should not fail because of another bad worktree' '\n-- \n2.50.0.rc2.48.gf1ca98f609.dirty\n\n"},{"id":"520318","messageId":"xmqqikkuy0m7.fsf@gitster.g","threadId":"63657","inReplyTo":"20250617002939.24478-1-rodmichelassi@gmail.com","subject":"Re: [PATCH v4] t2400: replace 'test -[efd]' with 'test_path_is_*'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-06-17T13:10:56Z","receivedAt":"2025-06-17T13:10:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Rodrigo Michelassi <rodmichelassi@gmail.com> writes:\n\n> 'test_path_is_file', 'test_path_is_dir' and 'test_file_is_missing'\n> are test helpers used in Git's development, that emit useful\n> diagnostic information when they detect a failing condition, while\n> test -[efd] does not.\n> Replace the basic shell commands 'test -f', 'test -d' and 'test -e',\n> with this modern path checking approach.\n>\n> Co-authored-by: Isabella Caselli <icaselli@usp.br>\n> Signed-off-by: Isabella Caselli <icaselli@usp.br>\n> Signed-off-by: Rodrigo Michelassi <rodmichelassi@gmail.com>\n> ---\n>  t/t2400-worktree-add.sh | 20 ++++++++++----------\n>  1 file changed, 10 insertions(+), 10 deletions(-)\n\nLooking good.  Will queue.\n\nThanks.\n"}]}