From: Junio C Hamano <gitster@pobox.com>
To: SoutrikDas <valusoutrik@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [GSOC PATCH] t7003: modernize path existence checks using test helpers
Date: Mon, 09 Feb 2026 10:11:14 -0800 [thread overview]
Message-ID: <xmqqpl6d4wjh.fsf@gitster.g> (raw)
In-Reply-To: <20260209172445.39536-1-valusoutrik@gmail.com> (SoutrikDas's message of "Mon, 9 Feb 2026 22:54:45 +0530")
SoutrikDas <valusoutrik@gmail.com> writes:
> Replace direct uses of 'test -f' and 'test -d' with
> git's helper functions 'test_path_is_file' ,
> 'test_path_is_missing' and 'test_path_is_dir'
>
> Signed-off-by: SoutrikDas <valusoutrik@gmail.com>
> ---
> t/t7003-filter-branch.sh | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
> index 5ab4d41ee7..c475769858 100755
> --- a/t/t7003-filter-branch.sh
> +++ b/t/t7003-filter-branch.sh
> @@ -92,8 +92,8 @@ test_expect_success 'rewrite, renaming a specific file' '
>
> test_expect_success 'test that the file was renamed' '
> test D = "$(git show HEAD:doh --)" &&
> - ! test -f D.t &&
> - test -f doh &&
> + test_path_is_missing D.t &&
> + test_path_is_file doh &&
> test D = "$(cat doh)"
> '
> @@ -103,10 +103,10 @@ test_expect_success 'rewrite, renaming a specific directory' '
>
> test_expect_success 'test that the directory was renamed' '
> test dir/D = "$(git show HEAD:diroh/D.t --)" &&
> - ! test -d dir &&
> - test -d diroh &&
> - ! test -d diroh/dir &&
> - test -f diroh/D.t &&
> + test_path_is_missing dir &&
> + test_path_is_dir diroh &&
> + test_path_is_missing diroh/dir &&
> + test_path_is_file diroh/D.t &&
> test dir/D = "$(cat diroh/D.t)"
> '
All the checks involving "is-missing" are now stricter than the
original, in that they used to allow "dir" to exist as long as it is
not a directory, etc., but if we audited the code that leads to
these tests can never create a "dir" that is a regular file or
something that is not a directory (which *I* did *NOT*, but
presumably you have already done so?---if so that is worth noting in
the proposed log message), then "test ! -d dir" that is rewritten to
"test_path_is_missing dir" is actually a _better_ test.
Thanks.
next prev parent reply other threads:[~2026-02-09 18:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 17:24 [GSOC PATCH] t7003: modernize path existence checks using test helpers SoutrikDas
2026-02-09 18:11 ` Junio C Hamano [this message]
2026-02-10 18:14 ` SoutrikDas
2026-02-10 18:41 ` [GSOC PATCH v2] " SoutrikDas
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=xmqqpl6d4wjh.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=valusoutrik@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.