]> granicus.if.org Git - cgit/commitdiff
ui-diff: Add link to ignore/show whitespace changes in diffs
authorJohan Herland <johan@herland.net>
Thu, 24 Jun 2010 15:53:20 +0000 (17:53 +0200)
committerLars Hjemli <hjemli@gmail.com>
Sun, 18 Jul 2010 08:54:02 +0000 (10:54 +0200)
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
ui-shared.c

index 1656b77b845ebbb7e0c9da69170458ca08859fce..0dcabe90b9931e4b53e009a89b9853dcf3ab8c76 100644 (file)
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -171,6 +171,11 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
        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;
index c99bcecdf7905fa373d8839d83e3935d9c30faeb..f46c935cdeeb784ddaed4fcaf7c2e57dee49a9d9 100644 (file)
@@ -349,6 +349,11 @@ void cgit_commit_link(char *name, const char *title, const char *class,
                htmlf("%d", ctx.qry.context);
                delim = "&amp;";
        }
+       if (ctx.qry.ignorews) {
+               html(delim);
+               html("ignorews=1");
+               delim = "&amp;";
+       }
        html("'>");
        html_txt(name);
        html("</a>");
@@ -397,6 +402,11 @@ void cgit_diff_link(const char *name, const char *title, const char *class,
                htmlf("%d", ctx.qry.context);
                delim = "&amp;";
        }
+       if (ctx.qry.ignorews) {
+               html(delim);
+               html("ignorews=1");
+               delim = "&amp;";
+       }
        html("'>");
        html_txt(name);
        html("</a>");