|
diff --git a/ui-diff.c b/ui-diff.c index ac9a3fa..4fcf852 100644 --- a/ ui-diff.c+++ b/ ui-diff.c |
|
@@ -96,54 +96,54 @@ static void filepair_cb(struct diff_filepair *pair) |
96 | print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); |
96 | print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); |
97 | return; |
97 | return; |
98 | } |
98 | } |
99 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, print_line)) |
99 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, print_line)) |
100 | cgit_print_error("Error running diff"); |
100 | cgit_print_error("Error running diff"); |
101 | } |
101 | } |
102 | |
102 | |
103 | void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) |
103 | void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) |
104 | { |
104 | { |
105 | enum object_type type; |
105 | enum object_type type; |
106 | unsigned long size; |
106 | unsigned long size; |
107 | struct commit *commit, *commit2; |
107 | struct commit *commit, *commit2; |
108 | |
108 | |
109 | if (!new_rev) |
109 | if (!new_rev) |
110 | new_rev = cgit_query_head; |
110 | new_rev = cgit_query_head; |
111 | get_sha1(new_rev, new_rev_sha1); |
111 | get_sha1(new_rev, new_rev_sha1); |
112 | type = sha1_object_info(new_rev_sha1, &size); |
112 | type = sha1_object_info(new_rev_sha1, &size); |
113 | if (type == OBJ_BAD) { |
113 | if (type == OBJ_BAD) { |
114 | cgit_print_error(fmt("Bad object name: %s", new_rev)); |
114 | cgit_print_error(fmt("Bad object name: %s", new_rev)); |
115 | return; |
115 | return; |
116 | } |
116 | } |
117 | if (type != OBJ_COMMIT) { |
117 | if (type != OBJ_COMMIT) { |
118 | cgit_print_error(fmt("Unhandled object type: %s", |
118 | cgit_print_error(fmt("Unhandled object type: %s", |
119 | typename(type))); |
119 | typename(type))); |
120 | return; |
120 | return; |
121 | } |
121 | } |
122 | |
122 | |
123 | commit = lookup_commit_reference(new_rev_sha1); |
123 | commit = lookup_commit_reference(new_rev_sha1); |
124 | if (!commit || parse_commit(commit)) |
124 | if (!commit || parse_commit(commit)) |
125 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(new_rev_sha1))); |
125 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(new_rev_sha1))); |
126 | |
126 | |
127 | if (old_rev) |
127 | if (old_rev) |
128 | get_sha1(old_rev, old_rev_sha1); |
128 | get_sha1(old_rev, old_rev_sha1); |
129 | else if (commit->parents && commit->parents->item) |
129 | else if (commit->parents && commit->parents->item) |
130 | hashcpy(old_rev_sha1, commit->parents->item->object.sha1); |
130 | hashcpy(old_rev_sha1, commit->parents->item->object.sha1); |
131 | else |
131 | else |
132 | hashclr(old_rev_sha1); |
132 | hashclr(old_rev_sha1); |
133 | |
133 | |
134 | if (!is_null_sha1(old_rev_sha1)) { |
134 | if (!is_null_sha1(old_rev_sha1)) { |
135 | type = sha1_object_info(old_rev_sha1, &size); |
135 | type = sha1_object_info(old_rev_sha1, &size); |
136 | if (type == OBJ_BAD) { |
136 | if (type == OBJ_BAD) { |
137 | cgit_print_error(fmt("Bad object name: %s", sha1_to_hex(old_rev_sha1))); |
137 | cgit_print_error(fmt("Bad object name: %s", sha1_to_hex(old_rev_sha1))); |
138 | return; |
138 | return; |
139 | } |
139 | } |
140 | commit2 = lookup_commit_reference(old_rev_sha1); |
140 | commit2 = lookup_commit_reference(old_rev_sha1); |
141 | if (!commit2 || parse_commit(commit2)) |
141 | if (!commit2 || parse_commit(commit2)) |
142 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1))); |
142 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1))); |
143 | } |
143 | } |
144 | html("<table class='diff'>"); |
144 | html("<table summary='diff' class='diff'>"); |
145 | html("<tr><td>"); |
145 | html("<tr><td>"); |
146 | cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix); |
146 | cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix); |
147 | html("</td></tr>"); |
147 | html("</td></tr>"); |
148 | html("</table>"); |
148 | html("</table>"); |
149 | } |
149 | } |
|