- if (!commit || parse_commit(commit))
- cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(new_rev_sha1)));
-
- if (old_rev)
- get_sha1(old_rev, old_rev_sha1);
- else if (commit->parents && commit->parents->item)
- hashcpy(old_rev_sha1, commit->parents->item->object.sha1);
- else
+ if (!commit || parse_commit(commit)) {
+ cgit_print_error_page(404, "Not found",
+ "Bad commit: %s", sha1_to_hex(new_rev_sha1));
+ return;
+ }
+ new_tree_sha1 = commit->tree->object.oid.hash;
+
+ if (old_rev) {
+ if (get_sha1(old_rev, old_rev_sha1)) {
+ cgit_print_error_page(404, "Not found",
+ "Bad object name: %s", old_rev);
+ return;
+ }
+ } else if (commit->parents && commit->parents->item) {
+ hashcpy(old_rev_sha1, commit->parents->item->object.oid.hash);
+ } else {