receive-pack: use find_commit_header() in check_cert_push_options()
commitf51d790b67255dd40b55654527fc4f59a53f44b0
authorRené Scharfe <l.s.r@web.de>
Fri, 9 Feb 2024 20:36:40 +0000 (9 21:36 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2024 22:03:15 +0000 (9 14:03 -0800)
tree504536b1d37bf3ffe619a13d9340dc813fa854e3
parent3526e67d917bcd03f317a058208fa02737654637
receive-pack: use find_commit_header() in check_cert_push_options()

Use the public function find_commit_header() instead of find_header() to
simplify the code.  This is possible and safe because we're operating on
a strbuf, which is always NUL-terminated, so there is no risk of running
over the end of the buffer.  It cannot contain NUL within the buffer, as
it is built using strbuf_addstr(), only.

The string comparison becomes more complicated because we need to check
for NUL explicitly after comparing the length-limited option, but on the
flip side we don't need to clean up allocations or track the remaining
buffer length.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/receive-pack.c