# [PATCH] t1001: replace 'test -f' with 'test_path_is_file'

2 messages from 2025-05-10 to 2025-05-12. Participants: Rodrigo Carvalho, Junio C Hamano.
Thread: https://gitlist.dev/t/63438

## Rodrigo Carvalho, 2025-05-10 23:09

Subject: [PATCH] t1001: replace 'test -f' with 'test_path_is_file'
Message-ID: <20250510230909.65519-1-rodrigorsdc@gmail.com>
URL: https://gitlist.dev/e/20250510230909.65519-1-rodrigorsdc%40gmail.com

```
'test_path_is_file' is a modern path checking method in Git's development.
 Replace the basic shell command 'test -f' with this approach.

Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>
---
 t/t1001-read-tree-m-2way.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
index 4a88bb9ef0..2e8d9384e1 100755
--- a/t/t1001-read-tree-m-2way.sh
+++ b/t/t1001-read-tree-m-2way.sh
@@ -362,7 +362,7 @@ test_expect_success 'a/b (untracked) vs a case setup.' '
 test_expect_success 'a/b (untracked) vs a, plus c/d case test.' '
 	read_tree_u_must_fail -u -m "$treeH" "$treeM" &&
 	git ls-files --stage &&
-	test -f a/b
+	test_path_is_file a/b
 '
 
 test_expect_success 'read-tree supports the super-prefix' '
-- 
2.43.0


```

## Junio C Hamano, 2025-05-12 17:09

Subject: Re: [PATCH] t1001: replace 'test -f' with 'test_path_is_file'
Message-ID: <xmqqldr1u56w.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqldr1u56w.fsf%40gitster.g
In-Reply-To: <20250510230909.65519-1-rodrigorsdc@gmail.com>

```
Rodrigo Carvalho <rodrigorsdc@gmail.com> writes:

> 'test_path_is_file' is a modern path checking method in Git's development.
>  Replace the basic shell command 'test -f' with this approach.
>
> Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>
> ---
>  t/t1001-read-tree-m-2way.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
> index 4a88bb9ef0..2e8d9384e1 100755
> --- a/t/t1001-read-tree-m-2way.sh
> +++ b/t/t1001-read-tree-m-2way.sh
> @@ -362,7 +362,7 @@ test_expect_success 'a/b (untracked) vs a case setup.' '
>  test_expect_success 'a/b (untracked) vs a, plus c/d case test.' '
>  	read_tree_u_must_fail -u -m "$treeH" "$treeM" &&
>  	git ls-files --stage &&
> -	test -f a/b
> +	test_path_is_file a/b
>  '

Obviously correct conversion.

This is an ancient part of the system, started before we even had a
"git checkout" rewritten as a single command, so it is not
surprising if it had quite a lot of antiquities and debugging
statement without much effect, which may be subject to further
clean-up.

Thanks, will queue.


```
