|
diff --git a/cgit.c b/cgit.c index 9b4815d..3e7e595 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -120,7 +120,8 @@ static void cgit_print_repo_page(struct cacheitem *item) |
120 | } else if (!strcmp(cgit_query_page, "view")) { |
120 | } else if (!strcmp(cgit_query_page, "view")) { |
121 | cgit_print_view(cgit_query_sha1, cgit_query_path); |
121 | cgit_print_view(cgit_query_sha1, cgit_query_path); |
122 | } else if (!strcmp(cgit_query_page, "diff")) { |
122 | } else if (!strcmp(cgit_query_page, "diff")) { |
123 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); |
123 | cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2, |
| |
124 | cgit_query_path); |
124 | } else { |
125 | } else { |
125 | cgit_print_error("Invalid request"); |
126 | cgit_print_error("Invalid request"); |
126 | } |
127 | } |
|
|
diff --git a/cgit.h b/cgit.h index ac710a6..764225d 100644 --- a/ cgit.h+++ b/ cgit.h |
|
@@ -176,7 +176,8 @@ extern void cgit_print_view(const char *hex, char *path); |
176 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
176 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
177 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); |
177 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); |
178 | extern void cgit_print_commit(const char *hex); |
178 | extern void cgit_print_commit(const char *hex); |
179 | extern void cgit_print_diff(const char *old_hex, const char *new_hex, char *path); |
179 | extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, |
| |
180 | char *path); |
180 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, |
181 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, |
181 | const char *format, const char *prefix, |
182 | const char *format, const char *prefix, |
182 | const char *filename); |
183 | const char *filename); |
|
|
diff --git a/ui-diff.c b/ui-diff.c index 999b6f3..afe1c90 100644 --- a/ ui-diff.c+++ b/ ui-diff.c |
|
@@ -66,11 +66,23 @@ static void filepair_cb(struct diff_filepair *pair) |
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); |
|