+void cgit_print_error_page(int code, const char *msg, const char *fmt, ...)
+{
+ va_list ap;
+ ctx.page.expires = ctx.cfg.cache_dynamic_ttl;
+ ctx.page.status = code;
+ ctx.page.statusmsg = msg;
+ cgit_print_layout_start();
+ va_start(ap, fmt);
+ cgit_vprint_error(fmt, ap);
+ va_end(ap);
+ cgit_print_layout_end();
+}
+
+void cgit_print_layout_start(void)
+{
+ cgit_print_http_headers();
+ cgit_print_docstart();
+ cgit_print_pageheader();
+}
+
+void cgit_print_layout_end(void)
+{
+ cgit_print_docend();
+}
+
+static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix)
+{
+ struct strbuf **url_list = strbuf_split_str(txt, ' ', 0);
+ int i;
+
+ for (i = 0; url_list[i]; i++) {
+ strbuf_rtrim(url_list[i]);
+ if (url_list[i]->len == 0)
+ continue;
+ if (suffix && *suffix)
+ strbuf_addf(url_list[i], "/%s", suffix);
+ fn(url_list[i]->buf);
+ }
+
+ strbuf_list_free(url_list);
+}
+
+void cgit_add_clone_urls(void (*fn)(const char *))
+{
+ if (ctx.repo->clone_url)
+ add_clone_urls(fn, expand_macros(ctx.repo->clone_url), NULL);
+ else if (ctx.cfg.clone_prefix)
+ add_clone_urls(fn, ctx.cfg.clone_prefix, ctx.repo->url);
+}
+
+static int print_branch_option(const char *refname, const struct object_id *oid,