object: add repository argument to lookup_object

Add a repository argument to allow callers of lookup_object to be more
specific about which repository to handle. 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: 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:52 -07:00
committed by Junio C Hamano
parent 109cd76dd3
commit 5abddd1eb7
15 changed files with 31 additions and 26 deletions

View File

@@ -230,7 +230,7 @@ static void export_blob(const struct object_id *oid)
if (is_null_oid(oid))
return;
object = lookup_object(oid->hash);
object = lookup_object(the_repository, oid->hash);
if (object && object->flags & SHOWN)
return;
@@ -402,7 +402,8 @@ static void show_filemodify(struct diff_queue_struct *q,
anonymize_sha1(&spec->oid) :
spec->oid.hash));
else {
struct object *object = lookup_object(spec->oid.hash);
struct object *object = lookup_object(the_repository,
spec->oid.hash);
printf("M %06o :%d ", spec->mode,
get_object_mark(object));
}

View File

@@ -410,7 +410,7 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
struct object *obj;
if (!is_null_oid(oid)) {
obj = lookup_object(oid->hash);
obj = lookup_object(the_repository, oid->hash);
if (obj && (obj->flags & HAS_OBJ)) {
if (timestamp && name_objects)
add_decoration(fsck_walk_options.object_names,
@@ -763,7 +763,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
const char *arg = argv[i];
struct object_id oid;
if (!get_oid(arg, &oid)) {
struct object *obj = lookup_object(oid.hash);
struct object *obj = lookup_object(the_repository,
oid.hash);
if (!obj || !(obj->flags & HAS_OBJ)) {
if (is_promisor_object(&oid))

View File

@@ -379,7 +379,8 @@ static void name_rev_line(char *p, struct name_ref_data *data)
*(p+1) = 0;
if (!get_oid(p - (GIT_SHA1_HEXSZ - 1), &oid)) {
struct object *o =
lookup_object(oid.hash);
lookup_object(the_repository,
oid.hash);
if (o)
name = get_rev_name(o, &buf);
}

View File

@@ -40,7 +40,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
* Do we know about this object?
* It must have been reachable
*/
if (lookup_object(oid->hash))
if (lookup_object(the_repository, oid->hash))
return 0;
if (lstat(fullpath, &st)) {

View File

@@ -331,7 +331,7 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,
{
struct object *obj;
struct obj_buffer *obj_buffer;
obj = lookup_object(base->hash);
obj = lookup_object(the_repository, base->hash);
if (!obj)
return 0;
obj_buffer = lookup_object_buffer(obj);