]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable/writer: drop Git-specific `QSORT()` macro
authorPatrick Steinhardt <ps@pks.im>
Tue, 12 Aug 2025 09:54:16 +0000 (11:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Aug 2025 14:40:59 +0000 (07:40 -0700)
The reftable writer accidentally uses the Git-specific `QSORT()` macro.
This macro removes the need for the caller to provide the element size,
but other than that it's mostly equivalent to `qsort()`.

Replace the macro accordingly to make the library usable outside of Git.

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

index 5bad130c7ed09dcab9e7b98798e2a47ec66534e1..0133b649759bcfba8f0e4e89740704da39b78d32 100644 (file)
@@ -399,7 +399,8 @@ int reftable_writer_add_refs(struct reftable_writer *w,
 {
        int err = 0;
 
-       QSORT(refs, n, reftable_ref_record_compare_name);
+       if (n)
+               qsort(refs, n, sizeof(*refs), reftable_ref_record_compare_name);
 
        for (size_t i = 0; err == 0 && i < n; i++)
                err = reftable_writer_add_ref(w, &refs[i]);
@@ -491,7 +492,8 @@ int reftable_writer_add_logs(struct reftable_writer *w,
 {
        int err = 0;
 
-       QSORT(logs, n, reftable_log_record_compare_key);
+       if (n)
+               qsort(logs, n, sizeof(*logs), reftable_log_record_compare_key);
 
        for (size_t i = 0; err == 0 && i < n; i++)
                err = reftable_writer_add_log(w, &logs[i]);