All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>, git@vger.kernel.org
Subject: Re: [GSoC] [PATCH 1/1] t0001: replace "test [-d|-f]" with test_path_is_* functions
Date: Fri, 21 Jan 2022 12:49:22 -0800	[thread overview]
Message-ID: <xmqqr190g6gd.fsf@gitster.g> (raw)
In-Reply-To: <Yer/oEZK6TBFSsde@nand.local> (Taylor Blau's message of "Fri, 21 Jan 2022 13:46:56 -0500")

Taylor Blau <me@ttaylorr.com> writes:

>> -	if test -d "$1" && test -f "$1/config" && test -d "$1/refs"
>> +	if test_path_is_dir "$1" && test_path_is_file "$1/config" && test_path_is_dir "$1/refs"
>>  	then
>>  		: happy
>>  	else
>
> Looks very reasonable to me. Indeed, this line comes from 6adcca3fe8
> (Fix initialization of a bare repository, 2007-08-27) which predates
> 2caf20c52b (test-lib: user-friendly alternatives to test [-d|-f|-e],
> 2010-08-10) when these helpers were originally introduced.
>
> I thought that we could probably just shorten this to calling
> "test_path_is_file" twice: once for "$1/config" and a second time for
> "$1/refs", but that assumes "$1" is non-empty. And to ensure that you'd
> need another check, which amounts to the same amount of code overall.

I had the same thought.

Since the first "$GIT_DIR must be a directory" matters only when the
caller is crazy enough to have a bare repository at the root of the
filesystem and to think that it is a good idea to say "" is the
"$GIT_DIR" (in which case, "test -d ''" would fail, even though the
tests for /config and /refs are checking the right thing), I do not
see much downside from omitting the first one, but I think that is
something we need to do _outside_ the topic of this change, which is
purely "modernize, using the helpers we already have, without
changing what we do".



  reply	other threads:[~2022-01-21 20:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21 10:21 [GSoC] [PATCH 0/1] t0001: replace "test [-d|-f]" with test_path_is_* functions Shaoxuan Yuan
2022-01-21 10:21 ` [GSoC] [PATCH 1/1] " Shaoxuan Yuan
2022-01-21 18:46   ` Taylor Blau
2022-01-21 20:49     ` Junio C Hamano [this message]
2022-01-24  5:56       ` Shaoxuan Yuan
2022-02-10  3:11       ` Shaoxuan Yuan
2022-02-10  7:12         ` Junio C Hamano
2022-02-10  7:21           ` Shaoxuan Yuan
2022-02-10 17:23             ` Junio C Hamano
2022-02-11  9:56               ` Shaoxuan Yuan
2022-02-11 16:53                 ` Junio C Hamano
2022-02-14  8:45                 ` Christian Couder
2022-02-14  8:53                   ` Shaoxuan Yuan

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=xmqqr190g6gd.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    --cc=shaoxuan.yuan02@gmail.com \
    /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.