summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2015-08-22 21:06:12 +0200
committerJunio C Hamano <gitster@pobox.com>2015-08-28 08:52:10 -0700
commit19ee29401dfc414924f335c21ef9880513f3c58d (patch)
treea96bcdacb92c6fb851cf8619afae338cff8d4143
parent8545932d45c91437ac439b1a2df12cf397f71311 (diff)
downloadgit-19ee29401dfc414924f335c21ef9880513f3c58d.tar.gz
t5004: test ZIP archives with many entries
A ZIP file directory has a 16-bit field for the number of entries it contains. There are 64-bit extensions to deal with that. Demonstrate that git archive --format=zip currently doesn't use them and instead overflows the field. InfoZIP's unzip doesn't care about this field and extracts all files anyway. Software that uses the directory for presenting a filesystem like view quickly -- notably Windows -- depends on it, but doesn't lend itself to an automatic test case easily. Use InfoZIP's zipinfo, which probably isn't available everywhere but at least can provides *some* way to check this field. To speed things up a bit create and commit only a subset of the files and build a fake tree out of duplicates and pass that to git archive. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t5004-archive-corner-cases.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index 654addaae3..c6bd7290a3 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -115,4 +115,44 @@ test_expect_success 'archive empty subtree by direct pathspec' '
check_dir extract sub
'
+ZIPINFO=zipinfo
+
+test_lazy_prereq ZIPINFO '
+ n=$("$ZIPINFO" "$TEST_DIRECTORY"/t5004/empty.zip | sed -n "2s/.* //p")
+ test "x$n" = "x0"
+'
+
+test_expect_failure ZIPINFO 'zip archive with many entries' '
+ # add a directory with 256 files
+ mkdir 00 &&
+ for a in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ do
+ for b in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ do
+ : >00/$a$b
+ done
+ done &&
+ git add 00 &&
+ git commit -m "256 files in 1 directory" &&
+
+ # duplicate it to get 65536 files in 256 directories
+ subtree=$(git write-tree --prefix=00/) &&
+ for c in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ do
+ for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ do
+ echo "040000 tree $subtree $c$d"
+ done
+ done >tree &&
+ tree=$(git mktree <tree) &&
+
+ # zip them
+ git archive -o many.zip $tree &&
+
+ # check the number of entries in the ZIP file directory
+ expr 65536 + 256 >expect &&
+ "$ZIPINFO" many.zip | head -2 | sed -n "2s/.* //p" >actual &&
+ test_cmp expect actual
+'
+
test_done