Skip to content

Commit 7ecd869

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 90e777f commit 7ecd869

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

builtin/cat-file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
7777
switch (opt) {
7878
case 't':
7979
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)
8181
die("git cat-file: could not get object info");
8282
if (sb.len) {
8383
printf("%s\n", sb.buf);
@@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
8888

8989
case 's':
9090
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)
9292
die("git cat-file: could not get object info");
9393
printf("%lu\n", size);
9494
return 0;
@@ -342,7 +342,7 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,
342342
struct strbuf buf = STRBUF_INIT;
343343

344344
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,
346346
OBJECT_INFO_LOOKUP_REPLACE) < 0) {
347347
printf("%s missing\n",
348348
obj_name ? obj_name : oid_to_hex(&data->oid));

cache.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,10 @@ struct object_info {
16731673
#define OBJECT_INFO_QUICK 8
16741674
/* Do not check loose object */
16751675
#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);
16771680

16781681
/*
16791682
* Set this to 0 to prevent sha1_object_info_extended() from fetching missing

packfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ static void *read_object(const struct object_id *oid, enum object_type *type,
14741474
oi.sizep = size;
14751475
oi.contentp = &content;
14761476

1477-
if (oid_object_info_extended(oid, &oi, 0) < 0)
1477+
if (oid_object_info_extended(the_repository, oid, &oi, 0) < 0)
14781478
return NULL;
14791479
return content;
14801480
}

sha1_file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ static int sha1_loose_object_info(struct repository *r,
12311231

12321232
int fetch_if_missing = 1;
12331233

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)
12351235
{
12361236
static struct object_info blank_oi = OBJECT_INFO_INIT;
12371237
struct pack_entry e;
@@ -1310,7 +1310,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
13101310
rtype = packed_object_info(e.p, e.offset, oi);
13111311
if (rtype < 0) {
13121312
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);
13141314
} else if (oi->whence == OI_PACKED) {
13151315
oi->u.packed.offset = e.offset;
13161316
oi->u.packed.pack = e.p;
@@ -1329,7 +1329,7 @@ int oid_object_info(const struct object_id *oid, unsigned long *sizep)
13291329

13301330
oi.typep = &type;
13311331
oi.sizep = sizep;
1332-
if (oid_object_info_extended(oid, &oi,
1332+
if (oid_object_info_extended(the_repository, oid, &oi,
13331333
OBJECT_INFO_LOOKUP_REPLACE) < 0)
13341334
return -1;
13351335
return type;
@@ -1347,7 +1347,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,
13471347

13481348
hashcpy(oid.hash, sha1);
13491349

1350-
if (oid_object_info_extended(&oid, &oi, 0) < 0)
1350+
if (oid_object_info_extended(the_repository, &oid, &oi, 0) < 0)
13511351
return NULL;
13521352
return content;
13531353
}
@@ -1745,7 +1745,7 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
17451745
if (!startup_info->have_repository)
17461746
return 0;
17471747
hashcpy(oid.hash, sha1);
1748-
return oid_object_info_extended(&oid, NULL,
1748+
return oid_object_info_extended(the_repository, &oid, NULL,
17491749
flags | OBJECT_INFO_SKIP_CACHED) >= 0;
17501750
}
17511751

streaming.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static enum input_source istream_source(const struct object_id *oid,
117117

118118
oi->typep = type;
119119
oi->sizep = &size;
120-
status = oid_object_info_extended(oid, oi, 0);
120+
status = oid_object_info_extended(the_repository, oid, oi, 0);
121121
if (status < 0)
122122
return stream_error;
123123

0 commit comments

Comments
 (0)