From 9f006ab5f57522f36f9c51eb2f370021311a72d4 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 25 Jul 2026 11:02:59 -1000 Subject: Cap the header branch switcher --- source/ui-shared.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index 3ec4f55..16ff875 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -948,7 +948,13 @@ void cgit_add_clone_urls(void (*fn)(const char *)) static int print_branch_option(const struct reference *ref, void *cb_data) { + int *count = cb_data; char *name = (char *)ref->name; + // The switcher runs on every page, so bound it like the refs list + // rather than emitting an option for every branch in the repo. + if (ctx.cfg.max_ref_count && *count >= ctx.cfg.max_ref_count) + return -1; + (*count)++; html_option(name, name, ctx.qry.head); return 0; } @@ -1065,11 +1071,12 @@ static void print_header(void) html("
\n"); cgit_add_hidden_formfields(0, 1, ctx.qry.page); html(" "); html(""); html("
\n"); -- cgit v2.8.0