{"thread":{"id":"62863","subject":"[PATCH v4 01/10] compat: drop `uncompress2()` compatibility shim","startedAt":"2025-01-28T08:41:34Z","lastAt":"2025-01-28T20:50:44Z","messageCount":12,"participants":["Patrick Steinhardt","Junio C Hamano"],"isPatch":true,"patchVersion":4,"patchTotal":10},"messages":[{"id":"511340","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-1-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 01/10] compat: drop `uncompress2()` compatibility shim","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:27Z","receivedAt":"2025-01-28T08:41:34Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Our compat library has an implementation of zlib's `uncompress2()`\nfunction that gets used when linking against an old version of zlib\nthat doesn't yet have it. The last user of `uncompress2()` got removed\nin 15a60b747e (reftable/block: open-code call to `uncompress2()`,\n2024-04-08), so the compatibility code is not required anymore. Drop it.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile                  |  1 -\n compat/zlib-uncompress2.c | 96 -----------------------------------------------\n git-compat-util.h         |  9 -----\n meson.build               |  1 -\n 4 files changed, 107 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 97e8385b66..86c6c3d7ad 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -984,7 +984,6 @@ LIB_OBJS += commit.o\n LIB_OBJS += compat/nonblock.o\n LIB_OBJS += compat/obstack.o\n LIB_OBJS += compat/terminal.o\n-LIB_OBJS += compat/zlib-uncompress2.o\n LIB_OBJS += config.o\n LIB_OBJS += connect.o\n LIB_OBJS += connected.o\ndiff --git a/compat/zlib-uncompress2.c b/compat/zlib-uncompress2.c\ndeleted file mode 100644\nindex 77a1b08048..0000000000\n--- a/compat/zlib-uncompress2.c\n+++ /dev/null\n@@ -1,96 +0,0 @@\n-#include \"git-compat-util.h\"\n-\n-#if ZLIB_VERNUM < 0x1290\n-/* taken from zlib's uncompr.c\n-\n-   commit cacf7f1d4e3d44d871b605da3b647f07d718623f\n-   Author: Mark Adler <madler@alumni.caltech.edu>\n-   Date:   Sun Jan 15 09:18:46 2017 -0800\n-\n-       zlib 1.2.11\n-\n-*/\n-\n-/*\n- * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler\n- * For conditions of distribution and use, see copyright notice in zlib.h\n- */\n-\n-/* clang-format off */\n-\n-/* ===========================================================================\n-     Decompresses the source buffer into the destination buffer.  *sourceLen is\n-   the byte length of the source buffer. Upon entry, *destLen is the total size\n-   of the destination buffer, which must be large enough to hold the entire\n-   uncompressed data. (The size of the uncompressed data must have been saved\n-   previously by the compressor and transmitted to the decompressor by some\n-   mechanism outside the scope of this compression library.) Upon exit,\n-   *destLen is the size of the decompressed data and *sourceLen is the number\n-   of source bytes consumed. Upon return, source + *sourceLen points to the\n-   first unused input byte.\n-\n-     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough\n-   memory, Z_BUF_ERROR if there was not enough room in the output buffer, or\n-   Z_DATA_ERROR if the input data was corrupted, including if the input data is\n-   an incomplete zlib stream.\n-*/\n-int ZEXPORT uncompress2 (\n-    Bytef *dest,\n-    uLongf *destLen,\n-    const Bytef *source,\n-    uLong *sourceLen) {\n-    z_stream stream;\n-    int err;\n-    const uInt max = (uInt)-1;\n-    uLong len, left;\n-    Byte buf[1];    /* for detection of incomplete stream when *destLen == 0 */\n-\n-    len = *sourceLen;\n-    if (*destLen) {\n-\tleft = *destLen;\n-\t*destLen = 0;\n-    }\n-    else {\n-\tleft = 1;\n-\tdest = buf;\n-    }\n-\n-    stream.next_in = (z_const Bytef *)source;\n-    stream.avail_in = 0;\n-    stream.zalloc = (alloc_func)0;\n-    stream.zfree = (free_func)0;\n-    stream.opaque = (voidpf)0;\n-\n-    err = inflateInit(&stream);\n-    if (err != Z_OK) return err;\n-\n-    stream.next_out = dest;\n-    stream.avail_out = 0;\n-\n-    do {\n-\tif (stream.avail_out == 0) {\n-\t    stream.avail_out = left > (uLong)max ? max : (uInt)left;\n-\t    left -= stream.avail_out;\n-\t}\n-\tif (stream.avail_in == 0) {\n-\t    stream.avail_in = len > (uLong)max ? max : (uInt)len;\n-\t    len -= stream.avail_in;\n-\t}\n-\terr = inflate(&stream, Z_NO_FLUSH);\n-    } while (err == Z_OK);\n-\n-    *sourceLen -= len + stream.avail_in;\n-    if (dest != buf)\n-\t*destLen = stream.total_out;\n-    else if (stream.total_out && err == Z_BUF_ERROR)\n-\tleft = 1;\n-\n-    inflateEnd(&stream);\n-    return err == Z_STREAM_END ? Z_OK :\n-\t   err == Z_NEED_DICT ? Z_DATA_ERROR  :\n-\t   err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :\n-\t   err;\n-}\n-#else\n-static void *dummy_variable = &dummy_variable;\n-#endif\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex e283c46c6f..d50f487c00 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1540,15 +1540,6 @@ int common_exit(const char *file, int line, int code);\n #define z_const\n #include <zlib.h>\n \n-#if ZLIB_VERNUM < 0x1290\n-/*\n- * This is uncompress2, which is only available in zlib >= 1.2.9\n- * (released as of early 2017). See compat/zlib-uncompress2.c.\n- */\n-int uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,\n-\t\tuLong *sourceLen);\n-#endif\n-\n /*\n  * This include must come after system headers, since it introduces macros that\n  * replace system names.\ndiff --git a/meson.build b/meson.build\nindex 30d7a89490..12129a8b95 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -263,7 +263,6 @@ libgit_sources = [\n   'compat/nonblock.c',\n   'compat/obstack.c',\n   'compat/terminal.c',\n-  'compat/zlib-uncompress2.c',\n   'config.c',\n   'connect.c',\n   'connected.c',\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511341","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250110-b4-pks-compat-drop-uncompress2-v1-0-965d0022a74d@pks.im","subject":"[PATCH v4 00/10] compat/zlib: allow use of zlib-ng as backend","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:26Z","receivedAt":"2025-01-28T08:41:34Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nI have recently started to play around with zlib-ng a bit, which is a\nhard fork of the zlib library. It describes itself as zlib replacement\nwith optimizations for \"next generation\" systems. As such, it contains\nseveral implementations of central algorithms using for example SSE2,\nAVX2 and other vectorized CPU intrinsics that supposedly speed up in-\nand deflating data.\n\nAnd indeed, compiling Git against zlib-ng leads to a significant speedup\nwhen reading objects. The following benchmark uses git-cat-file(1) with\n`--batch --batch-all-objects` in the Git repository:\n\n    Benchmark 1: zlib\n      Time (mean ± σ):     52.085 s ±  0.141 s    [User: 51.500 s, System: 0.456 s]\n      Range (min … max):   52.004 s … 52.335 s    5 runs\n\n    Benchmark 2: zlib-ng\n      Time (mean ± σ):     40.324 s ±  0.134 s    [User: 39.731 s, System: 0.490 s]\n      Range (min … max):   40.135 s … 40.484 s    5 runs\n\n    Summary\n      zlib-ng ran\n        1.29 ± 0.01 times faster than zlib\n\nSo we're looking at a ~25% speedup compared to zlib. This is of course\nan extreme example, as it makes us read through all objects in the\nrepository. But regardless, it should be possible to see some sort of\nspeedup in most commands that end up accessing the object database.\n\nThis patch series refactors how we wire up zlib in our project by\nintroducing a new \"compat/zlib.h\" header function. This header is then\nlater extended to patch over the differences between zlib and zlib-ng,\nwhich is mostly just that zlib-ng has a `zng_` prefix for each of its\nsymbols. Like this, we can support both libraries directly, and a new\nMeson build options allows users to pick whichever backend they like.\n\nIn theory, these changes shouldn't be necessary because zlib-ng provides\na compatibility layer that make it directly compatible with zlib. But\nmost distros don't allow you to install zlib-ng with that layer is it\nwould mean that zlib would need to be replaced globally. Instead, they\ntypically only provide a version of zlib-ng that only has the `zng_`\nprefixed symbols.\n\nGiven the observed speedup I do think that this is a worthwhile change\nso that users (or especially hosting providers) can easily switch to\nzlib-ng without impacting the rest of their system.\n\nChanges in v2:\n  - Wire up zlib-ng in our Makefile.\n  - Exercise zlib-ng via CI by adapting our \"linux-musl\" job to use\n    Meson and installing zlib-ng.\n  - Link to v1: https://lore.kernel.org/r/20250110-b4-pks-compat-drop-uncompress2-v1-0-965d0022a74d@pks.im\n\nChanges in v3:\n  - Fix a couple of commit message typos.\n  - Mention why we can safely drop \"CC=gcc\" when converting the musl job\n    to use Meson.\n  - Link to v2: https://lore.kernel.org/r/20250114-b4-pks-compat-drop-uncompress2-v2-0-614a2158e34e@pks.im\n\nChanges in v4:\n  - Add a comment explaining why we can stub out `deflateSetHeader()`.\n  - Add a comment explaining why we have to cast away constness with\n    zlib-ng's `next_in` field.\n  - Link to v3: https://lore.kernel.org/r/20250116-b4-pks-compat-drop-uncompress2-v3-0-f2af1f5c4a06@pks.im\n\nI've adjusted the series to be based on top of fbe8d3079d (Git 2.48,\n2025-01-10) with ps/meson-weak-sha1-build at 6a0ee54f9a (meson: provide\na summary of configured backends, 2024-12-30) and ps/build-meson-fixes\nat 4e517e68b5 (ci: wire up Visual Studio build with Meson, 2025-01-14)\nmerged into it. This matches what Junio has in his tree -- sorry for\nscrewing up the previous base!\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (10):\n      compat: drop `uncompress2()` compatibility shim\n      git-compat-util: drop `z_const` define\n      compat: introduce new \"zlib.h\" header\n      git-compat-util: move include of \"compat/zlib.h\" into \"git-zlib.h\"\n      compat/zlib: provide `deflateBound()` shim centrally\n      compat/zlib: provide stubs for `deflateSetHeader()`\n      git-zlib: cast away potential constness of `next_in` pointer\n      compat/zlib: allow use of zlib-ng as backend\n      ci: switch linux-musl to use Meson\n      ci: make \"linux-musl\" job use zlib-ng\n\n .github/workflows/main.yml |  2 +-\n .gitlab-ci.yml             |  2 +-\n Makefile                   | 21 +++++++---\n archive-tar.c              |  4 --\n archive.c                  |  1 +\n ci/install-dependencies.sh |  4 +-\n ci/lib.sh                  |  5 +--\n ci/run-build-and-tests.sh  |  3 +-\n compat/zlib-compat.h       | 53 +++++++++++++++++++++++++\n compat/zlib-uncompress2.c  | 96 ----------------------------------------------\n config.c                   |  1 +\n csum-file.c                |  3 +-\n environment.c              |  1 +\n git-compat-util.h          | 12 ------\n git-zlib.c                 |  7 +---\n git-zlib.h                 |  2 +\n meson.build                | 24 +++++++++---\n meson_options.txt          |  4 ++\n reftable/block.c           |  1 -\n reftable/system.h          |  1 +\n 20 files changed, 107 insertions(+), 140 deletions(-)\n\nRange-diff versus v3:\n\n 1:  00984b07b9 =  1:  fcfcf1ed81 compat: drop `uncompress2()` compatibility shim\n 2:  de7bf8bf15 =  2:  b483553549 git-compat-util: drop `z_const` define\n 3:  1aea050dae =  3:  f4f23ad8bc compat: introduce new \"zlib.h\" header\n 4:  40229f1c0a =  4:  14f6055809 git-compat-util: move include of \"compat/zlib.h\" into \"git-zlib.h\"\n 5:  230d23877f =  5:  acb5212ed3 compat/zlib: provide `deflateBound()` shim centrally\n 6:  05e0757235 !  6:  918cf3eb0d compat/zlib: provide stubs for `deflateSetHeader()`\n    @@ compat/zlib-compat.h\n      # define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n      #endif\n      \n    ++/*\n    ++ * zlib only gained support for setting up the gzip header in v1.2.2.1. In\n    ++ * Git we only set the header to make archives reproducible across different\n    ++ * operating systems, so it's fine to simply make this a no-op when using a\n    ++ * zlib version that doesn't support this yet.\n    ++ */\n     +#if ZLIB_VERNUM < 0x1221\n     +struct gz_header_s {\n     +\tint os;\n 7:  b10e6f35d7 !  7:  4047b9226a git-zlib: cast away potential constness of `next_in` pointer\n    @@ git-zlib.c: static void zlib_post_call(git_zstream *s)\n      \ts->total_out = s->z.total_out;\n      \ts->total_in = s->z.total_in;\n     -\ts->next_in = s->z.next_in;\n    ++\t/* zlib-ng marks `next_in` as `const`, so we have to cast it away. */\n     +\ts->next_in = (unsigned char *) s->z.next_in;\n      \ts->next_out = s->z.next_out;\n      \ts->avail_in -= bytes_consumed;\n 8:  6149885889 !  8:  d8f5c87d71 compat/zlib: allow use of zlib-ng as backend\n    @@ compat/zlib-compat.h\n     -#endif\n     +# define z_stream zng_stream\n     +#define gz_header_s zng_gz_header_s\n    - \n    --#if ZLIB_VERNUM < 0x1221\n    ++\n     +# define crc32(crc, buf, len) zng_crc32(crc, buf, len)\n     +\n     +# define inflate(strm, bits) zng_inflate(strm, bits)\n    @@ compat/zlib-compat.h\n     +# if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\n     +#  define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n     +# endif\n    -+\n    + \n    + /*\n    +  * zlib only gained support for setting up the gzip header in v1.2.2.1. In\n    +@@\n    +  * operating systems, so it's fine to simply make this a no-op when using a\n    +  * zlib version that doesn't support this yet.\n    +  */\n    +-#if ZLIB_VERNUM < 0x1221\n     +# if ZLIB_VERNUM < 0x1221\n      struct gz_header_s {\n      \tint os;\n 9:  f663af4332 =  9:  87fbc86f47 ci: switch linux-musl to use Meson\n10:  376c05fe77 = 10:  f3ea4c5a81 ci: make \"linux-musl\" job use zlib-ng\n\n---\nbase-commit: cbdbb490357c16eaaa6528c1d550c513a632d196\nchange-id: 20250110-b4-pks-compat-drop-uncompress2-eb5914459c32\n\n"},{"id":"511342","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-2-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 02/10] git-compat-util: drop `z_const` define","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:28Z","receivedAt":"2025-01-28T08:41:35Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Before including <zlib.h> we explicitly define `z_const` to an empty\nvalue. This has the effect that the `z_const` macro in \"zconf.h\" itself\nwill remain empty instead of being defined as `const`, which effectively\nadapts a couple of APIs so that their parameters are not marked as being\nconstants.\n\nIt is dubious though whether this is something we actually want: not\nmarking a parameter as a constant doesn't make it any less constant than\nit was. The define was added via 07564773c2 (compat: auto-detect if zlib\nhas uncompress2(), 2022-01-24), where it was seemingly carried over from\nour internal compatibility shim for `uncompress2()` that was removed in\nthe preceding commit. The commit message doesn't mention why we carry\nover the define and make it public, either, and I cannot think of any\nreason for why we would want to have it.\n\nDrop the define.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n git-compat-util.h | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex d50f487c00..c4b4b372b4 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1537,7 +1537,6 @@ int cmd_main(int, const char **);\n int common_exit(const char *file, int line, int code);\n #define exit(code) exit(common_exit(__FILE__, __LINE__, (code)))\n \n-#define z_const\n #include <zlib.h>\n \n /*\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511343","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-3-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 03/10] compat: introduce new \"zlib.h\" header","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:29Z","receivedAt":"2025-01-28T08:41:36Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Introduce a new \"compat/zlib-compat.h\" header that we include instead of\nincluding <zlib.h> directly. This will allow us to wire up zlib-ng as an\nalternative backend for zlib compression in a subsequent commit.\n\nNote that we cannot just call the file \"compat/zlib.h\", as that may\notherwise cause us to include that file instead of <zlib.h>.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n compat/zlib-compat.h | 6 ++++++\n git-compat-util.h    | 2 +-\n reftable/block.c     | 2 +-\n 3 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/zlib-compat.h b/compat/zlib-compat.h\nnew file mode 100644\nindex 0000000000..bc20b884ef\n--- /dev/null\n+++ b/compat/zlib-compat.h\n@@ -0,0 +1,6 @@\n+#ifndef COMPAT_ZLIB_H\n+#define COMPAT_ZLIB_H\n+\n+#include <zlib.h>\n+\n+#endif /* COMPAT_ZLIB_H */\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex c4b4b372b4..1ca2671322 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1537,7 +1537,7 @@ int cmd_main(int, const char **);\n int common_exit(const char *file, int line, int code);\n #define exit(code) exit(common_exit(__FILE__, __LINE__, (code)))\n \n-#include <zlib.h>\n+#include \"compat/zlib-compat.h\"\n \n /*\n  * This include must come after system headers, since it introduces macros that\ndiff --git a/reftable/block.c b/reftable/block.c\nindex 9858bbc7c5..bc9b079634 100644\n--- a/reftable/block.c\n+++ b/reftable/block.c\n@@ -13,7 +13,7 @@ license that can be found in the LICENSE file or at\n #include \"record.h\"\n #include \"reftable-error.h\"\n #include \"system.h\"\n-#include <zlib.h>\n+#include \"compat/zlib-compat.h\"\n \n int header_size(int version)\n {\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511344","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-4-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 04/10] git-compat-util: move include of \"compat/zlib.h\" into \"git-zlib.h\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:30Z","receivedAt":"2025-01-28T08:41:37Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We include \"compat/zlib.h\" in \"git-compat-util.h\", which is\nunnecessarily broad given that we only have a small handful of files\nthat use the zlib library. Move the header into \"git-zlib.h\" instead and\nadapt users of zlib to include that header.\n\nOne exception is the reftable library, as we don't want to use the\nGit-specific wrapper of zlib there, so we include \"compat/zlib.h\"\ninstead. Furthermore, we move the include into \"reftable/system.h\" so\nthat users of the library other than Git can wire up zlib themselves.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n archive.c         | 1 +\n config.c          | 1 +\n csum-file.c       | 3 ++-\n environment.c     | 1 +\n git-compat-util.h | 2 --\n git-zlib.h        | 2 ++\n reftable/block.c  | 1 -\n reftable/system.h | 1 +\n 8 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex b9c200cba6..8be4e7ac8d 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -7,6 +7,7 @@\n #include \"convert.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n+#include \"git-zlib.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n #include \"path.h\"\ndiff --git a/config.c b/config.c\nindex 50f2d17b39..36f76fafe5 100644\n--- a/config.c\n+++ b/config.c\n@@ -19,6 +19,7 @@\n #include \"convert.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n+#include \"git-zlib.h\"\n #include \"ident.h\"\n #include \"repository.h\"\n #include \"lockfile.h\"\ndiff --git a/csum-file.c b/csum-file.c\nindex 5716016e12..78e04356d3 100644\n--- a/csum-file.c\n+++ b/csum-file.c\n@@ -11,9 +11,10 @@\n #define USE_THE_REPOSITORY_VARIABLE\n \n #include \"git-compat-util.h\"\n-#include \"progress.h\"\n #include \"csum-file.h\"\n+#include \"git-zlib.h\"\n #include \"hash.h\"\n+#include \"progress.h\"\n \n static void verify_buffer_or_die(struct hashfile *f,\n \t\t\t\t const void *buf,\ndiff --git a/environment.c b/environment.c\nindex 8389a27270..e5b361bb5d 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -16,6 +16,7 @@\n #include \"convert.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n+#include \"git-zlib.h\"\n #include \"repository.h\"\n #include \"config.h\"\n #include \"refs.h\"\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 1ca2671322..fb25fbf503 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1537,8 +1537,6 @@ int cmd_main(int, const char **);\n int common_exit(const char *file, int line, int code);\n #define exit(code) exit(common_exit(__FILE__, __LINE__, (code)))\n \n-#include \"compat/zlib-compat.h\"\n-\n /*\n  * This include must come after system headers, since it introduces macros that\n  * replace system names.\ndiff --git a/git-zlib.h b/git-zlib.h\nindex d8a670aff9..1e8d9aabcb 100644\n--- a/git-zlib.h\n+++ b/git-zlib.h\n@@ -1,6 +1,8 @@\n #ifndef GIT_ZLIB_H\n #define GIT_ZLIB_H\n \n+#include \"compat/zlib-compat.h\"\n+\n typedef struct git_zstream {\n \tz_stream z;\n \tunsigned long avail_in;\ndiff --git a/reftable/block.c b/reftable/block.c\nindex bc9b079634..38e3081c61 100644\n--- a/reftable/block.c\n+++ b/reftable/block.c\n@@ -13,7 +13,6 @@ license that can be found in the LICENSE file or at\n #include \"record.h\"\n #include \"reftable-error.h\"\n #include \"system.h\"\n-#include \"compat/zlib-compat.h\"\n \n int header_size(int version)\n {\ndiff --git a/reftable/system.h b/reftable/system.h\nindex 5274eca1d0..f194a38686 100644\n--- a/reftable/system.h\n+++ b/reftable/system.h\n@@ -14,6 +14,7 @@ license that can be found in the LICENSE file or at\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n+#include \"compat/zlib-compat.h\"\n \n /*\n  * An implementation-specific temporary file. By making this specific to the\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511345","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-5-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 05/10] compat/zlib: provide `deflateBound()` shim centrally","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:31Z","receivedAt":"2025-01-28T08:41:37Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `deflateBound()` function has only been introduced with zlib 1.2.0.\nWhen linking against a zlib version older than that we thus provide our\nown compatibility shim. Move this shim into \"compat/zlib.h\" so that we\ncan adapt it based on whether or not we use zlib-ng in a subsequent\ncommit.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n compat/zlib-compat.h | 4 ++++\n git-zlib.c           | 4 ----\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/compat/zlib-compat.h b/compat/zlib-compat.h\nindex bc20b884ef..96a08811a9 100644\n--- a/compat/zlib-compat.h\n+++ b/compat/zlib-compat.h\n@@ -3,4 +3,8 @@\n \n #include <zlib.h>\n \n+#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\n+# define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n+#endif\n+\n #endif /* COMPAT_ZLIB_H */\ndiff --git a/git-zlib.c b/git-zlib.c\nindex d43bbeb6da..2e973320c2 100644\n--- a/git-zlib.c\n+++ b/git-zlib.c\n@@ -147,10 +147,6 @@ int git_inflate(git_zstream *strm, int flush)\n \treturn status;\n }\n \n-#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\n-#define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n-#endif\n-\n unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)\n {\n \treturn deflateBound(&strm->z, size);\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511346","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-6-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 06/10] compat/zlib: provide stubs for `deflateSetHeader()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:32Z","receivedAt":"2025-01-28T08:41:38Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The function `deflateSetHeader()` has been introduced with zlib v1.2.2.1,\nso we don't use it when linking against an older version of it. Refactor\nthe code to instead provide a central stub via \"compat/zlib.h\" so that\nwe can adapt it based on whether or not we use zlib-ng in a subsequent\ncommit.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n archive-tar.c        |  4 ----\n compat/zlib-compat.h | 19 +++++++++++++++++++\n 2 files changed, 19 insertions(+), 4 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex e7b3489e1e..0edf13fba7 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -473,9 +473,7 @@ static const char internal_gzip_command[] = \"git archive gzip\";\n static int write_tar_filter_archive(const struct archiver *ar,\n \t\t\t\t    struct archiver_args *args)\n {\n-#if ZLIB_VERNUM >= 0x1221\n \tstruct gz_header_s gzhead = { .os = 3 }; /* Unix, for reproducibility */\n-#endif\n \tstruct strbuf cmd = STRBUF_INIT;\n \tstruct child_process filter = CHILD_PROCESS_INIT;\n \tint r;\n@@ -486,10 +484,8 @@ static int write_tar_filter_archive(const struct archiver *ar,\n \tif (!strcmp(ar->filter_command, internal_gzip_command)) {\n \t\twrite_block = tgz_write_block;\n \t\tgit_deflate_init_gzip(&gzstream, args->compression_level);\n-#if ZLIB_VERNUM >= 0x1221\n \t\tif (deflateSetHeader(&gzstream.z, &gzhead) != Z_OK)\n \t\t\tBUG(\"deflateSetHeader() called too late\");\n-#endif\n \t\tgzstream.next_out = outbuf;\n \t\tgzstream.avail_out = sizeof(outbuf);\n \ndiff --git a/compat/zlib-compat.h b/compat/zlib-compat.h\nindex 96a08811a9..6226b30c0c 100644\n--- a/compat/zlib-compat.h\n+++ b/compat/zlib-compat.h\n@@ -7,4 +7,23 @@\n # define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n #endif\n \n+/*\n+ * zlib only gained support for setting up the gzip header in v1.2.2.1. In\n+ * Git we only set the header to make archives reproducible across different\n+ * operating systems, so it's fine to simply make this a no-op when using a\n+ * zlib version that doesn't support this yet.\n+ */\n+#if ZLIB_VERNUM < 0x1221\n+struct gz_header_s {\n+\tint os;\n+};\n+\n+static int deflateSetHeader(z_streamp strm, struct gz_header_s *head)\n+{\n+\t(void)(strm);\n+\t(void)(head);\n+\treturn Z_OK;\n+}\n+#endif\n+\n #endif /* COMPAT_ZLIB_H */\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511347","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-7-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 07/10] git-zlib: cast away potential constness of `next_in` pointer","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:33Z","receivedAt":"2025-01-28T08:41:39Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `struct git_zstream::next_in` variable points to the input data and\nis used in combination with `struct z_stream::next_in`. While that\nlatter field is not marked as a constant in zlib, it is marked as such\nin zlib-ng. This causes a couple of compiler errors when we try to\nassign these fields to one another due to mismatching constness.\n\nFix the issue by casting away the potential constness of `next_in`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n git-zlib.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-zlib.c b/git-zlib.c\nindex 2e973320c2..651dd9e07c 100644\n--- a/git-zlib.c\n+++ b/git-zlib.c\n@@ -59,7 +59,8 @@ static void zlib_post_call(git_zstream *s)\n \n \ts->total_out = s->z.total_out;\n \ts->total_in = s->z.total_in;\n-\ts->next_in = s->z.next_in;\n+\t/* zlib-ng marks `next_in` as `const`, so we have to cast it away. */\n+\ts->next_in = (unsigned char *) s->z.next_in;\n \ts->next_out = s->z.next_out;\n \ts->avail_in -= bytes_consumed;\n \ts->avail_out -= bytes_produced;\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511348","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-8-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 08/10] compat/zlib: allow use of zlib-ng as backend","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:34Z","receivedAt":"2025-01-28T08:41:39Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The zlib-ng library is a hard fork of the old and venerable zlib\nlibrary. It describes itself as zlib replacement with optimizations for\n\"next generation\" systems. As such, it contains several implementations\nof central algorithms using for example SSE2, AVX2 and other vectorized\nCPU intrinsics that supposedly speed up in- and deflating data.\n\nAnd indeed, compiling Git against zlib-ng leads to a significant speedup\nwhen reading objects. The following benchmark uses git-cat-file(1) with\n`--batch --batch-all-objects` in the Git repository:\n\n    Benchmark 1: zlib\n      Time (mean ± σ):     52.085 s ±  0.141 s    [User: 51.500 s, System: 0.456 s]\n      Range (min … max):   52.004 s … 52.335 s    5 runs\n\n    Benchmark 2: zlib-ng\n      Time (mean ± σ):     40.324 s ±  0.134 s    [User: 39.731 s, System: 0.490 s]\n      Range (min … max):   40.135 s … 40.484 s    5 runs\n\n    Summary\n      zlib-ng ran\n        1.29 ± 0.01 times faster than zlib\n\nSo we're looking at a ~25% speedup compared to zlib. This is of course\nan extreme example, as it makes us read through all objects in the\nrepository. But regardless, it should be possible to see some sort of\nspeedup in most commands that end up accessing the object database.\n\nThe zlib-ng library provides a compatibility layer that makes it a\nproper drop-in replacement for zlib: nothing needs to change in the\nbuild system to support it. Unfortunately though, this mode isn't easy\nto use on most systems because distributions do not allow you to install\nzlib-ng in that way, as that would mean that the zlib library would be\nglobally replaced. Instead, many distributions provide a package that\ninstalls zlib-ng without the compatibility layer. This version does\nprovide effectively the same APIs like zlib does, but all of the symbols\nare prefixed with `zng_` to avoid symbol collisions.\n\nImplement a new build option that allows us to link against zlib-ng\ndirectly. If set, we redefine zlib symbols so that we use the `zng_`\nprefixed versions thereof provided by that library. Like this, it\nbecomes possible to install both zlib and zlib-ng (without the compat\nlayer) and then pick whichever library one wants to link against for\nGit.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile             | 20 +++++++++++++++-----\n compat/zlib-compat.h | 36 ++++++++++++++++++++++++++++++------\n meson.build          | 21 +++++++++++++++++----\n meson_options.txt    |  2 ++\n 4 files changed, 64 insertions(+), 15 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 86c6c3d7ad..1853e6ddfa 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -183,7 +183,8 @@ include shared.mak\n # byte-order mark (BOM) when writing UTF-16 or UTF-32 and always writes in\n # big-endian format.\n #\n-# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.\n+# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound. Define\n+# ZLIB_NG if you want to use zlib-ng instead of zlib.\n #\n # Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,\n # as the compiler can crash (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)\n@@ -1687,11 +1688,20 @@ else\n endif\n IMAP_SEND_LDFLAGS += $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)\n \n-ifdef ZLIB_PATH\n-\tBASIC_CFLAGS += -I$(ZLIB_PATH)/include\n-\tEXTLIBS += $(call libpath_template,$(ZLIB_PATH)/$(lib))\n+ifdef ZLIB_NG\n+\tBASIC_CFLAGS += -DHAVE_ZLIB_NG\n+\tifdef ZLIB_NG_PATH\n+\t\tBASIC_CFLAGS += -I$(ZLIB_NG_PATH)/include\n+\t\tEXTLIBS += $(call libpath_template,$(ZLIB_NG_PATH)/$(lib))\n+\tendif\n+\tEXTLIBS += -lz-ng\n+else\n+\tifdef ZLIB_PATH\n+\t\tBASIC_CFLAGS += -I$(ZLIB_PATH)/include\n+\t\tEXTLIBS += $(call libpath_template,$(ZLIB_PATH)/$(lib))\n+\tendif\n+\tEXTLIBS += -lz\n endif\n-EXTLIBS += -lz\n \n ifndef NO_OPENSSL\n \tOPENSSL_LIBSSL = -lssl\ndiff --git a/compat/zlib-compat.h b/compat/zlib-compat.h\nindex 6226b30c0c..0c60e3af33 100644\n--- a/compat/zlib-compat.h\n+++ b/compat/zlib-compat.h\n@@ -1,11 +1,34 @@\n #ifndef COMPAT_ZLIB_H\n #define COMPAT_ZLIB_H\n \n-#include <zlib.h>\n+#ifdef HAVE_ZLIB_NG\n+# include <zlib-ng.h>\n \n-#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\n-# define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n-#endif\n+# define z_stream zng_stream\n+#define gz_header_s zng_gz_header_s\n+\n+# define crc32(crc, buf, len) zng_crc32(crc, buf, len)\n+\n+# define inflate(strm, bits) zng_inflate(strm, bits)\n+# define inflateEnd(strm) zng_inflateEnd(strm)\n+# define inflateInit(strm) zng_inflateInit(strm)\n+# define inflateInit2(strm, bits) zng_inflateInit2(strm, bits)\n+# define inflateReset(strm) zng_inflateReset(strm)\n+\n+# define deflate(strm, flush) zng_deflate(strm, flush)\n+# define deflateBound(strm, source_len) zng_deflateBound(strm, source_len)\n+# define deflateEnd(strm) zng_deflateEnd(strm)\n+# define deflateInit(strm, level) zng_deflateInit(strm, level)\n+# define deflateInit2(stream, level, method, window_bits, mem_level, strategy) zng_deflateInit2(stream, level, method, window_bits, mem_level, strategy)\n+# define deflateReset(strm) zng_deflateReset(strm)\n+# define deflateSetHeader(strm, head) zng_deflateSetHeader(strm, head)\n+\n+#else\n+# include <zlib.h>\n+\n+# if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\n+#  define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n+# endif\n \n /*\n  * zlib only gained support for setting up the gzip header in v1.2.2.1. In\n@@ -13,7 +36,7 @@\n  * operating systems, so it's fine to simply make this a no-op when using a\n  * zlib version that doesn't support this yet.\n  */\n-#if ZLIB_VERNUM < 0x1221\n+# if ZLIB_VERNUM < 0x1221\n struct gz_header_s {\n \tint os;\n };\n@@ -24,6 +47,7 @@ static int deflateSetHeader(z_streamp strm, struct gz_header_s *head)\n \t(void)(head);\n \treturn Z_OK;\n }\n-#endif\n+# endif\n+#endif /* HAVE_ZLIB_NG */\n \n #endif /* COMPAT_ZLIB_H */\ndiff --git a/meson.build b/meson.build\nindex 12129a8b95..f9e6a051e0 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -792,11 +792,23 @@ else\n   build_options_config.set('NO_PERL_CPAN_FALLBACKS', '')\n endif\n \n-zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])\n-if zlib.version().version_compare('<1.2.0')\n-  libgit_c_args += '-DNO_DEFLATE_BOUND'\n+zlib_backend = get_option('zlib_backend')\n+if zlib_backend in ['auto', 'zlib-ng']\n+  zlib_ng = dependency('zlib-ng', required: zlib_backend == 'zlib-ng')\n+  if zlib_ng.found()\n+    zlib_backend = 'zlib-ng'\n+    libgit_c_args += '-DHAVE_ZLIB_NG'\n+    libgit_dependencies += zlib_ng\n+  endif\n+endif\n+if zlib_backend in ['auto', 'zlib']\n+  zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])\n+  if zlib.version().version_compare('<1.2.0')\n+    libgit_c_args += '-DNO_DEFLATE_BOUND'\n+  endif\n+  zlib_backend = 'zlib'\n+  libgit_dependencies += zlib\n endif\n-libgit_dependencies += zlib\n \n threads = dependency('threads', required: false)\n if threads.found()\n@@ -2001,4 +2013,5 @@ summary({\n   'sha1': sha1_backend,\n   'sha1_unsafe': sha1_unsafe_backend,\n   'sha256': sha256_backend,\n+  'zlib': zlib_backend,\n }, section: 'Backends')\ndiff --git a/meson_options.txt b/meson_options.txt\nindex 5429022f30..c962c0a676 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -57,6 +57,8 @@ option('sha1_unsafe_backend', type: 'combo', choices: ['openssl', 'block', 'Comm\n   description: 'The backend used for hashing data with the SHA1 object format in case no cryptographic security is needed.')\n option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt', 'block'], value: 'block',\n   description: 'The backend used for hashing objects with the SHA256 object format.')\n+option('zlib_backend', type: 'combo', choices: ['auto', 'zlib', 'zlib-ng'], value: 'auto',\n+  description: 'The backend used for compressing objects and other data.')\n \n # Build tweaks.\n option('macos_use_homebrew_gettext', type: 'boolean', value: true,\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511349","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-9-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 09/10] ci: switch linux-musl to use Meson","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:35Z","receivedAt":"2025-01-28T08:41:40Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Switch over the \"linux-musl\" job to use Meson instead of Makefiles. This\nis done due to multiple reasons:\n\n  - It simplifies our CI infrastructure a bit as we don't have to\n    manually specify a couple of build options anymore.\n\n  - It verifies that Meson detects and sets those build options\n    automatically.\n\n  - It makes it easier for us to wire up a new CI job using zlib-ng as\n    backend.\n\nOne platform compatibility that Meson cannot easily detect automatically\nis the `GIT_TEST_UTF8_LOCALE` variable used in tests. Wire up a build\noption for it, which we set via a new \"MESONFLAGS\" environment variable.\n\nNote that we also drop the CC variable, which is set to \"gcc\". We\nalready default to GCC when CC is unset in \"ci/lib.sh\", so this is not\nneeded.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n .github/workflows/main.yml | 2 +-\n .gitlab-ci.yml             | 2 +-\n ci/install-dependencies.sh | 2 +-\n ci/lib.sh                  | 5 +----\n ci/run-build-and-tests.sh  | 3 ++-\n meson.build                | 2 +-\n meson_options.txt          | 2 ++\n 7 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 7f55f8b3a9..83bf9b918b 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -394,7 +394,7 @@ jobs:\n       fail-fast: false\n       matrix:\n         vector:\n-        - jobname: linux-musl\n+        - jobname: linux-musl-meson\n           image: alpine\n           distro: alpine-latest\n         # Supported until 2025-04-02.\ndiff --git a/.gitlab-ci.yml b/.gitlab-ci.yml\nindex 4976e18a05..f737e4177c 100644\n--- a/.gitlab-ci.yml\n+++ b/.gitlab-ci.yml\n@@ -67,7 +67,7 @@ test:linux:\n         CC: clang\n       - jobname: pedantic\n         image: fedora:latest\n-      - jobname: linux-musl\n+      - jobname: linux-musl-meson\n         image: alpine:latest\n       - jobname: linux-meson\n         image: ubuntu:latest\ndiff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh\nindex d1cb9fa878..5ae80b0486 100755\n--- a/ci/install-dependencies.sh\n+++ b/ci/install-dependencies.sh\n@@ -24,7 +24,7 @@ fi\n \n case \"$distro\" in\n alpine-*)\n-\tapk add --update shadow sudo build-base curl-dev openssl-dev expat-dev gettext \\\n+\tapk add --update shadow sudo meson ninja-build gcc libc-dev curl-dev openssl-dev expat-dev gettext \\\n \t\tpcre2-dev python3 musl-libintl perl-utils ncurses \\\n \t\tapache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \\\n \t\tbash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty >/dev/null\ndiff --git a/ci/lib.sh b/ci/lib.sh\nindex 8885ee3c3f..71d85ae85a 100755\n--- a/ci/lib.sh\n+++ b/ci/lib.sh\n@@ -378,10 +378,7 @@ linux32)\n \tCC=gcc\n \t;;\n linux-musl)\n-\tCC=gcc\n-\tMAKEFLAGS=\"$MAKEFLAGS PYTHON_PATH=/usr/bin/python3 USE_LIBPCRE2=Yes\"\n-\tMAKEFLAGS=\"$MAKEFLAGS NO_REGEX=Yes ICONV_OMITS_BOM=Yes\"\n-\tMAKEFLAGS=\"$MAKEFLAGS GIT_TEST_UTF8_LOCALE=C.UTF-8\"\n+\tMESONFLAGS=\"$MESONFLAGS -DGIT_TEST_UTF8_LOCALE=C.UTF-8\"\n \t;;\n linux-leaks|linux-reftable-leaks)\n \texport SANITIZE=leak\ndiff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh\nindex 964322055f..643c6a9dcc 100755\n--- a/ci/run-build-and-tests.sh\n+++ b/ci/run-build-and-tests.sh\n@@ -55,7 +55,8 @@ case \"$jobname\" in\n \t\t--fatal-meson-warnings \\\n \t\t--warnlevel 2 --werror \\\n \t\t--wrap-mode nofallback \\\n-\t\t-Dfuzzers=true\n+\t\t-Dfuzzers=true \\\n+\t\t$MESONFLAGS\n \tgroup \"Build\" meson compile -C build --\n \tif test -n \"$run_tests\"\n \tthen\ndiff --git a/meson.build b/meson.build\nindex f9e6a051e0..35b3c51fb1 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -664,7 +664,7 @@ build_options_config.set('GIT_TEST_CMP_USE_COPIED_CONTEXT', '')\n build_options_config.set('GIT_TEST_INDEX_VERSION', '')\n build_options_config.set('GIT_TEST_OPTS', '')\n build_options_config.set('GIT_TEST_PERL_FATAL_WARNINGS', '')\n-build_options_config.set('GIT_TEST_UTF8_LOCALE', '')\n+build_options_config.set_quoted('GIT_TEST_UTF8_LOCALE', get_option('test_utf8_locale'))\n build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))\n build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))\n \ndiff --git a/meson_options.txt b/meson_options.txt\nindex c962c0a676..e9f8e990e3 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -99,5 +99,7 @@ option('tests', type: 'boolean', value: true,\n   description: 'Enable building tests. This requires Perl, but is separate from the \"perl\" option such that you can build tests without Perl features enabled.')\n option('test_output_directory', type: 'string',\n   description: 'Path to the directory used to store test outputs')\n+option('test_utf8_locale', type: 'string',\n+  description: 'Name of a UTF-8 locale used for testing.')\n option('fuzzers', type: 'boolean', value: false,\n   description: 'Enable building fuzzers.')\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511350","messageId":"20250128-b4-pks-compat-drop-uncompress2-v4-10-129bc36ae8f5@pks.im","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"[PATCH v4 10/10] ci: make \"linux-musl\" job use zlib-ng","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-28T08:41:36Z","receivedAt":"2025-01-28T08:41:41Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We don't yet have any test coverage for the new zlib-ng backend as part\nof our CI. Add it by installing zlib-ng in Alpine Linux, which causes\nMeson to pick it up automatically.\n\nNote that we are somewhat limited with regards to where we run that job:\nDebian-based distributions don't have zlib-ng in their repositories,\nFedora has it but doesn't run tests, and Alma Linux doesn't have the\npackage either. Alpine Linux does have it available and is running our\ntest suite, which is why it was picked.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n ci/install-dependencies.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh\nindex 5ae80b0486..be7ab4b1bf 100755\n--- a/ci/install-dependencies.sh\n+++ b/ci/install-dependencies.sh\n@@ -25,7 +25,7 @@ fi\n case \"$distro\" in\n alpine-*)\n \tapk add --update shadow sudo meson ninja-build gcc libc-dev curl-dev openssl-dev expat-dev gettext \\\n-\t\tpcre2-dev python3 musl-libintl perl-utils ncurses \\\n+\t\tzlib-ng-dev pcre2-dev python3 musl-libintl perl-utils ncurses \\\n \t\tapache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \\\n \t\tbash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty >/dev/null\n \t;;\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511369","messageId":"xmqqv7tymzmm.fsf@gitster.g","threadId":"62863","inReplyTo":"20250128-b4-pks-compat-drop-uncompress2-v4-0-129bc36ae8f5@pks.im","subject":"Re: [PATCH v4 00/10] compat/zlib: allow use of zlib-ng as backend","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-01-28T20:50:41Z","receivedAt":"2025-01-28T20:50:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Changes in v4:\n>   - Add a comment explaining why we can stub out `deflateSetHeader()`.\n>   - Add a comment explaining why we have to cast away constness with\n>     zlib-ng's `next_in` field.\n>   - Link to v3: https://lore.kernel.org/r/20250116-b4-pks-compat-drop-uncompress2-v3-0-f2af1f5c4a06@pks.im\n>\n> I've adjusted the series to be based on top of fbe8d3079d (Git 2.48,\n> 2025-01-10) with ps/meson-weak-sha1-build at 6a0ee54f9a (meson: provide\n> a summary of configured backends, 2024-12-30) and ps/build-meson-fixes\n> at 4e517e68b5 (ci: wire up Visual Studio build with Meson, 2025-01-14)\n> merged into it. This matches what Junio has in his tree -- sorry for\n> screwing up the previous base!\n\nLooks like this is getting close to the final.  Will replace.\n\nThanks.\n"}]}