From a3ef996f04db6a46e41575ca5a0442cdd709e485 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 4 Nov 2026 21:45:26 -1000 Subject: Answer an empty repository's feed with a feed --- source/cgit.c | 4 ++++ source/ui-atom.c | 4 ++++ source/ui-empty.c | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/cgit.c b/source/cgit.c index d982fdb..12ed19e 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -1241,6 +1241,10 @@ static int prepare_repo_cmd(int nongit, int err, int clone) // and those clone urls expand macros such // as $CGIT_REPO_URL out of this environment. prepare_repo_env(ctx.repo); + // A feed reader cannot read the page below, so the feed goes + // out with no entries. + if (!strcmp(ctx.qry.page, "atom")) + return 0; cgit_print_layout_start(); cgit_print_empty_repo(); cgit_print_layout_end(); diff --git a/source/ui-atom.c b/source/ui-atom.c index b9762b1..dea9360 100644 --- a/source/ui-atom.c +++ b/source/ui-atom.c @@ -167,6 +167,10 @@ void cgit_print_atom(char *tip, const char *path, int max_count) argv[1] = "--all"; else if (!tip) argv[1] = ctx.qry.head; + // An empty repository has no head, and a walk given nowhere to start + // leaves the feed without entries. + if (!argv[1]) + argc = 1; if (path) { argv[argc++] = "--"; diff --git a/source/ui-empty.c b/source/ui-empty.c index 76b2697..0bebfec 100644 --- a/source/ui-empty.c +++ b/source/ui-empty.c @@ -3,7 +3,8 @@ * the clone urls someone needs in order to push the first commit. cgit.c * prints this in place of whatever page was asked for as soon as it finds * there is no branch to resolve, so none of the ref driven pages ever run - * against an empty repository. + * against an empty repository. The Atom feed is the exception, sent with no + * entries, since a feed reader cannot read this page. */ #include "cgit.h" -- cgit 2.12.1