summaryrefslogtreecommitdiff
path: root/archive-zip.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2008-07-18 16:30:32 +0200
committerJunio C Hamano <gitster@pobox.com>2008-07-19 11:17:43 -0700
commit3a176c6cde650f8907b2dbafafb72f6375038613 (patch)
treeb1ce068e0396408adb2712bc35a1d2722019ccaa /archive-zip.c
parent6259ac6628477aa5ebde9bd9e8daaeecca2a74ae (diff)
downloadgit-3a176c6cde650f8907b2dbafafb72f6375038613.tar.gz
archive: make zip compression level independent from core git
zlib_compression_level is the compression level used for git's object store. It's 1 by default, which is the fastest setting. This variable is also used as the default compression level for ZIP archives created by git archive. For archives, however, zlib's own default of 6 is more appropriate, as it's favouring small size over speed -- archive creation is not that performance critical most of the time. This patch makes git archive independent from git's internal compression level setting. It affects invocations of git archive without explicitly specified compression level option, only. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'archive-zip.c')
-rw-r--r--archive-zip.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/archive-zip.c b/archive-zip.c
index d56e5cfc1e..fb12398b0f 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -93,7 +93,7 @@ static void copy_le32(unsigned char *dest, unsigned int n)
}
static void *zlib_deflate(void *data, unsigned long size,
- unsigned long *compressed_size)
+ int compression_level, unsigned long *compressed_size)
{
z_stream stream;
unsigned long maxsize;
@@ -101,7 +101,7 @@ static void *zlib_deflate(void *data, unsigned long size,
int result;
memset(&stream, 0, sizeof(stream));
- deflateInit(&stream, zlib_compression_level);
+ deflateInit(&stream, compression_level);
maxsize = deflateBound(&stream, size);
buffer = xmalloc(maxsize);
@@ -157,7 +157,7 @@ static int write_zip_entry(struct archiver_args *args,
method = 0;
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
(mode & 0111) ? ((mode) << 16) : 0;
- if (S_ISREG(mode) && zlib_compression_level != 0)
+ if (S_ISREG(mode) && args->compression_level != 0)
method = 8;
crc = crc32(crc, buffer, size);
out = buffer;
@@ -169,7 +169,8 @@ static int write_zip_entry(struct archiver_args *args,
}
if (method == 8) {
- deflated = zlib_deflate(buffer, size, &compressed_size);
+ deflated = zlib_deflate(buffer, size, args->compression_level,
+ &compressed_size);
if (deflated && compressed_size - 6 < size) {
/* ZLIB --> raw compressed data (see RFC 1950) */
/* CMF and FLG ... */