]> granicus.if.org Git - cgit/commitdiff
Fix diff mode switching when side-by-side-diffs=1
authorTim Chen <timchen1@gmail.com>
Tue, 3 Jan 2012 16:02:14 +0000 (16:02 +0000)
committerLars Hjemli <hjemli@gmail.com>
Tue, 3 Jan 2012 16:02:14 +0000 (16:02 +0000)
When side-by-side-diffs=1 was set in cgitrc, specyfing 'ss=0' in the query-
string would not switch to unified diffs. This patch fixes the issue by
introducing a separate variable to track the occurrence of "ss" in the
querystring.

cgit.c
cgit.h
ui-diff.c

diff --git a/cgit.c b/cgit.c
index 5259f56fcd9cc09ebf152bcc163fd2801427afa4..435ce5a538d95ebec0c5a1397c5b9bdba00d86b8 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -281,6 +281,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 b5f00fc9c1c1d6d6e7f7a8cdc2695cab334752ab..63847ff49a64caa7ba9367e58526bcbebe9cfa9b 100644 (file)
--- a/cgit.h
+++ b/cgit.h
@@ -133,6 +133,7 @@ struct reflist {
 struct cgit_query {
        int has_symref;
        int has_sha1;
+       int has_ssdiff;
        char *raw;
        char *repo;
        char *page;
index 383a5347c2dbcb1ca9ae2bea53539a68d3ca94a3..f8782df260c03a5231ecb740658caff4e3f8a583 100644 (file)
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -372,8 +372,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
                }
        }
 
-       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;
 
        print_ssdiff_link();
        cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);