All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Mahendra Dani <danimahendra0904@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 1/1] t1403: verify that path exists and is a file
Date: Tue, 4 Mar 2025 12:02:54 +0100	[thread overview]
Message-ID: <Z8bd3iHrhXb4WH6A@pks.im> (raw)
In-Reply-To: <20250304092722.25757-1-danimahendra0904@gmail.com>

On Tue, Mar 04, 2025 at 02:57:22PM +0530, Mahendra Dani wrote:
> test -e does not provide a nice error message when
> we hit test failures, so use test_path_exists() instead
> and verify that if the path exists then it is a file using test_path_is_file().
> 
> Signed-off-by: Mahendra Dani <danimahendra0904@gmail.com>
> ---
>  t/t1403-show-ref.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
> index 9d698b3cc3..4afde01a29 100755
> --- a/t/t1403-show-ref.sh
> +++ b/t/t1403-show-ref.sh
> @@ -196,7 +196,8 @@ test_expect_success 'show-ref --verify with dangling ref' '
>  
>  	remove_object() {
>  		file=$(sha1_file "$*") &&
> -		test -e "$file" &&
> +		test_path_exists "$file" &&
> +		test_path_is_file "$file" &&
>  		rm -f "$file"
>  	} &&

There is no need to execute both functions. The underlying
implementation of these functions use `test -e` and `test -f`,
respectively. The former merely checks whether a path exists, whereas
the latter verifies that the path is a file. It follows that when the
path is a file it also has to exist, so using `test -e` (or rather its
wrapper function `test_path_exists`) is redundant.

Patrick

  reply	other threads:[~2025-03-04 11:03 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-01 10:58 [GSOC][PATCH 0/1] t1403: prefer test_path_exists helper function Mahendra Dani
2025-03-01 10:58 ` [PATCH 1/1] " Mahendra Dani
2025-03-03 10:26   ` Patrick Steinhardt
2025-03-04  2:27     ` Mahendra Dani
2025-03-04 12:05       ` Junio C Hamano
2025-03-04 17:24         ` Mahendra Dani
2025-03-04 17:26           ` Junio C Hamano
2025-03-04 17:35             ` Mahendra Dani
2025-03-04 17:44               ` Junio C Hamano
2025-03-04 17:49                 ` Mahendra Dani
2025-03-04 18:07                   ` Junio C Hamano
2025-03-04 17:35         ` Eric Sunshine
2025-03-04 17:49           ` Junio C Hamano
2025-03-04 18:07             ` Eric Sunshine
2025-03-04 18:28               ` Eric Sunshine
2025-03-04 18:30               ` Junio C Hamano
2025-03-04  9:15 ` [GSOC][PATCH v2 0/1] t1403: verify path exists and is a file Mahendra Dani
2025-03-04  9:41   ` [GSOC][PATCH v3 " Mahendra Dani
2025-03-04  9:41     ` [PATCH v3 1/1] t1403: verify that " Mahendra Dani
2025-03-04 18:05       ` Junio C Hamano
2025-03-04 18:06         ` Junio C Hamano
2025-03-04 18:13           ` Mahendra Dani
2025-03-04 11:23     ` [PATCH v4 0/1] t1403: verify " Mahendra Dani
2025-03-04 11:27     ` Mahendra Dani
2025-03-04 11:27       ` [PATCH v4 1/1] t1403: verify that " Mahendra Dani
2025-03-04 18:13         ` Junio C Hamano
2025-03-04 18:19           ` Mahendra Dani
2025-03-04 16:00     ` [GSOC][PATCH v3 0/1] t1403: verify " Junio C Hamano
2025-03-04  9:27 ` [PATCH v2 1/1] t1403: verify that " Mahendra Dani
2025-03-04 11:02   ` Patrick Steinhardt [this message]
2025-03-04 11:15     ` Mahendra Dani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z8bd3iHrhXb4WH6A@pks.im \
    --to=ps@pks.im \
    --cc=danimahendra0904@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.