Skip to content

Commit 2ffb7d1

Browse files
derrickstoleegitster
authored andcommitted
t5510: replace 'origin' with URL more carefully
The many test_configured_prune tests in t5510-fetch.sh test many combinations of --prune, --prune-tags, and using 'origin' or an explicit URL. Some machinery was introduced in e1790f9 (fetch tests: fetch <url> <spec> as well as fetch [<remote>], 2018-02-09) to replace 'origin' with this explicit URL. This URL is a "file:///" URL for the root of the $TRASH_DIRECTORY. However, if the current build tree has an '@' symbol, the replacement using perl fails. It drops the '@' as well as anything else in that directory name. You can observe this locally by cloning git.git into a "victim@03" directory and running the test script. As we are writing in Perl anyway, pass in the shell variables involved to the script as arguments and perform necessary string transformations inside it, instead of assuming that it is sufficient to enclose the $remote_url variable inside a pair of single quotes. Reported-by: Randall Becker <[email protected]> Original-patch-by: Derrick Stolee <[email protected]> Helped-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5b71c59 commit 2ffb7d1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

t/t5510-fetch.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,11 @@ test_configured_prune_type () {
853853
then
854854
new_cmdline=$cmdline_setup
855855
else
856-
new_cmdline=$(printf "%s" "$cmdline" | perl -pe 's[origin(?!/)]["'"$remote_url"'"]g')
856+
new_cmdline=$(perl -e '
857+
my ($cmdline, $url) = @ARGV;
858+
$cmdline =~ s[origin(?!/)][quotemeta($url)]ge;
859+
print $cmdline;
860+
' -- "$cmdline" "$remote_url")
857861
fi
858862

859863
if test "$fetch_prune_tags" = 'true' ||

0 commit comments

Comments
 (0)