archive: make zip compression level independent from core git
[git/git.git] / archive-zip.c
index d56e5cf..fb12398 100644 (file)
@@ -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 ... */