compat: introduce new "zlib.h" header

Introduce a new "compat/zlib-compat.h" header that we include instead of including <zlib.h> directly. This will allow us to wire up zlib-ng as an alternative backend for zlib compression in a subsequent commit. Note that we cannot just call the file "compat/zlib.h", as that may otherwise cause us to include that file instead of <zlib.h>. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jan 28, 2025 at 09:41 UTC 629188ede7ee00c925ef28b85b1e68fc9e05fb93
3 files changed +8 -2
compat/zlib-compat.h new
+6
@@ -0,0 +1,6 @@
1 +#ifndef COMPAT_ZLIB_H
2 +#define COMPAT_ZLIB_H
3 +
4 +#include <zlib.h>
5 +
6 +#endif /* COMPAT_ZLIB_H */
git-compat-util.h
+1 -1
@@ -1537,7 +1537,7 @@ int cmd_main(int, const char **);
1537 int common_exit(const char *file, int line, int code);
1538 #define exit(code) exit(common_exit(__FILE__, __LINE__, (code)))
1539
1540 -#include <zlib.h>
1540 +#include "compat/zlib-compat.h"
1541
1542 /*
1543 * This include must come after system headers, since it introduces macros that
reftable/block.c
+1 -1
@@ -13,7 +13,7 @@ https://developers.google.com/open-source/licenses/bsd
13 #include "record.h"
14 #include "reftable-error.h"
15 #include "system.h"
16 -#include <zlib.h>
16 +#include "compat/zlib-compat.h"
17
18 int header_size(int version)
19 {