tag: allow parse_tag_buffer to handle arbitrary repositories

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Stefan Beller 2018-06-28 18:22:12 -07:00 committed by Junio C Hamano
parent 8bde69b974
commit 84f80cd2db
2 changed files with 6 additions and 7 deletions

10
tag.c
View File

@ -126,7 +126,7 @@ void release_tag_memory(struct tag *t)
t->date = 0;
}
int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size)
int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size)
{
struct object_id oid;
char type[20];
@ -154,13 +154,13 @@ int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned
bufptr = nl + 1;
if (!strcmp(type, blob_type)) {
item->tagged = (struct object *)lookup_blob(the_repository, &oid);
item->tagged = (struct object *)lookup_blob(r, &oid);
} else if (!strcmp(type, tree_type)) {
item->tagged = (struct object *)lookup_tree(the_repository, &oid);
item->tagged = (struct object *)lookup_tree(r, &oid);
} else if (!strcmp(type, commit_type)) {
item->tagged = (struct object *)lookup_commit(the_repository, &oid);
item->tagged = (struct object *)lookup_commit(r, &oid);
} else if (!strcmp(type, tag_type)) {
item->tagged = (struct object *)lookup_tag(the_repository, &oid);
item->tagged = (struct object *)lookup_tag(r, &oid);
} else {
error("Unknown type %s", type);
item->tagged = NULL;

3
tag.h
View File

@ -12,8 +12,7 @@ struct tag {
timestamp_t date;
};
extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid);
#define parse_tag_buffer(r, i, d, s) parse_tag_buffer_##r(i, d, s)
extern int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size);
extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);
extern int parse_tag(struct tag *item);
extern void release_tag_memory(struct tag *t);
#define deref_tag(r, o, w, l) deref_tag_##r(o, w, l)