cgit

commit 04619c9b8512921a87187b9adf8573e2bdacd0a6

Author: Lars Hjemli <hjemli@gmail.com>

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>

 ui-diff.c | 6 ++----


diff --git a/ui-diff.c b/ui-diff.c
index 1c182aa0eeed916ae1904a275c905017a599980c..7ab1e49d996161aa114f89558eb78c06f1140d86 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -16,7 +16,6 @@
 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;
@@ -80,8 +79,8 @@ 		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",
@@ -145,7 +144,6 @@
 	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]);