From: Junio C Hamano <gitster@pobox.com>
To: "Štěpán Němec" <stepnem@smrk.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] test-lib: make sure TEST_DIRECTORY has no trailing slash
Date: Tue, 03 Oct 2023 14:57:39 -0700 [thread overview]
Message-ID: <xmqqjzs3wer0.fsf@gitster.g> (raw)
In-Reply-To: <xmqqwmw3wgeo.fsf@gitster.g> (Junio C. Hamano's message of "Tue, 03 Oct 2023 14:21:51 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> I wonder if this would be a safer alternative, or is it doing too
> much more than what is necessary?
An alternative with much smaller blast radius would be to do this.
Hopefully, by going "$(pwd)/." before asking the value returned by
the `pwd` command, we can make sure that the trailing slash is
removed (or at least $(pwd) and $TEST_DIRECTORY should be identical
after this is done).
t/test-lib.sh | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git c/t/test-lib.sh w/t/test-lib.sh
index 1656c9eed0..d159358b21 100644
--- c/t/test-lib.sh
+++ w/t/test-lib.sh
@@ -19,9 +19,13 @@
# t/ subdirectory and are run in 'trash directory' subdirectory.
if test -z "$TEST_DIRECTORY"
then
- # ensure that TEST_DIRECTORY is an absolute path so that it
+ # Ensure that TEST_DIRECTORY is an absolute path so that it
# is valid even if the current working directory is changed
- TEST_DIRECTORY=$(pwd)
+ # Some environments can talk the shell into keeping trailing
+ # slash in $PWD---go there and ask where we are to work it
+ # around, as we expect TEST_DIRECTORY and PWD are both
+ # canonical and can textually be compared for equality
+ TEST_DIRECTORY=$(cd "$(pwd)/." && pwd)
else
# The TEST_DIRECTORY will always be the path to the "t"
# directory in the git.git checkout. This is overridden by
next prev parent reply other threads:[~2023-10-03 21:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-03 8:23 [PATCH] test-lib: make sure TEST_DIRECTORY has no trailing slash Štěpán Němec
2023-10-03 21:21 ` Junio C Hamano
2023-10-03 21:57 ` Junio C Hamano [this message]
2023-10-04 9:34 ` Štěpán Němec
2023-10-04 16:19 ` Junio C Hamano
2023-10-04 17:01 ` Štěpán Němec
2023-10-04 17:15 ` Junio C Hamano
2023-10-04 17:40 ` Štěpán Němec
2023-10-04 18:24 ` 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=xmqqjzs3wer0.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=stepnem@smrk.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).