]> git.ipfire.org Git - thirdparty/git.git/commit
commit: sign commit after mutating buffer
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 27 Apr 2026 22:18:34 +0000 (22:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Apr 2026 00:51:11 +0000 (09:51 +0900)
commit7735d7eee3a586181dc397afa5aa8f02e009833b
treec13debc0c2b439e69192bbe6781329df1f8893e3
parent1ddc0481cfb744d51e235a8cccf97d4afb498743
commit: sign commit after mutating buffer

The ensure_utf8 function can mutate the buffer to change its encoding,
so we must call it before signing the buffer so that we do not
invalidate the signature, which is made over raw bytes.  Fix a bug which
caused the compatibility code to not convert the compatibility buffer if
the main buffer was invalid UTF-8.  We expect both buffers to be valid
UTF-8 or both invalid, since the only data that would differ between
them would be hex object IDs, which are always valid UTF-8.

Add a test for this case using 0xfe and 0xff, which are never valid in
UTF-8.

Reported-by: Kushal Das <kushal@sunet.se>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c
t/t7510-signed-commit.sh