From dad3f0607bf1c864f80723ab20b39527260f2c4f Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Thu, 5 Sep 2019 21:55:55 +0200 Subject: tag: factor out get_tagged_oid() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a function for accessing the ID of the object referenced by a tag safely, i.e. without causing a segfault when encountering a broken tag where ->tagged is NULL. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- tag.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tag.c') diff --git a/tag.c b/tag.c index 5db870edb9..bfa0e31435 100644 --- a/tag.c +++ b/tag.c @@ -212,3 +212,10 @@ int parse_tag(struct tag *item) free(data); return ret; } + +struct object_id *get_tagged_oid(struct tag *tag) +{ + if (!tag->tagged) + die("bad tag"); + return &tag->tagged->oid; +} -- cgit v1.3