]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tag: support arbitrary repositories in parse_tag()
authorRené Scharfe <l.s.r@web.de>
Sun, 28 Dec 2025 18:10:50 +0000 (19:10 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Dec 2025 13:02:54 +0000 (22:02 +0900)
Allow callers of parse_tag() pass in the repository to use.  Let most of
them pass in the_repository to get the same result as before.  One of
them has stopped using the_repository in ef9b0370da (sha1-name.c: store
and use repo in struct disambiguate_state, 2019-04-16); let it pass in
its stored repository.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/describe.c
builtin/pack-objects.c
fsck.c
object-name.c
ref-filter.c
tag.c
tag.h
walker.c

index 443546aaac96f0371b5414013b0ee41848633622..989a78d715d525ed925434986ff8c54063fe6217 100644 (file)
@@ -112,13 +112,13 @@ static int replace_name(struct commit_name *e,
 
                if (!e->tag) {
                        t = lookup_tag(the_repository, &e->oid);
-                       if (!t || parse_tag(t))
+                       if (!t || parse_tag(the_repository, t))
                                return 1;
                        e->tag = t;
                }
 
                t = lookup_tag(the_repository, oid);
-               if (!t || parse_tag(t))
+               if (!t || parse_tag(the_repository, t))
                        return 0;
                *tag = t;
 
@@ -335,7 +335,7 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
 {
        if (n->prio == 2 && !n->tag) {
                n->tag = lookup_tag(the_repository, &n->oid);
-               if (!n->tag || parse_tag(n->tag))
+               if (!n->tag || parse_tag(the_repository, n->tag))
                        die(_("annotated tag %s not available"), n->path);
        }
        if (n->tag && !n->name_checked) {
index 1ce8d6ee21532655366547bf87373a30be91f38a..ca44b7894fc064afe4f55c252a930d8c8bddc815 100644 (file)
@@ -3293,7 +3293,7 @@ static void add_tag_chain(const struct object_id *oid)
 
        tag = lookup_tag(the_repository, oid);
        while (1) {
-               if (!tag || parse_tag(tag) || !tag->tagged)
+               if (!tag || parse_tag(the_repository, tag) || !tag->tagged)
                        die(_("unable to pack objects reachable from tag %s"),
                            oid_to_hex(oid));
 
diff --git a/fsck.c b/fsck.c
index 138fffded935c42810878ef10e46afd8084114a1..fae18d8561e0673bda4a627f5610bb5202991a83 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -474,7 +474,7 @@ static int fsck_walk_tag(struct tag *tag, void *data, struct fsck_options *optio
 {
        const char *name = fsck_get_object_name(options, &tag->object.oid);
 
-       if (parse_tag(tag))
+       if (parse_tag(the_repository, tag))
                return -1;
        if (name)
                fsck_put_object_name(options, &tag->tagged->oid, "%s", name);
index fed5de51531fde8657be62c6ac311dd098f0b9ce..8b862c124e05a9270afa7b83e6f7871f0a8a15cc 100644 (file)
@@ -449,7 +449,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
        } else if (type == OBJ_TAG) {
                struct tag *tag = lookup_tag(ds->repo, oid);
 
-               if (!parse_tag(tag) && tag->tag) {
+               if (!parse_tag(ds->repo, tag) && tag->tag) {
                        /*
                         * TRANSLATORS: This is a line of ambiguous
                         * tag object output. E.g.:
index d7454269e87cd3a1feb2856799a23137fc1855d2..c318f9ca0ec8dd6f4d877ba2f89390e3272ec52e 100644 (file)
@@ -2866,7 +2866,7 @@ static int match_points_at(struct oid_array *points_at,
        while (obj && obj->type == OBJ_TAG) {
                struct tag *tag = (struct tag *)obj;
 
-               if (parse_tag(tag) < 0) {
+               if (parse_tag(the_repository, tag) < 0) {
                        obj = NULL;
                        break;
                }
diff --git a/tag.c b/tag.c
index 9373c49d0614b022b4f5f82aaec82464b227e9fc..9daeaf2a78ed54b10e237d1d19d729bb784fc620 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -13,6 +13,7 @@
 #include "gpg-interface.h"
 #include "hex.h"
 #include "packfile.h"
+#include "repository.h"
 
 const char *tag_type = "tag";
 
@@ -203,7 +204,7 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
        return 0;
 }
 
-int parse_tag(struct tag *item)
+int parse_tag(struct repository *r, struct tag *item)
 {
        enum object_type type;
        void *data;
@@ -212,8 +213,7 @@ int parse_tag(struct tag *item)
 
        if (item->object.parsed)
                return 0;
-       data = odb_read_object(the_repository->objects, &item->object.oid,
-                              &type, &size);
+       data = odb_read_object(r->objects, &item->object.oid, &type, &size);
        if (!data)
                return error("Could not read %s",
                             oid_to_hex(&item->object.oid));
@@ -222,7 +222,7 @@ int parse_tag(struct tag *item)
                return error("Object %s not a tag",
                             oid_to_hex(&item->object.oid));
        }
-       ret = parse_tag_buffer(the_repository, item, data, size);
+       ret = parse_tag_buffer(r, item, data, size);
        free(data);
        return ret;
 }
diff --git a/tag.h b/tag.h
index 55c2d0792b99cbc11dc595e3451b6c6c8f06b7c2..534687c4caeca44b98c9dbd24ccb457d2cd0039a 100644 (file)
--- a/tag.h
+++ b/tag.h
@@ -13,7 +13,7 @@ struct tag {
 };
 struct tag *lookup_tag(struct repository *r, const struct object_id *oid);
 int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);
-int parse_tag(struct tag *item);
+int parse_tag(struct repository *r, struct tag *item);
 void release_tag_memory(struct tag *t);
 struct object *deref_tag(struct repository *r, struct object *, const char *, int);
 int gpg_verify_tag(struct repository *r, const struct object_id *oid,
index 409b646578a3d4b39b7f7feee3854f2b4662b2b0..2891563b03620bc82b2e11a6712f407652ff2661 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -115,7 +115,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
 
 static int process_tag(struct walker *walker, struct tag *tag)
 {
-       if (parse_tag(tag))
+       if (parse_tag(the_repository, tag))
                return -1;
        return process(walker, tag->tagged);
 }