Skip to content

Commit

Permalink
Merge branch 'rs/zip-compresssed-size-with-export-subst' into maint
Browse files Browse the repository at this point in the history
When export-subst is used, "zip" output recorded incorrect
size of the file.

* rs/zip-compresssed-size-with-export-subst:
  archive-zip: fix compressed size for stored export-subst files
  • Loading branch information
Junio C Hamano committed Mar 26, 2013
2 parents d7cccbb + d3c1472 commit 7d2726c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion archive-zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ static int write_zip_entry(struct archiver_args *args,
(mode & 0111) ? ((mode) << 16) : 0;
if (S_ISREG(mode) && args->compression_level != 0 && size > 0)
method = 8;
compressed_size = (method == 0) ? size : 0;

if (S_ISREG(mode) && type == OBJ_BLOB && !args->convert &&
size > big_file_threshold) {
Expand All @@ -259,6 +258,7 @@ static int write_zip_entry(struct archiver_args *args,
crc = crc32(crc, buffer, size);
out = buffer;
}
compressed_size = (method == 0) ? size : 0;
} else {
return error("unsupported file mode: 0%o (SHA1: %s)", mode,
sha1_to_hex(sha1));
Expand Down
6 changes: 6 additions & 0 deletions t/t5003-archive-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 7d2726c

Please sign in to comment.