{"thread":{"id":"64320","subject":"[PATCH 1/1] t: update path checks using test_path helpers","startedAt":"2025-10-14T16:15:05Z","lastAt":"2025-10-15T20:38:19Z","messageCount":7,"participants":["Solly","Junio C Hamano","Usman Akinyemi","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"528743","messageId":"20251014161446.6135-1-solobarine@gmail.com","threadId":"64320","inReplyTo":null,"subject":"[PATCH 1/1] t: update path checks using test_path helpers","fromName":"Solly","fromEmail":"solobarine@gmail.com","sentAt":"2025-10-14T16:14:46Z","receivedAt":"2025-10-14T16:15:05Z","isPatch":true,"sender":{"key":"solobarine@gmail.com","avatar":"https://avatars.githubusercontent.com/u/105935114?v=4"},"body":"Update old-style shell path checks to use the modern test\nhelpers 'test_path_is_file' and 'test_path_is_dir' for improved\nreadability.\n\nSigned-off-by: Solly <solobarine@gmail.com>\n---\n t/t2401-worktree-prune.sh | 34 +++++++++++++++++-----------------\n 1 file changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh\nindex fe671d4197..27127fa5a5 100755\n--- a/t/t2401-worktree-prune.sh\n+++ b/t/t2401-worktree-prune.sh\n@@ -24,8 +24,8 @@ test_expect_success 'prune files inside $GIT_DIR/worktrees' '\n Removing worktrees/abc: not a valid directory\n EOF\n \ttest_cmp expect actual &&\n-\t! test -f .git/worktrees/abc &&\n-\t! test -d .git/worktrees\n+\t! test_path_is_file .git/worktrees/abc &&\n+\t! test_path_is_dir .git/worktrees\n '\n \n test_expect_success 'prune directories without gitdir' '\n@@ -36,8 +36,8 @@ Removing worktrees/def: gitdir file does not exist\n EOF\n \tgit worktree prune --verbose 2>actual &&\n \ttest_cmp expect actual &&\n-\t! test -d .git/worktrees/def &&\n-\t! test -d .git/worktrees\n+\t! test_path_is_dir .git/worktrees/def &&\n+\t! test_path_is_dir .git/worktrees\n '\n \n test_expect_success SANITY 'prune directories with unreadable gitdir' '\n@@ -47,8 +47,8 @@ test_expect_success SANITY 'prune directories with unreadable gitdir' '\n \tchmod u-r .git/worktrees/def/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_grep \"Removing worktrees/def: unable to read gitdir file\" actual &&\n-\t! test -d .git/worktrees/def &&\n-\t! test -d .git/worktrees\n+\t! test_path_is_dir .git/worktrees/def &&\n+\t! test_path_is_dir .git/worktrees\n '\n \n test_expect_success 'prune directories with invalid gitdir' '\n@@ -57,8 +57,8 @@ test_expect_success 'prune directories with invalid gitdir' '\n \t: >.git/worktrees/def/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_grep \"Removing worktrees/def: invalid gitdir file\" actual &&\n-\t! test -d .git/worktrees/def &&\n-\t! test -d .git/worktrees\n+\t! test_path_is_dir .git/worktrees/def &&\n+\t! test_path_is_dir .git/worktrees\n '\n \n test_expect_success 'prune directories with gitdir pointing to nowhere' '\n@@ -67,8 +67,8 @@ test_expect_success 'prune directories with gitdir pointing to nowhere' '\n \techo \"$(pwd)\"/nowhere >.git/worktrees/def/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_grep \"Removing worktrees/def: gitdir file points to non-existent location\" actual &&\n-\t! test -d .git/worktrees/def &&\n-\t! test -d .git/worktrees\n+\t! test_path_is_dir .git/worktrees/def &&\n+\t! test_path_is_dir .git/worktrees\n '\n \n test_expect_success 'not prune locked checkout' '\n@@ -76,23 +76,23 @@ test_expect_success 'not prune locked checkout' '\n \tmkdir -p .git/worktrees/ghi &&\n \t: >.git/worktrees/ghi/locked &&\n \tgit worktree prune &&\n-\ttest -d .git/worktrees/ghi\n+\ttest_path_is_dir .git/worktrees/ghi\n '\n \n test_expect_success 'not prune recent checkouts' '\n \ttest_when_finished rm -r .git/worktrees &&\n \tgit worktree add jlm HEAD &&\n-\ttest -d .git/worktrees/jlm &&\n+\ttest_path_is_dir .git/worktrees/jlm &&\n \trm -rf jlm &&\n \tgit worktree prune --verbose --expire=2.days.ago &&\n-\ttest -d .git/worktrees/jlm\n+\ttest_path_is_dir .git/worktrees/jlm\n '\n \n test_expect_success 'not prune proper checkouts' '\n \ttest_when_finished rm -r .git/worktrees &&\n \tgit worktree add --detach \"$PWD/nop\" main &&\n \tgit worktree prune &&\n-\ttest -d .git/worktrees/nop\n+\ttest_path_is_dir .git/worktrees/nop\n '\n \n test_expect_success 'prune duplicate (linked/linked)' '\n@@ -103,8 +103,8 @@ test_expect_success 'prune duplicate (linked/linked)' '\n \tmv .git/worktrees/w2/gitdir.new .git/worktrees/w2/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_grep \"duplicate entry\" actual &&\n-\ttest -d .git/worktrees/w1 &&\n-\t! test -d .git/worktrees/w2\n+\ttest_path_is_dir .git/worktrees/w1 &&\n+\t! test_path_is_dir .git/worktrees/w2\n '\n \n test_expect_success 'prune duplicate (main/linked)' '\n@@ -116,7 +116,7 @@ test_expect_success 'prune duplicate (main/linked)' '\n \tmv repo wt &&\n \tgit -C wt worktree prune --verbose 2>actual &&\n \ttest_grep \"duplicate entry\" actual &&\n-\t! test -d .git/worktrees/wt\n+\t! test_path_is_dir .git/worktrees/wt\n '\n \n test_expect_success 'not prune proper worktrees inside linked worktree with relative paths' '\n-- \n2.34.1\n\n"},{"id":"528750","messageId":"xmqqa51txs66.fsf@gitster.g","threadId":"64320","inReplyTo":"20251014161446.6135-1-solobarine@gmail.com","subject":"Re: [PATCH 1/1] t: update path checks using test_path helpers","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-14T18:19:13Z","receivedAt":"2025-10-14T18:19:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Solly <solobarine@gmail.com> writes:\n\n> Subject: Re: [PATCH 1/1] t: update path checks using test_path helpers\n\nUsing \"t2401:\" instead of \"t:\" would give you a bit more\ninformation.\n\n> Update old-style shell path checks to use the modern test\n> helpers 'test_path_is_file' and 'test_path_is_dir' for improved\n> readability.\n\nThis gives a wrong justification.\n\nFor readability, \"test -f tested-file\" is plenty readable.  The\npoint of using test_path_is_file and its friends is to get better\nruntime diagnosis.\n\nRead the helper you are using and understand what it does and why it\ndoes it (they are found in t/test-lib-functions.sh):\n\n        # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n        # The commands test the existence or non-existence of $1\n        test_path_is_file () {\n                test \"$#\" -ne 1 && BUG \"1 param\"\n                if ! test -f \"$1\"\n                then\n                        echo \"File $1 doesn't exist\"\n                        false\n                fi\n        }\n\nAnd imagine you wrote your test using this, perhaps like this:\n\n        test_expect_success 'ensure hello.c exists' '\n\t\ttest_path_is_file hello.c\n        '\n\nWhat happens when (1) hello.c does exist and (2) hello.c does not\nexist?  If hello.c exists, \"if ! test -f\" fails, and the control\ndoes not go inside of \"then\" part, hence the helper will succeed\nsilently.  If hello.c does not exist, it will say \"File hello.c\ndoesn't exist\".  The person who is running the test will be told why\nthe test failed (and the helper fails because it runs the 'false'\nafter giving the message).  And that is the value these helpers\noffer.\n\nArmed with that knowledge, you can tell that ...\n\n>  \ttest_cmp expect actual &&\n> -\t! test -f .git/worktrees/abc &&\n> -\t! test -d .git/worktrees\n> +\t! test_path_is_file .git/worktrees/abc &&\n> +\t! test_path_is_dir .git/worktrees\n\n... this is a bad rewrite, right?  The original wants to ensure that\na file .git/worktrees/abc does not exist.  You want the test to\nbe silent when the path is not a file (i.e. \"as expected, nothing\ninteresting to see here\"), and complain loudly when it *is* a file.\n\nAnd your \"! test_path_is_file .git/worktrees/abc\" would not do that,\nwould it?  They report loudly in a wrong case!\n\nIn this case, both of them should probably become\n\n\ttest_path_is_missing .git/worktrees/abc &&\n\ttest_path_is_missing .git/worktrees\n\nbecause the _intent_ of the test is NOT that it would be happy as\nlong as .git/worktrees/abc is not a file.  Even though the original\nuses \"! test -f\", seeing a .git/worktrees/abc directory there is an\nunexpected outcome of the test (you need to read what is being\ntested to fully understand this kind of thing).\n\nHope this helps.\n"},{"id":"528751","messageId":"CAPSxiM9Ovkoa18gY=0+5cCHukz6Ah56Q6wLwV-7Hbs0MeWjVng@mail.gmail.com","threadId":"64320","inReplyTo":"xmqqa51txs66.fsf@gitster.g","subject":"Re: [PATCH 1/1] t: update path checks using test_path helpers","fromName":"Usman Akinyemi","fromEmail":"usmanakinyemi202@gmail.com","sentAt":"2025-10-14T18:27:15Z","receivedAt":"2025-10-14T18:27:27Z","isPatch":true,"sender":{"key":"usmanakinyemi202@gmail.com","avatar":"https://avatars.githubusercontent.com/u/86585626?v=4"},"body":"> Hope this helps.\n>\nThanks Junio for the review.\n\nI was on this before the email entered.\n\nSolomon, in addition to this you might also\nwant to check similar review done by Junio and Eric in [1]\n\n[1]: https://public-inbox.org/git/CAPig+cRfO8t1tdCL6MB4b9XopF3HkZ==hU83AFZ38b-2zsXDjQ@mail.gmail.com/\n"},{"id":"528752","messageId":"CAPig+cRKf9r3UFh9ib19wMe2gF0=0Lhjb6WqCsZ0KMjV2Co0cg@mail.gmail.com","threadId":"64320","inReplyTo":"CAPSxiM9Ovkoa18gY=0+5cCHukz6Ah56Q6wLwV-7Hbs0MeWjVng@mail.gmail.com","subject":"Re: [PATCH 1/1] t: update path checks using test_path helpers","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-10-14T18:47:16Z","receivedAt":"2025-10-14T18:47:28Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Oct 14, 2025 at 2:27 PM Usman Akinyemi\n<usmanakinyemi202@gmail.com> wrote:\n> Thanks Junio for the review.\n>\n> I was on this before the email entered.\n>\n> Solomon, in addition to this you might also\n> want to check similar review done by Junio and Eric in [1]\n>\n> [1]: https://public-inbox.org/git/CAPig+cRfO8t1tdCL6MB4b9XopF3HkZ==hU83AFZ38b-2zsXDjQ@mail.gmail.com/\n\nThanks Junio for saying what I was going to say. And thanks Usman for\ndigging up the link to this previous review, thus saving me the effort\nof doing so.\n\nFor what it's worth, these days, I think we usually point people at\nthe lore.kernel.org archive rather than public-inbox.org, so the two\nreviews in questions can be found at [1] and [2].\n\n[1]: https://lore.kernel.org/git/CAPig+cRfO8t1tdCL6MB4b9XopF3HkZ==hU83AFZ38b-2zsXDjQ@mail.gmail.com/\n[2]: https://lore.kernel.org/git/xmqqwmqm8rmr.fsf@gitster.g/\n"},{"id":"528814","messageId":"20251015140329.13691-1-solobarine@gmail.com","threadId":"64320","inReplyTo":"20251014161446.6135-1-solobarine@gmail.com","subject":"[PATCH v2 0/1] *** t2401: update path checks using test_path helpers ***","fromName":"Solly","fromEmail":"solobarine@gmail.com","sentAt":"2025-10-15T14:03:28Z","receivedAt":"2025-10-15T14:03:53Z","isPatch":true,"sender":{"key":"solobarine@gmail.com","avatar":"https://avatars.githubusercontent.com/u/105935114?v=4"},"body":"*** \nThank you for the timely review.\nI applied the corrections and resolved the issues highlighted\nin the initial patch and used the appropriate test_helpers. \n***\n\nSolly (1):\n  t2401: update path checks using test_path helpers\n\n t/t2401-worktree-prune.sh | 34 +++++++++++++++++-----------------\n 1 file changed, 17 insertions(+), 17 deletions(-)\n\n\nbase-commit: 60f3f52f17cceefa5299709b189ce6fe2d181e7b\n-- \n2.34.1\n\n"},{"id":"528815","messageId":"20251015140329.13691-2-solobarine@gmail.com","threadId":"64320","inReplyTo":"20251015140329.13691-1-solobarine@gmail.com","subject":"[PATCH v2 1/1] t2401: update path checks using test_path helpers","fromName":"Solly","fromEmail":"solobarine@gmail.com","sentAt":"2025-10-15T14:03:29Z","receivedAt":"2025-10-15T14:03:59Z","isPatch":true,"sender":{"key":"solobarine@gmail.com","avatar":"https://avatars.githubusercontent.com/u/105935114?v=4"},"body":"Update old-style shell path checks to use the modern test\nhelpers 'test_path_is_file' and 'test_path_is_dir' for improved\nruntime diagnosis.\n\nSigned-off-by: Solly <solobarine@gmail.com>\n---\n t/t2401-worktree-prune.sh | 34 +++++++++++++++++-----------------\n 1 file changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh\nindex fe671d4197..f8f28c76ee 100755\n--- a/t/t2401-worktree-prune.sh\n+++ b/t/t2401-worktree-prune.sh\n@@ -24,8 +24,8 @@ test_expect_success 'prune files inside $GIT_DIR/worktrees' '\n Removing worktrees/abc: not a valid directory\n EOF\n \ttest_cmp expect actual &&\n-\t! test -f .git/worktrees/abc &&\n-\t! test -d .git/worktrees\n+\ttest_path_is_missing .git/worktrees/abc &&\n+\ttest_path_is_missing .git/worktrees\n '\n \n test_expect_success 'prune directories without gitdir' '\n@@ -36,8 +36,8 @@ Removing worktrees/def: gitdir file does not exist\n EOF\n \tgit worktree prune --verbose 2>actual &&\n \ttest_cmp expect actual &&\n-\t! test -d .git/worktrees/def &&\n-\t! test -d .git/worktrees\n+\ttest_path_is_missing .git/worktrees/def &&\n+\ttest_path_is_missing .git/worktrees\n '\n \n test_expect_success SANITY 'prune directories with unreadable gitdir' '\n@@ -47,8 +47,8 @@ test_expect_success SANITY 'prune directories with unreadable gitdir' '\n \tchmod u-r .git/worktrees/def/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_grep \"Removing worktrees/def: unable to read gitdir file\" actual &&\n-\t! test -d .git/worktrees/def &&\n-\t! test -d .git/worktrees\n+\ttest_path_is_missing .git/worktrees/def &&\n+\ttest_path_is_missing .git/worktrees\n '\n \n test_expect_success 'prune directories with invalid gitdir' '\n@@ -57,8 +57,8 @@ test_expect_success 'prune directories with invalid gitdir' '\n \t: >.git/worktrees/def/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_grep \"Removing worktrees/def: invalid gitdir file\" actual &&\n-\t! test -d .git/worktrees/def &&\n-\t! test -d .git/worktrees\n+\ttest_path_is_missing .git/worktrees/def &&\n+\ttest_path_is_missing .git/worktrees\n '\n \n test_expect_success 'prune directories with gitdir pointing to nowhere' '\n@@ -67,8 +67,8 @@ test_expect_success 'prune directories with gitdir pointing to nowhere' '\n \techo \"$(pwd)\"/nowhere >.git/worktrees/def/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_grep \"Removing worktrees/def: gitdir file points to non-existent location\" actual &&\n-\t! test -d .git/worktrees/def &&\n-\t! test -d .git/worktrees\n+\ttest_path_is_missing .git/worktrees/def &&\n+\ttest_path_is_missing .git/worktrees\n '\n \n test_expect_success 'not prune locked checkout' '\n@@ -76,23 +76,23 @@ test_expect_success 'not prune locked checkout' '\n \tmkdir -p .git/worktrees/ghi &&\n \t: >.git/worktrees/ghi/locked &&\n \tgit worktree prune &&\n-\ttest -d .git/worktrees/ghi\n+\ttest_path_is_dir .git/worktrees/ghi\n '\n \n test_expect_success 'not prune recent checkouts' '\n \ttest_when_finished rm -r .git/worktrees &&\n \tgit worktree add jlm HEAD &&\n-\ttest -d .git/worktrees/jlm &&\n+\ttest_path_is_dir .git/worktrees/jlm &&\n \trm -rf jlm &&\n \tgit worktree prune --verbose --expire=2.days.ago &&\n-\ttest -d .git/worktrees/jlm\n+\ttest_path_is_dir .git/worktrees/jlm\n '\n \n test_expect_success 'not prune proper checkouts' '\n \ttest_when_finished rm -r .git/worktrees &&\n \tgit worktree add --detach \"$PWD/nop\" main &&\n \tgit worktree prune &&\n-\ttest -d .git/worktrees/nop\n+\ttest_path_is_dir .git/worktrees/nop\n '\n \n test_expect_success 'prune duplicate (linked/linked)' '\n@@ -103,8 +103,8 @@ test_expect_success 'prune duplicate (linked/linked)' '\n \tmv .git/worktrees/w2/gitdir.new .git/worktrees/w2/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_grep \"duplicate entry\" actual &&\n-\ttest -d .git/worktrees/w1 &&\n-\t! test -d .git/worktrees/w2\n+\ttest_path_is_dir .git/worktrees/w1 &&\n+\ttest_path_is_missing .git/worktrees/w2\n '\n \n test_expect_success 'prune duplicate (main/linked)' '\n@@ -116,7 +116,7 @@ test_expect_success 'prune duplicate (main/linked)' '\n \tmv repo wt &&\n \tgit -C wt worktree prune --verbose 2>actual &&\n \ttest_grep \"duplicate entry\" actual &&\n-\t! test -d .git/worktrees/wt\n+\ttest_path_is_missing .git/worktrees/wt\n '\n \n test_expect_success 'not prune proper worktrees inside linked worktree with relative paths' '\n-- \n2.34.1\n\n"},{"id":"528832","messageId":"xmqqikgfuchy.fsf@gitster.g","threadId":"64320","inReplyTo":"20251015140329.13691-2-solobarine@gmail.com","subject":"Re: [PATCH v2 1/1] t2401: update path checks using test_path helpers","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-15T20:38:17Z","receivedAt":"2025-10-15T20:38:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Solly <solobarine@gmail.com> writes:\n\n> Update old-style shell path checks to use the modern test\n> helpers 'test_path_is_file' and 'test_path_is_dir' for improved\n> runtime diagnosis.\n>\n> Signed-off-by: Solly <solobarine@gmail.com>\n> ---\n>  t/t2401-worktree-prune.sh | 34 +++++++++++++++++-----------------\n>  1 file changed, 17 insertions(+), 17 deletions(-)\n\nLooks good.  Will queue.  Thanks.\n"}]}