[PATCH] fix diff mode switching when side-by-side-diffs=1

Lars Hjemli hjemli at gmail.com
Tue Jan 3 17:13:10 CET 2012


On Mon, Oct 10, 2011 at 05:17, Tim Chen <timchen1 at gmail.com> wrote:
> diff --git a/cgit.c b/cgit.c
> index b7807ad..1d50129 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -298,6 +298,7 @@ static void querystring_cb(const char *name, const
> char *value)
>                ctx.qry.period = xstrdup(value);
>        } else if (!strcmp(name, "ss")) {
>                ctx.qry.ssdiff = atoi(value);
> +               ctx.qry.has_ssdiff = 1;
>        } else if (!strcmp(name, "all")) {
>                ctx.qry.show_all = atoi(value);
>        } else if (!strcmp(name, "context")) {
> diff --git a/cgit.h b/cgit.h
> index bad66f0..c7ab5c6 100644
> --- a/cgit.h
> +++ b/cgit.h
> @@ -137,6 +137,7 @@ struct reflist {
>  struct cgit_query {
>        int has_symref;
>        int has_sha1;
> +       int has_ssdiff;
>        char *raw;
>        char *repo;
>        char *page;
> diff --git a/ui-diff.c b/ui-diff.c
> index d97a801..c6bad63 100644
> --- a/ui-diff.c
> +++ b/ui-diff.c
> @@ -341,9 +341,7 @@ void cgit_print_diff_ctrls()
>        html("<td class='label'>mode:</td>");
>        html("<td class='ctrl'>");
>        html("<select name='ss' onchange='this.form.submit();'>");
> -       curr = ctx.qry.ssdiff;
> -       if (!curr && ctx.cfg.ssdiff)
> -               curr = 1;
> +       curr = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff;

I've applied this change to master, and the other changes to stable. Thanks.


>        html_intoption(0, "unified", curr);
>        html_intoption(1, "ssdiff", curr);
>        html("</select></td></tr>");
> @@ -395,8 +393,7 @@ void cgit_print_diff(const char *new_rev, const
> char *old_rev,
>                }
>        }
>
> -       if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff &&
> ctx.cfg.ssdiff))
> -               use_ssdiff = 1;
> +       use_ssdiff = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff;
>
>        if (show_ctrls)
>                cgit_print_diff_ctrls();




More information about the CGit mailing list