tag: add repository argument to deref_tag

Add a repository argument to allow the callers of deref_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>
This commit is contained in:
Stefan Beller
2018-06-28 18:22:05 -07:00
committed by Junio C Hamano
parent 0e740fed5d
commit a74093da5e
18 changed files with 42 additions and 26 deletions

View File

@ -239,7 +239,8 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da
return 0;
/* We need to do this the hard way... */
obj = deref_tag(parse_object(the_repository, oid), NULL, 0);
obj = deref_tag(the_repository, parse_object(the_repository, oid),
NULL, 0);
if (obj && obj->type == OBJ_COMMIT)
return 1;
return 0;
@ -263,7 +264,8 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_
return 0;
/* We need to do this the hard way... */
obj = deref_tag(parse_object(the_repository, oid), NULL, 0);
obj = deref_tag(the_repository, parse_object(the_repository, oid),
NULL, 0);
if (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))
return 1;
return 0;
@ -968,7 +970,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid,
if (!o)
return -1;
if (!expected_type) {
o = deref_tag(o, name, sp - name - 2);
o = deref_tag(the_repository, o, name, sp - name - 2);
if (!o || (!o->parsed && !parse_object(the_repository, &o->oid)))
return -1;
oidcpy(oid, &o->oid);
@ -1100,7 +1102,8 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
if (!object)
return 0;
if (object->type == OBJ_TAG) {
object = deref_tag(object, path, strlen(path));
object = deref_tag(the_repository, object, path,
strlen(path));
if (!object)
return 0;
}