From c92c0fa877807f7c0dd7b27ed78fe1076d18d38f Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:37:56 -0700 Subject: Open the empty page's clone table on its first url The page guessed from the two settings cgit_add_clone_urls reads, so a clone-url that expanded to nothing, or an empty one turning the global off, still drew a Clone heading over no rows. The summary already waits for a first url, and both now draw the heading the same way. --- source/ui-empty.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'source/ui-empty.c') diff --git a/source/ui-empty.c b/source/ui-empty.c index deefc21..76b2697 100644 --- a/source/ui-empty.c +++ b/source/ui-empty.c @@ -11,8 +11,17 @@ #include "ui-empty.h" #include "ui-shared.h" +static int clone_urls_printed; + static void print_clone_url(const char *url) { + // cgit_add_clone_urls may call back no times at all, so the table + // waits for a first url rather than being opened ahead of the walk. + if (clone_urls_printed++ == 0) { + html("\n\n"); + html("\n"); + } + cgit_print_clone_row(url, 0); } @@ -23,14 +32,8 @@ static void print_clone_url(const char *url) void cgit_print_empty_repo(void) { cgit_print_error("Repository seems to be empty"); - - // cgit_add_clone_urls draws on these two alone, so with neither set - // the table below would be a Clone heading with no rows. - if (!ctx.repo->clone_url && !ctx.cfg.clone_prefix) - return; - - html("
Clone
\n\n"); - html("\n"); + clone_urls_printed = 0; cgit_add_clone_urls(print_clone_url); - html("\n
Clone
\n"); + if (clone_urls_printed) + html("\n\n"); } -- cgit