Thread (2 messages) flat view 2 messages, 2 authors, 5d ago

Re: [PATCH] t7610: use test_path_is_* helpers

From: Junio C Hamano <hidden>
Date: 2026-09-14 15:42:59

Tanishq Singh via B4 Relay
[off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help