# [PATCH] t0200: replace 'test -d' with 'test_path_is_dir' and 'test -f' with 'test_path_is_file'

3 messages from 2025-06-03 to 2025-06-18. Participants: Derick W. de M. Frias, Patrick Steinhardt.
Thread: https://gitlist.dev/t/63569

## Derick W. de M. Frias, 2025-06-03 05:20

Subject: [PATCH] t0200: replace 'test -d' with 'test_path_is_dir' and 'test -f' with 'test_path_is_file'
Message-ID: <20250603053137.66249-1-derick.william.moraes@gmail.com>
URL: https://gitlist.dev/e/20250603053137.66249-1-derick.william.moraes%40gmail.com

```
From: DerickWMFrias <derick.william.moraes@gmail.com>

'test_path_is_file' and 'test_path_is_dir' are modern path checking
methods in Git's development.

This patch replaces old 'test -d' and 'test -f' methods with them.

Signed-off-by: Derick W. de M. Frias <derick.william.moraes@gmail.com>
---
 t/t0200-gettext-basic.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t0200-gettext-basic.sh b/t/t0200-gettext-basic.sh
index 8853d8afb9..89d0899a5b 100755
--- a/t/t0200-gettext-basic.sh
+++ b/t/t0200-gettext-basic.sh
@@ -31,12 +31,12 @@ test_expect_success 'xgettext sanity: Comment extraction with --add-comments sto
 '
 
 test_expect_success GETTEXT 'sanity: $TEXTDOMAINDIR exists without NO_GETTEXT=YesPlease' '
-    test -d "$TEXTDOMAINDIR" &&
+    test_path_is_dir "$TEXTDOMAINDIR" &&
     test "$TEXTDOMAINDIR" = "$GIT_TEXTDOMAINDIR"
 '
 
 test_expect_success GETTEXT 'sanity: Icelandic locale was compiled' '
-    test -f "$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo"
+    test_path_is_file "$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo"
 '
 
 # TODO: When we have more locales, generalize this to test them
-- 
2.49.0.634.g8613c2bb6c.dirty


```

## Patrick Steinhardt, 2025-06-03 06:16

Subject: Re: [PATCH] t0200: replace 'test -d' with 'test_path_is_dir' and 'test -f' with 'test_path_is_file'
Message-ID: <aD6TJLuuaZmiFUvZ@pks.im>
URL: https://gitlist.dev/e/aD6TJLuuaZmiFUvZ%40pks.im
In-Reply-To: <20250603053137.66249-1-derick.william.moraes@gmail.com>

```
On Tue, Jun 03, 2025 at 02:20:28AM -0300, Derick W. de M. Frias wrote:
> From: DerickWMFrias <derick.william.moraes@gmail.com>

There is a mismatch between your name here (which would be applied as
the patch author) and the Signed-off-by. These two should match.

> 'test_path_is_file' and 'test_path_is_dir' are modern path checking
> methods in Git's development.

We typically want to provide enough context in commit messages to state
_why_ the replacement is better. Them being more "modern" isn't yet a
sufficiently good reason. So it would be great if we explicitly mention
what the replacements bring to the table in a sentence or two.

> This patch replaces old 'test -d' and 'test -f' methods with them.

We use imperative style for commit messages, as if instructing the code
to change. So instead of saying "This patch replaces", we'd say
"Replace `test -d` and `test -f` ...".

The patch itself looks obviously good to me, thanks!

Patrick

```

## Derick W. de M. Frias, 2025-06-18 18:31

Subject: [PATCH v2] t0200: replace 'test -d' with 'test_path_is_dir' and 'test -f' with 'test_path_is_file'
Message-ID: <20250618183754.108821-1-derick.william.moraes@gmail.com>
URL: https://gitlist.dev/e/20250618183754.108821-1-derick.william.moraes%40gmail.com
In-Reply-To: <aD6TJLuuaZmiFUvZ@pks.im>

```
Thanks for your feedback Patrick. I'm resending the patch with your
suggestions.

'test_path_is_file' and 'test_path_is_dir' are modern debbuging-friendly
path checking methods in Git's development that output useful messages
when the test fails, unlike 'test -f' and 'test -d' that don't provide 
feedback.

Replace 'test -d' and 'test -f' methods with 'test_path_is_dir' and
'test_path_is_file'.

Signed-off-by: Derick W. de M. Frias <derick.william.moraes@gmail.com>
---
 t/t0200-gettext-basic.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t0200-gettext-basic.sh b/t/t0200-gettext-basic.sh
index 8853d8afb9..89d0899a5b 100755
--- a/t/t0200-gettext-basic.sh
+++ b/t/t0200-gettext-basic.sh
@@ -31,12 +31,12 @@ test_expect_success 'xgettext sanity: Comment extraction with --add-comments sto
 '
 
 test_expect_success GETTEXT 'sanity: $TEXTDOMAINDIR exists without NO_GETTEXT=YesPlease' '
-    test -d "$TEXTDOMAINDIR" &&
+    test_path_is_dir "$TEXTDOMAINDIR" &&
     test "$TEXTDOMAINDIR" = "$GIT_TEXTDOMAINDIR"
 '
 
 test_expect_success GETTEXT 'sanity: Icelandic locale was compiled' '
-    test -f "$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo"
+    test_path_is_file "$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo"
 '
 
 # TODO: When we have more locales, generalize this to test them
-- 
2.50.0.rc0.62.g658f0ae201.dirty


```
