- html("<h2>diff</h2>\n");
- html("<table class='diff'><tr><td>");
- run_diff(sha1, sha2);
- html("</td></tr></table>");
+ type = sha1_object_info(sha1, &size);
+ if (type == OBJ_BAD) {
+ type = sha1_object_info(sha2, &size);
+ if (type == OBJ_BAD) {
+ cgit_print_error(fmt("Bad object names: %s, %s", old_hex, new_hex));
+ return;
+ }
+ }
+
+ html("<table class='diff'>");
+ switch(type) {
+ case OBJ_BLOB:
+ html("<tr><td>");
+ header(sha1, path, 0644, sha2, path, 0644);
+ if (cgit_diff_files(sha1, sha2, print_line))
+ cgit_print_error("Error running diff");
+ html("</td></tr>");
+ break;
+ case OBJ_TREE:
+ cgit_diff_tree(sha1, sha2, filepair_cb);
+ break;
+ default:
+ cgit_print_error(fmt("Unhandled object type: %s",
+ typename(type)));
+ break;
+ }
+ html("</table>");