* [PATCH] fix diff mode switching when side-by-side-diffs=1
@ 2011-10-10 3:17 timchen1
2012-01-03 16:13 ` hjemli
0 siblings, 1 reply; 2+ messages in thread
From: timchen1 @ 2011-10-10 3:17 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] fix diff mode switching when side-by-side-diffs=1
2011-10-10 3:17 [PATCH] fix diff mode switching when side-by-side-diffs=1 timchen1
@ 2012-01-03 16:13 ` hjemli
0 siblings, 0 replies; 2+ messages in thread
From: hjemli @ 2012-01-03 16:13 UTC (permalink / raw)
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();
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-03 16:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-10 3:17 [PATCH] fix diff mode switching when side-by-side-diffs=1 timchen1
2012-01-03 16:13 ` hjemli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).