aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 6243d1b..4e317d0 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -727,6 +727,43 @@ void cgit_print_docend()
727 html("</body>\n</html>\n"); 727 html("</body>\n</html>\n");
728} 728}
729 729
730static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix)
731{
732 struct strbuf buf = STRBUF_INIT;
733 char *h = txt, *t, c;
734
735 while (h && *h) {
736 while (h && *h == ' ')
737 h++;
738 if (!*h)
739 break;
740 t = h;
741 while (t && *t && *t != ' ')
742 t++;
743 c = *t;
744 *t = 0;
745
746 if (suffix && *suffix) {
747 strbuf_reset(&buf);
748 strbuf_addf(&buf, "%s/%s", h, suffix);
749 h = buf.buf;
750 }
751 fn(h);
752 *t = c;
753 h = t;
754 }
755
756 strbuf_release(&buf);
757}
758
759void cgit_add_clone_urls(void (*fn)(const char *))
760{
761 if (ctx.repo->clone_url)
762 add_clone_urls(fn, expand_macros(ctx.repo->clone_url), NULL);
763 else if (ctx.cfg.clone_prefix)
764 add_clone_urls(fn, ctx.cfg.clone_prefix, ctx.repo->url);
765}
766
730static int print_branch_option(const char *refname, const unsigned char *sha1, 767static int print_branch_option(const char *refname, const unsigned char *sha1,
731 int flags, void *cb_data) 768 int flags, void *cb_data)
732{ 769{