|
diff --git a/ui-diff.c b/ui-diff.c index fb836df..e0a72f7 100644 --- a/ ui-diff.c+++ b/ ui-diff.c |
|
@@ -124,13 +124,13 @@ static void inspect_filepair(struct diff_filepair *pair) |
124 | unsigned long old_size = 0; |
124 | unsigned long old_size = 0; |
125 | unsigned long new_size = 0; |
125 | unsigned long new_size = 0; |
126 | files++; |
126 | files++; |
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; |
134 | else |
134 | else |
135 | slots = slots * 2; |
135 | slots = slots * 2; |
136 | items = xrealloc(items, slots * sizeof(struct fileinfo)); |
136 | items = xrealloc(items, slots * sizeof(struct fileinfo)); |
@@ -153,19 +153,27 @@ static void inspect_filepair(struct diff_filepair *pair) |
153 | total_rems += lines_removed; |
153 | total_rems += lines_removed; |
154 | } |
154 | } |
155 | |
155 | |
156 | void cgit_print_diffstat(const unsigned char *old_sha1, |
156 | void 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; |
169 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix); |
177 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix); |
170 | for(i = 0; i<files; i++) |
178 | for(i = 0; i<files; i++) |
171 | print_fileinfo(&items[i]); |
179 | print_fileinfo(&items[i]); |
@@ -285,13 +293,13 @@ static void filepair_cb(struct diff_filepair *pair) |
285 | print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); |
293 | print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); |
286 | if (use_ssdiff) |
294 | if (use_ssdiff) |
287 | cgit_ssdiff_footer(); |
295 | cgit_ssdiff_footer(); |
288 | return; |
296 | return; |
289 | } |
297 | } |
290 | 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, |
291 | &new_size, &binary, print_line_fn)) |
299 | &new_size, &binary, ctx.qry.context, print_line_fn)) |
292 | cgit_print_error("Error running diff"); |
300 | cgit_print_error("Error running diff"); |
293 | if (binary) { |
301 | if (binary) { |
294 | if (use_ssdiff) |
302 | if (use_ssdiff) |
295 | html("<tr><td colspan='4'>Binary files differ</td></tr>"); |
303 | html("<tr><td colspan='4'>Binary files differ</td></tr>"); |
296 | else |
304 | else |
297 | html("Binary files differ"); |
305 | html("Binary files differ"); |
|