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>
Stefan Beller committed
Apr 25, 2018 at 11:20 UTC
7ecd8690602170f0993923c99645c7c6005e3dfa
5 files changed
+14
-11
builtin/cat-file.c
+3
-3
@@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
77
switch (opt) {
78
case 't':
79
oi.type_name = &sb;
80
- if (oid_object_info_extended(&oid, &oi, flags) < 0)
80
+ if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
81
die("git cat-file: could not get object info");
82
if (sb.len) {
83
printf("%s\n", sb.buf);
@@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
88
89
case 's':
90
oi.sizep = &size;
91
- if (oid_object_info_extended(&oid, &oi, flags) < 0)
91
+ if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
92
die("git cat-file: could not get object info");
93
printf("%lu\n", size);
94
return 0;
@@ -342,7 +342,7 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,
342
struct strbuf buf = STRBUF_INIT;
343
344
if (!data->skip_object_info &&
345
- oid_object_info_extended(&data->oid, &data->info,
345
+ oid_object_info_extended(the_repository, &data->oid, &data->info,
346
OBJECT_INFO_LOOKUP_REPLACE) < 0) {
347
printf("%s missing\n",
348
obj_name ? obj_name : oid_to_hex(&data->oid));
cache.h
+4
-1
@@ -1673,7 +1673,10 @@ struct object_info {
1673
#define OBJECT_INFO_QUICK 8
1674
/* Do not check loose object */
1675
#define OBJECT_INFO_IGNORE_LOOSE 16
1676
-extern int oid_object_info_extended(const struct object_id *, struct object_info *, unsigned flags);
1676
+
1677
+#define oid_object_info_extended(r, oid, oi, flags) \
1678
+ oid_object_info_extended_##r(oid, oi, flags)
1679
+int oid_object_info_extended_the_repository(const struct object_id *, struct object_info *, unsigned flags);
1680
1681
/*
1682
* Set this to 0 to prevent sha1_object_info_extended() from fetching missing
packfile.c
+1
-1
@@ -1474,7 +1474,7 @@ static void *read_object(const struct object_id *oid, enum object_type *type,
1474
oi.sizep = size;
1475
oi.contentp = &content;
1476
1477
- if (oid_object_info_extended(oid, &oi, 0) < 0)
1477
+ if (oid_object_info_extended(the_repository, oid, &oi, 0) < 0)
1478
return NULL;
1479
return content;
1480
}
sha1_file.c
+5
-5
@@ -1231,7 +1231,7 @@ static int sha1_loose_object_info(struct repository *r,
1231
1232
int fetch_if_missing = 1;
1233
1234
-int oid_object_info_extended(const struct object_id *oid, struct object_info *oi, unsigned flags)
1234
+int oid_object_info_extended_the_repository(const struct object_id *oid, struct object_info *oi, unsigned flags)
1235
{
1236
static struct object_info blank_oi = OBJECT_INFO_INIT;
1237
struct pack_entry e;
@@ -1310,7 +1310,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
1310
rtype = packed_object_info(e.p, e.offset, oi);
1311
if (rtype < 0) {
1312
mark_bad_packed_object(e.p, real->hash);
1313
- return oid_object_info_extended(real, oi, 0);
1313
+ return oid_object_info_extended(the_repository, real, oi, 0);
1314
} else if (oi->whence == OI_PACKED) {
1315
oi->u.packed.offset = e.offset;
1316
oi->u.packed.pack = e.p;
@@ -1329,7 +1329,7 @@ int oid_object_info(const struct object_id *oid, unsigned long *sizep)
1329
1330
oi.typep = &type;
1331
oi.sizep = sizep;
1332
- if (oid_object_info_extended(oid, &oi,
1332
+ if (oid_object_info_extended(the_repository, oid, &oi,
1333
OBJECT_INFO_LOOKUP_REPLACE) < 0)
1334
return -1;
1335
return type;
@@ -1347,7 +1347,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,
1347
1348
hashcpy(oid.hash, sha1);
1349
1350
- if (oid_object_info_extended(&oid, &oi, 0) < 0)
1350
+ if (oid_object_info_extended(the_repository, &oid, &oi, 0) < 0)
1351
return NULL;
1352
return content;
1353
}
@@ -1745,7 +1745,7 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
1745
if (!startup_info->have_repository)
1746
return 0;
1747
hashcpy(oid.hash, sha1);
1748
- return oid_object_info_extended(&oid, NULL,
1748
+ return oid_object_info_extended(the_repository, &oid, NULL,
1749
flags | OBJECT_INFO_SKIP_CACHED) >= 0;
1750
}
1751
streaming.c
+1
-1
@@ -117,7 +117,7 @@ static enum input_source istream_source(const struct object_id *oid,
117
118
oi->typep = type;
119
oi->sizep = &size;
120
- status = oid_object_info_extended(oid, oi, 0);
120
+ status = oid_object_info_extended(the_repository, oid, oi, 0);
121
if (status < 0)
122
return stream_error;
123