cache.h: add repository argument to oid_object_info_extended

Add a repository argument to allow oid_object_info_extended callers
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.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Stefan Beller 2018-04-25 11:20:58 -07:00 коммит произвёл Junio C Hamano
Родитель 90e777f1e2
Коммит 7ecd869060
5 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
switch (opt) {
case 't':
oi.type_name = &sb;
if (oid_object_info_extended(&oid, &oi, flags) < 0)
if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
die("git cat-file: could not get object info");
if (sb.len) {
printf("%s\n", sb.buf);
@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
case 's':
oi.sizep = &size;
if (oid_object_info_extended(&oid, &oi, flags) < 0)
if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
die("git cat-file: could not get object info");
printf("%lu\n", size);
return 0;
@ -342,7 +342,7 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,
struct strbuf buf = STRBUF_INIT;
if (!data->skip_object_info &&
oid_object_info_extended(&data->oid, &data->info,
oid_object_info_extended(the_repository, &data->oid, &data->info,
OBJECT_INFO_LOOKUP_REPLACE) < 0) {
printf("%s missing\n",
obj_name ? obj_name : oid_to_hex(&data->oid));

Просмотреть файл

@ -1673,7 +1673,10 @@ struct object_info {
#define OBJECT_INFO_QUICK 8
/* Do not check loose object */
#define OBJECT_INFO_IGNORE_LOOSE 16
extern int oid_object_info_extended(const struct object_id *, struct object_info *, unsigned flags);
#define oid_object_info_extended(r, oid, oi, flags) \
oid_object_info_extended_##r(oid, oi, flags)
int oid_object_info_extended_the_repository(const struct object_id *, struct object_info *, unsigned flags);
/*
* Set this to 0 to prevent sha1_object_info_extended() from fetching missing

Просмотреть файл

@ -1474,7 +1474,7 @@ static void *read_object(const struct object_id *oid, enum object_type *type,
oi.sizep = size;
oi.contentp = &content;
if (oid_object_info_extended(oid, &oi, 0) < 0)
if (oid_object_info_extended(the_repository, oid, &oi, 0) < 0)
return NULL;
return content;
}

Просмотреть файл

@ -1231,7 +1231,7 @@ static int sha1_loose_object_info(struct repository *r,
int fetch_if_missing = 1;
int oid_object_info_extended(const struct object_id *oid, struct object_info *oi, unsigned flags)
int oid_object_info_extended_the_repository(const struct object_id *oid, struct object_info *oi, unsigned flags)
{
static struct object_info blank_oi = OBJECT_INFO_INIT;
struct pack_entry e;
@ -1310,7 +1310,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
rtype = packed_object_info(e.p, e.offset, oi);
if (rtype < 0) {
mark_bad_packed_object(e.p, real->hash);
return oid_object_info_extended(real, oi, 0);
return oid_object_info_extended(the_repository, real, oi, 0);
} else if (oi->whence == OI_PACKED) {
oi->u.packed.offset = e.offset;
oi->u.packed.pack = e.p;
@ -1329,7 +1329,7 @@ int oid_object_info(const struct object_id *oid, unsigned long *sizep)
oi.typep = &type;
oi.sizep = sizep;
if (oid_object_info_extended(oid, &oi,
if (oid_object_info_extended(the_repository, oid, &oi,
OBJECT_INFO_LOOKUP_REPLACE) < 0)
return -1;
return type;
@ -1347,7 +1347,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,
hashcpy(oid.hash, sha1);
if (oid_object_info_extended(&oid, &oi, 0) < 0)
if (oid_object_info_extended(the_repository, &oid, &oi, 0) < 0)
return NULL;
return content;
}
@ -1745,7 +1745,7 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
if (!startup_info->have_repository)
return 0;
hashcpy(oid.hash, sha1);
return oid_object_info_extended(&oid, NULL,
return oid_object_info_extended(the_repository, &oid, NULL,
flags | OBJECT_INFO_SKIP_CACHED) >= 0;
}

Просмотреть файл

@ -117,7 +117,7 @@ static enum input_source istream_source(const struct object_id *oid,
oi->typep = type;
oi->sizep = &size;
status = oid_object_info_extended(oid, oi, 0);
status = oid_object_info_extended(the_repository, oid, oi, 0);
if (status < 0)
return stream_error;