git-archive --format=zip: add symlink support

Add symlink support to ZIP file creation, and a few tests.

This implementation sets the "version made by" field
(creator_version) to Unix for symlinks, only; regular files and
directories are still marked as originating from FAT/VFAT/NTFS.

Also set "external file attributes" (attr2) to 0 for regular
files and 16 for directories (FAT attribute), and to the file
mode for symlinks.

We could always set the creator_version to Unix and include the
mode, but then Info-ZIP unzip would set the mode of the extracted
files to *exactly* the value stored in attr2.  The FAT trick
makes it apply the umask instead.  Note: FAT has no executable
bit, so this information is not stored in the ZIP file.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Rene Scharfe
2006-10-07 01:47:35 +02:00
committed by Junio C Hamano
parent cf72fb07b7
commit 62cdce17c5
2 changed files with 44 additions and 4 deletions

View File

@ -26,6 +26,7 @@ commit id embedding:
. ./test-lib.sh
TAR=${TAR:-tar}
UNZIP=${UNZIP:-unzip}
test_expect_success \
'populate workdir' \
@ -95,4 +96,38 @@ test_expect_success \
'validate file contents with prefix' \
'diff -r a c/prefix/a'
test_expect_success \
'git-archive --format=zip' \
'git-archive --format=zip HEAD >d.zip'
test_expect_success \
'extract ZIP archive' \
'(mkdir d && cd d && $UNZIP ../d.zip)'
test_expect_success \
'validate filenames' \
'(cd d/a && find .) | sort >d.lst &&
diff a.lst d.lst'
test_expect_success \
'validate file contents' \
'diff -r a d/a'
test_expect_success \
'git-archive --format=zip with prefix' \
'git-archive --format=zip --prefix=prefix/ HEAD >e.zip'
test_expect_success \
'extract ZIP archive with prefix' \
'(mkdir e && cd e && $UNZIP ../e.zip)'
test_expect_success \
'validate filenames with prefix' \
'(cd e/prefix/a && find .) | sort >e.lst &&
diff a.lst e.lst'
test_expect_success \
'validate file contents with prefix' \
'diff -r a e/prefix/a'
test_done