From bdd3af7c6ab23ecb8fc377b3404282793eb9c802 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 1 Nov 2026 16:10:49 -1000 Subject: Say when nothing matches a mistyped url --- source/ui-repolist.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/ui-repolist.c b/source/ui-repolist.c index 87abf0b..3eb9375 100644 --- a/source/ui-repolist.c +++ b/source/ui-repolist.c @@ -169,6 +169,23 @@ static int any_repos_visible(void) return 0; } +/* + * Whether any listed repository lies under the url the request carried, + * whatever the search terms. + */ +static int any_repos_under_url(void) +{ + int i; + + for (i = 0; i < cgit_repolist.count; i++) { + struct cgit_repo *repo = &cgit_repolist.repos[i]; + + if (!repo->hide && !repo->ignore && matches_url(repo)) + return 1; + } + return 0; +} + /* * currenturl is passed in because it is the same for every heading and every * row, and working it out here would mean an allocation and a free per cell. @@ -398,7 +415,12 @@ void cgit_print_repolist(void) cgit_read_repo_desc(&cgit_repolist.repos[i]); if (!any_repos_visible()) { - cgit_print_error_page(404, "Not Found", "No repositories found"); + // A url naming no repository or page lands here, as a prefix + // that no repository's url starts with. + if (ctx.qry.url && *ctx.qry.url && !any_repos_under_url()) + cgit_print_error_page(404, "Not Found", "Nothing matches this url"); + else + cgit_print_error_page(404, "Not Found", "No repositories found"); return; } -- cgit 2.12.1