aboutsummaryrefslogtreecommitdiffstats
path: root/ui-diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-diff.c')
-rw-r--r--ui-diff.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/ui-diff.c b/ui-diff.c
index a92a768..e0a72f7 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -127,7 +127,7 @@ static void inspect_filepair(struct diff_filepair *pair)
127 lines_added = 0; 127 lines_added = 0;
128 lines_removed = 0; 128 lines_removed = 0;
129 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size, 129 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size,
130 &binary, count_diff_lines); 130 &binary, 0, count_diff_lines);
131 if (files >= slots) { 131 if (files >= slots) {
132 if (slots == 0) 132 if (slots == 0)
133 slots = 4; 133 slots = 4;
@@ -154,17 +154,27 @@ static void inspect_filepair(struct diff_filepair *pair)
154} 154}
155 155
156void cgit_print_diffstat(const unsigned char *old_sha1, 156void cgit_print_diffstat(const unsigned char *old_sha1,
157 const unsigned char *new_sha1) 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)
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)");
164 html("</div>"); 174 html("</div>");
165 html("<table summary='diffstat' class='diffstat'>"); 175 html("<table summary='diffstat' class='diffstat'>");
166 max_changes = 0; 176 max_changes = 0;
167 cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, NULL); 177 cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix);
168 for(i = 0; i<files; i++) 178 for(i = 0; i<files; i++)
169 print_fileinfo(&items[i]); 179 print_fileinfo(&items[i]);
170 html("</table>"); 180 html("</table>");
@@ -286,7 +296,7 @@ static void filepair_cb(struct diff_filepair *pair)
286 return; 296 return;
287 } 297 }
288 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, 298 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size,
289 &new_size, &binary, print_line_fn)) 299 &new_size, &binary, ctx.qry.context, print_line_fn))
290 cgit_print_error("Error running diff"); 300 cgit_print_error("Error running diff");
291 if (binary) { 301 if (binary) {
292 if (use_ssdiff) 302 if (use_ssdiff)
@@ -338,7 +348,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
338 use_ssdiff = 1; 348 use_ssdiff = 1;
339 349
340 print_ssdiff_link(); 350 print_ssdiff_link();
341 cgit_print_diffstat(old_rev_sha1, new_rev_sha1); 351 cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
342 352
343 if (use_ssdiff) { 353 if (use_ssdiff) {
344 html("<table summary='ssdiff' class='ssdiff'>"); 354 html("<table summary='ssdiff' class='ssdiff'>");