|
diff --git a/ui-diff.c b/ui-diff.c index 999b6f3..afe1c90 100644 --- a/ ui-diff.c+++ b/ ui-diff.c |
|
@@ -57,29 +57,41 @@ static void header(unsigned char *sha1, char *path1, |
57 | html("</div>"); |
57 | html("</div>"); |
58 | } |
58 | } |
59 | |
59 | |
60 | static void filepair_cb(struct diff_filepair *pair) |
60 | static void filepair_cb(struct diff_filepair *pair) |
61 | { |
61 | { |
62 | header(pair->one->sha1, pair->one->path, |
62 | header(pair->one->sha1, pair->one->path, |
63 | pair->two->sha1, pair->two->path); |
63 | pair->two->sha1, pair->two->path); |
64 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, print_line)) |
64 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, print_line)) |
65 | cgit_print_error("Error running diff"); |
65 | cgit_print_error("Error running diff"); |
66 | html("</tr></td>"); |
66 | html("</tr></td>"); |
67 | } |
67 | } |
68 | |
68 | |
69 | void cgit_print_diff(const char *old_hex, const char *new_hex, char *path) |
69 | void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, char *path) |
70 | { |
70 | { |
71 | unsigned char sha1[20], sha2[20]; |
71 | unsigned char sha1[20], sha2[20]; |
72 | enum object_type type; |
72 | enum object_type type; |
73 | unsigned long size; |
73 | unsigned long size; |
| |
74 | struct commit *commit; |
| |
75 | |
| |
76 | if (head && !old_hex && !new_hex) { |
| |
77 | get_sha1(head, sha1); |
| |
78 | commit = lookup_commit_reference(sha1); |
| |
79 | if (commit && !parse_commit(commit)) { |
| |
80 | html("<table class='diff'>"); |
| |
81 | cgit_diff_commit(commit, filepair_cb); |
| |
82 | html("</td></tr></table>"); |
| |
83 | } |
| |
84 | return; |
| |
85 | } |
74 | |
86 | |
75 | get_sha1(old_hex, sha1); |
87 | get_sha1(old_hex, sha1); |
76 | get_sha1(new_hex, sha2); |
88 | get_sha1(new_hex, sha2); |
77 | |
89 | |
78 | type = sha1_object_info(sha1, &size); |
90 | type = sha1_object_info(sha1, &size); |
79 | if (type == OBJ_BAD) { |
91 | if (type == OBJ_BAD) { |
80 | type = sha1_object_info(sha2, &size); |
92 | type = sha1_object_info(sha2, &size); |
81 | if (type == OBJ_BAD) { |
93 | if (type == OBJ_BAD) { |
82 | cgit_print_error(fmt("Bad object names: %s, %s", old_hex, new_hex)); |
94 | cgit_print_error(fmt("Bad object names: %s, %s", old_hex, new_hex)); |
83 | return; |
95 | return; |
84 | } |
96 | } |
85 | } |
97 | } |
|