]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tag: support arbitrary repositories in gpg_verify_tag()
authorRené Scharfe <l.s.r@web.de>
Sun, 28 Dec 2025 18:10:49 +0000 (19:10 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Dec 2025 13:02:53 +0000 (22:02 +0900)
Allow callers of gpg_verify_tag() specify the repository to use by
providing a parameter for that.  One of the two has not been using
the_repository since 43a8391977 (builtin/verify-tag: stop using
`the_repository`, 2025-03-08); let it pass in the correct repository.
The other simply passes the_repository to get the same result as before.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/tag.c
builtin/verify-tag.c
tag.c
tag.h

index 01eba90c5c7bb23fea867cb4d6ad46eb094e4c33..aeb04c487fe95a671932937a83d577b0e76ac4a4 100644 (file)
@@ -149,7 +149,7 @@ static int verify_tag(const char *name, const char *ref UNUSED,
        if (format->format)
                flags = GPG_VERIFY_OMIT_STATUS;
 
-       if (gpg_verify_tag(oid, name, flags))
+       if (gpg_verify_tag(the_repository, oid, name, flags))
                return -1;
 
        if (format->format)
index 558121eaa1688e306c1028411c0a89940a343b1a..4a261b2369729f91a206ee69ac20a0143b5aa8b9 100644 (file)
@@ -61,7 +61,7 @@ int cmd_verify_tag(int argc,
                        continue;
                }
 
-               if (gpg_verify_tag(&oid, name, flags)) {
+               if (gpg_verify_tag(repo, &oid, name, flags)) {
                        had_error = 1;
                        continue;
                }
diff --git a/tag.c b/tag.c
index dec5ea8eb0ab7402bcc577a6687941d20db4b073..9373c49d0614b022b4f5f82aaec82464b227e9fc 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -44,28 +44,28 @@ static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)
        return ret;
 }
 
-int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
-               unsigned flags)
+int gpg_verify_tag(struct repository *r, const struct object_id *oid,
+                  const char *name_to_report, unsigned flags)
 {
        enum object_type type;
        char *buf;
        unsigned long size;
        int ret;
 
-       type = odb_read_object_info(the_repository->objects, oid, NULL);
+       type = odb_read_object_info(r->objects, oid, NULL);
        if (type != OBJ_TAG)
                return error("%s: cannot verify a non-tag object of type %s.",
                                name_to_report ?
                                name_to_report :
-                               repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
+                               repo_find_unique_abbrev(r, oid, DEFAULT_ABBREV),
                                type_name(type));
 
-       buf = odb_read_object(the_repository->objects, oid, &type, &size);
+       buf = odb_read_object(r->objects, oid, &type, &size);
        if (!buf)
                return error("%s: unable to read file.",
                                name_to_report ?
                                name_to_report :
-                               repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
+                               repo_find_unique_abbrev(r, oid, DEFAULT_ABBREV));
 
        ret = run_gpg_verify(buf, size, flags);
 
diff --git a/tag.h b/tag.h
index ef12a610372063aff01b78285a2b161a23675614..55c2d0792b99cbc11dc595e3451b6c6c8f06b7c2 100644 (file)
--- a/tag.h
+++ b/tag.h
@@ -16,7 +16,7 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
 int parse_tag(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(const struct object_id *oid,
+int gpg_verify_tag(struct repository *r, const struct object_id *oid,
                   const char *name_to_report, unsigned flags);
 struct object_id *get_tagged_oid(struct tag *tag);