summaryrefslogtreecommitdiff
path: root/t/t5003-archive-zip.sh
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2013-02-27 10:20:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-02-27 15:38:32 (GMT)
commitd3c1472fe35e2575508d80415565822ee2211df5 (patch)
treefb824ed2d196f643f2847683b5c6cf134b07be3b /t/t5003-archive-zip.sh
parentd9f85f50ca35d7ed1b35e2990a0082b94f1e1370 (diff)
downloadgit-d3c1472fe35e2575508d80415565822ee2211df5.zip
git-d3c1472fe35e2575508d80415565822ee2211df5.tar.gz
git-d3c1472fe35e2575508d80415565822ee2211df5.tar.bz2
archive-zip: fix compressed size for stored export-subst files
Currently ZIP archive entries of files with export-subst attribute are broken if they are stored uncompressed. We get the size of a file from sha1_object_info(), but this number is likely wrong for files whose contents are changed due to export-subst placeholder expansion. We use sha1_file_to_archive() to get the expanded file contents and size in that case. We proceed to use that size for the uncompressed size field (good), but the compressed size field is set based on the size from sha1_object_info() (bad). This matters only for uncompressed files because for deflated files we use the correct value after compression is done. And for files without export-subst expansion the sizes from sha1_object_info() and sha1_file_to_archive() are the same, so they are unaffected as well. This patch fixes the issue by setting the compressed size based on the uncompressed size only after we actually know the latter. Also make use of the test file substfile1 to check for the breakage; it was only stored verbatim so far. For that purpose, set the attribute export-subst and replace its contents with the expected expansion after committing. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5003-archive-zip.sh')
-rwxr-xr-xt/t5003-archive-zip.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh
index 7cfe9ca..6a33606 100755
--- a/t/t5003-archive-zip.sh
+++ b/t/t5003-archive-zip.sh
@@ -76,6 +76,12 @@ test_expect_success \
git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
git commit-tree $treeid </dev/null)'
+test_expect_success 'setup export-subst' '
+ echo "substfile?" export-subst >>.git/info/attributes &&
+ git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
+ >a/substfile1
+'
+
test_expect_success \
'create bare clone' \
'git clone --bare . bare.git &&