Skip to content

Commit 9bf1ac4

Browse files
René Scharfegitster
authored andcommitted
t5000: test long filenames
Add a file with a long name to the test archive in order to check entries with pax extended headers. Also add a check for tar versions that doen't understand this format. Those versions should extract the headers as a regular files. Add code to check_tar() to interpret the path header if present, so that our tests work even with those tar versions. It's important to use the fallback code only if needed to still be able to detect git archive errorously creating pax headers as regular file entries (with a suitable tar version, of course). The archive used to check for pax header support in tar was generated using GNU tar 1.26 and its option --format=pax. Tested successfully on NetBSD 6.1, which has a tar version lacking pax header support. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0a00ee5 commit 9bf1ac4

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

t/t5000-tar-tree.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ GUNZIP=${GUNZIP:-gzip -d}
3030

3131
SUBSTFORMAT=%H%n
3232

33+
test_lazy_prereq TAR_NEEDS_PAX_FALLBACK '
34+
(
35+
mkdir pax &&
36+
cd pax &&
37+
"$TAR" xf "$TEST_DIRECTORY"/t5000/pax.tar &&
38+
test -f PaxHeaders.1791/file
39+
)
40+
'
41+
42+
get_pax_header() {
43+
file=$1
44+
header=$2=
45+
46+
while read len rest
47+
do
48+
if test "$len" = $(echo "$len $rest" | wc -c)
49+
then
50+
case "$rest" in
51+
$header*)
52+
echo "${rest#$header}"
53+
;;
54+
esac
55+
fi
56+
done <"$file"
57+
}
58+
3359
check_tar() {
3460
tarfile=$1.tar
3561
listfile=$1.lst
@@ -40,6 +66,24 @@ check_tar() {
4066
(mkdir $dir && cd $dir && "$TAR" xf -) <$tarfile
4167
'
4268

69+
test_expect_success TAR_NEEDS_PAX_FALLBACK ' interpret pax headers' '
70+
(
71+
cd $dir &&
72+
for header in *.paxheader
73+
do
74+
data=${header%.paxheader}.data &&
75+
if test -h $data -o -e $data
76+
then
77+
path=$(get_pax_header $header path) &&
78+
if test -n "$path"
79+
then
80+
mv "$data" "$path"
81+
fi
82+
fi
83+
done
84+
)
85+
'
86+
4387
test_expect_success ' validate filenames' '
4488
(cd ${dir_with_prefix}a && find .) | sort >$listfile &&
4589
test_cmp a.lst $listfile
@@ -54,6 +98,8 @@ test_expect_success \
5498
'populate workdir' \
5599
'mkdir a &&
56100
echo simple textfile >a/a &&
101+
ten=0123456789 && hundred=$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten &&
102+
echo long filename >a/four$hundred &&
57103
mkdir a/bin &&
58104
cp /bin/sh a/bin &&
59105
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&

t/t5000/pax.tar

10 KB
Binary file not shown.

0 commit comments

Comments
 (0)