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

[PATCH v2 00/16] object-file: get rid of `the_repository`

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 17, 2025, 04:56 UTC
Message-ID
<20250717-pks-object-file-wo-the-repository-v2-0-36d2cd6c700e@pks.im>
In-Reply-To
<20250709-pks-object-file-wo-the-repository-v1-0-62627b55707f@pks.im>
Hi,

this patch series refactors "object-file.c" to get rid of the dependency on `the_repository`. In many such cases this is done by passing in a `struct odb_source`, which prepares us for eventually converting this into the "loose" object source with pluggable object databases.

The patch series is built on top of a30f80fde92 (The eighth batch, 2025-07-08) with "ps/object-store" at 841a03b4046 (odb: rename `read_object_with_reference()`, 2025-07-01) merged into it.

Changes in v2:
  - Two small typo improvements.
  - Drop the last three patches from this series that move some global
    config into repo settings. Those cause a change in behaviour, and
    fixing that is a lot of effort that falls outside of the scope of
    this patch series.
  - Link to v1: https://lore.kernel.org/r/20250709-pks-object-file-wo-the-repository-v1-0-62627b55707f@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (16):
      object-file: fix -Wsign-compare warnings
      object-file: stop using `the_hash_algo`
      object-file: get rid of `the_repository` in `has_loose_object()`
      object-file: inline `check_and_freshen()` functions
      object-file: get rid of `the_repository` when freshening objects
      object-file: get rid of `the_repository` in `loose_object_info()`
      object-file: get rid of `the_repository` in `finalize_object_file()`
      loose: write loose objects map via their source
      odb: introduce `odb_write_object()`
      object-file: get rid of `the_repository` when writing objects
      object-file: inline `for_each_loose_file_in_objdir_buf()`
      object-file: remove declaration for `for_each_file_in_obj_subdir()`
      object-file: get rid of `the_repository` in loose object iterators
      object-file: get rid of `the_repository` in `read_loose_object()`
      object-file: get rid of `the_repository` in `force_object_loose()`
      object-file: get rid of `the_repository` in index-related functions
 apply.c                  |  11 +-
 builtin/cat-file.c       |   2 +-
 builtin/checkout.c       |   2 +-
 builtin/count-objects.c  |   2 +-
 builtin/fast-import.c    |   4 +-
 builtin/fsck.c           |  16 +--
 builtin/gc.c             |  10 +-
 builtin/index-pack.c     |   2 +-
 builtin/merge-file.c     |   3 +-
 builtin/mktag.c          |   2 +-
 builtin/mktree.c         |   2 +-
 builtin/notes.c          |   3 +-
 builtin/pack-objects.c   |  34 ++++--
 builtin/prune.c          |   2 +-
 builtin/receive-pack.c   |   4 +-
 builtin/replace.c        |   3 +-
 builtin/tag.c            |   4 +-
 builtin/unpack-objects.c |  15 +--
 bulk-checkin.c           |   2 +-
 cache-tree.c             |   5 +-
 commit.c                 |   4 +-
 http.c                   |   4 +-
 loose.c                  |  16 +--
 loose.h                  |   4 +-
 match-trees.c            |   2 +-
 merge-ort.c              |   7 +-
 midx-write.c             |   2 +-
 notes-cache.c            |   3 +-
 notes.c                  |  12 +-
 object-file.c            | 306 ++++++++++++++++++++++-------------------------
 object-file.h            |  65 ++++------
 odb.c                    |  10 ++
 odb.h                    |  38 ++++++
 pack-write.c             |  16 +--
 pack.h                   |   3 +-
 prune-packed.c           |   2 +-
 reachable.c              |   2 +-
 read-cache.c             |   2 +-
 tmp-objdir.c             |   2 +-
 39 files changed, 333 insertions(+), 295 deletions(-)
Range-diff versus v1:
 1:  c150744a648 =  1:  4fc36ad30ae object-file: fix -Wsign-compare warnings
 2:  5cdc43d3d27 !  2:  c5ad1d12618 object-file: stop using `the_hash_algo`
    @@ Commit message
         anymore, either by deriving it from already-available context or by
         using `the_repository->hash_algo`. The latter variant doesn't yet help
         to remove the global dependency, but such users will be adapted in the
    -    following commits to not use `the_repository` anymore, either.
    +    following commits to not use `the_repository` anymore.
     
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
 3:  8e63fb2d760 =  3:  76478623aa7 object-file: get rid of `the_repository` in `has_loose_object()`
 4:  14153d37df4 =  4:  ee7b31c95cd object-file: inline `check_and_freshen()` functions
 5:  70abad2d817 =  5:  4b7407f17b7 object-file: get rid of `the_repository` when freshening objects
 6:  5fc03ab39da =  6:  40a7c009c7b object-file: get rid of `the_repository` in `loose_object_info()`
 7:  9a07f6a27df =  7:  9568d7e996e object-file: get rid of `the_repository` in `finalize_object_file()`
 8:  739008ad578 =  8:  cf974b8b48d loose: write loose objects map via their source
 9:  f2f00d6f566 !  9:  fec51b64457 odb: introduce `odb_write_object()`
    @@ odb.h: enum for_each_object_flags {
     +	WRITE_OBJECT_PERSIST = (1 << 0),
     +
     +	/*
    -+	 * Do not print an error in case something gose wrong.
    ++	 * Do not print an error in case something goes wrong.
     +	 */
     +	WRITE_OBJECT_SILENT = (1 << 1),
     +};
10:  84411e2a8fc = 10:  ece58da8182 object-file: get rid of `the_repository` when writing objects
11:  f051bfbada1 = 11:  a76d5f24040 object-file: inline `for_each_loose_file_in_objdir_buf()`
12:  3754b37207a = 12:  70e60db13f6 object-file: remove declaration for `for_each_file_in_obj_subdir()`
13:  be855be5c0e = 13:  77ec9b765dc object-file: get rid of `the_repository` in loose object iterators
14:  6cb7f6bc040 = 14:  b091f019d01 object-file: get rid of `the_repository` in `read_loose_object()`
15:  8ddb96c9f30 = 15:  3982420285b object-file: get rid of `the_repository` in `force_object_loose()`
16:  d885f70f58d = 16:  21272b2644b object-file: get rid of `the_repository` in index-related functions
17:  1640212fe06 <  -:  ----------- environment: move compression level into repo settings
18:  36496f2c42c <  -:  ----------- environment: move object creation mode into repo settings
19:  8760509c0bb <  -:  ----------- object-file: drop USE_THE_REPOSITORY_VARIABLE

--- base-commit: f0228c39bf2fe539583cd594671039f05765bc9b change-id: 20250709-pks-object-file-wo-the-repository-9f41234c4747

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 43 of 60 in “object-file: get rid of `the_repository`”
  1. 00/19 object-file: get rid of `the_repository`Patrick Steinhardt, Jul 9, 2025
  2. 01/19 object-file: fix -Wsign-compare warningsPatrick Steinhardt, Jul 9, 2025
  3. 02/19 object-file: stop using `the_hash_algo`Patrick Steinhardt, Jul 9, 2025
  4. Karthik NayakJul 11, 2025
  5. 03/19 object-file: get rid of `the_repository` in `has_loose_object()`Patrick Steinhardt, Jul 9, 2025
  6. 04/19 object-file: inline `check_and_freshen()` functionsPatrick Steinhardt, Jul 9, 2025
  7. 05/19 object-file: get rid of `the_repository` when freshening objectsPatrick Steinhardt, Jul 9, 2025
  8. Karthik NayakJul 11, 2025
  9. 06/19 object-file: get rid of `the_repository` in `loose_object_info()`Patrick Steinhardt, Jul 9, 2025
  10. 07/19 object-file: get rid of `the_repository` in `finalize_object_file()`Patrick Steinhardt, Jul 9, 2025
  11. 08/19 loose: write loose objects map via their sourcePatrick Steinhardt, Jul 9, 2025
  12. Karthik NayakJul 11, 2025
  13. Patrick SteinhardtJul 15, 2025
  14. 09/19 odb: introduce `odb_write_object()`Patrick Steinhardt, Jul 9, 2025
  15. Toon ClaesJul 10, 2025
  16. Patrick SteinhardtJul 15, 2025
  17. 10/19 object-file: get rid of `the_repository` when writing objectsPatrick Steinhardt, Jul 9, 2025
  18. 11/19 object-file: inline `for_each_loose_file_in_objdir_buf()`Patrick Steinhardt, Jul 9, 2025
  19. 12/19 object-file: remove declaration for `for_each_file_in_obj_subdir()`Patrick Steinhardt, Jul 9, 2025
  20. 13/19 object-file: get rid of `the_repository` in loose object iteratorsPatrick Steinhardt, Jul 9, 2025
  21. Toon ClaesJul 10, 2025
  22. 14/19 object-file: get rid of `the_repository` in `read_loose_object()`Patrick Steinhardt, Jul 9, 2025
  23. 15/19 object-file: get rid of `the_repository` in `force_object_loose()`Patrick Steinhardt, Jul 9, 2025
  24. Toon ClaesJul 10, 2025
  25. Karthik NayakJul 11, 2025
  26. Patrick SteinhardtJul 15, 2025
  27. Toon ClaesJul 15, 2025
  28. 16/19 object-file: get rid of `the_repository` in index-related functionsPatrick Steinhardt, Jul 9, 2025
  29. 17/19 environment: move compression level into repo settingsPatrick Steinhardt, Jul 9, 2025
  30. Phillip WoodJul 9, 2025
  31. Junio C HamanoJul 11, 2025
  32. Patrick SteinhardtJul 15, 2025
  33. Patrick SteinhardtJul 15, 2025
  34. Phillip WoodJul 15, 2025
  35. Patrick SteinhardtJul 15, 2025
  36. Patrick SteinhardtJul 16, 2025
  37. Phillip WoodJul 17, 2025
  38. Junio C HamanoJul 17, 2025
  39. Junio C HamanoJul 15, 2025
  40. Ayush ChandekarJul 17, 2025
  41. 18/19 environment: move object creation mode into repo settingsPatrick Steinhardt, Jul 9, 2025
  42. 19/19 object-file: drop USE_THE_REPOSITORY_VARIABLEPatrick Steinhardt, Jul 9, 2025
  43. 00/16 object-file: get rid of `the_repository`Patrick Steinhardt, Jul 17, 2025
  44. 01/16 object-file: fix -Wsign-compare warningsPatrick Steinhardt, Jul 17, 2025
  45. Jeff KingApr 5, 2026
  46. 02/16 object-file: stop using `the_hash_algo`Patrick Steinhardt, Jul 17, 2025
  47. 03/16 object-file: get rid of `the_repository` in `has_loose_object()`Patrick Steinhardt, Jul 17, 2025
  48. 04/16 object-file: inline `check_and_freshen()` functionsPatrick Steinhardt, Jul 17, 2025
  49. 05/16 object-file: get rid of `the_repository` when freshening objectsPatrick Steinhardt, Jul 17, 2025
  50. 06/16 object-file: get rid of `the_repository` in `loose_object_info()`Patrick Steinhardt, Jul 17, 2025
  51. 07/16 object-file: get rid of `the_repository` in `finalize_object_file()`Patrick Steinhardt, Jul 17, 2025
  52. 08/16 loose: write loose objects map via their sourcePatrick Steinhardt, Jul 17, 2025
  53. 09/16 odb: introduce `odb_write_object()`Patrick Steinhardt, Jul 17, 2025
  54. 10/16 object-file: get rid of `the_repository` when writing objectsPatrick Steinhardt, Jul 17, 2025
  55. 11/16 object-file: inline `for_each_loose_file_in_objdir_buf()`Patrick Steinhardt, Jul 17, 2025
  56. 12/16 object-file: remove declaration for `for_each_file_in_obj_subdir()`Patrick Steinhardt, Jul 17, 2025
  57. 13/16 object-file: get rid of `the_repository` in loose object iteratorsPatrick Steinhardt, Jul 17, 2025
  58. 14/16 object-file: get rid of `the_repository` in `read_loose_object()`Patrick Steinhardt, Jul 17, 2025
  59. 15/16 object-file: get rid of `the_repository` in `force_object_loose()`Patrick Steinhardt, Jul 17, 2025
  60. 16/16 object-file: get rid of `the_repository` in index-related functionsPatrick Steinhardt, Jul 17, 2025

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.