From: Junio C Hamano <gitster@pobox.com>
To: Tanishq Singh via B4 Relay <devnull+hello.tanishqsingh.com@kernel.org>
Cc: git@vger.kernel.org, Elijah Newren <newren@gmail.com>,
Tanishq Singh <hello@tanishqsingh.com>
Subject: Re: [PATCH] t7610: use test_path_is_* helpers
Date: Mon, 14 Sep 2026 08:42:56 -0700 [thread overview]
Message-ID: <xmqqy0d36dq7.fsf@gitster.g> (raw)
In-Reply-To: <20260914-t7610-test-path-helpers-v1-1-4824812314c7@tanishqsingh.com> (Tanishq Singh via's message of "Mon, 14 Sep 2026 20:19:48 +0530")
Tanishq Singh via B4 Relay
<devnull+hello.tanishqsingh.com@kernel.org> writes:
> echo d | git mergetool a/a/file.txt &&
> - ! test -f a/a/file.txt &&
> + ! test_path_is_file a/a/file.txt &&
This is wrong. Consider why you would prefer test_path_is_file()
over test -f in the first place.
The goal is to be much louder when the expectation is not met,
while remaining as silent as test -f in the happy case. This grabs
the attention of those running tests. We want to be loud when
things break, and silent otherwise.
test_path_is_file() expects file X to exist and will not complain
when X is a file.
However, the test "! test -f a/a/file.txt" in this case expects
something totally different. It ensures that such a path does not
exist. It is an error if a/a/file.txt exists here. You want the
helper to be loud when the file exists, and silent when it does not.
test_path_is_file() called on a/a/file.txt, with or without a
leading !, behaves incorrectly for the purpose of this conversion,
even though the polarity of the returned status may be correct
(i.e., test_path_is_file(), just like test -f, exits with status 0
when the file a/a/file.txt exists, and a leading ! negates it,
making the test line fail when a/a/file.txt exists).
If the expectation is that a/a/file.txt does not exist, use
test_path_is_missing(). Please read through t/test-lib.sh and
t/test-lib-functions.sh to familiarize yourself with the helpers
these files offer before going further.
Thanks.
prev parent reply other threads:[~2026-09-14 15:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 14:49 [PATCH] t7610: use test_path_is_* helpers Tanishq Singh via B4 Relay
2026-09-14 14:49 ` Tanishq Singh
2026-09-14 15:42 ` Junio C Hamano [this message]
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=xmqqy0d36dq7.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=devnull+hello.tanishqsingh.com@kernel.org \
--cc=git@vger.kernel.org \
--cc=hello@tanishqsingh.com \
--cc=newren@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.