Skip to content

Commit 12d3b58

Browse files
pks-tgitster
authored andcommitted
packfile: drop repository parameter from packed_object_info()
The function `packed_object_info()` takes a packfile and offset and returns the object info for the corresponding object. Despite these two parameters though it also takes a repository pointer. This is redundant information though, as `struct packed_git` already has a repository pointer that is always populated. Drop the redundant parameter. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5ff2969 commit 12d3b58

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

builtin/cat-file.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,7 @@ static void batch_object_write(const char *obj_name,
487487
data->info.sizep = &data->size;
488488

489489
if (pack)
490-
ret = packed_object_info(the_repository, pack,
491-
offset, &data->info);
490+
ret = packed_object_info(pack, offset, &data->info);
492491
else
493492
ret = odb_read_object_info_extended(the_repository->objects,
494493
&data->oid, &data->info,

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,7 @@ static void drop_reused_delta(struct object_entry *entry)
24112411

24122412
oi.sizep = &size;
24132413
oi.typep = &type;
2414-
if (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
2414+
if (packed_object_info(IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
24152415
/*
24162416
* We failed to get the info from this pack for some reason;
24172417
* fall back to odb_read_object_info, which may find another copy.
@@ -3748,7 +3748,7 @@ static int add_object_entry_from_pack(const struct object_id *oid,
37483748
struct object_info oi = OBJECT_INFO_INIT;
37493749

37503750
oi.typep = &type;
3751-
if (packed_object_info(the_repository, p, ofs, &oi) < 0) {
3751+
if (packed_object_info(p, ofs, &oi) < 0) {
37523752
die(_("could not get type of object %s in pack %s"),
37533753
oid_to_hex(oid), p->pack_name);
37543754
} else if (type == OBJ_COMMIT) {

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ static int add_packed_commits(const struct object_id *oid,
14991499
display_progress(ctx->progress, ++ctx->progress_done);
15001500

15011501
oi.typep = &type;
1502-
if (packed_object_info(ctx->r, pack, offset, &oi) < 0)
1502+
if (packed_object_info(pack, offset, &oi) < 0)
15031503
die(_("unable to get type of object %s"), oid_to_hex(oid));
15041504

15051505
if (type != OBJ_COMMIT)

pack-bitmap.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,8 +1876,7 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
18761876
ofs = pack_pos_to_offset(pack, pos);
18771877
}
18781878

1879-
if (packed_object_info(bitmap_repo(bitmap_git), pack, ofs,
1880-
&oi) < 0) {
1879+
if (packed_object_info(pack, ofs, &oi) < 0) {
18811880
struct object_id oid;
18821881
nth_bitmap_object_oid(bitmap_git, &oid,
18831882
pack_pos_to_index(pack, pos));

packfile.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
15801580
hashmap_add(&delta_base_cache, &ent->ent);
15811581
}
15821582

1583-
int packed_object_info(struct repository *r, struct packed_git *p,
1583+
int packed_object_info(struct packed_git *p,
15841584
off_t obj_offset, struct object_info *oi)
15851585
{
15861586
struct pack_window *w_curs = NULL;
@@ -1594,7 +1594,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
15941594
* a "real" type later if the caller is interested.
15951595
*/
15961596
if (oi->contentp) {
1597-
*oi->contentp = cache_or_unpack_entry(r, p, obj_offset, oi->sizep,
1597+
*oi->contentp = cache_or_unpack_entry(p->repo, p, obj_offset, oi->sizep,
15981598
&type);
15991599
if (!*oi->contentp)
16001600
type = OBJ_BAD;
@@ -1635,7 +1635,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
16351635

16361636
if (oi->typep) {
16371637
enum object_type ptot;
1638-
ptot = packed_to_object_type(r, p, obj_offset,
1638+
ptot = packed_to_object_type(p->repo, p, obj_offset,
16391639
type, &w_curs, curpos);
16401640
if (oi->typep)
16411641
*oi->typep = ptot;
@@ -2170,7 +2170,7 @@ int packfile_store_read_object_info(struct packfile_store *store,
21702170
if (!oi)
21712171
return 0;
21722172

2173-
ret = packed_object_info(store->odb->repo, e.p, e.offset, oi);
2173+
ret = packed_object_info(e.p, e.offset, oi);
21742174
if (ret < 0) {
21752175
mark_bad_packed_object(e.p, oid);
21762176
return -1;

packfile.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,7 @@ extern int do_check_packed_object_crc;
382382
* Look up the object info for a specific offset in the packfile.
383383
* Returns zero on success, a negative error code otherwise.
384384
*/
385-
int packed_object_info(struct repository *r,
386-
struct packed_git *pack,
385+
int packed_object_info(struct packed_git *pack,
387386
off_t offset, struct object_info *);
388387

389388
void mark_bad_packed_object(struct packed_git *, const struct object_id *);

0 commit comments

Comments
 (0)