summaryrefslogtreecommitdiffabout
path: root/ui-diff.c
authorJohan Herland <johan@herland.net>2010-06-24 15:52:57 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-07-18 08:53:48 (UTC)
commit2cc8b99f083014c58d8937bfa4dcd2bc47cd7e58 (patch) (side-by-side diff)
tree48d555b15c0432bb98712d746100bf6c0fe2be4a /ui-diff.c
parentd20313e3daf855ee5d4808e050f54614c200d7b1 (diff)
downloadcgit-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>
Diffstat (limited to 'ui-diff.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-diff.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ui-diff.c b/ui-diff.c
index e0a72f7..1656b77 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -118,25 +118,25 @@ static void count_diff_lines(char *line, int len)
}
}
static void inspect_filepair(struct diff_filepair *pair)
{
int binary = 0;
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));
}
items[files-1].status = pair->status;
hashcpy(items[files-1].old_sha1, pair->one->sha1);
hashcpy(items[files-1].new_sha1, pair->two->sha1);
items[files-1].old_mode = pair->one->mode;
items[files-1].new_mode = pair->two->mode;
@@ -165,25 +165,26 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
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("<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);
html("</div>");
}
/*
* print a single line returned from xdiff
@@ -287,25 +288,26 @@ static void filepair_cb(struct diff_filepair *pair)
if (use_ssdiff)
cgit_ssdiff_header_end();
if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) {
if (S_ISGITLINK(pair->one->mode))
print_line_fn(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52);
if (S_ISGITLINK(pair->two->mode))
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");
}
if (use_ssdiff)
cgit_ssdiff_footer();
}
void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix)
@@ -347,17 +349,18 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
use_ssdiff = 1;
print_ssdiff_link();
cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
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>");
}