packfile: thread odb_source_packed through packed_object_info()
Add an optional `struct odb_source_packed *source` parameter to `packed_object_info()` and `packed_object_info_with_index_pos()`. This parameter is unused at this point in time, but it will be used in a follow-up commit so that we can record the source of a specific object. Note that callers in "odb/source-packed.c" pass the already-available source, but all other callers pass `NULL` instead. This is fine though, as we only care about populating this info when called via the packed store. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jul 2, 2026 at 14:01 UTC
11c689b8730e0927ef9fc73eea59270318b3177d
8 files changed
+17
-13
builtin/cat-file.c
+1
-1
@@ -497,7 +497,7 @@ static void batch_object_write(const char *obj_name,
497
data->info.sizep = &data->size;
498
499
if (pack)
500
- ret = packed_object_info(pack, offset, &data->info);
500
+ ret = packed_object_info(NULL, pack, offset, &data->info);
501
else
502
ret = odb_read_object_info_extended(the_repository->objects,
503
&data->oid, &data->info,
builtin/pack-objects.c
+2
-2
@@ -2463,7 +2463,7 @@ static void drop_reused_delta(struct object_entry *entry)
2463
2464
oi.sizep = &size;
2465
oi.typep = &type;
2466
- if (packed_object_info(IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
2466
+ if (packed_object_info(NULL, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
2467
/*
2468
* We failed to get the info from this pack for some reason;
2469
* fall back to odb_read_object_info, which may find another copy.
@@ -3804,7 +3804,7 @@ static int add_object_entry_from_pack(const struct object_id *oid,
3804
ofs = nth_packed_object_offset(p, pos);
3805
3806
oi.typep = &type;
3807
- if (packed_object_info(p, ofs, &oi) < 0) {
3807
+ if (packed_object_info(NULL, p, ofs, &oi) < 0) {
3808
die(_("could not get type of object %s in pack %s"),
3809
oid_to_hex(oid), p->pack_name);
3810
} else if (type == OBJ_COMMIT) {
commit-graph.c
+1
-1
@@ -1538,7 +1538,7 @@ static int add_packed_commits(const struct object_id *oid,
1538
struct object_info oi = OBJECT_INFO_INIT;
1539
1540
oi.typep = &type;
1541
- if (packed_object_info(pack, offset, &oi) < 0)
1541
+ if (packed_object_info(NULL, pack, offset, &oi) < 0)
1542
die(_("unable to get type of object %s"), oid_to_hex(oid));
1543
1544
return add_packed_commits_oi(oid, &oi, data);
odb/source-packed.c
+2
-2
@@ -59,7 +59,7 @@ static int odb_source_packed_read_object_info(struct odb_source *source,
59
if (!oi)
60
return 0;
61
62
- ret = packed_object_info(e.p, e.offset, oi);
62
+ ret = packed_object_info(packed, e.p, e.offset, oi);
63
if (ret < 0) {
64
mark_bad_packed_object(e.p, oid);
65
return -1;
@@ -99,7 +99,7 @@ static int odb_source_packed_for_each_object_wrapper(const struct object_id *oid
99
off_t offset = nth_packed_object_offset(pack, index_pos);
100
struct object_info oi = *data->request;
101
102
- if (packed_object_info_with_index_pos(pack, offset,
102
+ if (packed_object_info_with_index_pos(data->store, pack, offset,
103
&index_pos, &oi) < 0) {
104
mark_bad_packed_object(pack, oid);
105
return -1;
pack-bitmap.c
+1
-1
@@ -1877,7 +1877,7 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
1877
ofs = pack_pos_to_offset(pack, pos);
1878
}
1879
1880
- if (packed_object_info(pack, ofs, &oi) < 0) {
1880
+ if (packed_object_info(NULL, pack, ofs, &oi) < 0) {
1881
struct object_id oid;
1882
nth_bitmap_object_oid(bitmap_git, &oid,
1883
pack_pos_to_index(pack, pos));
packfile.c
+5
-3
@@ -1324,7 +1324,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
1324
hashmap_add(&delta_base_cache, &ent->ent);
1325
}
1326
1327
-int packed_object_info_with_index_pos(struct packed_git *p, off_t obj_offset,
1327
+int packed_object_info_with_index_pos(struct odb_source_packed *source UNUSED,
1328
+ struct packed_git *p, off_t obj_offset,
1329
uint32_t *maybe_index_pos, struct object_info *oi)
1330
{
1331
struct pack_window *w_curs = NULL;
@@ -1446,10 +1447,11 @@ out:
1447
return ret;
1448
}
1449
1449
-int packed_object_info(struct packed_git *p, off_t obj_offset,
1450
+int packed_object_info(struct odb_source_packed *source,
1451
+ struct packed_git *p, off_t obj_offset,
1452
struct object_info *oi)
1453
{
1452
- return packed_object_info_with_index_pos(p, obj_offset, NULL, oi);
1454
+ return packed_object_info_with_index_pos(source, p, obj_offset, NULL, oi);
1455
}
1456
1457
static void *unpack_compressed_entry(struct packed_git *p,
packfile.h
+4
-2
@@ -320,9 +320,11 @@ extern int do_check_packed_object_crc;
320
* Look up the object info for a specific offset in the packfile.
321
* Returns zero on success, a negative error code otherwise.
322
*/
323
-int packed_object_info(struct packed_git *pack,
323
+int packed_object_info(struct odb_source_packed *source,
324
+ struct packed_git *pack,
325
off_t offset, struct object_info *);
325
-int packed_object_info_with_index_pos(struct packed_git *p, off_t obj_offset,
326
+int packed_object_info_with_index_pos(struct odb_source_packed *source,
327
+ struct packed_git *p, off_t obj_offset,
328
uint32_t *maybe_index_pos, struct object_info *oi);
329
330
void mark_bad_packed_object(struct packed_git *, const struct object_id *);
t/helper/test-bitmap.c
+1
-1
@@ -52,7 +52,7 @@ static int add_packed_object(const struct object_id *oid,
52
53
entry = packlist_alloc(packed, oid);
54
entry->idx.offset = nth_packed_object_offset(pack, pos);
55
- if (packed_object_info(pack, entry->idx.offset, &oi) < 0)
55
+ if (packed_object_info(NULL, pack, entry->idx.offset, &oi) < 0)
56
die("could not get type of object %s",
57
oid_to_hex(oid));
58
oe_set_type(entry, type);