blame: handle deref_tag() returning NULL

Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 11, 2020 at 18:03 UTC db7d07f61057e94e2a3683ca10d67a2a219f542f
2 files changed +5 -3
blame.c
+3 -3
@@ -2670,7 +2670,7 @@ static struct commit *find_single_final(struct rev_info *revs,
2670 if (obj->flags & UNINTERESTING)
2671 continue;
2672 obj = deref_tag(revs->repo, obj, NULL, 0);
2673 - if (obj->type != OBJ_COMMIT)
2673 + if (!obj || obj->type != OBJ_COMMIT)
2674 die("Non commit %s?", revs->pending.objects[i].name);
2675 if (found)
2676 die("More than one commit to dig from %s and %s?",
@@ -2701,7 +2701,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
2701 /* Is that sole rev a committish? */
2702 obj = revs->pending.objects[0].item;
2703 obj = deref_tag(revs->repo, obj, NULL, 0);
2704 - if (obj->type != OBJ_COMMIT)
2704 + if (!obj || obj->type != OBJ_COMMIT)
2705 return NULL;
2706
2707 /* Do we have HEAD? */
@@ -2737,7 +2737,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
2737 if (!(obj->flags & UNINTERESTING))
2738 continue;
2739 obj = deref_tag(revs->repo, obj, NULL, 0);
2740 - if (obj->type != OBJ_COMMIT)
2740 + if (!obj || obj->type != OBJ_COMMIT)
2741 die("Non commit %s?", revs->pending.objects[i].name);
2742 if (found)
2743 die("More than one commit to dig up from, %s and %s?",
builtin/blame.c
+2
@@ -820,6 +820,8 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
820 if (kind != OBJ_TAG)
821 return -1;
822 obj = deref_tag(r, parse_object(r, &oid), NULL, 0);
823 + if (!obj)
824 + return -1;
825 oidcpy(&oid, &obj->oid);
826 }
827 }