]> git.ipfire.org Git - thirdparty/git.git/commit - cache.h
archive-zip: use deflateInit2() to ask for raw compressed data
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Fri, 15 Mar 2013 22:21:51 +0000 (23:21 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 17 Mar 2013 05:07:02 +0000 (22:07 -0700)
commitc3c2e1a09b84dc932d90fa09d1632e5efa34c940
tree35f5ce56cefcb5118af51427214da4155f0fc4f2
parentd3c1472fe35e2575508d80415565822ee2211df5
archive-zip: use deflateInit2() to ask for raw compressed data

We use the function git_deflate_init() -- which wraps the zlib function
deflateInit() -- to initialize compression of ZIP file entries.  This
results in compressed data prefixed with a two-bytes long header and
followed by a four-bytes trailer.  ZIP file entries consist of ZIP
headers and raw compressed data instead, so we remove the zlib wrapper
before writing the result.

We can ask zlib for the the raw compressed data without the unwanted
parts in the first place by using deflateInit2() and specifying a
negative number of bits to size the window.  For that purpose, factor
out the function do_git_deflate_init() and add git_deflate_init_raw(),
which wraps it.  Then use the latter in archive-zip.c and get rid of
the code that stripped the zlib header and trailer.

Also rename the helper function zlib_deflate() to zlib_deflate_raw()
to reflect the change.

Thus we avoid generating data that we throw away anyway, the code
becomes shorter and some magic constants are removed.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
archive-zip.c
cache.h
zlib.c