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

[PATCH v2 0/6] odb: refactor source-specific information in object info

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

this patch series refactors `struct object_info` to not contain the `whence` field anymore.

This field only gave the caller information about the type of source this was read from, but it didn't allow them to figure out which source specifically yielded the object. So instead, we replace this information with a new `struct odb_source_info` field that both contains info about the source, and any backend-specific data.

With this in place we can re-query the same backend for any given object. More importantly though, we can eventually also use the backend- specific data to also uniquely identify any given object, e.g. by recording the packfile and offset, so that we can even yield the same object in case one source contains the object multiple times.

Furthermore, with this change all information in `struct object_info` is now following the same request-response-field style.

The series is built on top of 26d8d94e94 (A few more topics before -rc2, 2026-06-21) with ps/odb-source-packed at 1bba3c035d (odb/source-packed: drop pointer to "files" parent source, 2026-06-17) merged into it.

Changes in v2:
  - Rename `struct object_info_source` to `odb_source_info` and the
    `sourcep` pointer to `source_infop`. This follows a suggestion made
    by Justin, as the current naming is too easy to confuse with the
    actual source.
  - Link to v1: https://patch.msgid.link/20260624-b4-pks-odb-drop-whence-v1-0-8d1877b790ac@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (6):
      packfile: thread odb_source_packed through packed_object_info()
      odb: make backend-specific fields optional
      odb: add `source` field to struct object_info_source
      treewide: convert users of `whence` to the new source field
      odb: drop `whence` field from object info
      odb: document object info fields
 builtin/cat-file.c     | 12 +++++---
 builtin/index-pack.c   |  9 ++++--
 builtin/pack-objects.c | 19 ++++++++----
 commit-graph.c         |  2 +-
 odb.c                  |  4 +--
 odb.h                  | 80 +++++++++++++++++++++++++++++++++++---------------
 odb/source-inmemory.c  |  3 +-
 odb/source-loose.c     |  4 +--
 odb/source-packed.c    |  4 +--
 pack-bitmap.c          |  2 +-
 packfile.c             | 45 ++++++++++++++++------------
 packfile.h             |  6 ++--
 reachable.c            |  7 +++--
 t/helper/test-bitmap.c |  2 +-
 14 files changed, 130 insertions(+), 69 deletions(-)
Range-diff versus v1:
1:  52cf49cd37 = 1:  19c247567e packfile: thread odb_source_packed through packed_object_info()
2:  325878ed04 = 2:  084c3592b4 odb: make backend-specific fields optional
3:  cb7f9154b6 < -:  ---------- odb: add `source` field to struct object_info_source
4:  63d2eb7b7c < -:  ---------- treewide: convert users of `whence` to the new source field
-:  ---------- > 3:  dc878542bf odb: add `source` field to struct object_info_source
-:  ---------- > 4:  d2e2b90842 treewide: convert users of `whence` to the new source field
5:  332899f012 ! 5:  7e09bc6aa9 odb: drop `whence` field from object info
    @@ odb.c: static int oid_object_info_convert(struct repository *r,
      		}
      	}
     -	input_oi->whence = new_oi.whence;
    - 	if (input_oi->sourcep)
    - 		*input_oi->sourcep = *new_oi.sourcep;
    + 	if (input_oi->source_infop)
    + 		*input_oi->source_infop = *new_oi.source_infop;
      	return ret;
     
      ## odb.h ##
     @@ odb.h: struct object_info {
      	 * or multiple times in the same source.
      	 */
    - 	struct object_info_source *sourcep;
    + 	struct odb_source_info *source_infop;
     -
     -	/* Response */
     -	enum {
    @@ odb.h: struct object_info {
      ## odb/source-inmemory.c ##
     @@ odb/source-inmemory.c: static void populate_object_info(struct odb_source_inmemory *source,
      		*oi->mtimep = 0;
    - 	if (oi->sourcep)
    - 		oi->sourcep->source = &source->base;
    + 	if (oi->source_infop)
    + 		oi->source_infop->source = &source->base;
     -
     -	oi->whence = OI_CACHED;
      }
    @@ odb/source-inmemory.c: static void populate_object_info(struct odb_source_inmemo
      ## odb/source-loose.c ##
     @@ odb/source-loose.c: static int read_object_info_from_path(struct odb_source_loose *loose,
      			oidclr(oi->delta_base_oid, loose->base.odb->repo->hash_algo);
    - 		if (oi->sourcep && !ret)
    - 			oi->sourcep->source = &loose->base;
    + 		if (oi->source_infop && !ret)
    + 			oi->source_infop->source = &loose->base;
     -		if (!ret)
     -			oi->whence = OI_LOOSE;
      	}
    @@ packfile.c: int packed_object_info_with_index_pos(struct odb_source_packed *sour
      
     -	oi->whence = OI_PACKED;
     -
    - 	if (oi->sourcep) {
    + 	if (oi->source_infop) {
      		if (!source)
      			BUG("cannot request source without an owning source");
6:  1e79d64921 ! 6:  1c25e56d0b odb: document object info fields
    @@ Commit message
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
      ## odb.h ##
    -@@ odb.h: struct object_info_source {
    +@@ odb.h: struct odb_source_info {
      	} u;
      };
      

--- base-commit: 969dbd51a70f9105ee9965adec5c5a02e75ab5b3 change-id: 20260612-b4-pks-odb-drop-whence-1b0af9ab16f4

Previous: Junio C HamanoNext: Patrick Steinhardt
Message 19 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.