Diff options
Diffstat (limited to '')
-rw-r--r--source/ui-patch.c39
1 file changed, 2 insertions, 37 deletions
diff --git a/source/ui-patch.c b/source/ui-patch.c
index 9cf61c0..763776a 100644
--- a/source/ui-patch.c
+++ b/source/ui-patch.c
@@ -16,42 +16,6 @@
// Room for two hex object ids, the two dots between them, and the null byte.
#define REV_RANGE_LEN (2 * GIT_MAX_HEXSZ + 3)
-/*
- * A root commit has no parent, so the old end is left null and the caller asks
- * for that one commit instead.
- */
-static int resolve_range(const char *new_rev, const char *old_rev,
- struct object_id *new_oid, struct object_id *old_oid)
-{
- struct commit *commit;
-
- if (repo_get_oid(the_repository, new_rev, new_oid)) {
- cgit_print_error_page(404, "Not Found", "Bad object id: %s", new_rev);
- return -1;
- }
- commit = lookup_commit_reference(the_repository, new_oid);
- if (!commit) {
- cgit_print_error_page(404, "Not Found", "Not a commit: %s", new_rev);
- return -1;
- }
-
- if (old_rev) {
- if (repo_get_oid(the_repository, old_rev, old_oid)) {
- cgit_print_error_page(404, "Not Found", "Bad object id: %s", old_rev);
- return -1;
- }
- if (!lookup_commit_reference(the_repository, old_oid)) {
- cgit_print_error_page(404, "Not Found", "Not a commit: %s", old_rev);
- return -1;
- }
- } else if (commit->parents && commit->parents->item) {
- oidcpy(old_oid, &commit->parents->item->object.oid);
- } else {
- oidclr(old_oid, the_repository->hash_algo);
- }
- return 0;
-}
-
void cgit_print_patch(const char *new_rev, const char *old_rev, const char *prefix)
{
struct rev_info rev;
@@ -71,7 +35,8 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, const char *pref
return;
}
- if (resolve_range(new_rev, old_rev, &new_oid, &old_oid))
+ commit = cgit_get_commit(new_rev, &new_oid);
+ if (!commit || cgit_get_old_oid(old_rev, commit, &old_oid))
return;
if (is_null_oid(&old_oid)) {