commit d1c012787ee97eddea5d0f5ef79f62a3705f6614
parent ae8535e329f9b78bf6e382b3e9ba08d4c4f7eb70
Author: Chris Bracken <chris@bracken.jp>
Date: Fri, 20 Feb 2026 18:08:46 +0900
atom: skip commits with missing/blank OID
Atom <entry> elements require an <id> child, so if we don't have one,
skip the entry.
Diffstat:
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/writer/atom/atom.c b/src/writer/atom/atom.c
@@ -1,6 +1,7 @@
#include "atom.h"
#include <assert.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -71,12 +72,14 @@ void atom_add_commit(Atom* atom,
if (atom->remaining_commits == 0) {
return;
}
+ if (!commit->oid || commit->oid[0] == '\0') {
+ warnx("atom: processed commit with missing/empty object ID");
+ return;
+ }
atom->remaining_commits--;
fprintf(out, "<entry>\n");
- if (commit->oid) {
- fprintf(out, "<id>%s</id>\n", commit->oid);
- }
+ fprintf(out, "<id>%s</id>\n", commit->oid);
fprintf(out, "<published>");
print_time_z(out, commit->author_time);
@@ -121,11 +124,9 @@ void atom_add_commit(Atom* atom,
fprintf(out, "</email>\n</author>\n");
fprintf(out, "<content>");
- if (commit->oid) {
- fprintf(out, "commit %s\n", commit->oid);
- }
+ fprintf(out, "commit %s\n", commit->oid);
const char* parentoid = commit->parentoid;
- if (parentoid && parentoid[0]) {
+ if (parentoid && parentoid[0] != '\0') {
fprintf(out, "parent %s\n", parentoid);
}
fprintf(out, "Author: ");