mirror of
https://git.zx2c4.com/cgit
synced 2024-11-22 16:38:42 +00:00
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>
This commit is contained in:
parent
6180e6169d
commit
d20313e3da
10
ui-diff.c
10
ui-diff.c
@ -156,13 +156,21 @@ static void inspect_filepair(struct diff_filepair *pair)
|
|||||||
void cgit_print_diffstat(const unsigned char *old_sha1,
|
void cgit_print_diffstat(const unsigned char *old_sha1,
|
||||||
const unsigned char *new_sha1, const char *prefix)
|
const unsigned char *new_sha1, const char *prefix)
|
||||||
{
|
{
|
||||||
int i;
|
int i, save_context = ctx.qry.context;
|
||||||
|
|
||||||
html("<div class='diffstat-header'>");
|
html("<div class='diffstat-header'>");
|
||||||
cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
|
cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
|
||||||
ctx.qry.sha2, NULL, 0);
|
ctx.qry.sha2, NULL, 0);
|
||||||
if (prefix)
|
if (prefix)
|
||||||
htmlf(" (limited to '%s')", 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("</div>");
|
||||||
html("<table summary='diffstat' class='diffstat'>");
|
html("<table summary='diffstat' class='diffstat'>");
|
||||||
max_changes = 0;
|
max_changes = 0;
|
||||||
|
14
ui-shared.c
14
ui-shared.c
@ -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)) {
|
if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
|
||||||
html(delim);
|
html(delim);
|
||||||
html("ss=1");
|
html("ss=1");
|
||||||
|
delim = "&";
|
||||||
|
}
|
||||||
|
if (ctx.qry.context > 0 && ctx.qry.context != 3) {
|
||||||
|
html(delim);
|
||||||
|
html("context=");
|
||||||
|
htmlf("%d", ctx.qry.context);
|
||||||
|
delim = "&";
|
||||||
}
|
}
|
||||||
html("'>");
|
html("'>");
|
||||||
html_txt(name);
|
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)) {
|
if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
|
||||||
html(delim);
|
html(delim);
|
||||||
html("ss=1");
|
html("ss=1");
|
||||||
|
delim = "&";
|
||||||
|
}
|
||||||
|
if (ctx.qry.context > 0 && ctx.qry.context != 3) {
|
||||||
|
html(delim);
|
||||||
|
html("context=");
|
||||||
|
htmlf("%d", ctx.qry.context);
|
||||||
|
delim = "&";
|
||||||
}
|
}
|
||||||
html("'>");
|
html("'>");
|
||||||
html_txt(name);
|
html_txt(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user