git-compat-util: move include of "compat/zlib.h" into "git-zlib.h"

We include "compat/zlib.h" in "git-compat-util.h", which is
unnecessarily broad given that we only have a small handful of files
that use the zlib library. Move the header into "git-zlib.h" instead and
adapt users of zlib to include that header.

One exception is the reftable library, as we don't want to use the
Git-specific wrapper of zlib there, so we include "compat/zlib.h"
instead. Furthermore, we move the include into "reftable/system.h" so
that users of the library other than Git can wire up zlib themselves.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Patrick Steinhardt 2025-01-28 09:41:30 +01:00 committed by Junio C Hamano
parent 629188ede7
commit 41f1a8435a
8 changed files with 8 additions and 4 deletions

View File

@ -7,6 +7,7 @@
#include "convert.h" #include "convert.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "git-zlib.h"
#include "hex.h" #include "hex.h"
#include "object-name.h" #include "object-name.h"
#include "path.h" #include "path.h"

View File

@ -19,6 +19,7 @@
#include "convert.h" #include "convert.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "git-zlib.h"
#include "ident.h" #include "ident.h"
#include "repository.h" #include "repository.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -11,9 +11,10 @@
#define USE_THE_REPOSITORY_VARIABLE #define USE_THE_REPOSITORY_VARIABLE


#include "git-compat-util.h" #include "git-compat-util.h"
#include "progress.h"
#include "csum-file.h" #include "csum-file.h"
#include "git-zlib.h"
#include "hash.h" #include "hash.h"
#include "progress.h"


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

View File

@ -16,6 +16,7 @@
#include "convert.h" #include "convert.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "git-zlib.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "refs.h" #include "refs.h"

View File

@ -1537,8 +1537,6 @@ int cmd_main(int, const char **);
int common_exit(const char *file, int line, int code); int common_exit(const char *file, int line, int code);
#define exit(code) exit(common_exit(__FILE__, __LINE__, (code))) #define exit(code) exit(common_exit(__FILE__, __LINE__, (code)))


#include "compat/zlib-compat.h"

/* /*
* This include must come after system headers, since it introduces macros that * This include must come after system headers, since it introduces macros that
* replace system names. * replace system names.

View File

@ -1,6 +1,8 @@
#ifndef GIT_ZLIB_H #ifndef GIT_ZLIB_H
#define GIT_ZLIB_H #define GIT_ZLIB_H


#include "compat/zlib-compat.h"

typedef struct git_zstream { typedef struct git_zstream {
z_stream z; z_stream z;
unsigned long avail_in; unsigned long avail_in;

View File

@ -13,7 +13,6 @@ https://developers.google.com/open-source/licenses/bsd
#include "record.h" #include "record.h"
#include "reftable-error.h" #include "reftable-error.h"
#include "system.h" #include "system.h"
#include "compat/zlib-compat.h"


int header_size(int version) int header_size(int version)
{ {

View File

@ -14,6 +14,7 @@ https://developers.google.com/open-source/licenses/bsd
#define DISABLE_SIGN_COMPARE_WARNINGS #define DISABLE_SIGN_COMPARE_WARNINGS


#include "git-compat-util.h" #include "git-compat-util.h"
#include "compat/zlib-compat.h"


/* /*
* An implementation-specific temporary file. By making this specific to the * An implementation-specific temporary file. By making this specific to the