git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t5301: use test_path_is_file instead of test -f

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 21, 2026, 16:00 UTC
Message-ID
<xmqqse1zqc05.fsf@gitster.g>
In-Reply-To
<pull.2269.git.1792488388022.gitgitgadget@gmail.com>
"Roger Koranteng via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 27 quoted lines
> From: Roger Koranteng <rogerkorantenng@gmail.com>
>
> Replace raw 'test -f' assertions with the 'test_path_is_file' helper,
> which gives diagnostic output when the assertion fails.
>
> Signed-off-by: Roger Koranteng <rogerkorantenng@gmail.com>
> ---
>     t5301: use test_path_is_file instead of test -f
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2269%2Frogerkorantenng%2Ft5301-modernize-path-checks-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2269/rogerkorantenng/t5301-modernize-path-checks-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/2269
>
>  t/t5301-sliding-window.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh
> index 3c3666b278..b6868229bf 100755
> --- a/t/t5301-sliding-window.sh
> +++ b/t/t5301-sliding-window.sh
> @@ -22,7 +22,7 @@ test_expect_success 'setup' '
>  	git repack -a -d &&
>  	test "$(git count-objects)" = "0 objects, 0 kilobytes" &&
>  	pack1=$(ls .git/objects/pack/*.pack) &&
> -	test -f "$pack1"
> +	test_path_is_file "$pack1"
>  '
OK.
Show 7 quoted lines
>  test_expect_success 'verify-pack -v, defaults' '
> @@ -48,7 +48,7 @@ test_expect_success 'repack -a -d, packedGit{WindowSize,Limit} == 1 page' '
>  	git repack -a -d &&
>  	test "$(git count-objects)" = "0 objects, 0 kilobytes" &&
>  	pack2=$(ls .git/objects/pack/*.pack) &&
> -	test -f "$pack2" &&
> +	test_path_is_file "$pack2" &&
OK.
>  	test "$pack1" \!= "$pack2"
>  '

This is an existing wart but we shouldn't quote letters that we do not have to quote like this. It gives a wrong hint to readers that something fishy might be going on and distracts them. We may want to have a separate job to find warts in tests similar to this one and eradicate them all, but that is totally outside the scope of this patch.

Looking good to me.
Previous: Roger Koranteng via GitGitGadget
Message 2 of 2 in “t5301: use test_path_is_file instead of test -f”
  1. t5301: use test_path_is_file instead of test -fRoger Koranteng via GitGitGadget, Oct 20, 2026
  2. Junio C HamanoOct 21, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.