summaryrefslogtreecommitdiffabout
path: root/ui-diff.c
authorLars Hjemli <hjemli@gmail.com>2008-09-23 15:47:26 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-09-23 15:47:26 (UTC)
commit04619c9b8512921a87187b9adf8573e2bdacd0a6 (patch) (side-by-side diff)
treeb25bd09ef7d09504dac0a09810598c4d183c53b3 /ui-diff.c
parent06e14dc61cf36c146f04de91497d2fe866c46f5e (diff)
downloadcgit-04619c9b8512921a87187b9adf8573e2bdacd0a6.zip
cgit-04619c9b8512921a87187b9adf8573e2bdacd0a6.tar.gz
cgit-04619c9b8512921a87187b9adf8573e2bdacd0a6.tar.bz2
ui-diff: fix links from diffstat
The links in the diffstat is supposed to work as a filter for the diff, but this only worked when a single rev was supplied, i.e. the filtered diff was always against the parent of the specified rev. With this patch it is now possible to use the diffstat as a 'filter menu' for urls like http://hjemli.net/git/cgit/diff/?id=v0.7.2&id2=v0.7.1 Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-diff.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-diff.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/ui-diff.c b/ui-diff.c
index 1c182aa..7ab1e49 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -13,13 +13,12 @@
unsigned char old_rev_sha1[20];
unsigned char new_rev_sha1[20];
static int files, slots;
static int total_adds, total_rems, max_changes;
static int lines_added, lines_removed;
-static char *curr_rev;
static struct fileinfo {
char status;
unsigned char old_sha1[20];
unsigned char new_sha1[20];
unsigned short old_mode;
@@ -77,14 +76,14 @@ static void print_fileinfo(struct fileinfo *info)
!is_null_sha1(info->new_sha1)) {
html("<span class='modechange'>[");
cgit_print_filemode(info->old_mode);
html("]</span>");
}
htmlf("</td><td class='%s'>", class);
- cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, curr_rev,
- NULL, info->new_path);
+ cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
+ ctx.qry.sha2, info->new_path);
if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED)
htmlf(" (%s from %s)",
info->status == DIFF_STATUS_COPIED ? "copied" : "renamed",
info->old_path);
html("</td><td class='right'>");
htmlf("%d", info->added + info->removed);
@@ -142,13 +141,12 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
{
int i;
html("<div class='diffstat-header'>Diffstat</div>");
html("<table summary='diffstat' class='diffstat'>");
max_changes = 0;
- curr_rev = xstrdup(sha1_to_hex(new_sha1));
cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, NULL);
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",