From: Jeff King Date: Thu, 2 Apr 2026 04:14:49 +0000 (-0400) Subject: convert: add const to fix strchr() warnings X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2b9665c4e82a1a62d93a64e9892574d6e03ec019;p=thirdparty%2Fgit.git convert: add const to fix strchr() warnings C23 versions of libc (like recent glibc) may provide generic versions of strchr() that match constness between the input and return value. The idea being that the compiler can detect when it implicitly converts a const pointer into a non-const one (which then emits a warning). There are a few cases here where the result pointer does not need to be non-const at all, and we should mark it as such. That silences the warning (and avoids any potential problems with trying to write via those pointers). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/convert.c b/convert.c index a34ec6ecdc..eae36c8a59 100644 --- a/convert.c +++ b/convert.c @@ -1168,7 +1168,8 @@ static int ident_to_worktree(const char *src, size_t len, struct strbuf *buf, int ident) { struct object_id oid; - char *to_free = NULL, *dollar, *spc; + char *to_free = NULL; + const char *dollar, *spc; int cnt; if (!ident)