object: add repository argument to parse_object

Add a repository argument to allow the callers of parse_object
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:21:51 -07:00
committed by Junio C Hamano
parent b16b60f71b
commit 109cd76dd3
33 changed files with 95 additions and 72 deletions

View File

@ -84,7 +84,7 @@ static void cache_one_alternate(const char *refname,
void *vcache)
{
struct alternate_object_cache *cache = vcache;
struct object *obj = parse_object(oid);
struct object *obj = parse_object(the_repository, oid);
if (!obj || (obj->flags & ALTERNATE))
return;
@ -126,7 +126,8 @@ static void rev_list_push(struct commit *commit, int mark)
static int rev_list_insert_ref(const char *refname, const struct object_id *oid)
{
struct object *o = deref_tag(parse_object(oid), refname, 0);
struct object *o = deref_tag(parse_object(the_repository, oid),
refname, 0);
if (o && o->type == OBJ_COMMIT)
rev_list_push((struct commit *)o, SEEN);
@ -143,7 +144,8 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *
static int clear_marks(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
{
struct object *o = deref_tag(parse_object(oid), refname, 0);
struct object *o = deref_tag(parse_object(the_repository, oid),
refname, 0);
if (o && o->type == OBJ_COMMIT)
clear_commit_marks((struct commit *)o,
@ -437,7 +439,7 @@ static int find_common(struct fetch_pack_args *args,
if (!lookup_object(oid.hash))
die(_("object not found: %s"), line);
/* make sure that it is parsed as shallow */
if (!parse_object(&oid))
if (!parse_object(the_repository, &oid))
die(_("error in object: %s"), line);
if (unregister_shallow(&oid))
die(_("no shallow found: %s"), line);
@ -570,14 +572,14 @@ static struct commit_list *complete;
static int mark_complete(const struct object_id *oid)
{
struct object *o = parse_object(oid);
struct object *o = parse_object(the_repository, oid);
while (o && o->type == OBJ_TAG) {
struct tag *t = (struct tag *) o;
if (!t->tagged)
break; /* broken repository */
o->flags |= COMPLETE;
o = parse_object(&t->tagged->oid);
o = parse_object(the_repository, &t->tagged->oid);
}
if (o && o->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *)o;
@ -768,7 +770,7 @@ static int everything_local(struct fetch_pack_args *args,
if (!has_object_file_with_flags(&ref->old_oid, flags))
continue;
o = parse_object(&ref->old_oid);
o = parse_object(the_repository, &ref->old_oid);
if (!o)
continue;
@ -1318,7 +1320,7 @@ static void receive_shallow_info(struct fetch_pack_args *args,
if (!lookup_object(oid.hash))
die(_("object not found: %s"), reader->line);
/* make sure that it is parsed as shallow */
if (!parse_object(&oid))
if (!parse_object(the_repository, &oid))
die(_("error in object: %s"), reader->line);
if (unregister_shallow(&oid))
die(_("no shallow found: %s"), reader->line);