]> git.ipfire.org Git - thirdparty/git.git/commit
shallow: give write_one_shallow() its own hex buffer
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 10 Jul 2026 11:39:36 +0000 (11:39 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jul 2026 15:13:55 +0000 (08:13 -0700)
commit764255357846d79f9f960cd0bf0cdbbe21ed0f72
treef5be4fe7628ea9a10379134adeb80f40025b33bc
parent83e717ee38e5c0ba43cc55762012a0c5da2a84f6
shallow: give write_one_shallow() its own hex buffer

The previous fix reuses the local `hex` variable that is already
computed at the top of `write_one_shallow()`. That works today, but
`oid_to_hex()` returns a pointer into a small rotating buffer, so it is
not stable across an unrelated call to `oid_to_hex()` from the same
thread. A future edit that adds such a call between the assignment and
the last user of `hex` would silently corrupt the output.

Move `write_one_shallow()` off the rotating buffer entirely by using a
local buffer instead. The current users of that `hex` variable are
unchanged.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Assisted-by: Claude Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
shallow.c