Skip to content

Commit ce71efb

Browse files
stefanbellergitster
authored andcommitted
tag: add repository argument to lookup_tag
Add a repository argument to allow the callers of lookup_tag to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3ce85f7 commit ce71efb

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

builtin/describe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ static int replace_name(struct commit_name *e,
9393
struct tag *t;
9494

9595
if (!e->tag) {
96-
t = lookup_tag(&e->oid);
96+
t = lookup_tag(the_repository, &e->oid);
9797
if (!t || parse_tag(t))
9898
return 1;
9999
e->tag = t;
100100
}
101101

102-
t = lookup_tag(oid);
102+
t = lookup_tag(the_repository, oid);
103103
if (!t || parse_tag(t))
104104
return 0;
105105
*tag = t;
@@ -267,7 +267,7 @@ static unsigned long finish_depth_computation(
267267
static void append_name(struct commit_name *n, struct strbuf *dst)
268268
{
269269
if (n->prio == 2 && !n->tag) {
270-
n->tag = lookup_tag(&n->oid);
270+
n->tag = lookup_tag(the_repository, &n->oid);
271271
if (!n->tag || parse_tag(n->tag))
272272
die(_("annotated tag %s not available"), n->path);
273273
}

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2474,7 +2474,7 @@ static void add_tag_chain(const struct object_id *oid)
24742474
if (packlist_find(&to_pack, oid->hash, NULL))
24752475
return;
24762476

2477-
tag = lookup_tag(oid);
2477+
tag = lookup_tag(the_repository, oid);
24782478
while (1) {
24792479
if (!tag || parse_tag(tag) || !tag->tagged)
24802480
die("unable to pack objects reachable from tag %s",

builtin/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static int check_one_mergetag(struct commit *commit,
402402
int i;
403403

404404
hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &tag_oid);
405-
tag = lookup_tag(&tag_oid);
405+
tag = lookup_tag(the_repository, &tag_oid);
406406
if (!tag)
407407
return error(_("bad mergetag in commit '%s'"), ref);
408408
if (parse_tag_buffer(tag, extra->value, extra->len))

log-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static int show_one_mergetag(struct commit *commit,
498498
size_t payload_size, gpg_message_offset;
499499

500500
hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &oid);
501-
tag = lookup_tag(&oid);
501+
tag = lookup_tag(the_repository, &oid);
502502
if (!tag)
503503
return -1; /* error message already given */
504504

object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e
223223
obj = &commit->object;
224224
}
225225
} else if (type == OBJ_TAG) {
226-
struct tag *tag = lookup_tag(oid);
226+
struct tag *tag = lookup_tag(the_repository, oid);
227227
if (tag) {
228228
if (parse_tag_buffer(tag, buffer, size))
229229
return NULL;

sha1-name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
358358
format_commit_message(commit, " %ad - %s", &desc, &pp);
359359
}
360360
} else if (type == OBJ_TAG) {
361-
struct tag *tag = lookup_tag(oid);
361+
struct tag *tag = lookup_tag(the_repository, oid);
362362
if (!parse_tag(tag) && tag->tag)
363363
strbuf_addf(&desc, " %s", tag->tag);
364364
}

tag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct object *deref_tag_noverify(struct object *o)
9292
return o;
9393
}
9494

95-
struct tag *lookup_tag(const struct object_id *oid)
95+
struct tag *lookup_tag_the_repository(const struct object_id *oid)
9696
{
9797
struct object *obj = lookup_object(the_repository, oid->hash);
9898
if (!obj)
@@ -160,7 +160,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
160160
} else if (!strcmp(type, commit_type)) {
161161
item->tagged = (struct object *)lookup_commit(the_repository, &oid);
162162
} else if (!strcmp(type, tag_type)) {
163-
item->tagged = (struct object *)lookup_tag(&oid);
163+
item->tagged = (struct object *)lookup_tag(the_repository, &oid);
164164
} else {
165165
error("Unknown type %s", type);
166166
item->tagged = NULL;

tag.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ struct tag {
1111
char *tag;
1212
timestamp_t date;
1313
};
14-
15-
extern struct tag *lookup_tag(const struct object_id *oid);
14+
#define lookup_tag(r, o) lookup_tag_##r(o)
15+
extern struct tag *lookup_tag_the_repository(const struct object_id *oid);
1616
extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long size);
1717
extern int parse_tag(struct tag *item);
1818
extern void release_tag_memory(struct tag *t);

0 commit comments

Comments
 (0)