summaryrefslogtreecommitdiffabout
path: root/ui-diff.c
authorJohan Herland <johan@herland.net>2010-06-10 18:15:51 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-06-19 11:00:07 (UTC)
commitd20313e3daf855ee5d4808e050f54614c200d7b1 (patch) (unidiff)
tree5c462f3ba6ec97c0b099a309dfd0fa87d03fbc72 /ui-diff.c
parent6180e6169d6e87a3bea7e4da835dca17f93e5cfd (diff)
downloadcgit-d20313e3daf855ee5d4808e050f54614c200d7b1.zip
cgit-d20313e3daf855ee5d4808e050f54614c200d7b1.tar.gz
cgit-d20313e3daf855ee5d4808e050f54614c200d7b1.tar.bz2
ui-diff: Add links to increase/decrease number of context lines in diffs
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>
Diffstat (limited to 'ui-diff.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-diff.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui-diff.c b/ui-diff.c
index d3a3b2c..e0a72f7 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -156,13 +156,21 @@ static void inspect_filepair(struct diff_filepair *pair)
156void cgit_print_diffstat(const unsigned char *old_sha1, 156void cgit_print_diffstat(const unsigned char *old_sha1,
157 const unsigned char *new_sha1, const char *prefix) 157 const unsigned char *new_sha1, const char *prefix)
158{ 158{
159 int i; 159 int i, save_context = ctx.qry.context;
160 160
161 html("<div class='diffstat-header'>"); 161 html("<div class='diffstat-header'>");
162 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, 162 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
163 ctx.qry.sha2, NULL, 0); 163 ctx.qry.sha2, NULL, 0);
164 if (prefix) 164 if (prefix)
165 htmlf(" (limited to '%s')", prefix); 165 htmlf(" (limited to '%s')", prefix);
166 html(" (");
167 ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
168 cgit_self_link("more", NULL, NULL, &ctx);
169 html("/");
170 ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
171 cgit_self_link("less", NULL, NULL, &ctx);
172 ctx.qry.context = save_context;
173 html(" context)");
166 html("</div>"); 174 html("</div>");
167 html("<table summary='diffstat' class='diffstat'>"); 175 html("<table summary='diffstat' class='diffstat'>");
168 max_changes = 0; 176 max_changes = 0;