public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Toon Claes <toon@iotcl•com>
To: Junio C Hamano <gitster@pobox•com>
Cc: Patrick Steinhardt <ps@pks•im>,
	Eric Sunshine <sunshine@sunshineco•com>,
	git@vger•kernel.org
Subject: Re: [PATCH 1/1] builtin/show-ref: treat directory directory as non-existing in --exists
Date: Thu, 18 Jan 2024 09:24:56 +0100	[thread overview]
Message-ID: <87le8nqc73.fsf@iotcl.com> (raw)
In-Reply-To: <xmqqmst3tv7j.fsf@gitster.g>


Junio C Hamano <gitster@pobox•com> writes:

> Yup.  The patch looks good.  Here is what I tentatively queued.
>
> ----- >8 -----
> From: Toon Claes <toon@iotcl•com>
> Date: Wed, 10 Jan 2024 15:15:59 +0100
> Subject: [PATCH] builtin/show-ref: treat directory directory as non-existing
>  in --exists

You have a duplicate "directory" here.

> 9080a7f178 (builtin/show-ref: add new mode to check for reference
> existence, 2023-10-31) added the option --exists to git-show-ref(1).
>
> When you use this option against a ref that doesn't exist, but it is
> a parent directory of an existing ref, you get the following error:
>
>     $ git show-ref --exists refs/heads
>     error: failed to look up reference: Is a directory
>
> when the ref-files backend is in use.  To be more clear to user,
> hide the error about having found a directory.  What matters to the
> user is that the named ref does not exist.  Instead, print the same
> error as when the ref was not found:
>
>     error: reference does not exist
>
> Signed-off-by: Toon Claes <toon@iotcl•com>
> Signed-off-by: Junio C Hamano <gitster@pobox•com>
> ---
>  builtin/show-ref.c  | 2 +-
>  t/t1403-show-ref.sh | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/show-ref.c b/builtin/show-ref.c
> index 7aac525a87..6025ce223d 100644
> --- a/builtin/show-ref.c
> +++ b/builtin/show-ref.c
> @@ -239,7 +239,7 @@ static int cmd_show_ref__exists(const char **refs)
>  	if (refs_read_raw_ref(get_main_ref_store(the_repository), ref,
>  			      &unused_oid, &unused_referent, &unused_type,
>  			      &failure_errno)) {
> -		if (failure_errno == ENOENT) {
> +		if (failure_errno == ENOENT || failure_errno == EISDIR) {
>  			error(_("reference does not exist"));
>  			ret = 2;
>  		} else {
> diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
> index b50ae6fcf1..a8055f7fe1 100755
> --- a/t/t1403-show-ref.sh
> +++ b/t/t1403-show-ref.sh
> @@ -260,9 +260,9 @@ test_expect_success '--exists with non-commit object' '
>
>  test_expect_success '--exists with directory fails with generic error' '
>  	cat >expect <<-EOF &&
> -	error: failed to look up reference: Is a directory
> +	error: reference does not exist
>  	EOF
> -	test_expect_code 1 git show-ref --exists refs/heads 2>err &&
> +	test_expect_code 2 git show-ref --exists refs/heads 2>err &&
>  	test_cmp expect err
>  '

The rest looks all good to me.

--
Toon

  reply	other threads:[~2024-01-18  8:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10 14:15 [PATCH 0/1] Fix error message in git-show-ref(1) --exists Toon Claes
2024-01-10 14:15 ` [PATCH 1/1] builtin/show-ref: treat directory directory as non-existing in --exists Toon Claes
2024-01-10 14:36   ` Eric Sunshine
2024-01-10 15:20     ` Toon Claes
2024-01-17  6:29       ` Patrick Steinhardt
2024-01-17 23:07         ` Junio C Hamano
2024-01-18  8:24           ` Toon Claes [this message]
2024-01-18 19:19             ` Junio C Hamano

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=87le8nqc73.fsf@iotcl.com \
    --to=toon@iotcl$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=ps@pks$(echo .)im \
    --cc=sunshine@sunshineco$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox