Skip to content

Commit 55292ea

Browse files
René Scharfegitster
authored andcommitted
t5003: check if unzip supports symlinks
Only add a symlink to the repository if both the filesystem and unzip support symlinks. To check the latter, add a ZIP file containing a symlink, created like this with InfoZIP zip 3.0: $ echo sample text >textfile $ ln -s textfile symlink $ zip -y infozip-symlinks.zip textfile symlink If we can extract it successfully, we add a symlink to the test repository for git archive --format=zip, or otherwise skip that step. Users can see the skipped test and perhaps run it again with a different unzip version. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9882c8 commit 55292ea

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

t/t5003-archive-zip.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ test_lazy_prereq UNZIP '
1212
test $? -ne 127
1313
'
1414

15+
test_lazy_prereq UNZIP_SYMLINKS '
16+
(
17+
mkdir unzip-symlinks &&
18+
cd unzip-symlinks &&
19+
"$GIT_UNZIP" "$TEST_DIRECTORY"/t5003/infozip-symlinks.zip &&
20+
test -h symlink
21+
)
22+
'
23+
1524
check_zip() {
1625
zipfile=$1.zip
1726
listfile=$1.lst
@@ -40,15 +49,18 @@ test_expect_success \
4049
cp /bin/sh a/bin &&
4150
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
4251
printf "A not substituted O" >a/substfile2 &&
43-
if test_have_prereq SYMLINKS; then
44-
ln -s a a/l1
45-
else
46-
printf %s a > a/l1
47-
fi &&
4852
(p=long_path_to_a_file && cd a &&
4953
for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
50-
echo text >file_with_long_path) &&
51-
(cd a && find .) | sort >a.lst'
54+
echo text >file_with_long_path)
55+
'
56+
57+
test_expect_success SYMLINKS,UNZIP_SYMLINKS 'add symlink' '
58+
ln -s a a/symlink_to_a
59+
'
60+
61+
test_expect_success 'prepare file list' '
62+
(cd a && find .) | sort >a.lst
63+
'
5264

5365
test_expect_success \
5466
'add ignored file' \

t/t5003/infozip-symlinks.zip

328 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)