diff options
Diffstat (limited to 'source/ui-shared.c')
| -rw-r--r-- | source/ui-shared.c | 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 9 insertions, 2 deletions
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("<form class='branch-switch' method='get'>\n"); cgit_add_hidden_formfields(0, 1, ctx.qry.page); html("<select name='h' aria-label='Branch' data-autosubmit='1'>\n"); + int branch_count = 0; refs_for_each_branch_ref(get_main_ref_store(the_repository), - print_branch_option, ctx.qry.head); + print_branch_option, &branch_count); if (ctx.repo->enable_remote_branches) refs_for_each_remote_ref(get_main_ref_store(the_repository), - print_branch_option, ctx.qry.head); + print_branch_option, &branch_count); html("</select> "); html("<input type='submit' value='switch'/>"); html("</form>\n"); |
