]> granicus.if.org Git - cgit/commitdiff
ui-diff: Add links to increase/decrease number of context lines in diffs
authorJohan Herland <johan@herland.net>
Thu, 10 Jun 2010 18:15:51 +0000 (20:15 +0200)
committerLars Hjemli <hjemli@gmail.com>
Sat, 19 Jun 2010 11:00:07 +0000 (13:00 +0200)
Add two links to the "Diffstat" line to show more/less context lines in the
generated diff.

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

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
ui-diff.c
ui-shared.c

index d3a3b2c8bd04977232baa77004ec2e7015eb51b6..e0a72f757e79eb904e1fdf512fc876518f04d2df 100644 (file)
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -156,13 +156,21 @@ static void inspect_filepair(struct diff_filepair *pair)
 void cgit_print_diffstat(const unsigned char *old_sha1,
                         const unsigned char *new_sha1, const char *prefix)
 {
-       int i;
+       int i, save_context = ctx.qry.context;
 
        html("<div class='diffstat-header'>");
        cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
                       ctx.qry.sha2, NULL, 0);
        if (prefix)
                htmlf(" (limited to '%s')", prefix);
+       html(" (");
+       ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
+       cgit_self_link("more", NULL, NULL, &ctx);
+       html("/");
+       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("</div>");
        html("<table summary='diffstat' class='diffstat'>");
        max_changes = 0;
index e9917993fb2d4181bf3adb6ff4c01dea0cb52f26..c99bcecdf7905fa373d8839d83e3935d9c30faeb 100644 (file)
@@ -341,6 +341,13 @@ void cgit_commit_link(char *name, const char *title, const char *class,
        if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
                html(delim);
                html("ss=1");
+               delim = "&amp;";
+       }
+       if (ctx.qry.context > 0 && ctx.qry.context != 3) {
+               html(delim);
+               html("context=");
+               htmlf("%d", ctx.qry.context);
+               delim = "&amp;";
        }
        html("'>");
        html_txt(name);
@@ -382,6 +389,13 @@ void cgit_diff_link(const char *name, const char *title, const char *class,
        if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
                html(delim);
                html("ss=1");
+               delim = "&amp;";
+       }
+       if (ctx.qry.context > 0 && ctx.qry.context != 3) {
+               html(delim);
+               html("context=");
+               htmlf("%d", ctx.qry.context);
+               delim = "&amp;";
        }
        html("'>");
        html_txt(name);