summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-10-11 16:03:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-10-12 19:25:14 (GMT)
commitdb7d07f61057e94e2a3683ca10d67a2a219f542f (patch)
treeff44066f9388f3ed228af7513e61cb9017b25dc5
parente30b1525fb017e86e08931a911f5451bf24176f5 (diff)
downloadgit-db7d07f61057e94e2a3683ca10d67a2a219f542f.zip
git-db7d07f61057e94e2a3683ca10d67a2a219f542f.tar.gz
git-db7d07f61057e94e2a3683ca10d67a2a219f542f.tar.bz2
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>
-rw-r--r--blame.c6
-rw-r--r--builtin/blame.c2
2 files changed, 5 insertions, 3 deletions
diff --git a/blame.c b/blame.c
index 686845b..de7b5d4 100644
--- a/blame.c
+++ b/blame.c
@@ -2670,7 +2670,7 @@ static struct commit *find_single_final(struct rev_info *revs,
if (obj->flags & UNINTERESTING)
continue;
obj = deref_tag(revs->repo, obj, NULL, 0);
- if (obj->type != OBJ_COMMIT)
+ if (!obj || obj->type != OBJ_COMMIT)
die("Non commit %s?", revs->pending.objects[i].name);
if (found)
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,
/* Is that sole rev a committish? */
obj = revs->pending.objects[0].item;
obj = deref_tag(revs->repo, obj, NULL, 0);
- if (obj->type != OBJ_COMMIT)
+ if (!obj || obj->type != OBJ_COMMIT)
return NULL;
/* Do we have HEAD? */
@@ -2737,7 +2737,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
if (!(obj->flags & UNINTERESTING))
continue;
obj = deref_tag(revs->repo, obj, NULL, 0);
- if (obj->type != OBJ_COMMIT)
+ if (!obj || obj->type != OBJ_COMMIT)
die("Non commit %s?", revs->pending.objects[i].name);
if (found)
die("More than one commit to dig up from, %s and %s?",
diff --git a/builtin/blame.c b/builtin/blame.c
index bb0f293..b5036ab 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -820,6 +820,8 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
if (kind != OBJ_TAG)
return -1;
obj = deref_tag(r, parse_object(r, &oid), NULL, 0);
+ if (!obj)
+ return -1;
oidcpy(&oid, &obj->oid);
}
}