From mboxrd@z Thu Jan 1 00:00:00 1970 From: andy at warmcat.com (Andy Green) Date: Tue, 19 Jun 2018 17:02:42 +0800 Subject: [PATCH v3 15/17] ui-shared: deduplicate some code in repolink In-Reply-To: <152939875224.4492.4288866616332837866.stgit@mail.warmcat.com> References: <152939875224.4492.4288866616332837866.stgit@mail.warmcat.com> Message-ID: <152939896267.4492.6949397538693469427.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 --- 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=");