reftable/stack: fix stale lock when dying
commit3054fbd93edb5f12c1a320dfb6abec139bdf9628
authorPatrick Steinhardt <ps@pks.im>
Mon, 11 Dec 2023 09:07:54 +0000 (11 10:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Dec 2023 15:23:16 +0000 (11 07:23 -0800)
treecfc459054905833a55035b5eeea760daefc49b09
parentd779996a1087747886853f4e73cff920c09ab1a2
reftable/stack: fix stale lock when dying

When starting a transaction via `reftable_stack_init_addition()`, we
create a lockfile for the reftable stack itself which we'll write the
new list of tables to. But if we terminate abnormally e.g. via a call to
`die()`, then we do not remove the lockfile. Subsequent executions of
Git which try to modify references will thus fail with an out-of-date
error.

Fix this bug by registering the lock as a `struct tempfile`, which
ensures automatic cleanup for us.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/stack.c