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 <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Jun 28, 2018 at 18:22 UTC
ce71efb713f97f476a2d2ab541a0c73f684a5db3
8 files changed
+12
-12
builtin/describe.c
+3
-3
@@ -93,13 +93,13 @@ static int replace_name(struct commit_name *e,
93
struct tag *t;
94
95
if (!e->tag) {
96
- t = lookup_tag(&e->oid);
96
+ t = lookup_tag(the_repository, &e->oid);
97
if (!t || parse_tag(t))
98
return 1;
99
e->tag = t;
100
}
101
102
- t = lookup_tag(oid);
102
+ t = lookup_tag(the_repository, oid);
103
if (!t || parse_tag(t))
104
return 0;
105
*tag = t;
@@ -267,7 +267,7 @@ static unsigned long finish_depth_computation(
267
static void append_name(struct commit_name *n, struct strbuf *dst)
268
{
269
if (n->prio == 2 && !n->tag) {
270
- n->tag = lookup_tag(&n->oid);
270
+ n->tag = lookup_tag(the_repository, &n->oid);
271
if (!n->tag || parse_tag(n->tag))
272
die(_("annotated tag %s not available"), n->path);
273
}
builtin/pack-objects.c
+1
-1
@@ -2474,7 +2474,7 @@ static void add_tag_chain(const struct object_id *oid)
2474
if (packlist_find(&to_pack, oid->hash, NULL))
2475
return;
2476
2477
- tag = lookup_tag(oid);
2477
+ tag = lookup_tag(the_repository, oid);
2478
while (1) {
2479
if (!tag || parse_tag(tag) || !tag->tagged)
2480
die("unable to pack objects reachable from tag %s",
builtin/replace.c
+1
-1
@@ -402,7 +402,7 @@ static int check_one_mergetag(struct commit *commit,
402
int i;
403
404
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);
406
if (!tag)
407
return error(_("bad mergetag in commit '%s'"), ref);
408
if (parse_tag_buffer(tag, extra->value, extra->len))
log-tree.c
+1
-1
@@ -498,7 +498,7 @@ static int show_one_mergetag(struct commit *commit,
498
size_t payload_size, gpg_message_offset;
499
500
hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &oid);
501
- tag = lookup_tag(&oid);
501
+ tag = lookup_tag(the_repository, &oid);
502
if (!tag)
503
return -1; /* error message already given */
504
object.c
+1
-1
@@ -223,7 +223,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e
223
obj = &commit->object;
224
}
225
} else if (type == OBJ_TAG) {
226
- struct tag *tag = lookup_tag(oid);
226
+ struct tag *tag = lookup_tag(the_repository, oid);
227
if (tag) {
228
if (parse_tag_buffer(tag, buffer, size))
229
return NULL;
sha1-name.c
+1
-1
@@ -358,7 +358,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
358
format_commit_message(commit, " %ad - %s", &desc, &pp);
359
}
360
} else if (type == OBJ_TAG) {
361
- struct tag *tag = lookup_tag(oid);
361
+ struct tag *tag = lookup_tag(the_repository, oid);
362
if (!parse_tag(tag) && tag->tag)
363
strbuf_addf(&desc, " %s", tag->tag);
364
}
tag.c
+2
-2
@@ -92,7 +92,7 @@ struct object *deref_tag_noverify(struct object *o)
92
return o;
93
}
94
95
-struct tag *lookup_tag(const struct object_id *oid)
95
+struct tag *lookup_tag_the_repository(const struct object_id *oid)
96
{
97
struct object *obj = lookup_object(the_repository, oid->hash);
98
if (!obj)
@@ -160,7 +160,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
160
} else if (!strcmp(type, commit_type)) {
161
item->tagged = (struct object *)lookup_commit(the_repository, &oid);
162
} else if (!strcmp(type, tag_type)) {
163
- item->tagged = (struct object *)lookup_tag(&oid);
163
+ item->tagged = (struct object *)lookup_tag(the_repository, &oid);
164
} else {
165
error("Unknown type %s", type);
166
item->tagged = NULL;
tag.h
+2
-2
@@ -11,8 +11,8 @@ struct tag {
11
char *tag;
12
timestamp_t date;
13
};
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);
16
extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long size);
17
extern int parse_tag(struct tag *item);
18
extern void release_tag_memory(struct tag *t);