tag: add repository argument to lookup_tag
authorStefan Beller <sbeller@google.com>
Fri, 29 Jun 2018 01:22:03 +0000 (18:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Jun 2018 17:43:39 +0000 (10:43 -0700)
Add a repository argument to allow the callers of lookup_tag
to be more specific about which repository to act on. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
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 c8ff64766d04c9dad38dc8f2ccccb7c9ffecaa63..41606c8a90092bca3f782980baf37031744e0cd6 100644 (file)
@@ -93,13 +93,13 @@ static int replace_name(struct commit_name *e,
                struct tag *t;
 
                if (!e->tag) {
-                       t = lookup_tag(&e->oid);
+                       t = lookup_tag(the_repository, &e->oid);
                        if (!t || parse_tag(t))
                                return 1;
                        e->tag = t;
                }
 
-               t = lookup_tag(oid);
+               t = lookup_tag(the_repository, oid);
                if (!t || parse_tag(t))
                        return 0;
                *tag = t;
@@ -267,7 +267,7 @@ static unsigned long finish_depth_computation(
 static void append_name(struct commit_name *n, struct strbuf *dst)
 {
        if (n->prio == 2 && !n->tag) {
-               n->tag = lookup_tag(&n->oid);
+               n->tag = lookup_tag(the_repository, &n->oid);
                if (!n->tag || parse_tag(n->tag))
                        die(_("annotated tag %s not available"), n->path);
        }
index 69d3d7b82af8b69b589327f9420bb02bab339a25..6565c800ac3865f9325c21bf28707cce0506195e 100644 (file)
@@ -2474,7 +2474,7 @@ static void add_tag_chain(const struct object_id *oid)
        if (packlist_find(&to_pack, oid->hash, NULL))
                return;
 
-       tag = lookup_tag(oid);
+       tag = lookup_tag(the_repository, oid);
        while (1) {
                if (!tag || parse_tag(tag) || !tag->tagged)
                        die("unable to pack objects reachable from tag %s",
index 0232f98f020c084f06df449775c698d1ffe3ef06..0351b7c62cf48c5c368b128fa555812bf3856549 100644 (file)
@@ -402,7 +402,7 @@ static int check_one_mergetag(struct commit *commit,
        int i;
 
        hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &tag_oid);
-       tag = lookup_tag(&tag_oid);
+       tag = lookup_tag(the_repository, &tag_oid);
        if (!tag)
                return error(_("bad mergetag in commit '%s'"), ref);
        if (parse_tag_buffer(tag, extra->value, extra->len))
index abe67e8b2e4079764358874506a14ebce4cb871d..840423ca149e63e48093c7e072c59975528a9e17 100644 (file)
@@ -498,7 +498,7 @@ static int show_one_mergetag(struct commit *commit,
        size_t payload_size, gpg_message_offset;
 
        hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &oid);
-       tag = lookup_tag(&oid);
+       tag = lookup_tag(the_repository, &oid);
        if (!tag)
                return -1; /* error message already given */
 
index f08a8874de38064ad6e25ae8d322d807b6d25253..bcfcfd387609dd2779d83dc68e6d0232e782fe22 100644 (file)
--- a/object.c
+++ b/object.c
@@ -223,7 +223,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e
                        obj = &commit->object;
                }
        } else if (type == OBJ_TAG) {
-               struct tag *tag = lookup_tag(oid);
+               struct tag *tag = lookup_tag(the_repository, oid);
                if (tag) {
                        if (parse_tag_buffer(tag, buffer, size))
                               return NULL;
index 98480ade12dec983415c54db6d628a441bc23833..5854bc75fe292949563aabfe715425c1db54d4ca 100644 (file)
@@ -358,7 +358,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);
+               struct tag *tag = lookup_tag(the_repository, oid);
                if (!parse_tag(tag) && tag->tag)
                        strbuf_addf(&desc, " %s", tag->tag);
        }
diff --git a/tag.c b/tag.c
index 5dcdf7bf6f9b46ab33b515daa0995f3dca2599a3..5b41fc71fadc8cc4fa427957abc8cffefdded957 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -92,7 +92,7 @@ struct object *deref_tag_noverify(struct object *o)
        return o;
 }
 
-struct tag *lookup_tag(const struct object_id *oid)
+struct tag *lookup_tag_the_repository(const struct object_id *oid)
 {
        struct object *obj = lookup_object(the_repository, oid->hash);
        if (!obj)
@@ -160,7 +160,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
        } else if (!strcmp(type, commit_type)) {
                item->tagged = (struct object *)lookup_commit(the_repository, &oid);
        } else if (!strcmp(type, tag_type)) {
-               item->tagged = (struct object *)lookup_tag(&oid);
+               item->tagged = (struct object *)lookup_tag(the_repository, &oid);
        } else {
                error("Unknown type %s", type);
                item->tagged = NULL;
diff --git a/tag.h b/tag.h
index 9057d76a50639d65aae1340b752d2daa7dc67aa9..276c448cd552c5cde41e4b45c682d23d9e1e5342 100644 (file)
--- a/tag.h
+++ b/tag.h
@@ -11,8 +11,8 @@ struct tag {
        char *tag;
        timestamp_t date;
 };
-
-extern struct tag *lookup_tag(const struct object_id *oid);
+#define lookup_tag(r, o) lookup_tag_##r(o)
+extern struct tag *lookup_tag_the_repository(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 void release_tag_memory(struct tag *t);