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

[PATCH 4/6] treewide: convert users of `whence` to the new source field

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 24, 2026, 12:19 UTC
Message-ID
<20260624-b4-pks-odb-drop-whence-v1-4-8d1877b790ac@pks.im>
In-Reply-To
<20260624-b4-pks-odb-drop-whence-v1-0-8d1877b790ac@pks.im>

The `whence` field has become redundant now that callers can learn about the exact source an object has been looked up from via the `struct object_info_source::source` field.

Adapt callers to use the new field. Note that all callsites already set up the `info.sourcep` request pointer, so the conversion is rather straight-forward.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/cat-file.c     | 2 +-
 builtin/index-pack.c   | 3 ++-
 builtin/pack-objects.c | 2 +-
 reachable.c            | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index adc626ce30..1b96150e5b 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -834,7 +834,7 @@ static int batch_one_object_oi(const struct object_id *oid,
 			       void *_payload)
 {
 	struct for_each_object_payload *payload = _payload;
-	if (oi && oi->whence == OI_PACKED)
+	if (oi && oi->sourcep->source->type == ODB_SOURCE_PACKED)
 		return payload->callback(oid, oi->sourcep->u.packed.pack,
 					 oi->sourcep->u.packed.offset,
 					 payload->payload);
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 77af26db8f..1b03b07e5e 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1833,7 +1833,8 @@ static void repack_local_links(void)
 		if (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))
 			/* Missing; assume it is a promisor object */
 			continue;
-		if (info.whence == OI_PACKED && info_source.u.packed.pack->pack_promisor)
+		if (info_source.source->type == ODB_SOURCE_PACKED &&
+		    info_source.u.packed.pack->pack_promisor)
 			continue;
 
 		if (!cmd.args.nr) {
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 9deb37e9e8..d0fdfad750 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -5010,7 +5010,7 @@ static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
 
 	if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
 		BUG("should_include_obj should only be called on existing objects");
-	return info.whence != OI_PACKED || !info_source.u.packed.pack->pack_promisor;
+	return info_source.source->type != ODB_SOURCE_PACKED || !info_source.u.packed.pack->pack_promisor;
 }
 
 static int is_not_in_promisor_pack(struct commit *commit, void *data) {
diff --git a/reachable.c b/reachable.c
index 2fc5b82d62..123a658944 100644
--- a/reachable.c
+++ b/reachable.c
@@ -234,7 +234,7 @@ static int add_recent_object(const struct object_id *oid,
 
 	add_pending_object(data->revs, obj, "");
 	if (data->cb) {
-		if (oi->whence == OI_PACKED)
+		if (oi->sourcep->source->type == ODB_SOURCE_PACKED)
 			data->cb(obj, oi->sourcep->u.packed.pack,
 				 oi->sourcep->u.packed.offset, *oi->mtimep);
 		else
-- 
2.55.0.rc1.745.g43192e7977.dirty
Previous: Junio C HamanoNext: Justin Tobler
Message 13 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.