From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Tue, 19 Jun 2018 22:48:55 +0100 Subject: [PATCH v3 15/17] ui-shared: deduplicate some code in repolink In-Reply-To: <152939896267.4492.6949397538693469427.stgit@mail.warmcat.com> References: <152939875224.4492.4288866616332837866.stgit@mail.warmcat.com> <152939896267.4492.6949397538693469427.stgit@mail.warmcat.com> Message-ID: <20180619214855.GB1922@john.keeping.me.uk> On Tue, Jun 19, 2018 at 05:02:42PM +0800, Andy Green wrote: > 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="); > > _______________________________________________ > CGit mailing list > CGit at lists.zx2c4.com > https://lists.zx2c4.com/mailman/listinfo/cgit