THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

tag: factor out get_tagged_oid()

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 <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tags/v2.24.0-rc0
René Scharfe Junio C Hamano 2 months ago
parent
commit
dad3f0607b
4 changed files with 10 additions and 6 deletions
  1. +1
    -3
      pack-bitmap.c
  2. +1
    -3
      revision.c
  3. +7
    -0
      tag.c
  4. +1
    -0
      tag.h

+ 1
- 3
pack-bitmap.c View File

@@ -709,9 +709,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
else
object_list_insert(object, &wants);

if (!tag->tagged)
die("bad tag");
object = parse_object_or_die(&tag->tagged->oid, NULL);
object = parse_object_or_die(get_tagged_oid(tag), NULL);
}

if (object->flags & UNINTERESTING)


+ 1
- 3
revision.c View File

@@ -404,9 +404,7 @@ static struct commit *handle_commit(struct rev_info *revs,
struct tag *tag = (struct tag *) object;
if (revs->tag_objects && !(flags & UNINTERESTING))
add_pending_object(revs, object, tag->tag);
if (!tag->tagged)
die("bad tag");
object = parse_object(revs->repo, &tag->tagged->oid);
object = parse_object(revs->repo, get_tagged_oid(tag));
if (!object) {
if (revs->ignore_missing_links || (flags & UNINTERESTING))
return NULL;


+ 7
- 0
tag.c View File

@@ -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;
}

+ 1
- 0
tag.h View File

@@ -19,5 +19,6 @@ struct object *deref_tag(struct repository *r, struct object *, const char *, in
struct object *deref_tag_noverify(struct object *);
int gpg_verify_tag(const struct object_id *oid,
const char *name_to_report, unsigned flags);
struct object_id *get_tagged_oid(struct tag *tag);

#endif /* TAG_H */

Loading…
Cancel
Save