summaryrefslogtreecommitdiff
path: root/reftable/record.c
Commit message (Collapse)AuthorAgeFilesLines
* reftable: add print functions to the record typesHan-Wen Nienhuys2022-01-201-14/+71
| | | | | | | | This isn't used per se, but it is useful for debugging, especially Windows CI failures. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* reftable: make reftable_record a tagged unionHan-Wen Nienhuys2022-01-201-112/+100
| | | | | | | | | | | | | | | | | | This reduces the amount of glue code, because we don't need a void pointer or vtable within the structure. The only snag is that reftable_index_record contain a strbuf, so it cannot be zero-initialized. To address this, use reftable_new_record() to return fresh instance, given a record type. Since reftable_new_record() doesn't cause heap allocation anymore, it should be balanced with reftable_record_release() rather than reftable_record_destroy(). Thanks to Peff for the suggestion. Helped-by: Jeff King <peff@peff.net> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* reftable: implement record equality genericallyHan-Wen Nienhuys2022-01-201-1/+56
| | | | | | | | This simplifies unittests a little, and provides further coverage for reftable_record_copy(). Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* reftable: make reftable-record.h function signatures const correctHan-Wen Nienhuys2022-01-201-7/+7
| | | | | Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* reftable: handle null refnames in reftable_ref_record_equalHan-Wen Nienhuys2022-01-201-3/+5
| | | | | | | Spotted by Coverity. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* reftable: fix OOB stack write in print functionsHan-Wen Nienhuys2022-01-201-2/+2
| | | | | Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* reftable: (de)serialization for the polymorphic record type.Han-Wen Nienhuys2021-10-081-0/+1212
The reftable format is structured as a sequence of blocks, and each block contains a sequence of prefix-compressed key-value records. There are 4 types of records, and they have similarities in how they must be handled. This is achieved by introducing a polymorphic 'record' type that encapsulates ref, log, index and object records. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>