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 <a...@warmcat.com>

Reviewed-by: John Keeping <j...@keeping.me.uk>

> ---
>  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 = "&amp;";
>       }
> +
> +     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@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/cgit
_______________________________________________
CGit mailing list
CGit@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/cgit

Reply via email to