git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/6] packfile: thread odb_source_packed through packed_object_info()

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 2, 2026, 12:01 UTC
Message-ID
<20260702-b4-pks-odb-drop-whence-v2-1-b0af7468ad95@pks.im>
In-Reply-To
<20260702-b4-pks-odb-drop-whence-v2-0-b0af7468ad95@pks.im>

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>
---
 builtin/cat-file.c     | 2 +-
 builtin/pack-objects.c | 4 ++--
 commit-graph.c         | 2 +-
 odb/source-packed.c    | 4 ++--
 pack-bitmap.c          | 2 +-
 packfile.c             | 8 +++++---
 packfile.h             | 6 ++++--
 t/helper/test-bitmap.c | 2 +-
 8 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 0f3dbd9850..8726485f1f 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -497,7 +497,7 @@ static void batch_object_write(const char *obj_name,
 			data->info.sizep = &data->size;
 
 		if (pack)
-			ret = packed_object_info(pack, offset, &data->info);
+			ret = packed_object_info(NULL, pack, offset, &data->info);
 		else
 			ret = odb_read_object_info_extended(the_repository->objects,
 							    &data->oid, &data->info,
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index bc5f9ef321..620d9ce085 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2463,7 +2463,7 @@ static void drop_reused_delta(struct object_entry *entry)
 
 	oi.sizep = &size;
 	oi.typep = &type;
-	if (packed_object_info(IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
+	if (packed_object_info(NULL, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
 		/*
 		 * We failed to get the info from this pack for some reason;
 		 * 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,
 	ofs = nth_packed_object_offset(p, pos);
 
 	oi.typep = &type;
-	if (packed_object_info(p, ofs, &oi) < 0) {
+	if (packed_object_info(NULL, p, ofs, &oi) < 0) {
 		die(_("could not get type of object %s in pack %s"),
 		    oid_to_hex(oid), p->pack_name);
 	} else if (type == OBJ_COMMIT) {
diff --git a/commit-graph.c b/commit-graph.c
index c6d9c5c740..9dc8bd5eee 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1538,7 +1538,7 @@ static int add_packed_commits(const struct object_id *oid,
 	struct object_info oi = OBJECT_INFO_INIT;
 
 	oi.typep = &type;
-	if (packed_object_info(pack, offset, &oi) < 0)
+	if (packed_object_info(NULL, pack, offset, &oi) < 0)
 		die(_("unable to get type of object %s"), oid_to_hex(oid));
 
 	return add_packed_commits_oi(oid, &oi, data);
diff --git a/odb/source-packed.c b/odb/source-packed.c
index 42c28fba0e..43fb53b72d 100644
--- a/odb/source-packed.c
+++ b/odb/source-packed.c
@@ -59,7 +59,7 @@ static int odb_source_packed_read_object_info(struct odb_source *source,
 	if (!oi)
 		return 0;
 
-	ret = packed_object_info(e.p, e.offset, oi);
+	ret = packed_object_info(packed, e.p, e.offset, oi);
 	if (ret < 0) {
 		mark_bad_packed_object(e.p, oid);
 		return -1;
@@ -99,7 +99,7 @@ static int odb_source_packed_for_each_object_wrapper(const struct object_id *oid
 		off_t offset = nth_packed_object_offset(pack, index_pos);
 		struct object_info oi = *data->request;
 
-		if (packed_object_info_with_index_pos(pack, offset,
+		if (packed_object_info_with_index_pos(data->store, pack, offset,
 						      &index_pos, &oi) < 0) {
 			mark_bad_packed_object(pack, oid);
 			return -1;
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 83eb47a28b..35774b6f0c 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1877,7 +1877,7 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
 			ofs = pack_pos_to_offset(pack, pos);
 		}
 
-		if (packed_object_info(pack, ofs, &oi) < 0) {
+		if (packed_object_info(NULL, pack, ofs, &oi) < 0) {
 			struct object_id oid;
 			nth_bitmap_object_oid(bitmap_git, &oid,
 					      pack_pos_to_index(pack, pos));
diff --git a/packfile.c b/packfile.c
index 1d1b23b6cc..2b741d7a76 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1324,7 +1324,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
 	hashmap_add(&delta_base_cache, &ent->ent);
 }
 
-int packed_object_info_with_index_pos(struct packed_git *p, off_t obj_offset,
+int packed_object_info_with_index_pos(struct odb_source_packed *source UNUSED,
+				      struct packed_git *p, off_t obj_offset,
 				      uint32_t *maybe_index_pos, struct object_info *oi)
 {
 	struct pack_window *w_curs = NULL;
@@ -1446,10 +1447,11 @@ int packed_object_info_with_index_pos(struct packed_git *p, off_t obj_offset,
 	return ret;
 }
 
-int packed_object_info(struct packed_git *p, off_t obj_offset,
+int packed_object_info(struct odb_source_packed *source,
+		       struct packed_git *p, off_t obj_offset,
 		       struct object_info *oi)
 {
-	return packed_object_info_with_index_pos(p, obj_offset, NULL, oi);
+	return packed_object_info_with_index_pos(source, p, obj_offset, NULL, oi);
 }
 
 static void *unpack_compressed_entry(struct packed_git *p,
diff --git a/packfile.h b/packfile.h
index 2329a69701..e1f77152b5 100644
--- a/packfile.h
+++ b/packfile.h
@@ -320,9 +320,11 @@ extern int do_check_packed_object_crc;
  * Look up the object info for a specific offset in the packfile.
  * Returns zero on success, a negative error code otherwise.
  */
-int packed_object_info(struct packed_git *pack,
+int packed_object_info(struct odb_source_packed *source,
+		       struct packed_git *pack,
 		       off_t offset, struct object_info *);
-int packed_object_info_with_index_pos(struct packed_git *p, off_t obj_offset,
+int packed_object_info_with_index_pos(struct odb_source_packed *source,
+				      struct packed_git *p, off_t obj_offset,
 				      uint32_t *maybe_index_pos, struct object_info *oi);
 
 void mark_bad_packed_object(struct packed_git *, const struct object_id *);
diff --git a/t/helper/test-bitmap.c b/t/helper/test-bitmap.c
index b130832b81..8547ef67e2 100644
--- a/t/helper/test-bitmap.c
+++ b/t/helper/test-bitmap.c
@@ -52,7 +52,7 @@ static int add_packed_object(const struct object_id *oid,
 
 	entry = packlist_alloc(packed, oid);
 	entry->idx.offset = nth_packed_object_offset(pack, pos);
-	if (packed_object_info(pack, entry->idx.offset, &oi) < 0)
+	if (packed_object_info(NULL, pack, entry->idx.offset, &oi) < 0)
 		die("could not get type of object %s",
 		    oid_to_hex(oid));
 	oe_set_type(entry, type);
-- 
2.55.0.795.g602f6c329a.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 20 of 26 in “odb: refactor source-specific information in object info”
  1. 0/6 odb: refactor source-specific information in object infoPatrick Steinhardt, Jun 24, 2026
  2. 1/6 packfile: thread odb_source_packed through packed_object_info()Patrick Steinhardt, Jun 24, 2026
  3. Justin ToblerJun 29, 2026
  4. Patrick SteinhardtJun 30, 2026
  5. 2/6 odb: make backend-specific fields optionalPatrick Steinhardt, Jun 24, 2026
  6. Justin ToblerJun 29, 2026
  7. Patrick SteinhardtJun 30, 2026
  8. 3/6 odb: add `source` field to struct object_info_sourcePatrick Steinhardt, Jun 24, 2026
  9. Justin ToblerJun 29, 2026
  10. Junio C HamanoJun 29, 2026
  11. Patrick SteinhardtJun 30, 2026
  12. Junio C HamanoJun 30, 2026
  13. 4/6 treewide: convert users of `whence` to the new source fieldPatrick Steinhardt, Jun 24, 2026
  14. Justin ToblerJun 29, 2026
  15. 5/6 odb: drop `whence` field from object infoPatrick Steinhardt, Jun 24, 2026
  16. Justin ToblerJun 29, 2026
  17. 6/6 odb: document object info fieldsPatrick Steinhardt, Jun 24, 2026
  18. Junio C HamanoJun 24, 2026
  19. 0/6 odb: refactor source-specific information in object infoPatrick Steinhardt, Jul 2, 2026
  20. 1/6 packfile: thread odb_source_packed through packed_object_info()Patrick Steinhardt, Jul 2, 2026
  21. 2/6 odb: make backend-specific fields optionalPatrick Steinhardt, Jul 2, 2026
  22. 3/6 odb: add `source` field to struct object_info_sourcePatrick Steinhardt, Jul 2, 2026
  23. 4/6 treewide: convert users of `whence` to the new source fieldPatrick Steinhardt, Jul 2, 2026
  24. 5/6 odb: drop `whence` field from object infoPatrick Steinhardt, Jul 2, 2026
  25. 6/6 odb: document object info fieldsPatrick Steinhardt, Jul 2, 2026
  26. Junio C HamanoJul 5, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.