Diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/ui-repolist.c | 24 |
1 file changed, 23 insertions, 1 deletion
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 @@ -170,6 +170,23 @@ static int any_repos_visible(void) } /* + * 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; } |
