From mboxrd@z Thu Jan 1 00:00:00 1970 From: andy at warmcat.com (Andy Green) Date: Wed, 20 Jun 2018 18:13:04 +0800 Subject: [PATCH v4 13/16] ui-shared: deduplicate some code in repolink In-Reply-To: <152948941145.29466.10223016890282865269.stgit@mail.warmcat.com> References: <152948941145.29466.10223016890282865269.stgit@mail.warmcat.com> Message-ID: <152948958485.29466.1544494167040225975.stgit@mail.warmcat.com> 8 lines of code are duplicated in repolink, clean it so the common code appears once Signed-off-by: Andy Green Reviewed-by: John Keeping --- ui-shared.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/ui-shared.c b/ui-shared.c index d2985c8..21bbded 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -241,28 +241,22 @@ static char *repolink(const char *title, const char *class, const char *page, if (ctx.cfg.virtual_root) { html_url_path(ctx.cfg.virtual_root); html_url_path(ctx.repo->url); - if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') - html("/"); - if (page) { - html_url_path(page); - html("/"); - if (path) - html_url_path(path); - } } else { html_url_path(ctx.cfg.script_name); html("?url="); html_url_arg(ctx.repo->url); - if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') - html("/"); - if (page) { - html_url_arg(page); - html("/"); - if (path) - html_url_arg(path); - } delim = "&"; } + + if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') + html("/"); + if (page) { + html_url_arg(page); + html("/"); + if (path) + html_url_arg(path); + } + if (head && ctx.repo->defbranch && strcmp(head, ctx.repo->defbranch)) { html(delim); html("h=");