Convert lookup_tag to struct object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sat, 6 May 2017 22:10:19 +0000 (22:10 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 May 2017 06:12:57 +0000 (15:12 +0900)
Convert lookup_tag to take a pointer to struct object_id.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/describe.c
builtin/pack-objects.c
builtin/replace.c
log-tree.c
object.c
sha1_name.c
tag.c
tag.h
index f6032f593cb6a08e27411a0973cf01c4d8e43fa8..893c8789f4f563c58041040740384322e6ea205b 100644 (file)
@@ -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);
        }
index d76ff054261927e3c06ed2bdbe89b460ec78959d..7cebb5a7f14a9fda7fb293fc9f96b43b20ee0722 100644 (file)
@@ -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",
index 3c44ef750e73f663e78dd81d18f85f67d31b891a..c921bc976f2299adc39277a21a74abbcc0c100f7 100644 (file)
@@ -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))
index 169fd039fd31e79dbcb56bf96c30eb60d628dd09..6532c892c2105188fc0805a87668d4c1ee05fa44 100644 (file)
@@ -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 */
 
index d23c5fad388f01c6bda7cb7abfb183c554f3aff9..dd4d3a1ea738c9fefc3112ed6aa0e6d57dbc7cd3 100644 (file)
--- 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;
index 390a09c41a1db40a3aca88df9e581804c57b891b..b7e09ac13964a370ebb98f5242c9598c46d4a51b 100644 (file)
@@ -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 062516b405cb957767ec06fd06619546900df2d5..571798519f3f99c02dbecbe560a76ae83dc81e2f 100644 (file)
--- 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 a5721b6731eb89e1db78e41fcf6b8dfd8784841e..8d6fc28145af5467a0b9b942333ddd153760355d 100644 (file)
--- 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);