author | Johan Herland <johan@herland.net> | 2010-06-24 15:52:57 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-07-18 08:53:48 (UTC) |
commit | 2cc8b99f083014c58d8937bfa4dcd2bc47cd7e58 (patch) (side-by-side diff) | |
tree | 48d555b15c0432bb98712d746100bf6c0fe2be4a /ui-diff.c | |
parent | d20313e3daf855ee5d4808e050f54614c200d7b1 (diff) | |
download | cgit-2cc8b99f083014c58d8937bfa4dcd2bc47cd7e58.zip cgit-2cc8b99f083014c58d8937bfa4dcd2bc47cd7e58.tar.gz cgit-2cc8b99f083014c58d8937bfa4dcd2bc47cd7e58.tar.bz2 |
Add URL parameter 'ignorews' for optionally ignoring whitespace in diffs
The new ctx.qry.ignorews variable is passed via cgit_diff_files() and
cgit_diff_tree() to Git's diff machinery. This is equivalent to passing
--ignore-all-space to 'git diff'.
Signed-off-by: Johan Herland <johan@herland.net>
-rw-r--r-- | ui-diff.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -124,13 +124,13 @@ static void inspect_filepair(struct diff_filepair *pair) unsigned long old_size = 0; unsigned long new_size = 0; files++; lines_added = 0; lines_removed = 0; cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size, - &binary, 0, count_diff_lines); + &binary, 0, ctx.qry.ignorews, count_diff_lines); if (files >= slots) { if (slots == 0) slots = 4; else slots = slots * 2; items = xrealloc(items, slots * sizeof(struct fileinfo)); @@ -171,13 +171,14 @@ void cgit_print_diffstat(const unsigned char *old_sha1, cgit_self_link("less", NULL, NULL, &ctx); ctx.qry.context = save_context; html(" context)"); html("</div>"); html("<table summary='diffstat' class='diffstat'>"); max_changes = 0; - cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix); + cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, + ctx.qry.ignorews); for(i = 0; i<files; i++) print_fileinfo(&items[i]); html("</table>"); html("<div class='diffstat-summary'>"); htmlf("%d files changed, %d insertions, %d deletions", files, total_adds, total_rems); @@ -293,13 +294,14 @@ static void filepair_cb(struct diff_filepair *pair) print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); if (use_ssdiff) cgit_ssdiff_footer(); return; } if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, - &new_size, &binary, ctx.qry.context, print_line_fn)) + &new_size, &binary, ctx.qry.context, + ctx.qry.ignorews, print_line_fn)) cgit_print_error("Error running diff"); if (binary) { if (use_ssdiff) html("<tr><td colspan='4'>Binary files differ</td></tr>"); else html("Binary files differ"); @@ -353,11 +355,12 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi if (use_ssdiff) { html("<table summary='ssdiff' class='ssdiff'>"); } else { html("<table summary='diff' class='diff'>"); html("<tr><td>"); } - cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix); + cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix, + ctx.qry.ignorews); if (!use_ssdiff) html("</td></tr>"); html("</table>"); } |