Skip to content

Commit c694b03

Browse files
committed
Merge branch 'ps/zlib-ng' into seen
* ps/zlib-ng: compat/zlib: allow use of zlib-ng as backend git-zlib: cast away potential constness of `next_in` pointer compat/zlib: provide stubs for `deflateSetHeader()` compat/zlib: provide `deflateBound()` shim centrally git-compat-util: move include of "compat/zlib.h" into "git-zlib.h" compat: introduce new "zlib.h" header git-compat-util: drop `z_const` define compat: drop `uncompress2()` compatibility shim
2 parents 89052f4 + 20d77dd commit c694b03

File tree

15 files changed

+75
-125
lines changed

15 files changed

+75
-125
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,6 @@ LIB_OBJS += common-init.o
993993
LIB_OBJS += compat/nonblock.o
994994
LIB_OBJS += compat/obstack.o
995995
LIB_OBJS += compat/terminal.o
996-
LIB_OBJS += compat/zlib-uncompress2.o
997996
LIB_OBJS += config.o
998997
LIB_OBJS += connect.o
999998
LIB_OBJS += connected.o

archive-tar.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,7 @@ static const char internal_gzip_command[] = "git archive gzip";
473473
static int write_tar_filter_archive(const struct archiver *ar,
474474
struct archiver_args *args)
475475
{
476-
#if ZLIB_VERNUM >= 0x1221
477476
struct gz_header_s gzhead = { .os = 3 }; /* Unix, for reproducibility */
478-
#endif
479477
struct strbuf cmd = STRBUF_INIT;
480478
struct child_process filter = CHILD_PROCESS_INIT;
481479
int r;
@@ -486,10 +484,8 @@ static int write_tar_filter_archive(const struct archiver *ar,
486484
if (!strcmp(ar->filter_command, internal_gzip_command)) {
487485
write_block = tgz_write_block;
488486
git_deflate_init_gzip(&gzstream, args->compression_level);
489-
#if ZLIB_VERNUM >= 0x1221
490487
if (deflateSetHeader(&gzstream.z, &gzhead) != Z_OK)
491488
BUG("deflateSetHeader() called too late");
492-
#endif
493489
gzstream.next_out = outbuf;
494490
gzstream.avail_out = sizeof(outbuf);
495491

archive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "convert.h"
88
#include "environment.h"
99
#include "gettext.h"
10+
#include "git-zlib.h"
1011
#include "hex.h"
1112
#include "object-name.h"
1213
#include "path.h"

compat/zlib-compat.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#ifndef COMPAT_ZLIB_H
2+
#define COMPAT_ZLIB_H
3+
4+
#ifdef HAVE_ZLIB_NG
5+
# include <zlib-ng.h>
6+
7+
# define z_stream zng_stream
8+
#define gz_header_s zng_gz_header_s
9+
10+
# define crc32(crc, buf, len) zng_crc32(crc, buf, len)
11+
12+
# define inflate(strm, bits) zng_inflate(strm, bits)
13+
# define inflateEnd(strm) zng_inflateEnd(strm)
14+
# define inflateInit(strm) zng_inflateInit(strm)
15+
# define inflateInit2(strm, bits) zng_inflateInit2(strm, bits)
16+
# define inflateReset(strm) zng_inflateReset(strm)
17+
18+
# define deflate(strm, flush) zng_deflate(strm, flush)
19+
# define deflateBound(strm, source_len) zng_deflateBound(strm, source_len)
20+
# define deflateEnd(strm) zng_deflateEnd(strm)
21+
# define deflateInit(strm, level) zng_deflateInit(strm, level)
22+
# define deflateInit2(stream, level, method, window_bits, mem_level, strategy) zng_deflateInit2(stream, level, method, window_bits, mem_level, strategy)
23+
# define deflateReset(strm) zng_deflateReset(strm)
24+
# define deflateSetHeader(strm, head) zng_deflateSetHeader(strm, head)
25+
26+
#else
27+
# include <zlib.h>
28+
29+
# if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
30+
# define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
31+
# endif
32+
33+
# if ZLIB_VERNUM < 0x1221
34+
struct gz_header_s {
35+
int os;
36+
};
37+
38+
static int deflateSetHeader(z_streamp strm, struct gz_header_s *head)
39+
{
40+
(void)(strm);
41+
(void)(head);
42+
return Z_OK;
43+
}
44+
# endif
45+
#endif /* HAVE_ZLIB_NG */
46+
47+
#endif /* COMPAT_ZLIB_H */

compat/zlib-uncompress2.c

Lines changed: 0 additions & 96 deletions
This file was deleted.

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "convert.h"
2020
#include "environment.h"
2121
#include "gettext.h"
22+
#include "git-zlib.h"
2223
#include "ident.h"
2324
#include "repository.h"
2425
#include "lockfile.h"

csum-file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
#define USE_THE_REPOSITORY_VARIABLE
1212

1313
#include "git-compat-util.h"
14-
#include "progress.h"
1514
#include "csum-file.h"
15+
#include "git-zlib.h"
1616
#include "hash.h"
17+
#include "progress.h"
1718

1819
static void verify_buffer_or_die(struct hashfile *f,
1920
const void *buf,

environment.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "convert.h"
1717
#include "environment.h"
1818
#include "gettext.h"
19+
#include "git-zlib.h"
1920
#include "repository.h"
2021
#include "config.h"
2122
#include "refs.h"

git-compat-util.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,18 +1555,6 @@ int cmd_main(int, const char **);
15551555
int common_exit(const char *file, int line, int code);
15561556
#define exit(code) exit(common_exit(__FILE__, __LINE__, (code)))
15571557

1558-
#define z_const
1559-
#include <zlib.h>
1560-
1561-
#if ZLIB_VERNUM < 0x1290
1562-
/*
1563-
* This is uncompress2, which is only available in zlib >= 1.2.9
1564-
* (released as of early 2017). See compat/zlib-uncompress2.c.
1565-
*/
1566-
int uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
1567-
uLong *sourceLen);
1568-
#endif
1569-
15701558
/*
15711559
* This include must come after system headers, since it introduces macros that
15721560
* replace system names.

git-zlib.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void zlib_post_call(git_zstream *s)
5959

6060
s->total_out = s->z.total_out;
6161
s->total_in = s->z.total_in;
62-
s->next_in = s->z.next_in;
62+
s->next_in = (unsigned char *) s->z.next_in;
6363
s->next_out = s->z.next_out;
6464
s->avail_in -= bytes_consumed;
6565
s->avail_out -= bytes_produced;
@@ -147,10 +147,6 @@ int git_inflate(git_zstream *strm, int flush)
147147
return status;
148148
}
149149

150-
#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
151-
#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
152-
#endif
153-
154150
unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)
155151
{
156152
return deflateBound(&strm->z, size);

0 commit comments

Comments
 (0)