• R
    archive-zip: fix compressed size for stored export-subst files · d3c1472f
    René Scharfe 提交于
    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: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    d3c1472f
t5003-archive-zip.sh 3.3 KB