From d3101b533d365825f52d8e5e52328702acbc8e3a Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sat, 6 May 2017 22:10:19 +0000 Subject: Convert lookup_tag to struct object_id Convert lookup_tag to take a pointer to struct object_id. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano diff --git a/builtin/describe.c b/builtin/describe.c index f6032f5..893c878 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -79,13 +79,13 @@ static int replace_name(struct commit_name *e, struct tag *t; if (!e->tag) { - t = lookup_tag(e->oid.hash); + t = lookup_tag(&e->oid); if (!t || parse_tag(t)) return 1; e->tag = t; } - t = lookup_tag(oid->hash); + t = lookup_tag(oid); if (!t || parse_tag(t)) return 0; *tag = t; @@ -245,7 +245,7 @@ static unsigned long finish_depth_computation( static void display_name(struct commit_name *n) { if (n->prio == 2 && !n->tag) { - n->tag = lookup_tag(n->oid.hash); + n->tag = lookup_tag(&n->oid); if (!n->tag || parse_tag(n->tag)) die(_("annotated tag %s not available"), n->path); } diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index d76ff05..7cebb5a 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -2348,7 +2348,7 @@ static void add_tag_chain(const struct object_id *oid) if (packlist_find(&to_pack, oid->hash, NULL)) return; - tag = lookup_tag(oid->hash); + tag = lookup_tag(oid); while (1) { if (!tag || parse_tag(tag) || !tag->tagged) die("unable to pack objects reachable from tag %s", diff --git a/builtin/replace.c b/builtin/replace.c index 3c44ef7..c921bc9 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -355,7 +355,7 @@ static void check_one_mergetag(struct commit *commit, int i; hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), tag_oid.hash); - tag = lookup_tag(tag_oid.hash); + tag = lookup_tag(&tag_oid); if (!tag) die(_("bad mergetag in commit '%s'"), ref); if (parse_tag_buffer(tag, extra->value, extra->len)) diff --git a/log-tree.c b/log-tree.c index 169fd03..6532c89 100644 --- a/log-tree.c +++ b/log-tree.c @@ -488,7 +488,7 @@ static void show_one_mergetag(struct commit *commit, size_t payload_size, gpg_message_offset; hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), oid.hash); - tag = lookup_tag(oid.hash); + tag = lookup_tag(&oid); if (!tag) return; /* error message already given */ diff --git a/object.c b/object.c index d23c5fa..dd4d3a1 100644 --- a/object.c +++ b/object.c @@ -220,7 +220,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t obj = &commit->object; } } else if (type == OBJ_TAG) { - struct tag *tag = lookup_tag(sha1); + struct tag *tag = lookup_tag(&oid); if (tag) { if (parse_tag_buffer(tag, buffer, size)) return NULL; diff --git a/sha1_name.c b/sha1_name.c index 390a09c..b7e09ac 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -361,7 +361,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data) format_commit_message(commit, " %ad - %s", &desc, &pp); } } else if (type == OBJ_TAG) { - struct tag *tag = lookup_tag(oid->hash); + struct tag *tag = lookup_tag(oid); if (!parse_tag(tag) && tag->tag) strbuf_addf(&desc, " %s", tag->tag); } diff --git a/tag.c b/tag.c index 062516b..5717985 100644 --- a/tag.c +++ b/tag.c @@ -89,11 +89,11 @@ struct object *deref_tag_noverify(struct object *o) return o; } -struct tag *lookup_tag(const unsigned char *sha1) +struct tag *lookup_tag(const struct object_id *oid) { - struct object *obj = lookup_object(sha1); + struct object *obj = lookup_object(oid->hash); if (!obj) - return create_object(sha1, alloc_tag_node()); + return create_object(oid->hash, alloc_tag_node()); return object_as_type(obj, OBJ_TAG, 0); } @@ -148,7 +148,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size) } else if (!strcmp(type, commit_type)) { item->tagged = &lookup_commit(&oid)->object; } else if (!strcmp(type, tag_type)) { - item->tagged = &lookup_tag(oid.hash)->object; + item->tagged = &lookup_tag(&oid)->object; } else { error("Unknown type %s", type); item->tagged = NULL; diff --git a/tag.h b/tag.h index a5721b6..8d6fc28 100644 --- a/tag.h +++ b/tag.h @@ -12,7 +12,7 @@ struct tag { unsigned long date; }; -extern struct tag *lookup_tag(const unsigned char *sha1); +extern struct tag *lookup_tag(const struct object_id *oid); extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long size); extern int parse_tag(struct tag *item); extern struct object *deref_tag(struct object *, const char *, int); -- cgit v0.10.2-6-g49f6