aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui-diff.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/ui-diff.c b/ui-diff.c
index 838db8c..1209c47 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -360,15 +360,11 @@ void cgit_print_diff_ctrls()
360void cgit_print_diff(const char *new_rev, const char *old_rev, 360void cgit_print_diff(const char *new_rev, const char *old_rev,
361 const char *prefix, int show_ctrls, int raw) 361 const char *prefix, int show_ctrls, int raw)
362{ 362{
363 enum object_type type;
364 unsigned long size;
365 struct commit *commit, *commit2; 363 struct commit *commit, *commit2;
366 364
367 if (!new_rev) 365 if (!new_rev)
368 new_rev = ctx.qry.head; 366 new_rev = ctx.qry.head;
369 get_sha1(new_rev, new_rev_sha1); 367 if (get_sha1(new_rev, new_rev_sha1)) {
370 type = sha1_object_info(new_rev_sha1, &size);
371 if (type == OBJ_BAD) {
372 cgit_print_error("Bad object name: %s", new_rev); 368 cgit_print_error("Bad object name: %s", new_rev);
373 return; 369 return;
374 } 370 }
@@ -378,19 +374,18 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
378 return; 374 return;
379 } 375 }
380 376
381 if (old_rev) 377 if (old_rev) {
382 get_sha1(old_rev, old_rev_sha1); 378 if (get_sha1(old_rev, old_rev_sha1)) {
383 else if (commit->parents && commit->parents->item) 379 cgit_print_error("Bad object name: %s", old_rev);
380 return;
381 }
382 } else if (commit->parents && commit->parents->item) {
384 hashcpy(old_rev_sha1, commit->parents->item->object.sha1); 383 hashcpy(old_rev_sha1, commit->parents->item->object.sha1);
385 else 384 } else {
386 hashclr(old_rev_sha1); 385 hashclr(old_rev_sha1);
386 }
387 387
388 if (!is_null_sha1(old_rev_sha1)) { 388 if (!is_null_sha1(old_rev_sha1)) {
389 type = sha1_object_info(old_rev_sha1, &size);
390 if (type == OBJ_BAD) {
391 cgit_print_error("Bad object name: %s", sha1_to_hex(old_rev_sha1));
392 return;
393 }
394 commit2 = lookup_commit_reference(old_rev_sha1); 389 commit2 = lookup_commit_reference(old_rev_sha1);
395 if (!commit2 || parse_commit(commit2)) { 390 if (!commit2 || parse_commit(commit2)) {
396 cgit_print_error("Bad commit: %s", sha1_to_hex(old_rev_sha1)); 391 cgit_print_error("Bad commit: %s", sha1_to_hex(old_rev_sha1));