{"thread":{"id":"64687","subject":"[PATCH 2/4] tag: support arbitrary repositories in gpg_verify_tag()","startedAt":"2025-12-28T18:10:59Z","lastAt":"2025-12-30T16:52:07Z","messageCount":6,"participants":["René Scharfe","Kristoffer Haugsbakk"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"532797","messageId":"20251228181051.68724-3-l.s.r@web.de","threadId":"64687","inReplyTo":"20251228181051.68724-1-l.s.r@web.de","subject":"[PATCH 2/4] tag: support arbitrary repositories in gpg_verify_tag()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2025-12-28T18:10:49Z","receivedAt":"2025-12-28T18:10:59Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Allow callers of gpg_verify_tag() specify the repository to use by\nproviding a parameter for that.  One of the two has not been using\nthe_repository since 43a8391977 (builtin/verify-tag: stop using\n`the_repository`, 2025-03-08); let it pass in the correct repository.\nThe other simply passes the_repository to get the same result as before.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n builtin/tag.c        |  2 +-\n builtin/verify-tag.c |  2 +-\n tag.c                | 12 ++++++------\n tag.h                |  2 +-\n 4 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 01eba90c5c..aeb04c487f 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -149,7 +149,7 @@ static int verify_tag(const char *name, const char *ref UNUSED,\n \tif (format->format)\n \t\tflags = GPG_VERIFY_OMIT_STATUS;\n \n-\tif (gpg_verify_tag(oid, name, flags))\n+\tif (gpg_verify_tag(the_repository, oid, name, flags))\n \t\treturn -1;\n \n \tif (format->format)\ndiff --git a/builtin/verify-tag.c b/builtin/verify-tag.c\nindex 558121eaa1..4a261b2369 100644\n--- a/builtin/verify-tag.c\n+++ b/builtin/verify-tag.c\n@@ -61,7 +61,7 @@ int cmd_verify_tag(int argc,\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (gpg_verify_tag(&oid, name, flags)) {\n+\t\tif (gpg_verify_tag(repo, &oid, name, flags)) {\n \t\t\thad_error = 1;\n \t\t\tcontinue;\n \t\t}\ndiff --git a/tag.c b/tag.c\nindex dec5ea8eb0..9373c49d06 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -44,28 +44,28 @@ static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)\n \treturn ret;\n }\n \n-int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n-\t\tunsigned flags)\n+int gpg_verify_tag(struct repository *r, const struct object_id *oid,\n+\t\t   const char *name_to_report, unsigned flags)\n {\n \tenum object_type type;\n \tchar *buf;\n \tunsigned long size;\n \tint ret;\n \n-\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n+\ttype = odb_read_object_info(r->objects, oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n \t\t\t\tname_to_report :\n-\t\t\t\trepo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),\n+\t\t\t\trepo_find_unique_abbrev(r, oid, DEFAULT_ABBREV),\n \t\t\t\ttype_name(type));\n \n-\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n+\tbuf = odb_read_object(r->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n \t\t\t\tname_to_report :\n-\t\t\t\trepo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));\n+\t\t\t\trepo_find_unique_abbrev(r, oid, DEFAULT_ABBREV));\n \n \tret = run_gpg_verify(buf, size, flags);\n \ndiff --git a/tag.h b/tag.h\nindex ef12a61037..55c2d0792b 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -16,7 +16,7 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u\n int parse_tag(struct tag *item);\n void release_tag_memory(struct tag *t);\n struct object *deref_tag(struct repository *r, struct object *, const char *, int);\n-int gpg_verify_tag(const struct object_id *oid,\n+int gpg_verify_tag(struct repository *r, const struct object_id *oid,\n \t\t   const char *name_to_report, unsigned flags);\n struct object_id *get_tagged_oid(struct tag *tag);\n \n-- \n2.52.0\n\n"},{"id":"532798","messageId":"20251228181051.68724-1-l.s.r@web.de","threadId":"64687","inReplyTo":null,"subject":"[PATCH 0/4] tag: stop using the_repository","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2025-12-28T18:10:47Z","receivedAt":"2025-12-28T18:10:59Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Push the use of the_repository and the_hash_algo from the tag\nfunctions to their callers.  Also converts some cases of implicit use,\nwhich seem unintended.\n\n  tag: use algo of repo parameter in parse_tag_buffer()\n  tag: support arbitrary repositories in gpg_verify_tag()\n  tag: support arbitrary repositories in parse_tag()\n  tag: stop using the_repository\n\n builtin/describe.c     |  6 +++---\n builtin/pack-objects.c |  2 +-\n builtin/tag.c          |  2 +-\n builtin/verify-tag.c   |  2 +-\n fsck.c                 |  2 +-\n object-name.c          |  2 +-\n ref-filter.c           |  2 +-\n tag.c                  | 27 ++++++++++++++-------------\n tag.h                  |  4 ++--\n walker.c               |  2 +-\n 10 files changed, 26 insertions(+), 25 deletions(-)\n\n-- \n2.52.0\n\n"},{"id":"532799","messageId":"20251228181051.68724-4-l.s.r@web.de","threadId":"64687","inReplyTo":"20251228181051.68724-1-l.s.r@web.de","subject":"[PATCH 3/4] tag: support arbitrary repositories in parse_tag()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2025-12-28T18:10:50Z","receivedAt":"2025-12-28T18:10:59Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Allow callers of parse_tag() pass in the repository to use.  Let most of\nthem pass in the_repository to get the same result as before.  One of\nthem has stopped using the_repository in ef9b0370da (sha1-name.c: store\nand use repo in struct disambiguate_state, 2019-04-16); let it pass in\nits stored repository.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n builtin/describe.c     | 6 +++---\n builtin/pack-objects.c | 2 +-\n fsck.c                 | 2 +-\n object-name.c          | 2 +-\n ref-filter.c           | 2 +-\n tag.c                  | 8 ++++----\n tag.h                  | 2 +-\n walker.c               | 2 +-\n 8 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 443546aaac..989a78d715 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -112,13 +112,13 @@ static int replace_name(struct commit_name *e,\n \n \t\tif (!e->tag) {\n \t\t\tt = lookup_tag(the_repository, &e->oid);\n-\t\t\tif (!t || parse_tag(t))\n+\t\t\tif (!t || parse_tag(the_repository, t))\n \t\t\t\treturn 1;\n \t\t\te->tag = t;\n \t\t}\n \n \t\tt = lookup_tag(the_repository, oid);\n-\t\tif (!t || parse_tag(t))\n+\t\tif (!t || parse_tag(the_repository, t))\n \t\t\treturn 0;\n \t\t*tag = t;\n \n@@ -335,7 +335,7 @@ static void append_name(struct commit_name *n, struct strbuf *dst)\n {\n \tif (n->prio == 2 && !n->tag) {\n \t\tn->tag = lookup_tag(the_repository, &n->oid);\n-\t\tif (!n->tag || parse_tag(n->tag))\n+\t\tif (!n->tag || parse_tag(the_repository, n->tag))\n \t\t\tdie(_(\"annotated tag %s not available\"), n->path);\n \t}\n \tif (n->tag && !n->name_checked) {\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 1ce8d6ee21..ca44b7894f 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3293,7 +3293,7 @@ static void add_tag_chain(const struct object_id *oid)\n \n \ttag = lookup_tag(the_repository, oid);\n \twhile (1) {\n-\t\tif (!tag || parse_tag(tag) || !tag->tagged)\n+\t\tif (!tag || parse_tag(the_repository, tag) || !tag->tagged)\n \t\t\tdie(_(\"unable to pack objects reachable from tag %s\"),\n \t\t\t    oid_to_hex(oid));\n \ndiff --git a/fsck.c b/fsck.c\nindex 138fffded9..fae18d8561 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -474,7 +474,7 @@ static int fsck_walk_tag(struct tag *tag, void *data, struct fsck_options *optio\n {\n \tconst char *name = fsck_get_object_name(options, &tag->object.oid);\n \n-\tif (parse_tag(tag))\n+\tif (parse_tag(the_repository, tag))\n \t\treturn -1;\n \tif (name)\n \t\tfsck_put_object_name(options, &tag->tagged->oid, \"%s\", name);\ndiff --git a/object-name.c b/object-name.c\nindex fed5de5153..8b862c124e 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -449,7 +449,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t} else if (type == OBJ_TAG) {\n \t\tstruct tag *tag = lookup_tag(ds->repo, oid);\n \n-\t\tif (!parse_tag(tag) && tag->tag) {\n+\t\tif (!parse_tag(ds->repo, tag) && tag->tag) {\n \t\t\t/*\n \t\t\t * TRANSLATORS: This is a line of ambiguous\n \t\t\t * tag object output. E.g.:\ndiff --git a/ref-filter.c b/ref-filter.c\nindex d7454269e8..c318f9ca0e 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2866,7 +2866,7 @@ static int match_points_at(struct oid_array *points_at,\n \twhile (obj && obj->type == OBJ_TAG) {\n \t\tstruct tag *tag = (struct tag *)obj;\n \n-\t\tif (parse_tag(tag) < 0) {\n+\t\tif (parse_tag(the_repository, tag) < 0) {\n \t\t\tobj = NULL;\n \t\t\tbreak;\n \t\t}\ndiff --git a/tag.c b/tag.c\nindex 9373c49d06..9daeaf2a78 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -13,6 +13,7 @@\n #include \"gpg-interface.h\"\n #include \"hex.h\"\n #include \"packfile.h\"\n+#include \"repository.h\"\n \n const char *tag_type = \"tag\";\n \n@@ -203,7 +204,7 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u\n \treturn 0;\n }\n \n-int parse_tag(struct tag *item)\n+int parse_tag(struct repository *r, struct tag *item)\n {\n \tenum object_type type;\n \tvoid *data;\n@@ -212,8 +213,7 @@ int parse_tag(struct tag *item)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tdata = odb_read_object(the_repository->objects, &item->object.oid,\n-\t\t\t       &type, &size);\n+\tdata = odb_read_object(r->objects, &item->object.oid, &type, &size);\n \tif (!data)\n \t\treturn error(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\n@@ -222,7 +222,7 @@ int parse_tag(struct tag *item)\n \t\treturn error(\"Object %s not a tag\",\n \t\t\t     oid_to_hex(&item->object.oid));\n \t}\n-\tret = parse_tag_buffer(the_repository, item, data, size);\n+\tret = parse_tag_buffer(r, item, data, size);\n \tfree(data);\n \treturn ret;\n }\ndiff --git a/tag.h b/tag.h\nindex 55c2d0792b..534687c4ca 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -13,7 +13,7 @@ struct tag {\n };\n struct tag *lookup_tag(struct repository *r, const struct object_id *oid);\n int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);\n-int parse_tag(struct tag *item);\n+int parse_tag(struct repository *r, struct tag *item);\n void release_tag_memory(struct tag *t);\n struct object *deref_tag(struct repository *r, struct object *, const char *, int);\n int gpg_verify_tag(struct repository *r, const struct object_id *oid,\ndiff --git a/walker.c b/walker.c\nindex 409b646578..2891563b03 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -115,7 +115,7 @@ static int process_commit(struct walker *walker, struct commit *commit)\n \n static int process_tag(struct walker *walker, struct tag *tag)\n {\n-\tif (parse_tag(tag))\n+\tif (parse_tag(the_repository, tag))\n \t\treturn -1;\n \treturn process(walker, tag->tagged);\n }\n-- \n2.52.0\n\n"},{"id":"532800","messageId":"20251228181051.68724-5-l.s.r@web.de","threadId":"64687","inReplyTo":"20251228181051.68724-1-l.s.r@web.de","subject":"[PATCH 4/4] tag: stop using the_repository","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2025-12-28T18:10:51Z","receivedAt":"2025-12-28T18:10:59Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"gpg_verify_tag() shows the passed in object name on error.  Both callers\nprovide one.  It falls back to abbreviated hashes for future callers\nthat pass in a NULL name.  DEFAULT_ABBREV is default_abbrev, which in\nturn is a global variable that's populated by git_default_config() and\nonly available with USE_THE_REPOSITORY_VARIABLE.\n\nDon't let that hypothetical hold us back from getting rid of\nthe_repository in tag.c.  Fall back to full hashes, which are more\nappropriate for error messages anyway.  This allows us to stop setting\nUSE_THE_REPOSITORY_VARIABLE.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n tag.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/tag.c b/tag.c\nindex 9daeaf2a78..2f12e51024 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -58,7 +57,7 @@ int gpg_verify_tag(struct repository *r, const struct object_id *oid,\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n \t\t\t\tname_to_report :\n-\t\t\t\trepo_find_unique_abbrev(r, oid, DEFAULT_ABBREV),\n+\t\t\t\toid_to_hex(oid),\n \t\t\t\ttype_name(type));\n \n \tbuf = odb_read_object(r->objects, oid, &type, &size);\n@@ -66,7 +65,7 @@ int gpg_verify_tag(struct repository *r, const struct object_id *oid,\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n \t\t\t\tname_to_report :\n-\t\t\t\trepo_find_unique_abbrev(r, oid, DEFAULT_ABBREV));\n+\t\t\t\toid_to_hex(oid));\n \n \tret = run_gpg_verify(buf, size, flags);\n \n-- \n2.52.0\n\n"},{"id":"532801","messageId":"20251228181051.68724-2-l.s.r@web.de","threadId":"64687","inReplyTo":"20251228181051.68724-1-l.s.r@web.de","subject":"[PATCH 1/4] tag: use algo of repo parameter in parse_tag_buffer()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2025-12-28T18:10:48Z","receivedAt":"2025-12-28T18:10:59Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Stop using \"the_hash_algo\" explicitly and implictly via parse_oid_hex()\nand instead use the \"hash_algo\" member of the passed in repository,\nwhich is more correct.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n tag.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/tag.c b/tag.c\nindex f5c232d2f1..dec5ea8eb0 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -148,9 +148,11 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u\n \t\tFREE_AND_NULL(item->tag);\n \t}\n \n-\tif (size < the_hash_algo->hexsz + 24)\n+\tif (size < r->hash_algo->hexsz + 24)\n \t\treturn -1;\n-\tif (memcmp(\"object \", bufptr, 7) || parse_oid_hex(bufptr + 7, &oid, &bufptr) || *bufptr++ != '\\n')\n+\tif (memcmp(\"object \", bufptr, 7) ||\n+\t    parse_oid_hex_algop(bufptr + 7, &oid, &bufptr, r->hash_algo) ||\n+\t    *bufptr++ != '\\n')\n \t\treturn -1;\n \n \tif (!starts_with(bufptr, \"type \"))\n-- \n2.52.0\n\n"},{"id":"532851","messageId":"b37d0318-e4c8-4aae-a764-ec9c4c13fd64@app.fastmail.com","threadId":"64687","inReplyTo":"20251228181051.68724-2-l.s.r@web.de","subject":"Re: [PATCH 1/4] tag: use algo of repo parameter in parse_tag_buffer()","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-12-30T16:51:45Z","receivedAt":"2025-12-30T16:52:07Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Sun, Dec 28, 2025, at 19:10, René Scharfe wrote:\n> Stop using \"the_hash_algo\" explicitly and implictly via parse_oid_hex()\n\ns/implictly/implicitly/\n\n> and instead use the \"hash_algo\" member of the passed in repository,\n> which is more correct.\n>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n>[snip]\n"}]}