]> git.ipfire.org Git - thirdparty/git.git/commitdiff
transport-helper: drop const to fix strchr() warnings
authorJeff King <peff@peff.net>
Thu, 2 Apr 2026 04:14:56 +0000 (00:14 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Apr 2026 05:08:50 +0000 (22:08 -0700)
We implicitly drop the const from our "key" variable when we do:

  char *p = strchr(key, ' ');

which causes compilation with some C23 versions of libc (notably recent
glibc) to complain.

We need "p" to remain writable, since we assign NUL over the space we
found. We can solve this by also making "key" writable. This works
because it comes from a strbuf, which is itself a writable string.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
transport-helper.c

index 4d95d84f9e4d05db5117016bcdacadf3a4fe46b2..4614036c99a5a0464beb81a7b8e47e602074700c 100644 (file)
@@ -781,7 +781,8 @@ static int push_update_ref_status(struct strbuf *buf,
 
        if (starts_with(buf->buf, "option ")) {
                struct object_id old_oid, new_oid;
-               const char *key, *val;
+               char *key;
+               const char *val;
                char *p;
 
                if (!state->hint || !(state->report || state->new_report))