|
diff --git a/ui-diff.c b/ui-diff.c index 2196745..7ff7e46 100644 --- a/ ui-diff.c+++ b/ ui-diff.c |
|
@@ -11,2 +11,3 @@ |
11 | #include "ui-shared.h" |
11 | #include "ui-shared.h" |
| |
12 | #include "ui-ssdiff.h" |
12 | |
13 | |
@@ -34,2 +35,3 @@ static struct fileinfo { |
34 | |
35 | |
| |
36 | static int use_ssdiff = 0; |
35 | |
37 | |
@@ -85,3 +87,3 @@ static void print_fileinfo(struct fileinfo *info) |
85 | cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
87 | cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
86 | ctx.qry.sha2, info->new_path); |
88 | ctx.qry.sha2, info->new_path, 0); |
87 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) |
89 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) |
@@ -92,3 +94,3 @@ static void print_fileinfo(struct fileinfo *info) |
92 | if (info->binary) { |
94 | if (info->binary) { |
93 | htmlf("bin</td><td class='graph'>%d -> %d bytes", |
95 | htmlf("bin</td><td class='graph'>%ld -> %ld bytes", |
94 | info->old_size, info->new_size); |
96 | info->old_size, info->new_size); |
@@ -127,3 +129,3 @@ static void inspect_filepair(struct diff_filepair *pair) |
127 | 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, |
128 | &binary, count_diff_lines); |
130 | &binary, 0, ctx.qry.ignorews, count_diff_lines); |
129 | if (files >= slots) { |
131 | if (files >= slots) { |
@@ -154,5 +156,5 @@ static void inspect_filepair(struct diff_filepair *pair) |
154 | void cgit_print_diffstat(const unsigned char *old_sha1, |
156 | void cgit_print_diffstat(const unsigned char *old_sha1, |
155 | const unsigned char *new_sha1) |
157 | const unsigned char *new_sha1, const char *prefix) |
156 | { |
158 | { |
157 | int i; |
159 | int i, save_context = ctx.qry.context; |
158 | |
160 | |
@@ -160,3 +162,18 @@ void cgit_print_diffstat(const unsigned char *old_sha1, |
160 | 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, |
161 | ctx.qry.sha2, NULL); |
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)"); |
| |
174 | html(" ("); |
| |
175 | ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2; |
| |
176 | cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx); |
| |
177 | ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2; |
| |
178 | html(" whitespace changes)"); |
162 | html("</div>"); |
179 | html("</div>"); |
@@ -164,3 +181,4 @@ void cgit_print_diffstat(const unsigned char *old_sha1, |
164 | max_changes = 0; |
181 | max_changes = 0; |
165 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, NULL); |
182 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, |
| |
183 | ctx.qry.ignorews); |
166 | for(i = 0; i<files; i++) |
184 | for(i = 0; i<files; i++) |
@@ -248,2 +266,15 @@ static void header(unsigned char *sha1, char *path1, int mode1, |
248 | |
266 | |
| |
267 | static void print_ssdiff_link() |
| |
268 | { |
| |
269 | if (!strcmp(ctx.qry.page, "diff")) { |
| |
270 | if (use_ssdiff) |
| |
271 | cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head, |
| |
272 | ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1); |
| |
273 | else |
| |
274 | cgit_diff_link("Side-by-side diff", NULL, NULL, |
| |
275 | ctx.qry.head, ctx.qry.sha1, |
| |
276 | ctx.qry.sha2, ctx.qry.path, 1); |
| |
277 | } |
| |
278 | } |
| |
279 | |
249 | static void filepair_cb(struct diff_filepair *pair) |
280 | static void filepair_cb(struct diff_filepair *pair) |
@@ -253,10 +284,19 @@ static void filepair_cb(struct diff_filepair *pair) |
253 | int binary = 0; |
284 | int binary = 0; |
| |
285 | linediff_fn print_line_fn = print_line; |
254 | |
286 | |
| |
287 | if (use_ssdiff) { |
| |
288 | cgit_ssdiff_header_begin(); |
| |
289 | print_line_fn = cgit_ssdiff_line_cb; |
| |
290 | } |
255 | header(pair->one->sha1, pair->one->path, pair->one->mode, |
291 | header(pair->one->sha1, pair->one->path, pair->one->mode, |
256 | pair->two->sha1, pair->two->path, pair->two->mode); |
292 | pair->two->sha1, pair->two->path, pair->two->mode); |
| |
293 | if (use_ssdiff) |
| |
294 | cgit_ssdiff_header_end(); |
257 | if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { |
295 | if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { |
258 | if (S_ISGITLINK(pair->one->mode)) |
296 | if (S_ISGITLINK(pair->one->mode)) |
259 | print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); |
297 | print_line_fn(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); |
260 | if (S_ISGITLINK(pair->two->mode)) |
298 | if (S_ISGITLINK(pair->two->mode)) |
261 | print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); |
299 | print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); |
| |
300 | if (use_ssdiff) |
| |
301 | cgit_ssdiff_footer(); |
262 | return; |
302 | return; |
@@ -264,7 +304,14 @@ static void filepair_cb(struct diff_filepair *pair) |
264 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, |
304 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, |
265 | &new_size, &binary, print_line)) |
305 | &new_size, &binary, ctx.qry.context, |
| |
306 | ctx.qry.ignorews, print_line_fn)) |
266 | cgit_print_error("Error running diff"); |
307 | cgit_print_error("Error running diff"); |
267 | if (binary) |
308 | if (binary) { |
| |
309 | if (use_ssdiff) |
| |
310 | html("<tr><td colspan='4'>Binary files differ</td></tr>"); |
| |
311 | else |
268 | html("Binary files differ"); |
312 | html("Binary files differ"); |
269 | } |
313 | } |
| |
314 | if (use_ssdiff) |
| |
315 | cgit_ssdiff_footer(); |
| |
316 | } |
270 | |
317 | |
@@ -305,7 +352,18 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi |
305 | } |
352 | } |
306 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1); |
| |
307 | |
353 | |
| |
354 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) |
| |
355 | use_ssdiff = 1; |
| |
356 | |
| |
357 | print_ssdiff_link(); |
| |
358 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix); |
| |
359 | |
| |
360 | if (use_ssdiff) { |
| |
361 | html("<table summary='ssdiff' class='ssdiff'>"); |
| |
362 | } else { |
308 | html("<table summary='diff' class='diff'>"); |
363 | html("<table summary='diff' class='diff'>"); |
309 | html("<tr><td>"); |
364 | html("<tr><td>"); |
310 | cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix); |
365 | } |
| |
366 | cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix, |
| |
367 | ctx.qry.ignorews); |
| |
368 | if (!use_ssdiff) |
311 | html("</td></tr>"); |
369 | html("</td></tr>"); |
|