cgit

commit 72ef913514288bd2aae23509581097bfd3edf8c4

Author: Johan Herland <johan@herland.net>

ui-diff: Add link to ignore/show whitespace changes in diffs

Add a link to the "Diffstat" line to ignore/show whitespace changes in the
generated diff.

To support this, cgit_commit_link() and cgit_diff_link() has learned to
preserve the ctx.qry.ignorews variable.

Signed-off-by: Johan Herland <johan@herland.net>

 ui-diff.c | 5 +++++
 ui-shared.c | 10 ++++++++++


diff --git a/ui-diff.c b/ui-diff.c
index 1656b77b845ebbb7e0c9da69170458ca08859fce..0dcabe90b9931e4b53e009a89b9853dcf3ab8c76 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -171,6 +171,11 @@ 	ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
 	cgit_self_link("less", NULL, NULL, &ctx);
 	ctx.qry.context = save_context;
 	html(" context)");
+	html(" (");
+	ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
+	cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx);
+	ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
+	html(" whitespace changes)");
 	html("</div>");
 	html("<table summary='diffstat' class='diffstat'>");
 	max_changes = 0;




diff --git a/ui-shared.c b/ui-shared.c
index c99bcecdf7905fa373d8839d83e3935d9c30faeb..f46c935cdeeb784ddaed4fcaf7c2e57dee49a9d9 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -349,6 +349,11 @@ 		html("context=");
 		htmlf("%d", ctx.qry.context);
 		delim = "&amp;";
 	}
+	if (ctx.qry.ignorews) {
+		html(delim);
+		html("ignorews=1");
+		delim = "&amp;";
+	}
 	html("'>");
 	html_txt(name);
 	html("</a>");
@@ -395,6 +400,11 @@ 	if (ctx.qry.context > 0 && ctx.qry.context != 3) {
 		html(delim);
 		html("context=");
 		htmlf("%d", ctx.qry.context);
+		delim = "&amp;";
+	}
+	if (ctx.qry.ignorews) {
+		html(delim);
+		html("ignorews=1");
 		delim = "&amp;";
 	}
 	html("'>");