Skip to content

Commit b6e4cc8

Browse files
rscharfegitster
authored andcommitted
tag: support arbitrary repositories in parse_tag()
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 ef9b037 (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>
1 parent 154717b commit b6e4cc8

8 files changed

Lines changed: 13 additions & 13 deletions

File tree

builtin/describe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ static int replace_name(struct commit_name *e,
112112

113113
if (!e->tag) {
114114
t = lookup_tag(the_repository, &e->oid);
115-
if (!t || parse_tag(t))
115+
if (!t || parse_tag(the_repository, t))
116116
return 1;
117117
e->tag = t;
118118
}
119119

120120
t = lookup_tag(the_repository, oid);
121-
if (!t || parse_tag(t))
121+
if (!t || parse_tag(the_repository, t))
122122
return 0;
123123
*tag = t;
124124

@@ -335,7 +335,7 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
335335
{
336336
if (n->prio == 2 && !n->tag) {
337337
n->tag = lookup_tag(the_repository, &n->oid);
338-
if (!n->tag || parse_tag(n->tag))
338+
if (!n->tag || parse_tag(the_repository, n->tag))
339339
die(_("annotated tag %s not available"), n->path);
340340
}
341341
if (n->tag && !n->name_checked) {

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,7 @@ static void add_tag_chain(const struct object_id *oid)
32933293

32943294
tag = lookup_tag(the_repository, oid);
32953295
while (1) {
3296-
if (!tag || parse_tag(tag) || !tag->tagged)
3296+
if (!tag || parse_tag(the_repository, tag) || !tag->tagged)
32973297
die(_("unable to pack objects reachable from tag %s"),
32983298
oid_to_hex(oid));
32993299

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static int fsck_walk_tag(struct tag *tag, void *data, struct fsck_options *optio
474474
{
475475
const char *name = fsck_get_object_name(options, &tag->object.oid);
476476

477-
if (parse_tag(tag))
477+
if (parse_tag(the_repository, tag))
478478
return -1;
479479
if (name)
480480
fsck_put_object_name(options, &tag->tagged->oid, "%s", name);

object-name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
449449
} else if (type == OBJ_TAG) {
450450
struct tag *tag = lookup_tag(ds->repo, oid);
451451

452-
if (!parse_tag(tag) && tag->tag) {
452+
if (!parse_tag(ds->repo, tag) && tag->tag) {
453453
/*
454454
* TRANSLATORS: This is a line of ambiguous
455455
* tag object output. E.g.:

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,7 @@ static int match_points_at(struct oid_array *points_at,
28662866
while (obj && obj->type == OBJ_TAG) {
28672867
struct tag *tag = (struct tag *)obj;
28682868

2869-
if (parse_tag(tag) < 0) {
2869+
if (parse_tag(the_repository, tag) < 0) {
28702870
obj = NULL;
28712871
break;
28722872
}

tag.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "gpg-interface.h"
1414
#include "hex.h"
1515
#include "packfile.h"
16+
#include "repository.h"
1617

1718
const char *tag_type = "tag";
1819

@@ -203,7 +204,7 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
203204
return 0;
204205
}
205206

206-
int parse_tag(struct tag *item)
207+
int parse_tag(struct repository *r, struct tag *item)
207208
{
208209
enum object_type type;
209210
void *data;
@@ -212,8 +213,7 @@ int parse_tag(struct tag *item)
212213

213214
if (item->object.parsed)
214215
return 0;
215-
data = odb_read_object(the_repository->objects, &item->object.oid,
216-
&type, &size);
216+
data = odb_read_object(r->objects, &item->object.oid, &type, &size);
217217
if (!data)
218218
return error("Could not read %s",
219219
oid_to_hex(&item->object.oid));
@@ -222,7 +222,7 @@ int parse_tag(struct tag *item)
222222
return error("Object %s not a tag",
223223
oid_to_hex(&item->object.oid));
224224
}
225-
ret = parse_tag_buffer(the_repository, item, data, size);
225+
ret = parse_tag_buffer(r, item, data, size);
226226
free(data);
227227
return ret;
228228
}

tag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct tag {
1313
};
1414
struct tag *lookup_tag(struct repository *r, const struct object_id *oid);
1515
int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);
16-
int parse_tag(struct tag *item);
16+
int parse_tag(struct repository *r, struct tag *item);
1717
void release_tag_memory(struct tag *t);
1818
struct object *deref_tag(struct repository *r, struct object *, const char *, int);
1919
int gpg_verify_tag(struct repository *r, const struct object_id *oid,

walker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
115115

116116
static int process_tag(struct walker *walker, struct tag *tag)
117117
{
118-
if (parse_tag(tag))
118+
if (parse_tag(the_repository, tag))
119119
return -1;
120120
return process(walker, tag->tagged);
121121
}

0 commit comments

Comments
 (0)