]> git.ipfire.org Git - thirdparty/git.git/commit - reftable/stack.c
reftable/stack: do not overwrite errors when compacting
authorPatrick Steinhardt <ps@pks.im>
Wed, 3 Jan 2024 06:22:13 +0000 (07:22 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Jan 2024 17:54:20 +0000 (09:54 -0800)
commitd26c21483d327fdecb52a98be8239f0f224423f9
tree386432457eb20c151d8c17aa389e8593f283702f
parent5809004f261e0468ae9c8bca83b600852e751920
reftable/stack: do not overwrite errors when compacting

In order to compact multiple stacks we iterate through the merged ref
and log records. When there is any error either when reading the records
from the old merged table or when writing the records to the new table
then we break out of the respective loops. When breaking out of the loop
for the ref records though the error code will be overwritten, which may
cause us to inadvertently skip over bad ref records. In the worst case,
this can lead to a compacted stack that is missing records.

Fix the code by using `goto done` instead so that any potential error
codes are properly returned to the caller.

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