reftable/record: don't BUG() in reftable_record_cmp()

The reftable library aborts with a bug in case `reftable_record_cmp()`
is invoked with two records of differing types. This would cause the
program to die without the caller being able to handle the error, which
is not something we want in the context of library code. And it ties us
to the Git codebase.

Refactor the code such that `reftable_record_cmp()` returns an error
code separate from the actual comparison result. This requires us to
also adapt some callers up the callchain in a similar fashion.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-02-18 10:20:42 +01:00
committed by Junio C Hamano
parent 9d9fac0f34
commit 6f6127decd
7 changed files with 92 additions and 34 deletions

View File

@@ -22,7 +22,7 @@ struct merged_iter_pqueue {
size_t cap;
};
struct pq_entry merged_iter_pqueue_remove(struct merged_iter_pqueue *pq);
int merged_iter_pqueue_remove(struct merged_iter_pqueue *pq, struct pq_entry *out);
int merged_iter_pqueue_add(struct merged_iter_pqueue *pq, const struct pq_entry *e);
void merged_iter_pqueue_release(struct merged_iter_pqueue *pq);
int pq_less(struct pq_entry *a, struct pq_entry *b);