summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-01-08 16:40:11 +0900
committerJunio C Hamano <gitster@pobox.com>2026-01-08 16:40:11 +0900
commitd28d2be5f2aa6acbd0c86b8fbae68cd222de3f4f (patch)
treedc76572fbf677e72117a545e2b0da7d4fe94e889
parente0bfec3dfc356f7d808eb5ee546a54116b794397 (diff)
parent009fceeda26e12e2dbacd04eef47c62d4e206403 (diff)
downloadgit-d28d2be5f2aa6acbd0c86b8fbae68cd222de3f4f.tar.xz
Merge branch 'rs/tag-wo-the-repository'
Code clean-up. * rs/tag-wo-the-repository: tag: stop using the_repository tag: support arbitrary repositories in parse_tag() tag: support arbitrary repositories in gpg_verify_tag() tag: use algo of repo parameter in parse_tag_buffer()
-rw-r--r--builtin/describe.c6
-rw-r--r--builtin/pack-objects.c2
-rw-r--r--builtin/tag.c2
-rw-r--r--builtin/verify-tag.c2
-rw-r--r--fsck.c2
-rw-r--r--object-name.c2
-rw-r--r--ref-filter.c2
-rw-r--r--tag.c27
-rw-r--r--tag.h4
-rw-r--r--walker.c2
10 files changed, 26 insertions, 25 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 443546aaac..989a78d715 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -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) {
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 1ce8d6ee21..ca44b7894f 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -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/builtin/tag.c b/builtin/tag.c
index 01eba90c5c..aeb04c487f 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -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)
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 558121eaa1..4a261b2369 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -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/fsck.c b/fsck.c
index 138fffded9..fae18d8561 100644
--- 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);
diff --git a/object-name.c b/object-name.c
index fed5de5153..8b862c124e 100644
--- a/object-name.c
+++ b/object-name.c
@@ -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.:
diff --git a/ref-filter.c b/ref-filter.c
index d7454269e8..c318f9ca0e 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -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 f5c232d2f1..2f12e51024 100644
--- a/tag.c
+++ b/tag.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
@@ -13,6 +12,7 @@
#include "gpg-interface.h"
#include "hex.h"
#include "packfile.h"
+#include "repository.h"
const char *tag_type = "tag";
@@ -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),
+ oid_to_hex(oid),
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));
+ oid_to_hex(oid));
ret = run_gpg_verify(buf, size, flags);
@@ -148,9 +148,11 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
FREE_AND_NULL(item->tag);
}
- if (size < the_hash_algo->hexsz + 24)
+ if (size < r->hash_algo->hexsz + 24)
return -1;
- if (memcmp("object ", bufptr, 7) || parse_oid_hex(bufptr + 7, &oid, &bufptr) || *bufptr++ != '\n')
+ if (memcmp("object ", bufptr, 7) ||
+ parse_oid_hex_algop(bufptr + 7, &oid, &bufptr, r->hash_algo) ||
+ *bufptr++ != '\n')
return -1;
if (!starts_with(bufptr, "type "))
@@ -201,7 +203,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;
@@ -210,8 +212,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));
@@ -220,7 +221,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 ef12a61037..534687c4ca 100644
--- a/tag.h
+++ b/tag.h
@@ -13,10 +13,10 @@ 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(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);
diff --git a/walker.c b/walker.c
index 409b646578..2891563b03 100644
--- 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);
}