[PATCH] fix diff mode switching when side-by-side-diffs=1
Tim Chen
timchen1 at gmail.com
Mon Oct 10 05:17:28 CEST 2011
This is the patch for my previous email....
From: Tim Chen <timchen1 at gmail.com>
---
cgit.c | 1 +
cgit.h | 1 +
ui-diff.c | 7 ++-----
3 files changed, 4 insertions(+), 5 deletions(-)
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;
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();
--
1.7.6
More information about the CGit
mailing list