]> Kevux Git Server - rit/commit
refs/files-backend: drop const to fix strchr() warning
authorJeff King <peff@peff.net>
Thu, 2 Apr 2026 04:15:16 +0000 (00:15 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Apr 2026 05:08:53 +0000 (22:08 -0700)
commitf1b8a4d10888922eacaa9552d9925d3330ed5d8b
treef8eedbcdc4f30c909aabb11836b772be1fc63d16
parent8a0566b42b133b73423c801a7ab6f356de69f51a
refs/files-backend: drop const to fix strchr() warning

In show_one_reflog_ent(), we're fed a writable strbuf buffer, which we
parse into the various reflog components. We write a NUL over email_end
to tie off one of the fields, and thus email_end must be non-const.

But with a C23 implementation of libc, strchr() will now complain when
assigning the result to a non-const pointer from a const one. So we can
fix this by making the source pointer non-const.

But there's a catch. We derive that source pointer by parsing the line
with parse_oid_hex_algop(), which requires a const pointer for its
out-parameter. We can work around that by teaching it to use our
CONST_OUTPARAM() trick, just like skip_prefix().

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
hex.c
hex.h
refs/files-backend.c