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 <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2013-05-20 11:58:29 +02:00 committed by Junio C Hamano
parent 0a00ee5844
commit 9bf1ac41d2
2 changed files with 46 additions and 0 deletions

View File

@ -30,6 +30,32 @@ GUNZIP=${GUNZIP:-gzip -d}
SUBSTFORMAT=%H%n SUBSTFORMAT=%H%n
test_lazy_prereq TAR_NEEDS_PAX_FALLBACK '
(
mkdir pax &&
cd pax &&
"$TAR" xf "$TEST_DIRECTORY"/t5000/pax.tar &&
test -f PaxHeaders.1791/file
)
'
get_pax_header() {
file=$1
header=$2=
while read len rest
do
if test "$len" = $(echo "$len $rest" | wc -c)
then
case "$rest" in
$header*)
echo "${rest#$header}"
;;
esac
fi
done <"$file"
}
check_tar() { check_tar() {
tarfile=$1.tar tarfile=$1.tar
listfile=$1.lst listfile=$1.lst
@ -40,6 +66,24 @@ check_tar() {
(mkdir $dir && cd $dir && "$TAR" xf -) <$tarfile (mkdir $dir && cd $dir && "$TAR" xf -) <$tarfile
' '
test_expect_success TAR_NEEDS_PAX_FALLBACK ' interpret pax headers' '
(
cd $dir &&
for header in *.paxheader
do
data=${header%.paxheader}.data &&
if test -h $data -o -e $data
then
path=$(get_pax_header $header path) &&
if test -n "$path"
then
mv "$data" "$path"
fi
fi
done
)
'
test_expect_success ' validate filenames' ' test_expect_success ' validate filenames' '
(cd ${dir_with_prefix}a && find .) | sort >$listfile && (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
test_cmp a.lst $listfile test_cmp a.lst $listfile
@ -54,6 +98,8 @@ test_expect_success \
'populate workdir' \ 'populate workdir' \
'mkdir a && 'mkdir a &&
echo simple textfile >a/a && echo simple textfile >a/a &&
ten=0123456789 && hundred=$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten &&
echo long filename >a/four$hundred &&
mkdir a/bin && mkdir a/bin &&
cp /bin/sh a/bin && cp /bin/sh a/bin &&
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 && printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&

BIN
t/t5000/pax.tar Normal file

Binary file not shown.