{"thread":{"id":"63403","subject":"[PATCH 00/17] object-store: carve out the object database subsystem","startedAt":"2025-05-06T11:09:20Z","lastAt":"2025-07-01T14:32:00Z","messageCount":143,"participants":["Patrick Steinhardt","Derrick Stolee","Junio C Hamano","Toon Claes","Justin Tobler"],"isPatch":true,"patchVersion":1,"patchTotal":17},"messages":[{"id":"517312","messageId":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":null,"subject":"[PATCH 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:13Z","receivedAt":"2025-05-06T11:09:20Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series refactors the object store subsystem to become more\nself-contained by getting rid of `the_repository`. Instead of passing in\nthe repository explicitly, we start to pass in the object store itself,\nwhich is in contrast to many other refactorings we did, but in line with\nwhat we did for the ref store, as well.\n\nThis series also starts to properly scope functions to the carved out\nobject database subsystem, which requires a bit of shuffling. This\nallows us to have a short-and-sweet `odb_` prefix for functions and\nprepares us for a future with pluggable object backends.\n\nThe series is structured as follows:\n\n  - Patches 1 to 3 rename `struct object_store` and `struct\n    object_directory` as well as the code files.\n\n  - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n\n  - Patches 13 to 17 adjust the name of remaining functions so that they\n    can be clearly attributed to the ODB. I'm happy to kick these\n    patches out of this series and resend them at a later point in case\n    they create too much turmoil.\n\nThis series is built on top of 6f84262c44a (The eleventh batch,\n2025-05-05) with ps/object-store-cleanup at 8a9e27be821 (object-store:\ndrop `repo_has_object_file()`, 2025-04-29) merged into it. There are a\ncouple of trivial conflicts when merged with \"seen\", I have appended the\nmerge conflict resolution as a patch at the end of this mail.\n\nThanks!\n\nPatrick\n\n-- >8 --\n\ndiff --cc builtin/pack-objects.c\nindex e88a13dbb9f,2936a08e130..00000000000\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@@ -4063,9 -4318,10 +4320,10 @@@ static void add_objects_in_unpacked_pac\n  }\n  \n  static int add_loose_object(const struct object_id *oid, const char *path,\n- \t\t\t    void *data UNUSED)\n+ \t\t\t    void *data)\n  {\n+ \tstruct rev_info *revs = data;\n -\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n +\tenum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);\n  \n  \tif (type < 0) {\n  \t\twarning(_(\"loose object at %s could not be examined\"), path);\ndiff --cc odb.h\nindex 03f269c4e82,af0b3d856f5..00000000000\n--- a/odb.h\n+++ b/odb.h\n@@@ -338,25 -258,10 +338,28 @@@ struct object_info \n  /* Die if object corruption (not just an object being missing) was detected. */\n  #define OBJECT_INFO_DIE_IF_CORRUPT 32\n  \n -int oid_object_info_extended(struct repository *r,\n -\t\t\t     const struct object_id *,\n -\t\t\t     struct object_info *, unsigned flags);\n +/*\n + * Read object info from the object database and populate the `object_info`\n + * structure. Returns 0 on success, a negative error code otherwise.\n + */\n +int odb_read_object_info_extended(struct object_database *odb,\n +\t\t\t\t  const struct object_id *oid,\n +\t\t\t\t  struct object_info *oi,\n +\t\t\t\t  unsigned flags);\n +\n +/*\n + * Read a subset of object info for the given object ID. Returns an `enum\n + * object_type` on success, a negative error code otherwise. If successful and\n + * `sizep` is non-NULL, then the size of the object will be written to the\n + * pointer.\n + */\n +int odb_read_object_info(struct object_database *odb,\n +\t\t\t const struct object_id *oid,\n +\t\t\t unsigned long *sizep);\n +\n++/* Free pointers inside of object_info, but not object_info itself */\n++void free_object_info_contents(struct object_info *object_info);\n+ \n  enum {\n  \t/* Retry packed storage after checking packed and loose storage */\n  \tHAS_OBJECT_RECHECK_PACKED = (1 << 0),\ndiff --git a/fetch-object-info.c b/fetch-object-info.c\nindex 1b2c6c4d27c..6c2abb78055 100644\n--- a/fetch-object-info.c\n+++ b/fetch-object-info.c\n@@ -4,7 +4,7 @@\n #include \"pkt-line.h\"\n #include \"connect.h\"\n #include \"oid-array.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"fetch-object-info.h\"\n #include \"string-list.h\"\n \ndiff --git a/fetch-object-info.h b/fetch-object-info.h\nindex 7910d7f1532..d35284bd6bc 100644\n--- a/fetch-object-info.h\n+++ b/fetch-object-info.h\n@@ -3,7 +3,7 @@\n \n #include \"pkt-line.h\"\n #include \"protocol.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct object_info_args {\n \tstruct string_list *object_info_options;\ndiff --git a/transport.h b/transport.h\nindex 5a4f27451ae..3ef3acf8650 100644\n--- a/transport.h\n+++ b/transport.h\n@@ -5,7 +5,7 @@\n #include \"remote.h\"\n #include \"list-objects-filter-options.h\"\n #include \"string-list.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct git_transport_options {\n \tunsigned thin : 1;\n\n---\nPatrick Steinhardt (17):\n      object-store: rename `raw_object_store` to `object_database`\n      object-store: rename `object_directory` to `odb_backend`\n      object-store: rename files to \"odb.{c,h}\"\n      odb: introduce parent pointers\n      odb: get rid of `the_repository` in `find_odb()`\n      odb: get rid of `the_repository` in `assert_oid_type()`\n      odb: get rid of `the_repository` in `assert_oid_type()`\n      odb: get rid of `the_repository` when handling alternates\n      odb: get rid of `the_repository`  in `for_each()` functions\n      odb: get rid of `the_repository` when handling the primary backend\n      odb: get rid of `the_repository` when handling submodule backends\n      odb: trivial refactorings to get rid of `the_repository`\n      odb: rename `oid_object_info()`\n      odb: rename `repo_read_object_file()`\n      odb: rename `has_object()`\n      odb: rename `pretend_object_file()`\n      odb: rename `read_object_with_reference()`\n\n Documentation/user-manual.adoc          |   4 +-\n Makefile                                |   2 +-\n apply.c                                 |  14 +-\n archive-tar.c                           |   2 +-\n archive-zip.c                           |   2 +-\n archive.c                               |   6 +-\n attr.c                                  |   4 +-\n bisect.c                                |   8 +-\n blame.c                                 |  22 +-\n builtin/backfill.c                      |   6 +-\n builtin/blame.c                         |   6 +-\n builtin/cat-file.c                      |  62 +++--\n builtin/checkout.c                      |   2 +-\n builtin/clone.c                         |  14 +-\n builtin/commit-graph.c                  |  20 +-\n builtin/commit-tree.c                   |   4 +-\n builtin/count-objects.c                 |   4 +-\n builtin/describe.c                      |   5 +-\n builtin/difftool.c                      |   4 +-\n builtin/fast-export.c                   |  10 +-\n builtin/fast-import.c                   |  49 ++--\n builtin/fetch.c                         |  21 +-\n builtin/fsck.c                          |  31 +--\n builtin/gc.c                            |  16 +-\n builtin/grep.c                          |  26 +--\n builtin/hash-object.c                   |   2 +-\n builtin/index-pack.c                    |  29 +--\n builtin/log.c                           |   4 +-\n builtin/ls-files.c                      |   4 +-\n builtin/ls-tree.c                       |   6 +-\n builtin/merge-file.c                    |   2 +-\n builtin/merge-tree.c                    |  14 +-\n builtin/mktag.c                         |   6 +-\n builtin/mktree.c                        |  10 +-\n builtin/multi-pack-index.c              |   6 +-\n builtin/notes.c                         |   8 +-\n builtin/pack-objects.c                  |  70 +++---\n builtin/pack-redundant.c                |   2 +-\n builtin/prune.c                         |   6 +-\n builtin/receive-pack.c                  |   9 +-\n builtin/remote.c                        |   6 +-\n builtin/repack.c                        |   7 +-\n builtin/replace.c                       |  12 +-\n builtin/rev-list.c                      |   8 +-\n builtin/show-ref.c                      |   6 +-\n builtin/submodule--helper.c             |   7 +-\n builtin/tag.c                           |  10 +-\n builtin/unpack-file.c                   |   4 +-\n builtin/unpack-objects.c                |  12 +-\n bulk-checkin.c                          |   6 +-\n bundle-uri.c                            |   5 +-\n bundle.c                                |   6 +-\n cache-tree.c                            |  17 +-\n combine-diff.c                          |   4 +-\n commit-graph.c                          |  56 ++---\n commit-graph.h                          |  20 +-\n commit.c                                |  15 +-\n config.c                                |   4 +-\n connected.c                             |   2 +-\n contrib/coccinelle/the_repository.cocci |   2 +-\n diagnose.c                              |   8 +-\n diff.c                                  |  20 +-\n dir.c                                   |   2 +-\n entry.c                                 |   6 +-\n fetch-pack.c                            |  17 +-\n fmt-merge-msg.c                         |   6 +-\n fsck.c                                  |   4 +-\n grep.c                                  |   6 +-\n http-backend.c                          |   2 +-\n http-push.c                             |  20 +-\n http-walker.c                           |  12 +-\n http.c                                  |   6 +-\n list-objects-filter.c                   |   4 +-\n list-objects.c                          |   6 +-\n log-tree.c                              |   2 +-\n loose.c                                 |  24 +-\n mailmap.c                               |   4 +-\n match-trees.c                           |   6 +-\n merge-blobs.c                           |  10 +-\n merge-ort.c                             |   8 +-\n meson.build                             |   2 +-\n midx-write.c                            |   2 +-\n midx.c                                  |   6 +-\n notes-cache.c                           |   4 +-\n notes-merge.c                           |   4 +-\n notes.c                                 |  19 +-\n object-file.c                           |  60 ++---\n object-file.h                           |  12 +-\n object-name.c                           |  24 +-\n object.c                                |   8 +-\n object-store.c => odb.c                 | 395 +++++++++++++++++---------------\n object-store.h => odb.h                 | 271 ++++++++++++++++------\n oss-fuzz/fuzz-pack-idx.c                |   2 +-\n pack-bitmap-write.c                     |   9 +-\n pack-bitmap.c                           |  10 +-\n pack-check.c                            |   2 +-\n pack-mtimes.c                           |   2 +-\n pack-objects.h                          |   2 +-\n pack-revindex.c                         |   2 +-\n pack-write.c                            |  10 +-\n packfile.c                              |  29 +--\n packfile.h                              |   8 +-\n path.c                                  |   4 +-\n promisor-remote.c                       |   6 +-\n protocol-caps.c                         |   4 +-\n reachable.c                             |   2 +-\n read-cache.c                            |  14 +-\n ref-filter.c                            |   6 +-\n reflog.c                                |   8 +-\n refs.c                                  |   7 +-\n remote.c                                |   9 +-\n replace-object.c                        |   2 +-\n replace-object.h                        |   2 +-\n repository.c                            |  21 +-\n repository.h                            |   4 +-\n rerere.c                                |   7 +-\n revision.c                              |   5 +-\n send-pack.c                             |   4 +-\n sequencer.c                             |   7 +-\n server-info.c                           |   2 +-\n shallow.c                               |  14 +-\n streaming.c                             |  10 +-\n submodule-config.c                      |   9 +-\n submodule.c                             |  32 +--\n submodule.h                             |   9 -\n t/helper/test-find-pack.c               |   2 +-\n t/helper/test-pack-mtimes.c             |   2 +-\n t/helper/test-partial-clone.c           |   4 +-\n t/helper/test-read-graph.c              |   8 +-\n t/helper/test-read-midx.c               |   2 +-\n t/helper/test-ref-store.c               |   4 +-\n tag.c                                   |  10 +-\n tmp-objdir.c                            |  18 +-\n tree-walk.c                             |  18 +-\n tree.c                                  |   6 +-\n unpack-trees.c                          |   2 +-\n upload-pack.c                           |   4 +-\n walker.c                                |   6 +-\n xdiff-interface.c                       |   4 +-\n 139 files changed, 1104 insertions(+), 961 deletions(-)\n\n\n---\nbase-commit: 046efb6f2b050efd580e1c1750b77328a1790c0e\nchange-id: 20250505-pks-object-store-wo-the-repository-9c6cbdf8d4b1\n\n"},{"id":"517313","messageId":"20250506-pks-object-store-wo-the-repository-v1-1-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:14Z","receivedAt":"2025-05-06T11:09:21Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `raw_object_store` structure is the central entry point for reading\nand writing objects in a repository. The main purpose of this structure\nis to manage object directories and provide an interface to access and\nwrite objects in those object directories.\n\nRight now, many of the functions associated with the raw object store\nimplicitly rely on `the_repository` to get access to its `objects`\npointer, which is the `raw_object_store`. As we want to generally get\nrid of using `the_repository` across our codebase we will have to\nconvert this implicit dependency on this global variable into an\nexplicit parameter.\n\nThis conversion can be done by simply passing in an explicit pointer to\na repository and then using its `->objects` pointer. But there is a\nsecond effort underway, which is to make the object subsystem more\nselfcontained so that we can eventually have pluggale object backends.\nAs such, passing in a repository wouldn't make a ton of sense, and the\ngoal is to convert the object store interfaces such that we always pass\nin a reference to the `raw_object_store` instead.\n\nThis will expose the `raw_object_store` type to a lot more callers\nthough, which surfaces that this type is named somewhat awkwardly. The\n\"raw_\" prefix makes readers wonder whether there is a non-raw variant of\nthe object store, but there isn't. Furthermore, we nowadays want to name\nfunctions in a way that they can be clearly attributed to a specific\nsubsystem, but calling them e.g. `raw_object_store_has_object()` is just\ntoo unwieldy, even when dropping the \"raw_\" prefix.\n\nInstead, rename the structure to `object_database`. This term is already\nused a lot throughout our codebase, and it cannot easily be mistaken for\n\"object directories\", either. Furthermore, its acronym ODB is already\nwell-known and works well as part of a function's name, like for example\n`odb_has_object()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n commit-graph.c |  2 +-\n commit-graph.h |  4 ++--\n object-store.c | 12 ++++++------\n object-store.h | 11 ++++++++---\n packfile.c     |  2 +-\n packfile.h     |  4 ++--\n repository.c   |  4 ++--\n repository.h   |  4 ++--\n 8 files changed, 24 insertions(+), 19 deletions(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 6394752b0b0..1b66486b9c9 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -829,7 +829,7 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)\n \treturn NULL;\n }\n \n-void close_commit_graph(struct raw_object_store *o)\n+void close_commit_graph(struct object_database *o)\n {\n \tif (!o->commit_graph)\n \t\treturn;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 13f662827d4..20d38c100ce 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -26,7 +26,7 @@ void git_test_write_commit_graph_or_die(void);\n struct commit;\n struct bloom_filter_settings;\n struct repository;\n-struct raw_object_store;\n+struct object_database;\n struct string_list;\n \n char *get_commit_graph_filename(struct object_directory *odb);\n@@ -186,7 +186,7 @@ int write_commit_graph(struct object_directory *odb,\n \n int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags);\n \n-void close_commit_graph(struct raw_object_store *);\n+void close_commit_graph(struct object_database *);\n void free_commit_graph(struct commit_graph *);\n \n /*\ndiff --git a/object-store.c b/object-store.c\nindex 2f51d0e3b03..1effcb12273 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -44,7 +44,7 @@ struct cached_object_entry {\n \t} value;\n };\n \n-static const struct cached_object *find_cached_object(struct raw_object_store *object_store,\n+static const struct cached_object *find_cached_object(struct object_database *object_store,\n \t\t\t\t\t\t      const struct object_id *oid)\n {\n \tstatic const struct cached_object empty_tree = {\n@@ -86,7 +86,7 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n /*\n  * Return non-zero iff the path is usable as an alternate object database.\n  */\n-static int alt_odb_usable(struct raw_object_store *o,\n+static int alt_odb_usable(struct object_database *o,\n \t\t\t  struct strbuf *path,\n \t\t\t  const char *normalized_objdir, khiter_t *pos)\n {\n@@ -959,9 +959,9 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct raw_object_store *raw_object_store_new(void)\n+struct object_database *odb_new(void)\n {\n-\tstruct raw_object_store *o = xmalloc(sizeof(*o));\n+\tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n@@ -970,7 +970,7 @@ struct raw_object_store *raw_object_store_new(void)\n \treturn o;\n }\n \n-static void free_object_directories(struct raw_object_store *o)\n+static void free_object_directories(struct object_database *o)\n {\n \twhile (o->odb) {\n \t\tstruct object_directory *next;\n@@ -983,7 +983,7 @@ static void free_object_directories(struct raw_object_store *o)\n \to->odb_by_path = NULL;\n }\n \n-void raw_object_store_clear(struct raw_object_store *o)\n+void odb_clear(struct object_database *o)\n {\n \tFREE_AND_NULL(o->alternate_db);\n \ndiff --git a/object-store.h b/object-store.h\nindex c2fe5a19605..34b8efbbb83 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -86,7 +86,12 @@ struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n \n-struct raw_object_store {\n+/*\n+ * The object database encapsulates access to objects in a repository. It\n+ * manages one or more backends that store the actual objects which are\n+ * configured via alternates.\n+ */\n+struct object_database {\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -168,8 +173,8 @@ struct raw_object_store {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct raw_object_store *raw_object_store_new(void);\n-void raw_object_store_clear(struct raw_object_store *o);\n+struct object_database *odb_new(void);\n+void odb_clear(struct object_database *o);\n \n /*\n  * Create a temporary file rooted in the object database directory, or\ndiff --git a/packfile.c b/packfile.c\nindex d91016f1c7f..8f51665266d 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -359,7 +359,7 @@ void close_pack(struct packed_git *p)\n \toidset_clear(&p->bad_objects);\n }\n \n-void close_object_store(struct raw_object_store *o)\n+void close_object_store(struct object_database *o)\n {\n \tstruct packed_git *p;\n \ndiff --git a/packfile.h b/packfile.h\nindex 3a3c77cf05a..826eb7f475f 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -183,12 +183,12 @@ int close_pack_fd(struct packed_git *p);\n \n uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);\n \n-struct raw_object_store;\n+struct object_database;\n \n unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);\n void close_pack_windows(struct packed_git *);\n void close_pack(struct packed_git *);\n-void close_object_store(struct raw_object_store *o);\n+void close_object_store(struct object_database *o);\n void unuse_pack(struct pack_window **);\n void clear_delta_base_cache(void);\n struct packed_git *add_packed_git(struct repository *r, const char *path,\ndiff --git a/repository.c b/repository.c\nindex 9b3d6665fc6..07757e6e0c9 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = raw_object_store_new();\n+\trepo->objects = odb_new();\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -374,7 +374,7 @@ void repo_clear(struct repository *repo)\n \tFREE_AND_NULL(repo->worktree);\n \tFREE_AND_NULL(repo->submodule_prefix);\n \n-\traw_object_store_clear(repo->objects);\n+\todb_clear(repo->objects);\n \tFREE_AND_NULL(repo->objects);\n \n \tparsed_object_pool_clear(repo->parsed_objects);\ndiff --git a/repository.h b/repository.h\nindex c4c92b2ab9c..3a5ef9c781e 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -9,7 +9,7 @@ struct git_hash_algo;\n struct index_state;\n struct lock_file;\n struct pathspec;\n-struct raw_object_store;\n+struct object_database;\n struct submodule_cache;\n struct promisor_remote_config;\n struct remote_state;\n@@ -47,7 +47,7 @@ struct repository {\n \t/*\n \t * Holds any information related to accessing the raw object content.\n \t */\n-\tstruct raw_object_store *objects;\n+\tstruct object_database *objects;\n \n \t/*\n \t * All objects in this repository that have been parsed. This structure\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517314","messageId":"20250506-pks-object-store-wo-the-repository-v1-2-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 02/17] object-store: rename `object_directory` to `odb_backend`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:15Z","receivedAt":"2025-05-06T11:09:22Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `object_directory` structure is used as an access point for a single\nobject directory like \".git/objects\". While the structure isn't yet\nfully self-contained, the intent is for it to eventually contain all\ninformation required to access objects in one specific location.\n\nWhile the name \"object directory\" is a good fit for now, this will\nchange over time as we continue with the agenda to make pluggable object\ndatabases a thing. Eventually, objects may not be accessed via any kind\nof directory at all anymore, but they could instead be backed by any\nkind of durable storage mechanism. While it seems quite far-fetched for\nnow, it is thinkable that eventually this might even be some form of a\ndatabase, for example.\n\nAs such, the current name of this structure will become worse over time\nas we evolve into the direction of pluggable ODBs. Immediate next steps\nwill start to carve out proper self-contained object directories, which\nrequires us to pass in these object directories as parameters. Based on\nour modern naming schema this means that those functions should then be\nnamed after their subsystem, which means that we would start to bake the\ncurrent name into the codebase more and more.\n\nLet's preempt this by renaming the structure to `odb_backend` now\nalready. This name is agnostic of how exactly objects are stored and\nallows us to easily introduce e.g. a `files_odb_backend` and other\nspecific implementations over time.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c      |   4 +-\n builtin/count-objects.c     |   2 +-\n builtin/fetch.c             |   2 +-\n builtin/fsck.c              |  14 +++----\n builtin/gc.c                |  14 +++----\n builtin/grep.c              |   2 +-\n builtin/multi-pack-index.c  |   4 +-\n builtin/submodule--helper.c |   2 +-\n bundle.c                    |   2 +-\n commit-graph.c              |  44 +++++++++----------\n commit-graph.h              |  14 +++----\n diagnose.c                  |   4 +-\n http-walker.c               |   2 +-\n http.c                      |   4 +-\n loose.c                     |  20 ++++-----\n midx.c                      |   6 +--\n object-file.c               |  46 ++++++++++----------\n object-file.h               |   8 ++--\n object-name.c               |   6 +--\n object-store.c              | 100 ++++++++++++++++++++++----------------------\n object-store.h              |  23 +++++-----\n packfile.c                  |  16 +++----\n path.c                      |   2 +-\n refs.c                      |   2 +-\n repository.c                |  17 ++++----\n submodule-config.c          |   2 +-\n t/helper/test-read-graph.c  |   6 +--\n tmp-objdir.c                |   4 +-\n 28 files changed, 187 insertions(+), 185 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex a783a86e797..b4cbdbb1f7b 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \t\t\tstruct repository *repo UNUSED)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_backend *odb = NULL;\n \tchar *graph_name;\n \tchar *chain_name;\n \tenum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;\n@@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \tstruct string_list pack_indexes = STRING_LIST_INIT_DUP;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct oidset commits = OIDSET_INIT;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_backend *odb = NULL;\n \tint result = 0;\n \tenum commit_graph_write_flags flags = 0;\n \tstruct progress *progress = NULL;\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex a88c0c9c09a..80f2693ac3c 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -80,7 +80,7 @@ static int count_cruft(const char *basename UNUSED, const char *path,\n \treturn 0;\n }\n \n-static int print_alternate(struct object_directory *odb, void *data UNUSED)\n+static int print_alternate(struct odb_backend *odb, void *data UNUSED)\n {\n \tprintf(\"alternate: \");\n \tquote_c_style(odb->path, NULL, stdout, 0);\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex cda6eaf1fd6..0b15121ff7c 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2652,7 +2652,7 @@ int cmd_fetch(int argc,\n \t\t\tcommit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n \t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\", the_repository);\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->backends,\n \t\t\t\t\t     commit_graph_flags,\n \t\t\t\t\t     NULL);\n \t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\", the_repository);\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6cac28356ce..0c1df302129 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -965,7 +965,7 @@ int cmd_fsck(int argc,\n \t     struct repository *repo UNUSED)\n {\n \tint i;\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \n \t/* fsck knows how to handle missing promisor objects */\n \tfetch_if_missing = 0;\n@@ -1007,8 +1007,8 @@ int cmd_fsck(int argc,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next)\n-\t\t\tfsck_object_dir(odb->path);\n+\t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next)\n+\t\t\tfsck_object_dir(backend->path);\n \n \t\tif (check_full) {\n \t\t\tstruct packed_git *p;\n@@ -1118,11 +1118,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&commit_graph_verify.args, \"commit-graph\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", backend->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&commit_graph_verify.args, \"--progress\");\n \t\t\telse\n@@ -1136,11 +1136,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&midx_verify.args, \"multi-pack-index\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", backend->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&midx_verify.args, \"--progress\");\n \t\t\telse\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 78a2751aa8a..ea13660dba1 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -944,7 +944,7 @@ struct repository *repo UNUSED)\n \t}\n \n \tif (the_repository->settings.gc_write_commit_graph == 1)\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->backends,\n \t\t\t\t\t     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,\n \t\t\t\t\t     NULL);\n \n@@ -1197,7 +1197,7 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)\n \tif (loose_object_auto_limit < 0)\n \t\treturn 1;\n \n-\treturn for_each_loose_file_in_objdir(the_repository->objects->odb->path,\n+\treturn for_each_loose_file_in_objdir(the_repository->objects->backends->path,\n \t\t\t\t\t     loose_object_count,\n \t\t\t\t\t     NULL, NULL, &count);\n }\n@@ -1232,7 +1232,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t * Do not start pack-objects process\n \t * if there are no loose objects.\n \t */\n-\tif (!for_each_loose_file_in_objdir(r->objects->odb->path,\n+\tif (!for_each_loose_file_in_objdir(r->objects->backends->path,\n \t\t\t\t\t   bail_on_loose,\n \t\t\t\t\t   NULL, NULL, NULL))\n \t\treturn 0;\n@@ -1244,7 +1244,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t\tstrvec_push(&pack_proc.args, \"--quiet\");\n \telse\n \t\tstrvec_push(&pack_proc.args, \"--no-quiet\");\n-\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->odb->path);\n+\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->backends->path);\n \n \tpack_proc.in = -1;\n \n@@ -1272,7 +1272,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \telse if (data.batch_size > 0)\n \t\tdata.batch_size--; /* Decrease for equality on limit. */\n \n-\tfor_each_loose_file_in_objdir(r->objects->odb->path,\n+\tfor_each_loose_file_in_objdir(r->objects->backends->path,\n \t\t\t\t      write_loose_object_to_stdin,\n \t\t\t\t      NULL,\n \t\t\t\t      NULL,\n@@ -1525,7 +1525,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,\n \tint result = 0;\n \tstruct lock_file lk;\n \tstruct repository *r = the_repository;\n-\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->backends->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\t/*\n@@ -2997,7 +2997,7 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,\n \tunsigned int i;\n \tint result = 0;\n \tstruct lock_file lk;\n-\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->backends->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\tif (errno == EEXIST)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ce574a605b..3affe523df1 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->odb->path);\n+\tadd_submodule_odb_by_path(subrepo->objects->backends->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex 69a97507324..87173307bf3 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -294,8 +294,8 @@ int cmd_multi_pack_index(int argc,\n \n \tif (the_repository &&\n \t    the_repository->objects &&\n-\t    the_repository->objects->odb)\n-\t\topts.object_dir = xstrdup(the_repository->objects->odb->path);\n+\t    the_repository->objects->backends)\n+\t\topts.object_dir = xstrdup(the_repository->objects->backends->path);\n \n \targc = parse_options(argc, argv, prefix, options,\n \t\t\t     builtin_multi_pack_index_usage, 0);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 53da2116ddf..13fb4ecfaac 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1582,7 +1582,7 @@ static const char alternate_error_advice[] = N_(\n );\n \n static int add_possible_reference_from_superproject(\n-\t\tstruct object_directory *odb, void *sas_cb)\n+\t\tstruct odb_backend *odb, void *sas_cb)\n {\n \tstruct submodule_alternate_setup *sas = sas_cb;\n \tsize_t len;\ndiff --git a/bundle.c b/bundle.c\nindex b0a3fee2efa..dd4c082f8e7 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -233,7 +233,7 @@ int verify_bundle(struct repository *r,\n \t\t.quiet = 1,\n \t};\n \n-\tif (!r || !r->objects || !r->objects->odb)\n+\tif (!r || !r->objects || !r->objects->backends)\n \t\treturn error(_(\"need a repository to verify a bundle\"));\n \n \tfor (i = 0; i < p->nr; i++) {\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 1b66486b9c9..7a85b73cd99 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -37,7 +37,7 @@ void git_test_write_commit_graph_or_die(void)\n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph_reachable(the_repository->objects->odb,\n+\tif (write_commit_graph_reachable(the_repository->objects->backends,\n \t\t\t\t\t flags, NULL))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n@@ -191,19 +191,19 @@ static int commit_gen_cmp(const void *va, const void *vb)\n \treturn 0;\n }\n \n-char *get_commit_graph_filename(struct object_directory *obj_dir)\n+char *get_commit_graph_filename(struct odb_backend *obj_dir)\n {\n \treturn xstrfmt(\"%s/info/commit-graph\", obj_dir->path);\n }\n \n-static char *get_split_graph_filename(struct object_directory *odb,\n+static char *get_split_graph_filename(struct odb_backend *odb,\n \t\t\t\t      const char *oid_hex)\n {\n \treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", odb->path,\n \t\t       oid_hex);\n }\n \n-char *get_commit_graph_chain_filename(struct object_directory *odb)\n+char *get_commit_graph_chain_filename(struct odb_backend *odb)\n {\n \treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", odb->path);\n }\n@@ -250,7 +250,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_backend *odb)\n {\n \tvoid *graph_map;\n \tsize_t graph_size;\n@@ -487,7 +487,7 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s,\n \n static struct commit_graph *load_commit_graph_one(struct repository *r,\n \t\t\t\t\t\t  const char *graph_file,\n-\t\t\t\t\t\t  struct object_directory *odb)\n+\t\t\t\t\t\t  struct odb_backend *odb)\n {\n \n \tstruct stat st;\n@@ -507,7 +507,7 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_v1(struct repository *r,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_backend *odb)\n {\n \tchar *graph_name = get_commit_graph_filename(odb);\n \tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n@@ -652,7 +652,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tprepare_alt_odb(r);\n \n \tfor (i = 0; i < count; i++) {\n-\t\tstruct object_directory *odb;\n+\t\tstruct odb_backend *backend;\n \n \t\tif (strbuf_getline_lf(&line, fp) == EOF)\n \t\t\tbreak;\n@@ -665,9 +665,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t}\n \n \t\tvalid = 0;\n-\t\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t\tchar *graph_name = get_split_graph_filename(odb, line.buf);\n-\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\t\tfor (backend = r->objects->backends; backend; backend = backend->next) {\n+\t\t\tchar *graph_name = get_split_graph_filename(backend, line.buf);\n+\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, backend);\n \n \t\t\tfree(graph_name);\n \n@@ -701,7 +701,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_chain(struct repository *r,\n-\t\t\t\t\t\t    struct object_directory *odb)\n+\t\t\t\t\t\t    struct odb_backend *odb)\n {\n \tchar *chain_file = get_commit_graph_chain_filename(odb);\n \tstruct stat st;\n@@ -719,7 +719,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,\n }\n \n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb)\n+\t\t\t\t\t   struct odb_backend *odb)\n {\n \tstruct commit_graph *g = load_commit_graph_v1(r, odb);\n \n@@ -730,7 +730,7 @@ struct commit_graph *read_commit_graph_one(struct repository *r,\n }\n \n static void prepare_commit_graph_one(struct repository *r,\n-\t\t\t\t     struct object_directory *odb)\n+\t\t\t\t     struct odb_backend *odb)\n {\n \n \tif (r->objects->commit_graph)\n@@ -747,7 +747,7 @@ static void prepare_commit_graph_one(struct repository *r,\n  */\n static int prepare_commit_graph(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \n \t/*\n \t * Early return if there is no git dir or if the commit graph is\n@@ -779,10 +779,10 @@ static int prepare_commit_graph(struct repository *r)\n \t\treturn 0;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb;\n-\t     !r->objects->commit_graph && odb;\n-\t     odb = odb->next)\n-\t\tprepare_commit_graph_one(r, odb);\n+\tfor (backend = r->objects->backends;\n+\t     !r->objects->commit_graph && backend;\n+\t     backend = backend->next)\n+\t\tprepare_commit_graph_one(r, backend);\n \treturn !!r->objects->commit_graph;\n }\n \n@@ -1137,7 +1137,7 @@ struct packed_commit_list {\n \n struct write_commit_graph_context {\n \tstruct repository *r;\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *odb;\n \tchar *graph_name;\n \tstruct oid_array oids;\n \tstruct packed_commit_list commits;\n@@ -1870,7 +1870,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \treturn 0;\n }\n \n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_backend *odb,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts)\n {\n@@ -2502,7 +2502,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tstrbuf_release(&path);\n }\n \n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_backend *odb,\n \t\t       const struct string_list *const pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 20d38c100ce..437cb48081d 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -29,8 +29,8 @@ struct repository;\n struct object_database;\n struct string_list;\n \n-char *get_commit_graph_filename(struct object_directory *odb);\n-char *get_commit_graph_chain_filename(struct object_directory *odb);\n+char *get_commit_graph_filename(struct odb_backend *odb);\n+char *get_commit_graph_chain_filename(struct odb_backend *odb);\n int open_commit_graph(const char *graph_file, int *fd, struct stat *st);\n int open_commit_graph_chain(const char *chain_file, int *fd, struct stat *st);\n \n@@ -89,7 +89,7 @@ struct commit_graph {\n \tuint32_t num_commits;\n \tstruct object_id oid;\n \tchar *filename;\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *odb;\n \n \tuint32_t num_commits_in_base;\n \tunsigned int read_generation_data;\n@@ -115,12 +115,12 @@ struct commit_graph {\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb);\n+\t\t\t\t\t\t struct odb_backend *odb);\n struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t\t\t\t\t   int fd, struct stat *st,\n \t\t\t\t\t\t   int *incomplete_chain);\n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb);\n+\t\t\t\t\t   struct odb_backend *odb);\n \n struct repo_settings;\n \n@@ -173,10 +173,10 @@ struct commit_graph_opts {\n  * is not compatible with the commit-graph feature, then the\n  * methods will return 0 without writing a commit-graph.\n  */\n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_backend *odb,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts);\n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_backend *odb,\n \t\t       const struct string_list *pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\ndiff --git a/diagnose.c b/diagnose.c\nindex b1be74be983..3016ad223d2 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -59,7 +59,7 @@ static void dir_file_stats_objects(const char *full_path,\n \t\t\t    (uintmax_t)st.st_size);\n }\n \n-static int dir_file_stats(struct object_directory *object_dir, void *data)\n+static int dir_file_stats(struct odb_backend *object_dir, void *data)\n {\n \tstruct strbuf *buf = data;\n \n@@ -228,7 +228,7 @@ int create_diagnostics_archive(struct repository *r,\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n-\tdir_file_stats(r->objects->odb, &buf);\n+\tdir_file_stats(r->objects->backends, &buf);\n \tforeach_alt_odb(dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \ndiff --git a/http-walker.c b/http-walker.c\nindex 463f7b119ad..abb44d73067 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -543,7 +543,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \t\tret = error(\"File %s has bad hash\", hex);\n \t} else if (req->rename < 0) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\todb_loose_path(the_repository->objects->odb, &buf, &req->oid);\n+\t\todb_loose_path(the_repository->objects->backends, &buf, &req->oid);\n \t\tret = error(\"unable to write sha1 filename %s\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\ndiff --git a/http.c b/http.c\nindex 3c029cf8947..302738dd29b 100644\n--- a/http.c\n+++ b/http.c\n@@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \toidcpy(&freq->oid, oid);\n \tfreq->localfile = -1;\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->backends, &filename, oid);\n \tstrbuf_addf(&freq->tmpfile, \"%s.temp\", filename.buf);\n \n \tstrbuf_addf(&prevfile, \"%s.prev\", filename.buf);\n@@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)\n \t\tunlink_or_warn(freq->tmpfile.buf);\n \t\treturn -1;\n \t}\n-\todb_loose_path(the_repository->objects->odb, &filename, &freq->oid);\n+\todb_loose_path(the_repository->objects->backends, &filename, &freq->oid);\n \tfreq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);\n \tstrbuf_release(&filename);\n \ndiff --git a/loose.c b/loose.c\nindex bb602aaa366..fab7f99868d 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -44,7 +44,7 @@ static int insert_oid_pair(kh_oid_map_t *map, const struct object_id *key, const\n \treturn 1;\n }\n \n-static int insert_loose_map(struct object_directory *odb,\n+static int insert_loose_map(struct odb_backend *odb,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\n {\n@@ -59,7 +59,7 @@ static int insert_loose_map(struct object_directory *odb,\n \treturn inserted;\n }\n \n-static int load_one_loose_object_map(struct repository *repo, struct object_directory *dir)\n+static int load_one_loose_object_map(struct repository *repo, struct odb_backend *dir)\n {\n \tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n \tFILE *fp;\n@@ -107,15 +107,15 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \n int repo_read_loose_object_map(struct repository *repo)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_backend *backend;\n \n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n \tprepare_alt_odb(repo);\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tif (load_one_loose_object_map(repo, dir) < 0) {\n+\tfor (backend = repo->objects->backends; backend; backend = backend->next) {\n+\t\tif (load_one_loose_object_map(repo, backend) < 0) {\n \t\t\treturn -1;\n \t\t}\n \t}\n@@ -124,7 +124,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \n int repo_write_loose_object_map(struct repository *repo)\n {\n-\tkh_oid_map_t *map = repo->objects->odb->loose_map->to_compat;\n+\tkh_oid_map_t *map = repo->objects->backends->loose_map->to_compat;\n \tstruct lock_file lock;\n \tint fd;\n \tkhiter_t iter;\n@@ -212,7 +212,7 @@ int repo_add_loose_object_map(struct repository *repo, const struct object_id *o\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tinserted = insert_loose_map(repo->objects->odb, oid, compat_oid);\n+\tinserted = insert_loose_map(repo->objects->backends, oid, compat_oid);\n \tif (inserted)\n \t\treturn write_one_object(repo, oid, compat_oid);\n \treturn 0;\n@@ -223,12 +223,12 @@ int repo_loose_object_map_oid(struct repository *repo,\n \t\t\t      const struct git_hash_algo *to,\n \t\t\t      struct object_id *dest)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_backend *backend;\n \tkh_oid_map_t *map;\n \tkhiter_t pos;\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tstruct loose_object_map *loose_map = dir->loose_map;\n+\tfor (backend = repo->objects->backends; backend; backend = backend->next) {\n+\t\tstruct loose_object_map *loose_map = backend->loose_map;\n \t\tif (!loose_map)\n \t\t\tcontinue;\n \t\tmap = (to == repo->compat_hash_algo) ?\ndiff --git a/midx.c b/midx.c\nindex 3d0015f7828..767217678eb 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -824,7 +824,7 @@ void clear_midx_file(struct repository *r)\n {\n \tstruct strbuf midx = STRBUF_INIT;\n \n-\tget_midx_filename(r->hash_algo, &midx, r->objects->odb->path);\n+\tget_midx_filename(r->hash_algo, &midx, r->objects->backends->path);\n \n \tif (r->objects && r->objects->multi_pack_index) {\n \t\tclose_midx(r->objects->multi_pack_index);\n@@ -834,8 +834,8 @@ void clear_midx_file(struct repository *r)\n \tif (remove_path(midx.buf))\n \t\tdie(_(\"failed to clear multi-pack-index at %s\"), midx.buf);\n \n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_BITMAP, NULL);\n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_REV, NULL);\n+\tclear_midx_files_ext(r->objects->backends->path, MIDX_EXT_BITMAP, NULL);\n+\tclear_midx_files_ext(r->objects->backends->path, MIDX_EXT_REV, NULL);\n \n \tstrbuf_release(&midx);\n }\ndiff --git a/object-file.c b/object-file.c\nindex dc56a4766df..4940103ac6d 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -55,7 +55,7 @@ static void fill_loose_path(struct strbuf *buf, const struct object_id *oid)\n \t}\n }\n \n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_backend *odb,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid)\n {\n@@ -88,7 +88,7 @@ int check_and_freshen_file(const char *fn, int freshen)\n \treturn 1;\n }\n \n-static int check_and_freshen_odb(struct object_directory *odb,\n+static int check_and_freshen_odb(struct odb_backend *odb,\n \t\t\t\t const struct object_id *oid,\n \t\t\t\t int freshen)\n {\n@@ -99,16 +99,16 @@ static int check_and_freshen_odb(struct object_directory *odb,\n \n static int check_and_freshen_local(const struct object_id *oid, int freshen)\n {\n-\treturn check_and_freshen_odb(the_repository->objects->odb, oid, freshen);\n+\treturn check_and_freshen_odb(the_repository->objects->backends, oid, freshen);\n }\n \n static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb->next; odb; odb = odb->next) {\n-\t\tif (check_and_freshen_odb(odb, oid, freshen))\n+\tfor (backend = the_repository->objects->backends->next; backend; backend = backend->next) {\n+\t\tif (check_and_freshen_odb(backend, oid, freshen))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -208,12 +208,12 @@ int stream_object_signature(struct repository *r, const struct object_id *oid)\n static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \t\t\t     struct stat *st, const char **path)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (backend = r->objects->backends; backend; backend = backend->next) {\n+\t\t*path = odb_loose_path(backend, &buf, oid);\n \t\tif (!lstat(*path, st))\n \t\t\treturn 0;\n \t}\n@@ -229,13 +229,13 @@ static int open_loose_object(struct repository *r,\n \t\t\t     const struct object_id *oid, const char **path)\n {\n \tint fd;\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (backend = r->objects->backends; backend; backend = backend->next) {\n+\t\t*path = odb_loose_path(backend, &buf, oid);\n \t\tfd = git_open(*path);\n \t\tif (fd >= 0)\n \t\t\treturn fd;\n@@ -250,11 +250,11 @@ static int open_loose_object(struct repository *r,\n static int quick_has_loose(struct repository *r,\n \t\t\t   const struct object_id *oid)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tif (oidtree_contains(odb_loose_cache(odb, oid), oid))\n+\tfor (backend = r->objects->backends; backend; backend = backend->next) {\n+\t\tif (oidtree_contains(odb_loose_cache(backend, oid), oid))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -750,7 +750,7 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,\n /* Finalize a file on disk, and close it. */\n static void close_loose_object(int fd, const char *filename)\n {\n-\tif (the_repository->objects->odb->will_destroy)\n+\tif (the_repository->objects->backends->will_destroy)\n \t\tgoto out;\n \n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n@@ -932,7 +932,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,\n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n \t\tprepare_loose_object_bulk_checkin();\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->backends, &filename, oid);\n \n \tfd = start_loose_object_common(&tmp_file, filename.buf, flags,\n \t\t\t\t       &stream, compressed, sizeof(compressed),\n@@ -1079,7 +1079,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,\n \t\tgoto cleanup;\n \t}\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->backends, &filename, oid);\n \n \t/* We finally know the object path, and create the missing dir. */\n \tdirlen = directory_size(filename.buf);\n@@ -1540,11 +1540,11 @@ int for_each_loose_file_in_objdir(const char *path,\n int for_each_loose_object(each_loose_object_fn cb, void *data,\n \t\t\t  enum for_each_object_flags flags)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n-\t\tint r = for_each_loose_file_in_objdir(odb->path, cb, NULL,\n+\tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n+\t\tint r = for_each_loose_file_in_objdir(backend->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\n \t\tif (r)\n \t\t\treturn r;\n@@ -1564,7 +1564,7 @@ static int append_loose_object(const struct object_id *oid,\n \treturn 0;\n }\n \n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n+struct oidtree *odb_loose_cache(struct odb_backend *odb,\n \t\t\t\t  const struct object_id *oid)\n {\n \tint subdir_nr = oid->hash[0];\n@@ -1595,7 +1595,7 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,\n \treturn odb->loose_objects_cache;\n }\n \n-void odb_clear_loose_cache(struct object_directory *odb)\n+void odb_clear_loose_cache(struct odb_backend *odb)\n {\n \toidtree_clear(odb->loose_objects_cache);\n \tFREE_AND_NULL(odb->loose_objects_cache);\ndiff --git a/object-file.h b/object-file.h\nindex a85b2e5b494..630a8ef1cbd 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -24,23 +24,23 @@ enum {\n int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n \n-struct object_directory;\n+struct odb_backend;\n \n /*\n  * Populate and return the loose object cache array corresponding to the\n  * given object ID.\n  */\n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n+struct oidtree *odb_loose_cache(struct odb_backend *odb,\n \t\t\t\tconst struct object_id *oid);\n \n /* Empty the loose object cache for the specified object directory. */\n-void odb_clear_loose_cache(struct object_directory *odb);\n+void odb_clear_loose_cache(struct odb_backend *odb);\n \n /*\n  * Put in `buf` the name of the file in the local object database that\n  * would be used to store a loose object with the specified oid.\n  */\n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_backend *odb,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid);\n \ndiff --git a/object-name.c b/object-name.c\nindex 9288b2dd245..b80791a9018 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -112,10 +112,10 @@ static enum cb_next match_prefix(const struct object_id *oid, void *arg)\n \n static void find_short_object_filename(struct disambiguate_state *ds)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \n-\tfor (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next)\n-\t\toidtree_each(odb_loose_cache(odb, &ds->bin_pfx),\n+\tfor (backend = ds->repo->objects->backends; backend && !ds->ambiguous; backend = backend->next)\n+\t\toidtree_each(odb_loose_cache(backend, &ds->bin_pfx),\n \t\t\t\t&ds->bin_pfx, ds->len, match_prefix, ds);\n }\n \ndiff --git a/object-store.c b/object-store.c\nindex 1effcb12273..1c57c7b1a32 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -27,7 +27,7 @@\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n-\tstruct object_directory *, 1, fspathhash, fspatheq)\n+\tstruct odb_backend *, 1, fspathhash, fspatheq)\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n@@ -104,18 +104,18 @@ static int alt_odb_usable(struct object_database *o,\n \t * Prevent the common mistake of listing the same\n \t * thing twice, or object directory itself.\n \t */\n-\tif (!o->odb_by_path) {\n+\tif (!o->backend_by_path) {\n \t\tkhiter_t p;\n \n-\t\to->odb_by_path = kh_init_odb_path_map();\n-\t\tassert(!o->odb->next);\n-\t\tp = kh_put_odb_path_map(o->odb_by_path, o->odb->path, &r);\n+\t\to->backend_by_path = kh_init_odb_path_map();\n+\t\tassert(!o->backends->next);\n+\t\tp = kh_put_odb_path_map(o->backend_by_path, o->backends->path, &r);\n \t\tassert(r == 1); /* never used */\n-\t\tkh_value(o->odb_by_path, p) = o->odb;\n+\t\tkh_value(o->backend_by_path, p) = o->backends;\n \t}\n \tif (fspatheq(path->buf, normalized_objdir))\n \t\treturn 0;\n-\t*pos = kh_put_odb_path_map(o->odb_by_path, path->buf, &r);\n+\t*pos = kh_put_odb_path_map(o->backend_by_path, path->buf, &r);\n \t/* r: 0 = exists, 1 = never used, 2 = deleted */\n \treturn r == 0 ? 0 : 1;\n }\n@@ -124,7 +124,7 @@ static int alt_odb_usable(struct object_database *o,\n  * Prepare alternate object database registry.\n  *\n  * The variable alt_odb_list points at the list of struct\n- * object_directory.  The elements on this list come from\n+ * odb_backend.  The elements on this list come from\n  * non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT\n  * environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates,\n  * whose contents is similar to that environment variable but can be\n@@ -141,7 +141,7 @@ static void read_info_alternates(struct repository *r,\n static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tconst char *relative_base, int depth, const char *normalized_objdir)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_backend *backend;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n \tstruct strbuf tmp = STRBUF_INIT;\n \tkhiter_t pos;\n@@ -170,19 +170,19 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n-\tCALLOC_ARRAY(ent, 1);\n-\t/* pathbuf.buf is already in r->objects->odb_by_path */\n-\tent->path = strbuf_detach(&pathbuf, NULL);\n+\tCALLOC_ARRAY(backend, 1);\n+\t/* pathbuf.buf is already in r->objects->backend_by_path */\n+\tbackend->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->odb_tail = ent;\n-\tr->objects->odb_tail = &(ent->next);\n-\tent->next = NULL;\n-\tassert(r->objects->odb_by_path);\n-\tkh_value(r->objects->odb_by_path, pos) = ent;\n+\t*r->objects->backends_tail = backend;\n+\tr->objects->backends_tail = &(backend->next);\n+\tbackend->next = NULL;\n+\tassert(r->objects->backend_by_path);\n+\tkh_value(r->objects->backend_by_path, pos) = backend;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, ent->path, depth + 1);\n+\tread_info_alternates(r, backend->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -234,7 +234,7 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->odb->path, 1);\n+\tstrbuf_realpath(&objdirbuf, r->objects->backends->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n@@ -321,9 +321,9 @@ void add_to_alternates_memory(const char *reference)\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy)\n {\n-\tstruct object_directory *new_odb;\n+\tstruct odb_backend *backend;\n \n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n@@ -335,21 +335,21 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n-\tnew_odb = xcalloc(1, sizeof(*new_odb));\n-\tnew_odb->path = xstrdup(dir);\n+\tbackend = xcalloc(1, sizeof(*backend));\n+\tbackend->path = xstrdup(dir);\n \n \t/*\n \t * Disable ref updates while a temporary odb is active, since\n \t * the objects in the database may roll back.\n \t */\n-\tnew_odb->disable_ref_updates = 1;\n-\tnew_odb->will_destroy = will_destroy;\n-\tnew_odb->next = the_repository->objects->odb;\n-\tthe_repository->objects->odb = new_odb;\n-\treturn new_odb->next;\n+\tbackend->disable_ref_updates = 1;\n+\tbackend->will_destroy = will_destroy;\n+\tbackend->next = the_repository->objects->backends;\n+\tthe_repository->objects->backends = backend;\n+\treturn backend->next;\n }\n \n-static void free_object_directory(struct object_directory *odb)\n+static void free_object_directory(struct odb_backend *odb)\n {\n \tfree(odb->path);\n \todb_clear_loose_cache(odb);\n@@ -357,9 +357,9 @@ static void free_object_directory(struct object_directory *odb)\n \tfree(odb);\n }\n \n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path)\n+void restore_primary_odb(struct odb_backend *restore_odb, const char *old_path)\n {\n-\tstruct object_directory *cur_odb = the_repository->objects->odb;\n+\tstruct odb_backend *cur_odb = the_repository->objects->backends;\n \n \tif (strcmp(old_path, cur_odb->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n@@ -368,7 +368,7 @@ void restore_primary_odb(struct object_directory *restore_odb, const char *old_p\n \tif (cur_odb->next != restore_odb)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->odb = restore_odb;\n+\tthe_repository->objects->backends = restore_odb;\n \tfree_object_directory(cur_odb);\n }\n \n@@ -442,14 +442,14 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_backend *find_odb(struct repository *r, const char *obj_dir)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *odb;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n+\tfor (odb = r->objects->backends; odb; odb = odb->next) {\n \t\tstrbuf_realpath(&odb_path_real, odb->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\n@@ -527,7 +527,7 @@ struct alternate_refs_data {\n \tvoid *data;\n };\n \n-static int refs_from_alternate_cb(struct object_directory *e,\n+static int refs_from_alternate_cb(struct odb_backend *e,\n \t\t\t\t  void *data)\n {\n \tstruct strbuf path = STRBUF_INIT;\n@@ -563,12 +563,12 @@ void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n \n int foreach_alt_odb(alt_odb_fn fn, void *cb)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_backend *backend;\n \tint r = 0;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (ent = the_repository->objects->odb->next; ent; ent = ent->next) {\n-\t\tr = fn(ent, cb);\n+\tfor (backend = the_repository->objects->backends->next; backend; backend = backend->next) {\n+\t\tr = fn(backend, cb);\n \t\tif (r)\n \t\t\tbreak;\n \t}\n@@ -582,14 +582,14 @@ void prepare_alt_odb(struct repository *r)\n \n \tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->odb->path, 0);\n+\tread_info_alternates(r, r->objects->backends->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n int has_alt_odb(struct repository *r)\n {\n \tprepare_alt_odb(r);\n-\treturn !!r->objects->odb->next;\n+\treturn !!r->objects->backends->next;\n }\n \n int obj_read_use_lock = 0;\n@@ -959,7 +959,7 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct object_database *odb_new(void)\n+struct object_database *odb_new(struct repository *repo)\n {\n \tstruct object_database *o = xmalloc(sizeof(*o));\n \n@@ -972,15 +972,15 @@ struct object_database *odb_new(void)\n \n static void free_object_directories(struct object_database *o)\n {\n-\twhile (o->odb) {\n-\t\tstruct object_directory *next;\n+\twhile (o->backends) {\n+\t\tstruct odb_backend *next;\n \n-\t\tnext = o->odb->next;\n-\t\tfree_object_directory(o->odb);\n-\t\to->odb = next;\n+\t\tnext = o->backends->next;\n+\t\tfree_object_directory(o->backends);\n+\t\to->backends = next;\n \t}\n-\tkh_destroy_odb_path_map(o->odb_by_path);\n-\to->odb_by_path = NULL;\n+\tkh_destroy_odb_path_map(o->backend_by_path);\n+\to->backend_by_path = NULL;\n }\n \n void odb_clear(struct object_database *o)\n@@ -996,7 +996,7 @@ void odb_clear(struct object_database *o)\n \to->commit_graph_attempted = 0;\n \n \tfree_object_directories(o);\n-\to->odb_tail = NULL;\n+\to->backends_tail = NULL;\n \to->loaded_alternates = 0;\n \n \tfor (size_t i = 0; i < o->cached_object_nr; i++)\ndiff --git a/object-store.h b/object-store.h\nindex 34b8efbbb83..94b678eb63c 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -12,8 +12,9 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n-struct object_directory {\n-\tstruct object_directory *next;\n+/* The backend used to access objects in a specific object directory. */\n+struct odb_backend {\n+\tstruct odb_backend *next;\n \n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n@@ -52,8 +53,8 @@ struct object_directory {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct object_directory *find_odb(struct repository *r, const char *obj_dir);\n-typedef int alt_odb_fn(struct object_directory *, void *);\n+struct odb_backend *find_odb(struct repository *r, const char *obj_dir);\n+typedef int alt_odb_fn(struct odb_backend *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n@@ -75,12 +76,12 @@ void add_to_alternates_memory(const char *dir);\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n  */\n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy);\n+struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy);\n \n /*\n  * Restore a previous ODB replaced by set_temporary_main_odb.\n  */\n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);\n+void restore_primary_odb(struct odb_backend *restore_odb, const char *old_path);\n \n struct packed_git;\n struct multi_pack_index;\n@@ -97,16 +98,16 @@ struct object_database {\n \t * cannot be NULL after initialization). Subsequent directories are\n \t * alternates.\n \t */\n-\tstruct object_directory *odb;\n-\tstruct object_directory **odb_tail;\n-\tstruct kh_odb_path_map *odb_by_path;\n+\tstruct odb_backend *backends;\n+\tstruct odb_backend **backends_tail;\n+\tstruct kh_odb_path_map *backend_by_path;\n \n \tint loaded_alternates;\n \n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"odb\" list when prepare_alt_odb() is run.\n+\t * populate the \"backends\" list when prepare_alt_odb() is run.\n \t */\n \tchar *alternate_db;\n \n@@ -173,7 +174,7 @@ struct object_database {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct object_database *odb_new(void);\n+struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n /*\ndiff --git a/packfile.c b/packfile.c\nindex 8f51665266d..69096849654 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1018,16 +1018,16 @@ static void prepare_packed_git_mru(struct repository *r)\n \n static void prepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tint local = (odb == r->objects->odb);\n-\t\tprepare_multi_pack_index_one(r, odb->path, local);\n-\t\tprepare_packed_git_one(r, odb->path, local);\n+\tfor (backend = r->objects->backends; backend; backend = backend->next) {\n+\t\tint local = (backend == r->objects->backends);\n+\t\tprepare_multi_pack_index_one(r, backend->path, local);\n+\t\tprepare_packed_git_one(r, backend->path, local);\n \t}\n \trearrange_packed_git(r);\n \n@@ -1037,7 +1037,7 @@ static void prepare_packed_git(struct repository *r)\n \n void reprepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \n \tobj_read_lock();\n \n@@ -1050,8 +1050,8 @@ void reprepare_packed_git(struct repository *r)\n \tr->objects->loaded_alternates = 0;\n \tprepare_alt_odb(r);\n \n-\tfor (odb = r->objects->odb; odb; odb = odb->next)\n-\t\todb_clear_loose_cache(odb);\n+\tfor (backend = r->objects->backends; backend; backend = backend->next)\n+\t\todb_clear_loose_cache(backend);\n \n \tr->objects->approximate_object_count_valid = 0;\n \tr->objects->packed_git_initialized = 0;\ndiff --git a/path.c b/path.c\nindex 3b598b2847f..04a9ef5a1b1 100644\n--- a/path.c\n+++ b/path.c\n@@ -397,7 +397,7 @@ static void adjust_git_path(struct repository *repo,\n \t\tstrbuf_splice(buf, 0, buf->len,\n \t\t\t      repo->index_file, strlen(repo->index_file));\n \telse if (dir_prefix(base, \"objects\"))\n-\t\treplace_dir(buf, git_dir_len + 7, repo->objects->odb->path);\n+\t\treplace_dir(buf, git_dir_len + 7, repo->objects->backends->path);\n \telse if (repo_settings_get_hooks_path(repo) && dir_prefix(base, \"hooks\"))\n \t\treplace_dir(buf, git_dir_len + 5, repo_settings_get_hooks_path(repo));\n \telse if (repo->different_commondir)\ndiff --git a/refs.c b/refs.c\nindex dce5c49ca2b..ff2d5d6e92b 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -2477,7 +2477,7 @@ int ref_transaction_prepare(struct ref_transaction *transaction,\n \t\tbreak;\n \t}\n \n-\tif (refs->repo->objects->odb->disable_ref_updates) {\n+\tif (refs->repo->objects->backends->disable_ref_updates) {\n \t\tstrbuf_addstr(err,\n \t\t\t      _(\"ref updates forbidden inside quarantine environment\"));\n \t\treturn -1;\ndiff --git a/repository.c b/repository.c\nindex 07757e6e0c9..0ab73846de3 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = odb_new();\n+\trepo->objects = odb_new(repo);\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -107,9 +107,9 @@ const char *repo_get_common_dir(struct repository *repo)\n \n const char *repo_get_object_directory(struct repository *repo)\n {\n-\tif (!repo->objects->odb)\n+\tif (!repo->objects->backends)\n \t\tBUG(\"repository hasn't been set up\");\n-\treturn repo->objects->odb->path;\n+\treturn repo->objects->backends->path;\n }\n \n const char *repo_get_index_file(struct repository *repo)\n@@ -165,14 +165,15 @@ void repo_set_gitdir(struct repository *repo,\n \n \trepo_set_commondir(repo, o->commondir);\n \n-\tif (!repo->objects->odb) {\n-\t\tCALLOC_ARRAY(repo->objects->odb, 1);\n-\t\trepo->objects->odb_tail = &repo->objects->odb->next;\n+\tif (!repo->objects->backends) {\n+\t\tCALLOC_ARRAY(repo->objects->backends, 1);\n+\t\trepo->objects->backends->odb = repo->objects;\n+\t\trepo->objects->backends_tail = &repo->objects->backends->next;\n \t}\n-\texpand_base_dir(&repo->objects->odb->path, o->object_dir,\n+\texpand_base_dir(&repo->objects->backends->path, o->object_dir,\n \t\t\trepo->commondir, \"objects\");\n \n-\trepo->objects->odb->disable_ref_updates = o->disable_ref_updates;\n+\trepo->objects->backends->disable_ref_updates = o->disable_ref_updates;\n \n \tfree(repo->objects->alternate_db);\n \trepo->objects->alternate_db = xstrdup_or_null(o->alternate_db);\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 8630e27947d..c9418f51265 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,7 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->odb->path);\n+\t\t\t\tadd_submodule_odb_by_path(repo->objects->backends->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 8b413b644be..45b0043eb93 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -73,15 +73,15 @@ static void dump_graph_bloom_filters(struct commit_graph *graph)\n int cmd__read_graph(int argc, const char **argv)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb;\n+\tstruct odb_backend *backend;\n \tint ret = 0;\n \n \tsetup_git_directory();\n-\todb = the_repository->objects->odb;\n+\tbackend = the_repository->objects->backends;\n \n \tprepare_repo_settings(the_repository);\n \n-\tgraph = read_commit_graph_one(the_repository, odb);\n+\tgraph = read_commit_graph_one(the_repository, backend);\n \tif (!graph) {\n \t\tret = 1;\n \t\tgoto done;\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex c38fbeb5e8a..cc4efb3d816 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -17,7 +17,7 @@ struct tmp_objdir {\n \tstruct repository *repo;\n \tstruct strbuf path;\n \tstruct strvec env;\n-\tstruct object_directory *prev_odb;\n+\tstruct odb_backend *prev_odb;\n \tint will_destroy;\n };\n \n@@ -277,7 +277,7 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \t\treturn 0;\n \n \tif (t->prev_odb) {\n-\t\tif (t->repo->objects->odb->will_destroy)\n+\t\tif (t->repo->objects->backends->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n \t\trestore_primary_odb(t->prev_odb, t->path.buf);\n \t\tt->prev_odb = NULL;\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517315","messageId":"20250506-pks-object-store-wo-the-repository-v1-4-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 04/17] odb: introduce parent pointers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:17Z","receivedAt":"2025-05-06T11:09:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In subsequent commits we'll get rid of our use of `the_repository` in\n\"odb.c\" in favor of explicitly passing in a `struct object_database` or\na `struct odb_backend`. In some cases though we'll need access to the\nrepository, for example to read a config value from it, but we don't\nhave a way to access the repository owning a specific object database.\n\nIntroduce parent pointers for `struct object_database` to its owning\nrepository as well as for `struct odb_backend` to its owning object\ndatabase, which will allow us to adapt those use cases.\n\nNote that this change requires us to pass through the object database to\n`link_alt_odb_entry()` so that we can set up the parent pointers for any\nalternative backends there. The callchain is adapted to pass through the\nobject database accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c | 43 +++++++++++++++++++++++++------------------\n odb.h |  6 ++++++\n 2 files changed, 31 insertions(+), 18 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex 435f532a9c4..67207ce636d 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -135,11 +135,15 @@ static int alt_odb_usable(struct object_database *o,\n  * of the object ID, an extra slash for the first level indirection, and\n  * the terminating NUL.\n  */\n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth);\n-static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n-\tconst char *relative_base, int depth, const char *normalized_objdir)\n+\n+static int link_alt_odb_entry(struct object_database *odb,\n+\t\t\t      const struct strbuf *entry,\n+\t\t\t      const char *relative_base,\n+\t\t\t      int depth,\n+\t\t\t      const char *normalized_objdir)\n {\n \tstruct odb_backend *backend;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n@@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \twhile (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')\n \t\tstrbuf_setlen(&pathbuf, pathbuf.len - 1);\n \n-\tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n+\tif (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n \tCALLOC_ARRAY(backend, 1);\n+\tbackend->odb = odb;\n \t/* pathbuf.buf is already in r->objects->backend_by_path */\n \tbackend->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->backends_tail = backend;\n-\tr->objects->backends_tail = &(backend->next);\n+\t*odb->backends_tail = backend;\n+\todb->backends_tail = &(backend->next);\n \tbackend->next = NULL;\n-\tassert(r->objects->backend_by_path);\n-\tkh_value(r->objects->backend_by_path, pos) = backend;\n+\tassert(odb->backend_by_path);\n+\tkh_value(odb->backend_by_path, pos) = backend;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, backend->path, depth + 1);\n+\tread_info_alternates(odb, backend->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -219,7 +224,7 @@ static const char *parse_alt_odb_entry(const char *string,\n \treturn end;\n }\n \n-static void link_alt_odb_entries(struct repository *r, const char *alt,\n+static void link_alt_odb_entries(struct object_database *odb, const char *alt,\n \t\t\t\t int sep, const char *relative_base, int depth)\n {\n \tstruct strbuf objdirbuf = STRBUF_INIT;\n@@ -234,20 +239,20 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->backends->path, 1);\n+\tstrbuf_realpath(&objdirbuf, odb->backends->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n \t\tif (!entry.len)\n \t\t\tcontinue;\n-\t\tlink_alt_odb_entry(r, &entry,\n+\t\tlink_alt_odb_entry(odb, &entry,\n \t\t\t\t   relative_base, depth, objdirbuf.buf);\n \t}\n \tstrbuf_release(&entry);\n \tstrbuf_release(&objdirbuf);\n }\n \n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth)\n {\n@@ -261,7 +266,7 @@ static void read_info_alternates(struct repository *r,\n \t\treturn;\n \t}\n \n-\tlink_alt_odb_entries(r, buf.buf, '\\n', relative_base, depth);\n+\tlink_alt_odb_entries(odb, buf.buf, '\\n', relative_base, depth);\n \tstrbuf_release(&buf);\n \tfree(path);\n }\n@@ -303,7 +308,7 @@ void add_to_alternates_file(const char *reference)\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n \t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository, reference,\n+\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n@@ -317,7 +322,7 @@ void add_to_alternates_memory(const char *reference)\n \t */\n \tprepare_alt_odb(the_repository);\n \n-\tlink_alt_odb_entries(the_repository, reference,\n+\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -336,6 +341,7 @@ struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * alternate\n \t */\n \tbackend = xcalloc(1, sizeof(*backend));\n+\tbackend->odb = the_repository->objects;\n \tbackend->path = xstrdup(dir);\n \n \t/*\n@@ -580,9 +586,9 @@ void prepare_alt_odb(struct repository *r)\n \tif (r->objects->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->backends->path, 0);\n+\tread_info_alternates(r->objects, r->objects->backends->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n@@ -964,6 +970,7 @@ struct object_database *odb_new(struct repository *repo)\n \tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n+\to->repo = repo;\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\ndiff --git a/odb.h b/odb.h\nindex 5774e1d615b..1617a9bac2c 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -16,6 +16,9 @@ struct repository;\n struct odb_backend {\n \tstruct odb_backend *next;\n \n+\t/* Object database that owns this backend. */\n+\tstruct object_database *odb;\n+\n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n \t * sacrificing accuracy due to races for speed. That includes\n@@ -93,6 +96,9 @@ struct cached_object_entry;\n  * configured via alternates.\n  */\n struct object_database {\n+\t/* Repository that owns this database. */\n+\tstruct repository *repo;\n+\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517317","messageId":"20250506-pks-object-store-wo-the-repository-v1-3-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:16Z","receivedAt":"2025-05-06T11:09:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In the preceding commits we have renamed the structures contained in\n\"object-store.h\" to `struct object_database` and `struct odb_backend`.\nAs such, the code files \"object-store.{c,h}\" are confusingly named now.\nRename them to \"odb.{c,h}\" accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile                                | 2 +-\n apply.c                                 | 2 +-\n archive-tar.c                           | 2 +-\n archive-zip.c                           | 2 +-\n archive.c                               | 2 +-\n attr.c                                  | 2 +-\n bisect.c                                | 2 +-\n blame.c                                 | 2 +-\n builtin/backfill.c                      | 2 +-\n builtin/blame.c                         | 2 +-\n builtin/cat-file.c                      | 2 +-\n builtin/checkout.c                      | 2 +-\n builtin/clone.c                         | 2 +-\n builtin/commit-graph.c                  | 2 +-\n builtin/commit-tree.c                   | 2 +-\n builtin/describe.c                      | 2 +-\n builtin/difftool.c                      | 2 +-\n builtin/fast-export.c                   | 2 +-\n builtin/fast-import.c                   | 2 +-\n builtin/fetch.c                         | 2 +-\n builtin/fsck.c                          | 2 +-\n builtin/grep.c                          | 2 +-\n builtin/hash-object.c                   | 2 +-\n builtin/index-pack.c                    | 2 +-\n builtin/log.c                           | 2 +-\n builtin/ls-files.c                      | 2 +-\n builtin/ls-tree.c                       | 2 +-\n builtin/merge-file.c                    | 2 +-\n builtin/merge-tree.c                    | 2 +-\n builtin/mktag.c                         | 2 +-\n builtin/mktree.c                        | 2 +-\n builtin/multi-pack-index.c              | 2 +-\n builtin/notes.c                         | 2 +-\n builtin/pack-objects.c                  | 2 +-\n builtin/pack-redundant.c                | 2 +-\n builtin/prune.c                         | 2 +-\n builtin/receive-pack.c                  | 2 +-\n builtin/remote.c                        | 2 +-\n builtin/repack.c                        | 2 +-\n builtin/replace.c                       | 2 +-\n builtin/rev-list.c                      | 2 +-\n builtin/show-ref.c                      | 2 +-\n builtin/submodule--helper.c             | 2 +-\n builtin/tag.c                           | 2 +-\n builtin/unpack-file.c                   | 2 +-\n builtin/unpack-objects.c                | 2 +-\n bulk-checkin.c                          | 2 +-\n bundle-uri.c                            | 2 +-\n bundle.c                                | 2 +-\n cache-tree.c                            | 2 +-\n combine-diff.c                          | 2 +-\n commit-graph.c                          | 2 +-\n commit-graph.h                          | 2 +-\n commit.c                                | 2 +-\n config.c                                | 2 +-\n connected.c                             | 2 +-\n contrib/coccinelle/the_repository.cocci | 2 +-\n diagnose.c                              | 2 +-\n diff.c                                  | 2 +-\n entry.c                                 | 2 +-\n fetch-pack.c                            | 2 +-\n fmt-merge-msg.c                         | 2 +-\n fsck.c                                  | 2 +-\n grep.c                                  | 2 +-\n http-backend.c                          | 2 +-\n http-push.c                             | 2 +-\n http-walker.c                           | 2 +-\n http.c                                  | 2 +-\n list-objects-filter.c                   | 2 +-\n list-objects.c                          | 2 +-\n loose.c                                 | 2 +-\n mailmap.c                               | 2 +-\n match-trees.c                           | 2 +-\n merge-blobs.c                           | 2 +-\n merge-ort.c                             | 2 +-\n meson.build                             | 2 +-\n notes-cache.c                           | 2 +-\n notes-merge.c                           | 2 +-\n notes.c                                 | 2 +-\n object-file.c                           | 2 +-\n object-file.h                           | 2 +-\n object-store.c => odb.c                 | 2 +-\n object-store.h => odb.h                 | 6 +++---\n oss-fuzz/fuzz-pack-idx.c                | 2 +-\n pack-bitmap-write.c                     | 2 +-\n pack-bitmap.c                           | 2 +-\n pack-check.c                            | 2 +-\n pack-mtimes.c                           | 2 +-\n pack-objects.h                          | 2 +-\n pack-revindex.c                         | 2 +-\n packfile.c                              | 2 +-\n packfile.h                              | 4 ++--\n path.c                                  | 2 +-\n promisor-remote.c                       | 2 +-\n protocol-caps.c                         | 2 +-\n read-cache.c                            | 2 +-\n ref-filter.c                            | 2 +-\n reflog.c                                | 2 +-\n refs.c                                  | 2 +-\n remote.c                                | 2 +-\n replace-object.c                        | 2 +-\n replace-object.h                        | 2 +-\n repository.c                            | 2 +-\n rerere.c                                | 2 +-\n revision.c                              | 2 +-\n send-pack.c                             | 2 +-\n sequencer.c                             | 2 +-\n server-info.c                           | 2 +-\n shallow.c                               | 2 +-\n streaming.c                             | 2 +-\n submodule-config.c                      | 2 +-\n submodule.c                             | 2 +-\n t/helper/test-find-pack.c               | 2 +-\n t/helper/test-pack-mtimes.c             | 2 +-\n t/helper/test-partial-clone.c           | 2 +-\n t/helper/test-read-graph.c              | 2 +-\n t/helper/test-read-midx.c               | 2 +-\n t/helper/test-ref-store.c               | 2 +-\n tag.c                                   | 2 +-\n tmp-objdir.c                            | 2 +-\n tree-walk.c                             | 2 +-\n tree.c                                  | 2 +-\n unpack-trees.c                          | 2 +-\n upload-pack.c                           | 2 +-\n walker.c                                | 2 +-\n xdiff-interface.c                       | 2 +-\n 126 files changed, 129 insertions(+), 129 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8a7f1c76543..d2d65f30907 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1083,8 +1083,8 @@ LIB_OBJS += notes.o\n LIB_OBJS += object-file-convert.o\n LIB_OBJS += object-file.o\n LIB_OBJS += object-name.o\n-LIB_OBJS += object-store.o\n LIB_OBJS += object.o\n+LIB_OBJS += odb.o\n LIB_OBJS += oid-array.o\n LIB_OBJS += oidmap.o\n LIB_OBJS += oidset.o\ndiff --git a/apply.c b/apply.c\nindex 381d2e3652f..879f04df31e 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -14,7 +14,7 @@\n #include \"abspath.h\"\n #include \"base85.h\"\n #include \"config.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"delta.h\"\n #include \"diff.h\"\n #include \"dir.h\"\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 282b48196f9..249164ea77d 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -11,7 +11,7 @@\n #include \"hex.h\"\n #include \"tar.h\"\n #include \"archive.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"streaming.h\"\n #include \"run-command.h\"\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 405da6f3d83..df8866d5bae 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -12,7 +12,7 @@\n #include \"hex.h\"\n #include \"streaming.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"userdiff.h\"\n #include \"write-or-die.h\"\ndiff --git a/archive.c b/archive.c\nindex 8309ea213e6..7fa2cc2596a 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -14,7 +14,7 @@\n #include \"pretty.h\"\n #include \"setup.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/attr.c b/attr.c\nindex 86b6109fc4e..e5680db7f65 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -22,7 +22,7 @@\n #include \"read-cache-ll.h\"\n #include \"refs.h\"\n #include \"revision.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/bisect.c b/bisect.c\nindex a327468c75b..a7939216d00 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -20,7 +20,7 @@\n #include \"commit-slab.h\"\n #include \"commit-reach.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"dir.h\"\n \ndiff --git a/blame.c b/blame.c\nindex 57daa45e899..0ceea080a80 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -3,7 +3,7 @@\n \n #include \"git-compat-util.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"cache-tree.h\"\n #include \"mergesort.h\"\n #include \"commit.h\"\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex fa82ad2f6ff..0b49baa39fa 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -13,7 +13,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"promisor-remote.h\"\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 944952e30eb..15eda60af90 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -28,7 +28,7 @@\n #include \"line-log.h\"\n #include \"progress.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"blame.h\"\n #include \"refs.h\"\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 3914a2a3f61..2fa5e3f43bd 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -24,7 +24,7 @@\n #include \"pack-bitmap.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"promisor-remote.h\"\n #include \"mailmap.h\"\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex d185982f3a6..e7dd66173dd 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -20,7 +20,7 @@\n #include \"merge-ort-wrappers.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"path.h\"\n #include \"preload-index.h\"\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 91b9cd0d164..1eafeefb48d 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -25,7 +25,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex b4cbdbb1f7b..0a184d39720 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -6,7 +6,7 @@\n #include \"hex.h\"\n #include \"parse-options.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"progress.h\"\n #include \"replace-object.h\"\n #include \"strbuf.h\"\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex ad6b2c93209..546069f8682 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -9,7 +9,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n #include \"commit.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 2d50883b729..96cb68e5e5d 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -19,7 +19,7 @@\n #include \"setup.h\"\n #include \"strvec.h\"\n #include \"run-command.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects.h\"\n #include \"commit-slab.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex a3b64ce6942..fac613e3bc3 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -30,7 +30,7 @@\n #include \"strbuf.h\"\n #include \"lockfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"entry.h\"\n #include \"setup.h\"\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 37c01d6c6fe..0505f289a94 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"object.h\"\n #include \"tag.h\"\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex b2839c5f439..52c792488e1 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -24,7 +24,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"mem-pool.h\"\n #include \"commit-reach.h\"\n #include \"khash.h\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 0b15121ff7c..851c0a9419e 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"oid-array.h\"\n #include \"commit.h\"\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 0c1df302129..895c9ca5381 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3affe523df1..7b1940be2a1 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -26,7 +26,7 @@\n #include \"submodule-config.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pager.h\"\n #include \"path.h\"\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex cd53fa3bde8..9ce0b87c30b 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -11,7 +11,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 147e9b8b479..8ce446064e8 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -21,7 +21,7 @@\n #include \"packfile.h\"\n #include \"pack-revindex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"path.h\"\ndiff --git a/builtin/log.c b/builtin/log.c\nindex b450cd3bde8..fe9cc5ebecb 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -15,7 +15,7 @@\n #include \"hex.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"color.h\"\n #include \"commit.h\"\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex be74f0a03b2..821339b07d4 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -25,7 +25,7 @@\n #include \"setup.h\"\n #include \"sparse-index.h\"\n #include \"submodule.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n \n \ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 8aafc30ca48..62b6fd58c16 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -10,7 +10,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"path.h\"\n #include \"quote.h\"\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 2b16b10d2ca..9464f275629 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -7,7 +7,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"setup.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 4aafa73c615..709ae3966a6 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -10,7 +10,7 @@\n #include \"commit-reach.h\"\n #include \"merge-ort.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 7ac11c46d53..1809b38f937 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -6,7 +6,7 @@\n #include \"strbuf.h\"\n #include \"replace-object.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"fsck.h\"\n #include \"config.h\"\n \ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 4b478034675..016b0e5b224 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -12,7 +12,7 @@\n #include \"tree.h\"\n #include \"parse-options.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct treeent {\n \tunsigned mode;\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex 87173307bf3..ca77d71d5a4 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -7,7 +7,7 @@\n #include \"midx.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex a3f433ca4c0..783d4932ca6 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -16,7 +16,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n \n #include \"pretty.h\"\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8b33edc2ff5..99b63cb0980 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -32,7 +32,7 @@\n #include \"list.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"dir.h\"\n #include \"midx.h\"\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 5d1fc781761..3134cb8c689 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -13,7 +13,7 @@\n #include \"hex.h\"\n \n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n \n #define BLKSIZE 512\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex e930caa0c0a..7bbfb14c2be 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -17,7 +17,7 @@\n #include \"replace-object.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"shallow.h\"\n \n static const char * const prune_usage[] = {\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex c92e57ba188..cb5fd55a8e4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -33,7 +33,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"protocol.h\"\n #include \"commit-reach.h\"\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 0d6755bcb71..ac5b8d2a1a6 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -14,7 +14,7 @@\n #include \"rebase.h\"\n #include \"refs.h\"\n #include \"refspec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strvec.h\"\n #include \"commit-reach.h\"\n #include \"progress.h\"\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 59214dbdfdf..16782320058 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -17,7 +17,7 @@\n #include \"midx.h\"\n #include \"packfile.h\"\n #include \"prune-packed.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"shallow.h\"\n #include \"pack.h\"\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 48c7c6a2d56..11c7e2d4c0c 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"tag.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex c4cd4ed5c81..ee25d61c802 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -14,7 +14,7 @@\n #include \"object.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"parse-options.h\"\n #include \"log-tree.h\"\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 623a52a45f8..90ec1de78f9 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"refs/refs-internal.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"string-list.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 13fb4ecfaac..7f672e4808c 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -28,7 +28,7 @@\n #include \"diff.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"advice.h\"\n #include \"branch.h\"\n #include \"list-objects-filter-options.h\"\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 4742b27d16e..cf2ea4b4993 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -19,7 +19,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"tag.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex e33acfc4ee4..b92fd4710a9 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static char *create_temp_file(struct object_id *oid)\n {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex e905d5f4e19..7bf395eec84 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -9,7 +9,7 @@\n #include \"git-zlib.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"delta.h\"\n #include \"pack.h\"\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 678e2ecc2c2..55406a539e7 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -17,7 +17,7 @@\n #include \"tmp-objdir.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int odb_transaction_nesting;\n \ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 96d2ba726d9..993ac62c271 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -14,7 +14,7 @@\n #include \"fetch-pack.h\"\n #include \"remote.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct {\n \tenum bundle_list_heuristic heuristic;\ndiff --git a/bundle.c b/bundle.c\nindex dd4c082f8e7..90c8ec4166a 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -7,7 +7,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/cache-tree.c b/cache-tree.c\nindex fa3858e2829..9786b32b3a1 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -10,7 +10,7 @@\n #include \"cache-tree.h\"\n #include \"bulk-checkin.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\ndiff --git a/combine-diff.c b/combine-diff.c\nindex dfae9f7995d..cf23a753407 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -2,7 +2,7 @@\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"convert.h\"\n #include \"diff.h\"\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 7a85b73cd99..d58d1bf39ed 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -13,7 +13,7 @@\n #include \"refs.h\"\n #include \"hash-lookup.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"alloc.h\"\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 437cb48081d..eaec7d13f3a 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -1,7 +1,7 @@\n #ifndef COMMIT_GRAPH_H\n #define COMMIT_GRAPH_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n #define GIT_TEST_COMMIT_GRAPH \"GIT_TEST_COMMIT_GRAPH\"\ndiff --git a/commit.c b/commit.c\nindex e915b2b9a12..1d30f8ce15a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -9,7 +9,7 @@\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/config.c b/config.c\nindex b18b5617fcd..883dd066827 100644\n--- a/config.c\n+++ b/config.c\n@@ -31,7 +31,7 @@\n #include \"hashmap.h\"\n #include \"string-list.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"path.h\"\n #include \"utf8.h\"\ndiff --git a/connected.c b/connected.c\nindex 4415388beba..18c13245d8e 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"run-command.h\"\n #include \"sigchain.h\"\n #include \"connected.h\"\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 765ad689678..ea7fe1c8db7 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -77,7 +77,7 @@\n |\n - diff_setup\n + repo_diff_setup\n-// object-store.h\n+// odb.h\n |\n - read_object_file\n + repo_read_object_file\ndiff --git a/diagnose.c b/diagnose.c\nindex 3016ad223d2..6ec07761a0f 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -7,7 +7,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"strvec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"repository.h\"\ndiff --git a/diff.c b/diff.c\nindex 63e9ecb30c6..193da8bee68 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -23,7 +23,7 @@\n #include \"color.h\"\n #include \"run-command.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"userdiff.h\"\n #include \"submodule.h\"\n #include \"hashmap.h\"\ndiff --git a/entry.c b/entry.c\nindex f36ec5ad242..75d55038d7c 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -1,7 +1,7 @@\n #define USE_THE_REPOSITORY_VARIABLE\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex fa4231fee74..cf157f5d7e5 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -24,7 +24,7 @@\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"connected.h\"\n #include \"fetch-negotiator.h\"\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 501b5acdd44..1a8c972adf3 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -6,7 +6,7 @@\n #include \"environment.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"diff.h\"\n #include \"diff-merges.h\"\n #include \"hex.h\"\ndiff --git a/fsck.c b/fsck.c\nindex 8dc8472ceb3..e69baab3af7 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"dir.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"object.h\"\ndiff --git a/grep.c b/grep.c\nindex f8d535182c3..dc77e6c4631 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"grep.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\ndiff --git a/http-backend.c b/http-backend.c\nindex 0c575aa88aa..ad8c4037493 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -18,7 +18,7 @@\n #include \"url.h\"\n #include \"strvec.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"protocol.h\"\n #include \"date.h\"\n #include \"write-or-die.h\"\ndiff --git a/http-push.c b/http-push.c\nindex f9e67cabd4b..d1b1bb23711 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -20,7 +20,7 @@\n #include \"url.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n \n #ifdef EXPAT_NEEDS_XMLPARSE_H\ndiff --git a/http-walker.c b/http-walker.c\nindex abb44d73067..12767e65a79 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -10,7 +10,7 @@\n #include \"transport.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct alt_base {\n \tchar *base;\ndiff --git a/http.c b/http.c\nindex 302738dd29b..a33914dc02d 100644\n--- a/http.c\n+++ b/http.c\n@@ -19,7 +19,7 @@\n #include \"packfile.h\"\n #include \"string-list.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tempfile.h\"\n \n static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 7765761b3c6..cb9c16734b1 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -12,7 +12,7 @@\n #include \"oidmap.h\"\n #include \"oidset.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n /* Remember to update object flag allocation in object.h */\n /*\ndiff --git a/list-objects.c b/list-objects.c\nindex 597114281f6..c50b9578584 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -14,7 +14,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace.h\"\n #include \"environment.h\"\n \ndiff --git a/loose.c b/loose.c\nindex fab7f99868d..e52397bb3e5 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"hash.h\"\n #include \"path.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"wrapper.h\"\ndiff --git a/mailmap.c b/mailmap.c\nindex 9e2642a043b..b18e74c2110 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -6,7 +6,7 @@\n #include \"string-list.h\"\n #include \"mailmap.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n char *git_mailmap_file;\ndiff --git a/match-trees.c b/match-trees.c\nindex 72922d5d64e..4704f95c340 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -7,7 +7,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n static int score_missing(unsigned mode)\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 53f36dbc175..ba8a3fdfd82 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -4,7 +4,7 @@\n #include \"merge-ll.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 77310a4a52c..f86c84635f0 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -39,7 +39,7 @@\n #include \"mem-pool.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/meson.build b/meson.build\nindex 270ce933d0f..a3c917b1345 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -394,8 +394,8 @@ libgit_sources = [\n   'object-file-convert.c',\n   'object-file.c',\n   'object-name.c',\n-  'object-store.c',\n   'object.c',\n+  'odb.c',\n   'oid-array.c',\n   'oidmap.c',\n   'oidset.c',\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 150241b15e0..344f67762b8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"notes-cache.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"repository.h\"\n #include \"commit.h\"\ndiff --git a/notes-merge.c b/notes-merge.c\nindex dae8e6a281a..de6a52e2e7f 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -8,7 +8,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"diff.h\"\ndiff --git a/notes.c b/notes.c\nindex 0a128f1de98..fc000e501d2 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -8,7 +8,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"strbuf.h\"\n #include \"tree-walk.h\"\ndiff --git a/object-file.c b/object-file.c\nindex 4940103ac6d..cc81729ae25 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -21,7 +21,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidtree.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/object-file.h b/object-file.h\nindex 630a8ef1cbd..aff33f61bb4 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -3,7 +3,7 @@\n \n #include \"git-zlib.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct index_state;\n \ndiff --git a/object-store.c b/odb.c\nsimilarity index 99%\nrename from object-store.c\nrename to odb.c\nindex 1c57c7b1a32..435f532a9c4 100644\n--- a/object-store.c\n+++ b/odb.c\n@@ -13,7 +13,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/object-store.h b/odb.h\nsimilarity index 99%\nrename from object-store.h\nrename to odb.h\nindex 94b678eb63c..5774e1d615b 100644\n--- a/object-store.h\n+++ b/odb.h\n@@ -1,5 +1,5 @@\n-#ifndef OBJECT_STORE_H\n-#define OBJECT_STORE_H\n+#ifndef ODB_H\n+#define ODB_H\n \n #include \"hashmap.h\"\n #include \"object.h\"\n@@ -343,4 +343,4 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n-#endif /* OBJECT_STORE_H */\n+#endif /* ODB_H */\ndiff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c\nindex 609a343ee3e..d2a92f34d98 100644\n--- a/oss-fuzz/fuzz-pack-idx.c\n+++ b/oss-fuzz/fuzz-pack-idx.c\n@@ -1,5 +1,5 @@\n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n \n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 7f400ee0121..37648b57125 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -4,7 +4,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex b9f1d866046..467a3e91035 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"repository.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects-filter-options.h\"\n #include \"midx.h\"\n #include \"config.h\"\ndiff --git a/pack-check.c b/pack-check.c\nindex 874897d6cba..67cb2cf72f2 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -8,7 +8,7 @@\n #include \"progress.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct idx_entry {\n \toff_t                offset;\ndiff --git a/pack-mtimes.c b/pack-mtimes.c\nindex 20900ca88d3..8e1f2dec0ef 100644\n--- a/pack-mtimes.c\n+++ b/pack-mtimes.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-mtimes.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 475a2d67ce3..1ac8644201b 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -1,7 +1,7 @@\n #ifndef PACK_OBJECTS_H\n #define PACK_OBJECTS_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"thread-utils.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex ffcde48870d..0cc422a1e67 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-revindex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\ndiff --git a/packfile.c b/packfile.c\nindex 69096849654..0f3d60721a9 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -19,7 +19,7 @@\n #include \"tree-walk.h\"\n #include \"tree.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"midx.h\"\n #include \"commit-graph.h\"\n #include \"pack-revindex.h\"\ndiff --git a/packfile.h b/packfile.h\nindex 826eb7f475f..53c3b7d3b43 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -3,10 +3,10 @@\n \n #include \"list.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n-/* in object-store.h */\n+/* in odb.h */\n struct object_info;\n \n struct packed_git {\ndiff --git a/path.c b/path.c\nindex 04a9ef5a1b1..8b4d7d8aba2 100644\n--- a/path.c\n+++ b/path.c\n@@ -15,7 +15,7 @@\n #include \"submodule-config.h\"\n #include \"path.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"lockfile.h\"\n #include \"exec-cmd.h\"\n \ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 9d058586dfa..2baa286bfd0 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"config.h\"\n #include \"trace2.h\"\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 9b8db37a210..3022f69a1bd 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -6,7 +6,7 @@\n #include \"hash.h\"\n #include \"hex.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"string-list.h\"\n #include \"strbuf.h\"\ndiff --git a/read-cache.c b/read-cache.c\nindex 73f83a7e7a1..dce1056ec7c 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -20,7 +20,7 @@\n #include \"refs.h\"\n #include \"dir.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 7a274633cfc..4ce45440ad1 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"wildmatch.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"repo-settings.h\"\n #include \"repository.h\"\ndiff --git a/reflog.c b/reflog.c\nindex 15d81ebea97..4f8a3b717cd 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -5,7 +5,7 @@\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"parse-options.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"reflog.h\"\n #include \"refs.h\"\n #include \"revision.h\"\ndiff --git a/refs.c b/refs.c\nindex ff2d5d6e92b..d91063bab09 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"hook.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"path.h\"\n #include \"submodule.h\"\ndiff --git a/remote.c b/remote.c\nindex 4099183cacd..17a842f5684 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/replace-object.c b/replace-object.c\nindex 7b8a09b5cb4..65b3c108629 100644\n--- a/replace-object.c\n+++ b/replace-object.c\n@@ -2,7 +2,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"oidmap.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"refs.h\"\n #include \"repository.h\"\ndiff --git a/replace-object.h b/replace-object.h\nindex ba478eb30c4..b1b059ed2fe 100644\n--- a/replace-object.h\n+++ b/replace-object.h\n@@ -3,7 +3,7 @@\n \n #include \"oidmap.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct replace_object {\n \tstruct oidmap_entry original;\ndiff --git a/repository.c b/repository.c\nindex 0ab73846de3..bcf31ad8e42 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"object.h\"\n #include \"lockfile.h\"\ndiff --git a/rerere.c b/rerere.c\nindex 3cd37c5f0ae..951e4bf8b41 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -18,7 +18,7 @@\n #include \"path.h\"\n #include \"pathspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strmap.h\"\n \n #define RESOLVED 0\ndiff --git a/revision.c b/revision.c\nindex 2c36a9c179e..cdefe7d6e48 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -8,7 +8,7 @@\n #include \"hex.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"tag.h\"\n #include \"blob.h\"\ndiff --git a/send-pack.c b/send-pack.c\nindex 86592ce526d..abca2dd38a7 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"run-command.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex b5c4043757e..35f4e68d59f 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -13,7 +13,7 @@\n #include \"dir.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"pager.h\"\n #include \"commit.h\"\ndiff --git a/server-info.c b/server-info.c\nindex d6cd20a39d7..9bb30d9ab71 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -11,7 +11,7 @@\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"server-info.h\"\n #include \"strbuf.h\"\n #include \"tempfile.h\"\ndiff --git a/shallow.c b/shallow.c\nindex faeeeb45f98..d379756e39a 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -5,7 +5,7 @@\n #include \"repository.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"pkt-line.h\"\ndiff --git a/streaming.c b/streaming.c\nindex 127d6b5d6ac..29cc877f22a 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -10,7 +10,7 @@\n #include \"streaming.h\"\n #include \"repository.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"packfile.h\"\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex c9418f51265..4abef906f26 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -13,7 +13,7 @@\n #include \"submodule.h\"\n #include \"strbuf.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/submodule.c b/submodule.c\nindex ead3fb5dadc..9b1018877df 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -27,7 +27,7 @@\n #include \"parse-options.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c\nindex 76c2f4eba85..611a13a3261 100644\n--- a/t/helper/test-find-pack.c\n+++ b/t/helper/test-find-pack.c\n@@ -2,7 +2,7 @@\n \n #include \"test-tool.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c\nindex fdf1b13437b..d51aaa3dc40 100644\n--- a/t/helper/test-pack-mtimes.c\n+++ b/t/helper/test-pack-mtimes.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"strbuf.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pack-mtimes.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex 34f1aee5581..dba227259a2 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -1,7 +1,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n /*\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 45b0043eb93..8a6af828153 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"commit-graph.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"bloom.h\"\n #include \"setup.h\"\n \ndiff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c\nindex ac81390899a..da2aa036b57 100644\n--- a/t/helper/test-read-midx.c\n+++ b/t/helper/test-read-midx.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"midx.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"packfile.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 4cfc7c90b59..2920ca59d72 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -5,7 +5,7 @@\n #include \"refs.h\"\n #include \"setup.h\"\n #include \"worktree.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"strbuf.h\"\ndiff --git a/tag.c b/tag.c\nindex 05be39067cf..5f6868bf7b1 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -5,7 +5,7 @@\n #include \"environment.h\"\n #include \"tag.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"blob.h\"\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex cc4efb3d816..f9e8277fd7c 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -10,7 +10,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"quote.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n struct tmp_objdir {\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 90655d52378..34b0fff4873 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -6,7 +6,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace2.h\"\n #include \"tree.h\"\n #include \"pathspec.h\"\ndiff --git a/tree.c b/tree.c\nindex b85f56267fb..341b7c2ff3f 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"tree.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"alloc.h\"\n #include \"tree-walk.h\"\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 471837f0329..f38c761ab98 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -26,7 +26,7 @@\n #include \"symlinks.h\"\n #include \"trace2.h\"\n #include \"fsmonitor.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"entry.h\"\n #include \"parallel-checkout.h\"\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 956da5b061a..cec12cb478a 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -10,7 +10,7 @@\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/walker.c b/walker.c\nindex b470d43e54d..a8abe8a2e78 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"walker.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"strbuf.h\"\n #include \"tree.h\"\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 1edcd319e6e..01e6e378ea6 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"config.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"xdiff-interface.h\"\n #include \"xdiff/xtypes.h\"\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517316","messageId":"20250506-pks-object-store-wo-the-repository-v1-5-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:18Z","receivedAt":"2025-05-06T11:09:24Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `find_odb()` by passing\nin the object database in which we want to search for the backend and\nadjusting all callers.\n\nRename the function to `odb_find_backend()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c | 18 +++++++++---------\n midx-write.c           |  2 +-\n odb.c                  | 14 +++++++-------\n odb.h                  |  7 ++++++-\n 4 files changed, 23 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 0a184d39720..28550d3bcc9 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \t\t\tstruct repository *repo UNUSED)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct odb_backend *odb = NULL;\n+\tstruct odb_backend *backend = NULL;\n \tchar *graph_name;\n \tchar *chain_name;\n \tenum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;\n@@ -101,9 +101,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n-\tgraph_name = get_commit_graph_filename(odb);\n-\tchain_name = get_commit_graph_chain_filename(odb);\n+\tbackend = odb_find_backend(the_repository->objects, opts.obj_dir);\n+\tgraph_name = get_commit_graph_filename(backend);\n+\tchain_name = get_commit_graph_chain_filename(backend);\n \tif (open_commit_graph(graph_name, &fd, &st))\n \t\topened = OPENED_GRAPH;\n \telse if (errno != ENOENT)\n@@ -120,7 +120,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opened == OPENED_NONE)\n \t\treturn 0;\n \telse if (opened == OPENED_GRAPH)\n-\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);\n+\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, backend);\n \telse\n \t\tgraph = load_commit_graph_chain_fd_st(the_repository, fd, &st,\n \t\t\t\t\t\t      &incomplete_chain);\n@@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \tstruct string_list pack_indexes = STRING_LIST_INIT_DUP;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct oidset commits = OIDSET_INIT;\n-\tstruct odb_backend *odb = NULL;\n+\tstruct odb_backend *backend = NULL;\n \tint result = 0;\n \tenum commit_graph_write_flags flags = 0;\n \tstruct progress *progress = NULL;\n@@ -289,10 +289,10 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n+\tbackend = odb_find_backend(the_repository->objects, opts.obj_dir);\n \n \tif (opts.reachable) {\n-\t\tif (write_commit_graph_reachable(odb, flags, &write_opts))\n+\t\tif (write_commit_graph_reachable(backend, flags, &write_opts))\n \t\t\tresult = 1;\n \t\tgoto cleanup;\n \t}\n@@ -318,7 +318,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t\tstop_progress(&progress);\n \t}\n \n-\tif (write_commit_graph(odb,\n+\tif (write_commit_graph(backend,\n \t\t\t       opts.stdin_packs ? &pack_indexes : NULL,\n \t\t\t       opts.stdin_commits ? &commits : NULL,\n \t\t\t       flags,\ndiff --git a/midx-write.c b/midx-write.c\nindex dd3b3070e55..e8371a84a14 100644\n--- a/midx-write.c\n+++ b/midx-write.c\n@@ -922,7 +922,7 @@ static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,\n \tstruct strbuf cur_path_real = STRBUF_INIT;\n \n \t/* Ensure the given object_dir is local, or a known alternate. */\n-\tfind_odb(r, obj_dir_real);\n+\todb_find_backend(r->objects, obj_dir_real);\n \n \tfor (cur = get_multi_pack_index(r); cur; cur = cur->next) {\n \t\tstrbuf_realpath(&cur_path_real, cur->object_dir, 1);\ndiff --git a/odb.c b/odb.c\nindex 67207ce636d..6359c541d78 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -448,15 +448,15 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct odb_backend *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir)\n {\n-\tstruct odb_backend *odb;\n+\tstruct odb_backend *backend;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n-\tfor (odb = r->objects->backends; odb; odb = odb->next) {\n-\t\tstrbuf_realpath(&odb_path_real, odb->path, 1);\n+\tprepare_alt_odb(odb->repo);\n+\tfor (backend = odb->backends; backend; backend = backend->next) {\n+\t\tstrbuf_realpath(&odb_path_real, backend->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\n \t}\n@@ -464,9 +464,9 @@ struct odb_backend *find_odb(struct repository *r, const char *obj_dir)\n \tfree(obj_dir_real);\n \tstrbuf_release(&odb_path_real);\n \n-\tif (!odb)\n+\tif (!backend)\n \t\tdie(_(\"could not find object directory matching %s\"), obj_dir);\n-\treturn odb;\n+\treturn backend;\n }\n \n static void fill_alternate_refs_command(struct child_process *cmd,\ndiff --git a/odb.h b/odb.h\nindex 1617a9bac2c..a8c0f788969 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -56,7 +56,6 @@ struct odb_backend {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct odb_backend *find_odb(struct repository *r, const char *obj_dir);\n typedef int alt_odb_fn(struct odb_backend *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n@@ -183,6 +182,12 @@ struct object_database {\n struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n+/*\n+ * Find backend by its object directory path. Dies in case the object directory\n+ * couldn't be found.\n+ */\n+struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir);\n+\n /*\n  * Create a temporary file rooted in the object database directory, or\n  * die on failure. The filename is taken from \"pattern\", which should have the\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517318","messageId":"20250506-pks-object-store-wo-the-repository-v1-6-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 06/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:19Z","receivedAt":"2025-05-06T11:09:25Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `assert_oid_type()` by\npassing in the object database as a parameter and adjusting all callers.\n\nRename the function to `odb_assert_oid_type()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-tree.c | 2 +-\n commit.c              | 2 +-\n odb.c                 | 5 +++--\n odb.h                 | 3 ++-\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 546069f8682..31cfd9bd15d 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -48,7 +48,7 @@ static int parse_parent_arg_callback(const struct option *opt,\n \tif (repo_get_oid_commit(the_repository, arg, &oid))\n \t\tdie(_(\"not a valid object name %s\"), arg);\n \n-\tassert_oid_type(&oid, OBJ_COMMIT);\n+\todb_assert_oid_type(the_repository->objects, &oid, OBJ_COMMIT);\n \tnew_parent(lookup_commit(the_repository, &oid), parents);\n \treturn 0;\n }\ndiff --git a/commit.c b/commit.c\nindex 1d30f8ce15a..aa65183d8b6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1706,7 +1706,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,\n \t/* Not having i18n.commitencoding is the same as having utf-8 */\n \tencoding_is_utf8 = is_encoding_utf8(git_commit_encoding);\n \n-\tassert_oid_type(tree, OBJ_TREE);\n+\todb_assert_oid_type(the_repository->objects, tree, OBJ_TREE);\n \n \tif (memchr(msg, '\\0', msg_len))\n \t\treturn error(\"a NUL byte in commit log message not allowed.\");\ndiff --git a/odb.c b/odb.c\nindex 6359c541d78..b4265da2993 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -955,9 +955,10 @@ int has_object(struct repository *r, const struct object_id *oid,\n \treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n }\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect)\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex a8c0f788969..7e634db16f2 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -293,7 +293,8 @@ enum {\n int has_object(struct repository *r, const struct object_id *oid,\n \t       unsigned flags);\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect);\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect);\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517319","messageId":"20250506-pks-object-store-wo-the-repository-v1-7-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 07/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:20Z","receivedAt":"2025-05-06T11:09:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `assert_oid_type()` by\npassing in the object database as a parameter and adjusting all callers.\n\nRename the function to `odb_assert_oid_type()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/fast-import.c |  3 ++-\n builtin/index-pack.c  |  2 +-\n bundle-uri.c          |  3 ++-\n odb.c                 |  9 +++++----\n odb.h                 | 11 ++++++-----\n pack-bitmap-write.c   |  3 ++-\n pack-write.c          | 10 ++++++----\n 7 files changed, 24 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 52c792488e1..413304db9b5 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -763,7 +763,8 @@ static void start_packfile(void)\n \tstruct packed_git *p;\n \tint pack_fd;\n \n-\tpack_fd = odb_mkstemp(&tmp_file, \"pack/tmp_pack_XXXXXX\");\n+\tpack_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n+\t\t\t      \"pack/tmp_pack_XXXXXX\");\n \tFLEX_ALLOC_STR(p, pack_name, tmp_file.buf);\n \tstrbuf_release(&tmp_file);\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 8ce446064e8..8e5acefde40 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -362,7 +362,7 @@ static const char *open_pack_file(const char *pack_name)\n \t\tinput_fd = 0;\n \t\tif (!pack_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\toutput_fd = odb_mkstemp(&tmp_file,\n+\t\t\toutput_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n \t\t\t\t\t\t\"pack/tmp_pack_XXXXXX\");\n \t\t\tpack_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 993ac62c271..87a5ba50945 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -278,7 +278,8 @@ static char *find_temp_filename(void)\n \t * Find a temporary filename that is available. This is briefly\n \t * racy, but unlikely to collide.\n \t */\n-\tfd = odb_mkstemp(&name, \"bundles/tmp_uri_XXXXXX\");\n+\tfd = odb_mkstemp(the_repository->objects, &name,\n+\t\t\t \"bundles/tmp_uri_XXXXXX\");\n \tif (fd < 0) {\n \t\twarning(_(\"failed to create temporary file\"));\n \t\treturn NULL;\ndiff --git a/odb.c b/odb.c\nindex b4265da2993..9bd87204737 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -63,7 +63,8 @@ static const struct cached_object *find_cached_object(struct object_database *ob\n \treturn NULL;\n }\n \n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern)\n {\n \tint fd;\n \t/*\n@@ -71,15 +72,15 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n \t * restrictive except to remove write permission.\n \t */\n \tint mode = 0444;\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n \tfd = git_mkstemp_mode(temp_filename->buf, mode);\n \tif (0 <= fd)\n \t\treturn fd;\n \n \t/* slow path */\n \t/* some mkstemp implementations erase temp_filename on failure */\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n-\tsafe_create_leading_directories(the_repository, temp_filename->buf);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n+\tsafe_create_leading_directories(odb->repo, temp_filename->buf);\n \treturn xmkstemp_mode(temp_filename->buf, mode);\n }\n \ndiff --git a/odb.h b/odb.h\nindex 7e634db16f2..62967da6cf6 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -189,12 +189,13 @@ void odb_clear(struct object_database *o);\n struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir);\n \n /*\n- * Create a temporary file rooted in the object database directory, or\n- * die on failure. The filename is taken from \"pattern\", which should have the\n- * usual \"XXXXXX\" trailer, and the resulting filename is written into the\n- * \"template\" buffer. Returns the open descriptor.\n+ * Create a temporary file rooted in the primary object database backend's\n+ * directory, or die on failure. The filename is taken from \"pattern\", which\n+ * should have the usual \"XXXXXX\" trailer, and the resulting filename is\n+ * written into the \"template\" buffer. Returns the open descriptor.\n  */\n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern);\n \n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 37648b57125..c847369eaaa 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1052,7 +1052,8 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n \n \tstruct bitmap_disk_header header;\n \n-\tint fd = odb_mkstemp(&tmp_file, \"pack/tmp_bitmap_XXXXXX\");\n+\tint fd = odb_mkstemp(writer->repo->objects, &tmp_file,\n+\t\t\t     \"pack/tmp_bitmap_XXXXXX\");\n \n \tif (writer->pseudo_merges_nr)\n \t\toptions |= BITMAP_OPT_PSEUDO_MERGES;\ndiff --git a/pack-write.c b/pack-write.c\nindex 6b06315f80a..eccdc798e36 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -84,7 +84,8 @@ const char *write_idx_file(struct repository *repo,\n \t} else {\n \t\tif (!index_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_idx_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_idx_XXXXXX\");\n \t\t\tindex_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(index_name);\n@@ -259,7 +260,8 @@ char *write_rev_file_order(struct repository *repo,\n \tif (flags & WRITE_REV) {\n \t\tif (!rev_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_rev_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_rev_XXXXXX\");\n \t\t\tpath = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(rev_name);\n@@ -342,7 +344,7 @@ static char *write_mtimes_file(struct repository *repo,\n \tif (!to_pack)\n \t\tBUG(\"cannot call write_mtimes_file with NULL packing_data\");\n \n-\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n \tmtimes_name = strbuf_detach(&tmp_file, NULL);\n \tf = hashfd(repo->hash_algo, fd, mtimes_name);\n \n@@ -531,7 +533,7 @@ struct hashfile *create_tmp_packfile(struct repository *repo,\n \tstruct strbuf tmpname = STRBUF_INIT;\n \tint fd;\n \n-\tfd = odb_mkstemp(&tmpname, \"pack/tmp_pack_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmpname, \"pack/tmp_pack_XXXXXX\");\n \t*pack_tmp_name = strbuf_detach(&tmpname, NULL);\n \treturn hashfd(repo->hash_algo, fd, *pack_tmp_name);\n }\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517320","messageId":"20250506-pks-object-store-wo-the-repository-v1-8-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:21Z","receivedAt":"2025-05-06T11:09:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions to manage alternates all depend on `the_repository`.\nRefactor them to accept an object database as parameter and adjusting\nall callers. The functions are renamed accordingly.\n\nNote that right now the situation is still somewhat weird because we end\nup using the path provided by the object store's repository anyway. This\nwill be adapted over time though so that we instead store the path to\nthe primary object directory in the object database itself.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/clone.c           | 10 +++++----\n builtin/fsck.c            |  6 +++---\n builtin/grep.c            |  2 +-\n builtin/repack.c          |  3 ++-\n commit-graph.c            |  4 ++--\n loose.c                   |  2 +-\n object-file.c             | 10 ++++-----\n object-name.c             |  2 +-\n odb.c                     | 44 ++++++++++++++++++---------------------\n odb.h                     | 53 ++++++++++++++++++++++++++++++++---------------\n packfile.c                |  4 ++--\n submodule.c               |  3 ++-\n t/helper/test-ref-store.c |  2 +-\n tmp-objdir.c              |  2 +-\n 14 files changed, 83 insertions(+), 64 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 1eafeefb48d..3aabdf6570b 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -171,7 +171,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)\n \t} else {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstrbuf_addf(&sb, \"%s/objects\", ref_git);\n-\t\tadd_to_alternates_file(sb.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \t}\n \n@@ -212,12 +212,14 @@ static void copy_alternates(struct strbuf *src, const char *src_repo)\n \t\tif (!line.len || line.buf[0] == '#')\n \t\t\tcontinue;\n \t\tif (is_absolute_path(line.buf)) {\n-\t\t\tadd_to_alternates_file(line.buf);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   line.buf);\n \t\t\tcontinue;\n \t\t}\n \t\tabs_path = mkpathdup(\"%s/objects/%s\", src_repo, line.buf);\n \t\tif (!normalize_path_copy(abs_path, abs_path))\n-\t\t\tadd_to_alternates_file(abs_path);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   abs_path);\n \t\telse\n \t\t\twarning(\"skipping invalid relative alternate: %s/%s\",\n \t\t\t\tsrc_repo, line.buf);\n@@ -352,7 +354,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)\n \t\tstruct strbuf alt = STRBUF_INIT;\n \t\tget_common_dir(&alt, src_repo);\n \t\tstrbuf_addstr(&alt, \"/objects\");\n-\t\tadd_to_alternates_file(alt.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, alt.buf);\n \t\tstrbuf_release(&alt);\n \t} else {\n \t\tstruct strbuf src = STRBUF_INIT;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 895c9ca5381..ffae00b1723 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -1006,7 +1006,7 @@ int cmd_fsck(int argc,\n \t\tfor_each_packed_object(the_repository,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next)\n \t\t\tfsck_object_dir(backend->path);\n \n@@ -1117,7 +1117,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_commit_graph) {\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n@@ -1135,7 +1135,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_multi_pack_index) {\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 7b1940be2a1..610428e6298 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -462,7 +462,7 @@ static int grep_submodule(struct grep_opt *opt,\n \n \t/*\n \t * NEEDSWORK: repo_read_gitmodules() might call\n-\t * add_to_alternates_memory() via config_from_gitmodules(). This\n+\t * odb_add_to_alternates_memory() via config_from_gitmodules(). This\n \t * operation causes a race condition with concurrent object readings\n \t * performed by the worker threads. That's why we need obj_read_lock()\n \t * here. It should be removed once it's no longer necessary to add the\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 16782320058..8145474cf8d 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -1256,7 +1256,8 @@ int cmd_repack(int argc,\n \tif (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)\n \t\tdie(_(incremental_bitmap_conflict_error));\n \n-\tif (write_bitmaps && po_args.local && has_alt_odb(the_repository)) {\n+\tif (write_bitmaps && po_args.local &&\n+\t    odb_has_alternates(the_repository->objects)) {\n \t\t/*\n \t\t * When asked to do a local repack, but we have\n \t\t * packfiles that are inherited from an alternate, then\ndiff --git a/commit-graph.c b/commit-graph.c\nindex d58d1bf39ed..ff72f7e32ae 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -649,7 +649,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tcount = st->st_size / (the_hash_algo->hexsz + 1);\n \tCALLOC_ARRAY(oids, count);\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (i = 0; i < count; i++) {\n \t\tstruct odb_backend *backend;\n@@ -778,7 +778,7 @@ static int prepare_commit_graph(struct repository *r)\n \tif (!commit_graph_compatible(r))\n \t\treturn 0;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (backend = r->objects->backends;\n \t     !r->objects->commit_graph && backend;\n \t     backend = backend->next)\ndiff --git a/loose.c b/loose.c\nindex e52397bb3e5..dbeafe05c3b 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -112,7 +112,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tprepare_alt_odb(repo);\n+\todb_prepare_alternates(repo->objects);\n \n \tfor (backend = repo->objects->backends; backend; backend = backend->next) {\n \t\tif (load_one_loose_object_map(repo, backend) < 0) {\ndiff --git a/object-file.c b/object-file.c\nindex cc81729ae25..c70a3fc317a 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -106,7 +106,7 @@ static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n \tstruct odb_backend *backend;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (backend = the_repository->objects->backends->next; backend; backend = backend->next) {\n \t\tif (check_and_freshen_odb(backend, oid, freshen))\n \t\t\treturn 1;\n@@ -211,7 +211,7 @@ static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \tstruct odb_backend *backend;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (backend = r->objects->backends; backend; backend = backend->next) {\n \t\t*path = odb_loose_path(backend, &buf, oid);\n \t\tif (!lstat(*path, st))\n@@ -233,7 +233,7 @@ static int open_loose_object(struct repository *r,\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (backend = r->objects->backends; backend; backend = backend->next) {\n \t\t*path = odb_loose_path(backend, &buf, oid);\n \t\tfd = git_open(*path);\n@@ -252,7 +252,7 @@ static int quick_has_loose(struct repository *r,\n {\n \tstruct odb_backend *backend;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (backend = r->objects->backends; backend; backend = backend->next) {\n \t\tif (oidtree_contains(odb_loose_cache(backend, oid), oid))\n \t\t\treturn 1;\n@@ -1542,7 +1542,7 @@ int for_each_loose_object(each_loose_object_fn cb, void *data,\n {\n \tstruct odb_backend *backend;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n \t\tint r = for_each_loose_file_in_objdir(backend->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\ndiff --git a/object-name.c b/object-name.c\nindex b80791a9018..919a3e7a9f8 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -376,7 +376,7 @@ static int init_object_disambiguation(struct repository *r,\n \tds->hex_pfx[len] = '\\0';\n \tds->repo = r;\n \tds->bin_pfx.algo = algo ? hash_algo_by_ptr(algo) : GIT_HASH_UNKNOWN;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \treturn 0;\n }\n \ndiff --git a/odb.c b/odb.c\nindex 9bd87204737..229e048d573 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -272,10 +272,11 @@ static void read_info_alternates(struct object_database *odb,\n \tfree(path);\n }\n \n-void add_to_alternates_file(const char *reference)\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *reference)\n {\n \tstruct lock_file lock = LOCK_INIT;\n-\tchar *alts = repo_git_path(the_repository, \"objects/info/alternates\");\n+\tchar *alts = repo_git_path(odb->repo, \"objects/info/alternates\");\n \tFILE *in, *out;\n \tint found = 0;\n \n@@ -308,22 +309,23 @@ void add_to_alternates_file(const char *reference)\n \t\tfprintf_or_die(out, \"%s\\n\", reference);\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n-\t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n+\t\tif (odb->loaded_alternates)\n+\t\t\tlink_alt_odb_entries(odb, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n }\n \n-void add_to_alternates_memory(const char *reference)\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *reference)\n {\n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(odb);\n \n-\tlink_alt_odb_entries(the_repository->objects, reference,\n+\tlink_alt_odb_entries(odb, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -335,7 +337,7 @@ struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n@@ -379,12 +381,6 @@ void restore_primary_odb(struct odb_backend *restore_odb, const char *old_path)\n \tfree_object_directory(cur_odb);\n }\n \n-/*\n- * Compute the exact path an alternate is at and returns it. In case of\n- * error NULL is returned and the human readable error is added to `err`\n- * `path` may be relative and should point to $GIT_DIR.\n- * `err` must not be null.\n- */\n char *compute_alternate_path(const char *path, struct strbuf *err)\n {\n \tchar *ref_git = NULL;\n@@ -455,7 +451,7 @@ struct odb_backend *odb_find_backend(struct object_database *odb, const char *ob\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(odb->repo);\n+\todb_prepare_alternates(odb);\n \tfor (backend = odb->backends; backend; backend = backend->next) {\n \t\tstrbuf_realpath(&odb_path_real, backend->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n@@ -573,7 +569,7 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \tstruct odb_backend *backend;\n \tint r = 0;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (backend = the_repository->objects->backends->next; backend; backend = backend->next) {\n \t\tr = fn(backend, cb);\n \t\tif (r)\n@@ -582,21 +578,21 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \treturn r;\n }\n \n-void prepare_alt_odb(struct repository *r)\n+void odb_prepare_alternates(struct object_database *odb)\n {\n-\tif (r->objects->loaded_alternates)\n+\tif (odb->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(odb, odb->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r->objects, r->objects->backends->path, 0);\n-\tr->objects->loaded_alternates = 1;\n+\tread_info_alternates(odb, odb->backends->path, 0);\n+\todb->loaded_alternates = 1;\n }\n \n-int has_alt_odb(struct repository *r)\n+int odb_has_alternates(struct object_database *odb)\n {\n-\tprepare_alt_odb(r);\n-\treturn !!r->objects->backends->next;\n+\todb_prepare_alternates(odb);\n+\treturn !!odb->backends->next;\n }\n \n int obj_read_use_lock = 0;\ndiff --git a/odb.h b/odb.h\nindex 62967da6cf6..2221af208ee 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -12,6 +12,14 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n+/*\n+ * Compute the exact path an alternate is at and returns it. In case of\n+ * error NULL is returned and the human readable error is added to `err`\n+ * `path` may be relative and should point to $GIT_DIR.\n+ * `err` must not be null.\n+ */\n+char *compute_alternate_path(const char *path, struct strbuf *err);\n+\n /* The backend used to access objects in a specific object directory. */\n struct odb_backend {\n \tstruct odb_backend *next;\n@@ -53,27 +61,11 @@ struct odb_backend {\n \tchar *path;\n };\n \n-void prepare_alt_odb(struct repository *r);\n-int has_alt_odb(struct repository *r);\n-char *compute_alternate_path(const char *path, struct strbuf *err);\n typedef int alt_odb_fn(struct odb_backend *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n \n-/*\n- * Add the directory to the on-disk alternates file; the new entry will also\n- * take effect in the current process.\n- */\n-void add_to_alternates_file(const char *dir);\n-\n-/*\n- * Add the directory to the in-memory list of alternates (along with any\n- * recursive alternates it points to), but do not modify the on-disk alternates\n- * file.\n- */\n-void add_to_alternates_memory(const char *dir);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -112,7 +104,7 @@ struct object_database {\n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"backends\" list when prepare_alt_odb() is run.\n+\t * populate the \"backends\" list when odb_prepare_alternates() is run.\n \t */\n \tchar *alternate_db;\n \n@@ -197,6 +189,33 @@ struct odb_backend *odb_find_backend(struct object_database *odb, const char *ob\n int odb_mkstemp(struct object_database *odb,\n \t\tstruct strbuf *temp_filename, const char *pattern);\n \n+/*\n+ * Prepare alternate object backends for the given database by reading\n+ * \"objects/info/alternates\" and opening the respective backends.\n+ */\n+void odb_prepare_alternates(struct object_database *odb);\n+\n+/*\n+ * Check whether the object database has any alternate backends. The primary\n+ * object backend does not count as alternate.\n+ */\n+int odb_has_alternates(struct object_database *odb);\n+\n+/*\n+ * Add the directory to the on-disk alternates file; the new entry will also\n+ * take effect in the current process.\n+ */\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *dir);\n+\n+/*\n+ * Add the directory to the in-memory list of alternates (along with any\n+ * recursive alternates it points to), but do not modify the on-disk alternates\n+ * file.\n+ */\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *dir);\n+\n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\n \t\t\t    enum object_type *type,\ndiff --git a/packfile.c b/packfile.c\nindex 0f3d60721a9..263056a6279 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1023,7 +1023,7 @@ static void prepare_packed_git(struct repository *r)\n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (backend = r->objects->backends; backend; backend = backend->next) {\n \t\tint local = (backend == r->objects->backends);\n \t\tprepare_multi_pack_index_one(r, backend->path, local);\n@@ -1048,7 +1048,7 @@ void reprepare_packed_git(struct repository *r)\n \t * the lifetime of the process.\n \t */\n \tr->objects->loaded_alternates = 0;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (backend = r->objects->backends; backend; backend = backend->next)\n \t\todb_clear_loose_cache(backend);\ndiff --git a/submodule.c b/submodule.c\nindex 9b1018877df..386be234230 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -189,7 +189,8 @@ int register_all_submodule_odb_as_alternates(void)\n \tint ret = added_submodule_odb_paths.nr;\n \n \tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\tadd_to_alternates_memory(added_submodule_odb_paths.items[i].string);\n+\t\todb_add_to_alternates_memory(the_repository->objects,\n+\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n \tif (ret) {\n \t\tstring_list_clear(&added_submodule_odb_paths, 0);\n \t\ttrace2_data_intmax(\"submodule\", the_repository,\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 2920ca59d72..8d9a271845c 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -79,7 +79,7 @@ static const char **get_store(const char **argv, struct ref_store **refs)\n \t\tif (!repo_submodule_path_append(the_repository,\n \t\t\t\t\t\t&sb, gitdir, \"objects/\"))\n \t\t\tdie(\"computing submodule path failed\");\n-\t\tadd_to_alternates_memory(sb.buf);\n+\t\todb_add_to_alternates_memory(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \n \t\t*refs = repo_get_submodule_ref_store(the_repository, gitdir);\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex f9e8277fd7c..2982c646569 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -304,7 +304,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)\n \n void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n {\n-\tadd_to_alternates_memory(t->path.buf);\n+\todb_add_to_alternates_memory(t->repo->objects, t->path.buf);\n }\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517321","messageId":"20250506-pks-object-store-wo-the-repository-v1-9-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:22Z","receivedAt":"2025-05-06T11:09:27Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"There are a couple of iterator-style functions that execute a callback\nfor each instance of a given set, all of which currently depend on\n`the_repository`. Refactor them to instead take an object database as\nparameter so that we can get rid of this dependency.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/count-objects.c     |  2 +-\n builtin/receive-pack.c      |  3 ++-\n builtin/submodule--helper.c |  3 ++-\n diagnose.c                  |  2 +-\n fetch-pack.c                |  3 ++-\n odb.c                       | 36 +++++++++++++++++++-----------------\n odb.h                       | 23 ++++++++++++++++++-----\n revision.c                  |  3 ++-\n 8 files changed, 47 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex 80f2693ac3c..5ca806d53e3 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -159,7 +159,7 @@ int cmd_count_objects(int argc,\n \t\tprintf(\"prune-packable: %lu\\n\", packed_loose);\n \t\tprintf(\"garbage: %lu\\n\", garbage);\n \t\tprintf(\"size-garbage: %s\\n\", garbage_buf.buf);\n-\t\tforeach_alt_odb(print_alternate, NULL);\n+\t\todb_for_each_backend(the_repository->objects, print_alternate, NULL);\n \t\tstrbuf_release(&loose_buf);\n \t\tstrbuf_release(&pack_buf);\n \t\tstrbuf_release(&garbage_buf);\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex cb5fd55a8e4..8c157ea7d1b 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -358,7 +358,8 @@ static void write_head_info(void)\n \n \trefs_for_each_fullref_in(get_main_ref_store(the_repository), \"\",\n \t\t\t\t exclude_patterns, show_ref_cb, &seen);\n-\tfor_each_alternate_ref(show_one_alternate_ref, &seen);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   show_one_alternate_ref, &seen);\n \n \toidset_clear(&seen);\n \tstrvec_clear(&excludes_vector);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 7f672e4808c..d54546df9da 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1668,7 +1668,8 @@ static void prepare_possible_alternates(const char *sm_name,\n \t\tdie(_(\"Value '%s' for submodule.alternateErrorStrategy is not recognized\"), error_strategy);\n \n \tif (!strcmp(sm_alternate, \"superproject\"))\n-\t\tforeach_alt_odb(add_possible_reference_from_superproject, &sas);\n+\t\todb_for_each_backend(the_repository->objects,\n+\t\t\t\t     add_possible_reference_from_superproject, &sas);\n \telse if (!strcmp(sm_alternate, \"no\"))\n \t\t; /* do nothing */\n \telse\ndiff --git a/diagnose.c b/diagnose.c\nindex 6ec07761a0f..0529e239837 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -229,7 +229,7 @@ int create_diagnostics_archive(struct repository *r,\n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n \tdir_file_stats(r->objects->backends, &buf);\n-\tforeach_alt_odb(dir_file_stats, &buf);\n+\todb_for_each_backend(r->objects, dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \n \tstrbuf_reset(&buf);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex cf157f5d7e5..47fa7fa4c49 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -115,7 +115,8 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,\n \tsize_t i;\n \n \tif (!initialized) {\n-\t\tfor_each_alternate_ref(cache_one_alternate, &cache);\n+\t\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t\t   cache_one_alternate, &cache);\n \t\tinitialized = 1;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex 229e048d573..66cad14f538 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -494,8 +494,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n }\n \n static void read_alternate_refs(const char *path,\n-\t\t\t\talternate_ref_fn *cb,\n-\t\t\t\tvoid *data)\n+\t\t\t\todb_for_each_alternate_ref_fn *cb,\n+\t\t\t\tvoid *payload)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tstruct strbuf line = STRBUF_INIT;\n@@ -517,7 +517,7 @@ static void read_alternate_refs(const char *path,\n \t\t\tbreak;\n \t\t}\n \n-\t\tcb(&oid, data);\n+\t\tcb(&oid, payload);\n \t}\n \n \tfclose(fh);\n@@ -526,16 +526,16 @@ static void read_alternate_refs(const char *path,\n }\n \n struct alternate_refs_data {\n-\talternate_ref_fn *fn;\n-\tvoid *data;\n+\todb_for_each_alternate_ref_fn *fn;\n+\tvoid *payload;\n };\n \n static int refs_from_alternate_cb(struct odb_backend *e,\n-\t\t\t\t  void *data)\n+\t\t\t\t  void *payload)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n-\tstruct alternate_refs_data *cb = data;\n+\tstruct alternate_refs_data *cb = payload;\n \n \tif (!strbuf_realpath(&path, e->path, 0))\n \t\tgoto out;\n@@ -549,29 +549,31 @@ static int refs_from_alternate_cb(struct odb_backend *e,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->data);\n+\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n \treturn 0;\n }\n \n-void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload)\n {\n-\tstruct alternate_refs_data cb;\n-\tcb.fn = fn;\n-\tcb.data = data;\n-\tforeach_alt_odb(refs_from_alternate_cb, &cb);\n+\tstruct alternate_refs_data data;\n+\tdata.fn = cb;\n+\tdata.payload = payload;\n+\todb_for_each_backend(odb, refs_from_alternate_cb, &data);\n }\n \n-int foreach_alt_odb(alt_odb_fn fn, void *cb)\n+int odb_for_each_backend(struct object_database *odb,\n+\t\t\t odb_for_each_backend_fn cb, void *payload)\n {\n \tstruct odb_backend *backend;\n \tint r = 0;\n \n-\todb_prepare_alternates(the_repository->objects);\n-\tfor (backend = the_repository->objects->backends->next; backend; backend = backend->next) {\n-\t\tr = fn(backend, cb);\n+\todb_prepare_alternates(odb);\n+\tfor (backend = odb->backends->next; backend; backend = backend->next) {\n+\t\tr = cb(backend, payload);\n \t\tif (r)\n \t\t\tbreak;\n \t}\ndiff --git a/odb.h b/odb.h\nindex 2221af208ee..2165396a165 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -61,11 +61,6 @@ struct odb_backend {\n \tchar *path;\n };\n \n-typedef int alt_odb_fn(struct odb_backend *, void *);\n-int foreach_alt_odb(alt_odb_fn, void*);\n-typedef void alternate_ref_fn(const struct object_id *oid, void *);\n-void for_each_alternate_ref(alternate_ref_fn, void *);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -180,6 +175,24 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Iterate through all backends of the database and execute the provided\n+ * callback function for each of them. Stop iterating once the callback\n+ * function returns a non-zero value, in which case the value is bubbled up\n+ * from the callback.\n+ */\n+typedef int odb_for_each_backend_fn(struct odb_backend *, void *);\n+int odb_for_each_backend(struct object_database *odb,\n+\t\t\t odb_for_each_backend_fn cb, void *payload);\n+\n+/*\n+ * Iterate through all alternative object backends of the database and yield\n+ * their respective references.\n+ */\n+typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n+\n /*\n  * Create a temporary file rooted in the primary object database backend's\n  * directory, or die on failure. The filename is taken from \"pattern\", which\ndiff --git a/revision.c b/revision.c\nindex cdefe7d6e48..b0364f556ee 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1907,7 +1907,8 @@ static void add_alternate_refs_to_pending(struct rev_info *revs,\n \tstruct add_alternate_refs_data data;\n \tdata.revs = revs;\n \tdata.flags = flags;\n-\tfor_each_alternate_ref(add_one_alternate_ref, &data);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   add_one_alternate_ref, &data);\n }\n \n static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517322","messageId":"20250506-pks-object-store-wo-the-repository-v1-10-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 10/17] odb: get rid of `the_repository` when handling the primary backend","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:23Z","receivedAt":"2025-05-06T11:09:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions `set_temporary_primary_odb()` and `restore_primary_odb()`\nare responsible for managing a temporary primary backend for the\ndatabase. Both of these fucntions implicitly rely on `the_repository`.\n\nRefactor them to instead take an explicit object database parameter as\nargument and adjust callers. Rename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 19 +++++++++++--------\n odb.h        | 25 ++++++++++++++-----------\n tmp-objdir.c | 10 ++++++----\n 3 files changed, 31 insertions(+), 23 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex 66cad14f538..8be5d4fb2d6 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -329,7 +329,8 @@ void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_backend *odb_set_temporary_primary_backend(struct object_database *odb,\n+\t\t\t\t\t\t      const char *dir, int will_destroy)\n {\n \tstruct odb_backend *backend;\n \n@@ -337,14 +338,14 @@ struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\todb_prepare_alternates(the_repository->objects);\n+\todb_prepare_alternates(odb);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n \tbackend = xcalloc(1, sizeof(*backend));\n-\tbackend->odb = the_repository->objects;\n+\tbackend->odb = odb;\n \tbackend->path = xstrdup(dir);\n \n \t/*\n@@ -353,8 +354,8 @@ struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t */\n \tbackend->disable_ref_updates = 1;\n \tbackend->will_destroy = will_destroy;\n-\tbackend->next = the_repository->objects->backends;\n-\tthe_repository->objects->backends = backend;\n+\tbackend->next = odb->backends;\n+\todb->backends = backend;\n \treturn backend->next;\n }\n \n@@ -366,9 +367,11 @@ static void free_object_directory(struct odb_backend *odb)\n \tfree(odb);\n }\n \n-void restore_primary_odb(struct odb_backend *restore_odb, const char *old_path)\n+void odb_restore_primary_backend(struct object_database *odb,\n+\t\t\t\t struct odb_backend *restore_odb,\n+\t\t\t\t const char *old_path)\n {\n-\tstruct odb_backend *cur_odb = the_repository->objects->backends;\n+\tstruct odb_backend *cur_odb = odb->backends;\n \n \tif (strcmp(old_path, cur_odb->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n@@ -377,7 +380,7 @@ void restore_primary_odb(struct odb_backend *restore_odb, const char *old_path)\n \tif (cur_odb->next != restore_odb)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->backends = restore_odb;\n+\todb->backends = restore_odb;\n \tfree_object_directory(cur_odb);\n }\n \ndiff --git a/odb.h b/odb.h\nindex 2165396a165..e80ee5efec6 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -61,17 +61,6 @@ struct odb_backend {\n \tchar *path;\n };\n \n-/*\n- * Replace the current writable object directory with the specified temporary\n- * object directory; returns the former primary object directory.\n- */\n-struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy);\n-\n-/*\n- * Restore a previous ODB replaced by set_temporary_main_odb.\n- */\n-void restore_primary_odb(struct odb_backend *restore_odb, const char *old_path);\n-\n struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n@@ -175,6 +164,20 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Replace the current writable object directory with the specified temporary\n+ * object directory; returns the former primary backend.\n+ */\n+struct odb_backend *odb_set_temporary_primary_backend(struct object_database *odb,\n+\t\t\t\t\t\t      const char *dir, int will_destroy);\n+\n+/*\n+ * Restore a previous bakcend replaced by `odb_set_temporary_primary_backend()`.\n+ */\n+void odb_restore_primary_backend(struct object_database *odb,\n+\t\t\t\t struct odb_backend *restore_odb,\n+\t\t\t\t const char *old_path);\n+\n /*\n  * Iterate through all backends of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex 2982c646569..e6221879395 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -47,7 +47,7 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \t\tthe_tmp_objdir = NULL;\n \n \tif (t->prev_odb)\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n+\t\todb_restore_primary_backend(t->repo->objects, t->prev_odb, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -279,7 +279,7 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (t->prev_odb) {\n \t\tif (t->repo->objects->backends->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n+\t\todb_restore_primary_backend(t->repo->objects, t->prev_odb, t->path.buf);\n \t\tt->prev_odb = NULL;\n \t}\n \n@@ -311,7 +311,8 @@ void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n \tif (t->prev_odb)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_odb = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_odb = odb_set_temporary_primary_backend(t->repo->objects,\n+\t\t\t\t\t\t\tt->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n@@ -320,7 +321,8 @@ struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n \tif (!the_tmp_objdir || !the_tmp_objdir->prev_odb)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf);\n+\todb_restore_primary_backend(the_tmp_objdir->repo->objects,\n+\t\t\t\t    the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf);\n \tthe_tmp_objdir->prev_odb = NULL;\n \treturn the_tmp_objdir;\n }\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517323","messageId":"20250506-pks-object-store-wo-the-repository-v1-11-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 11/17] odb: get rid of `the_repository` when handling submodule backends","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:24Z","receivedAt":"2025-05-06T11:09:29Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"--recursive\" flag for git-grep(1) allows users to grep for a string\nacross submodule boundaries. To make this work we add each submodule's\nobject backend to our own object database so that the objects can be\naccessed directly.\n\nThe infrastructure for this depends on a global string list of submodule\npaths. The caller is expected to call `add_submodule_odb_by_path()` for\neach backend and the object database will then eventually register all\nsubmodule backends via `do_oid_object_info_extended()` in case it isn't\nable to look up a specific object.\n\nThis reliance on global state is of course suboptimal with regards to\nour libification efforts.\n\nRefactor the logic so that the list of submodule backends is instead\ntracked in the object database itself. This allows us to lose the\ncondition of `r == the_repository` before registering submodule backends\nas we only ever add submodule backends to `the_repository` anyway. As\nsuch, behaviour before and after this refactoring should always be the\nsame.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/grep.c     |  3 ++-\n odb.c              | 37 +++++++++++++++++++++++++++++++------\n odb.h              | 15 +++++++++++++++\n submodule-config.c |  3 ++-\n submodule.c        | 26 --------------------------\n submodule.h        |  9 ---------\n 6 files changed, 50 insertions(+), 43 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 610428e6298..e9816cce8cd 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,8 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->backends->path);\n+\todb_add_submodule_backend_by_path(the_repository->objects,\n+\t\t\t\t\t  subrepo->objects->backends->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/odb.c b/odb.c\nindex 8be5d4fb2d6..bfdf36751e0 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -24,6 +24,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"submodule.h\"\n+#include \"trace2.h\"\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n@@ -469,6 +470,12 @@ struct odb_backend *odb_find_backend(struct object_database *odb, const char *ob\n \treturn backend;\n }\n \n+void odb_add_submodule_backend_by_path(struct object_database *odb,\n+\t\t\t\t       const char *path)\n+{\n+\tstring_list_insert(&odb->submodule_backend_paths, path);\n+}\n+\n static void fill_alternate_refs_command(struct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n@@ -623,6 +630,23 @@ void disable_obj_read_lock(void)\n \n int fetch_if_missing = 1;\n \n+static int register_all_submodule_backends(struct object_database *odb)\n+{\n+\tint ret = odb->submodule_backend_paths.nr;\n+\n+\tfor (size_t i = 0; i < odb->submodule_backend_paths.nr; i++)\n+\t\todb_add_to_alternates_memory(odb,\n+\t\t\t\t\t     odb->submodule_backend_paths.items[i].string);\n+\tif (ret) {\n+\t\tstring_list_clear(&odb->submodule_backend_paths, 0);\n+\t\ttrace2_data_intmax(\"submodule\", odb->repo,\n+\t\t\t\t   \"register_all_submodule_backends/registered\", ret);\n+\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n+\t\t\tBUG(\"register_all_submodule_backends() called\");\n+\t}\n+\treturn ret;\n+}\n+\n static int do_oid_object_info_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n@@ -678,13 +702,12 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t}\n \n \t\t/*\n-\t\t * If r is the_repository, this might be an attempt at\n-\t\t * accessing a submodule object as if it were in the_repository\n-\t\t * (having called add_submodule_odb() on that submodule's ODB).\n-\t\t * If any such ODBs exist, register them and try again.\n+\t\t * This might be an attempt at accessing a submodule object as\n+\t\t * if it were in main object store (having called\n+\t\t * `odb_add_submodule_backend_by_path()` on that submodule's\n+\t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (r == the_repository &&\n-\t\t    register_all_submodule_odb_as_alternates())\n+\t\tif (register_all_submodule_backends(r->objects))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n@@ -977,6 +1000,7 @@ struct object_database *odb_new(struct repository *repo)\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n+\tstring_list_init_dup(&o->submodule_backend_paths);\n \treturn o;\n }\n \n@@ -1027,4 +1051,5 @@ void odb_clear(struct object_database *o)\n \to->packed_git = NULL;\n \n \thashmap_clear(&o->pack_map);\n+\tstring_list_clear(&o->submodule_backend_paths, 0);\n }\ndiff --git a/odb.h b/odb.h\nindex e80ee5efec6..1558f467425 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -5,6 +5,7 @@\n #include \"object.h\"\n #include \"list.h\"\n #include \"oidset.h\"\n+#include \"string-list.h\"\n #include \"thread-utils.h\"\n \n struct oidmap;\n@@ -153,6 +154,12 @@ struct object_database {\n \t * packs.\n \t */\n \tunsigned packed_git_initialized : 1;\n+\n+\t/*\n+\t * Submodule backend paths that will be added as alternatives to allow\n+\t * lookup of submodule objects via the main object database.\n+\t */\n+\tstruct string_list submodule_backend_paths;\n };\n \n struct object_database *odb_new(struct repository *repo);\n@@ -178,6 +185,14 @@ void odb_restore_primary_backend(struct object_database *odb,\n \t\t\t\t struct odb_backend *restore_odb,\n \t\t\t\t const char *old_path);\n \n+/*\n+ * Call odb_add_submodule_backend_by_path() to add the submodule at the given\n+ * path to a list. The object stores of all submodules in that list will be\n+ * added as alternates in the object store when looking up objects.\n+ */\n+void odb_add_submodule_backend_by_path(struct object_database *odb,\n+\t\t\t\t       const char *path);\n+\n /*\n  * Iterate through all backends of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 4abef906f26..ed4bb32dc37 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,8 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->backends->path);\n+\t\t\t\todb_add_submodule_backend_by_path(the_repository->objects,\n+\t\t\t\t\t\t\t\t  repo->objects->backends->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/submodule.c b/submodule.c\nindex 386be234230..788c9e55ed3 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -31,7 +31,6 @@\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\n-#include \"trace2.h\"\n \n static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;\n static int initialized_fetch_ref_tips;\n@@ -176,31 +175,6 @@ void stage_updated_gitmodules(struct index_state *istate)\n \t\tdie(_(\"staging updated .gitmodules failed\"));\n }\n \n-static struct string_list added_submodule_odb_paths = STRING_LIST_INIT_DUP;\n-\n-void add_submodule_odb_by_path(const char *path)\n-{\n-\tstring_list_insert(&added_submodule_odb_paths, path);\n-}\n-\n-int register_all_submodule_odb_as_alternates(void)\n-{\n-\tint i;\n-\tint ret = added_submodule_odb_paths.nr;\n-\n-\tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\todb_add_to_alternates_memory(the_repository->objects,\n-\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n-\tif (ret) {\n-\t\tstring_list_clear(&added_submodule_odb_paths, 0);\n-\t\ttrace2_data_intmax(\"submodule\", the_repository,\n-\t\t\t\t   \"register_all_submodule_odb_as_alternates/registered\", ret);\n-\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n-\t\t\tBUG(\"register_all_submodule_odb_as_alternates() called\");\n-\t}\n-\treturn ret;\n-}\n-\n void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\t\t\t\t     const char *path)\n {\ndiff --git a/submodule.h b/submodule.h\nindex db980c1d083..b10e16e6c06 100644\n--- a/submodule.h\n+++ b/submodule.h\n@@ -104,15 +104,6 @@ int submodule_uses_gitfile(const char *path);\n #define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)\n int bad_to_remove_submodule(const char *path, unsigned flags);\n \n-/*\n- * Call add_submodule_odb_by_path() to add the submodule at the given\n- * path to a list. When register_all_submodule_odb_as_alternates() is\n- * called, the object stores of all submodules in that list will be\n- * added as alternates in the_repository.\n- */\n-void add_submodule_odb_by_path(const char *path);\n-int register_all_submodule_odb_as_alternates(void);\n-\n /*\n  * Checks if there are submodule changes in a..b. If a is the null OID,\n  * checks b and all its ancestors instead.\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517324","messageId":"20250506-pks-object-store-wo-the-repository-v1-12-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:25Z","receivedAt":"2025-05-06T11:09:30Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"All of the external functions provided by the object database subsystem\ndon't depend on `the_repository` anymore, but some internal functions\nstill do. Refactor those cases by plumbing through the repository that\nowns the object database.\n\nThis change allows us to get rid of the `USE_THE_REPOSITORY_VARIABLE`\npreprocessor define.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex bfdf36751e0..8901e3f43a3 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"commit-graph.h\"\n@@ -476,12 +474,13 @@ void odb_add_submodule_backend_by_path(struct object_database *odb,\n \tstring_list_insert(&odb->submodule_backend_paths, path);\n }\n \n-static void fill_alternate_refs_command(struct child_process *cmd,\n+static void fill_alternate_refs_command(struct repository *repo,\n+\t\t\t\t\tstruct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n \tconst char *value;\n \n-\tif (!git_config_get_value(\"core.alternateRefsCommand\", &value)) {\n+\tif (!repo_config_get_value(repo, \"core.alternateRefsCommand\", &value)) {\n \t\tcmd->use_shell = 1;\n \n \t\tstrvec_push(&cmd->args, value);\n@@ -493,7 +492,7 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \t\tstrvec_push(&cmd->args, \"for-each-ref\");\n \t\tstrvec_push(&cmd->args, \"--format=%(objectname)\");\n \n-\t\tif (!git_config_get_value(\"core.alternateRefsPrefixes\", &value)) {\n+\t\tif (!repo_config_get_value(repo, \"core.alternateRefsPrefixes\", &value)) {\n \t\t\tstrvec_push(&cmd->args, \"--\");\n \t\t\tstrvec_split(&cmd->args, value);\n \t\t}\n@@ -503,7 +502,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \tcmd->out = -1;\n }\n \n-static void read_alternate_refs(const char *path,\n+static void read_alternate_refs(struct repository *repo,\n+\t\t\t\tconst char *path,\n \t\t\t\todb_for_each_alternate_ref_fn *cb,\n \t\t\t\tvoid *payload)\n {\n@@ -511,7 +511,7 @@ static void read_alternate_refs(const char *path,\n \tstruct strbuf line = STRBUF_INIT;\n \tFILE *fh;\n \n-\tfill_alternate_refs_command(&cmd, path);\n+\tfill_alternate_refs_command(repo, &cmd, path);\n \n \tif (start_command(&cmd))\n \t\treturn;\n@@ -521,7 +521,7 @@ static void read_alternate_refs(const char *path,\n \t\tstruct object_id oid;\n \t\tconst char *p;\n \n-\t\tif (parse_oid_hex(line.buf, &oid, &p) || *p) {\n+\t\tif (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) {\n \t\t\twarning(_(\"invalid line while parsing alternate refs: %s\"),\n \t\t\t\tline.buf);\n \t\t\tbreak;\n@@ -559,7 +559,7 @@ static int refs_from_alternate_cb(struct odb_backend *e,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n+\tread_alternate_refs(e->odb->repo, path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, the_repository->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n \t\tif (oi->type_name)\n \t\t\tstrbuf_addstr(oi->type_name, type_name(co->type));\n \t\tif (oi->contentp)\n@@ -765,10 +765,10 @@ static int oid_object_info_convert(struct repository *r,\n \tvoid *content;\n \tint ret;\n \n-\tif (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) {\n+\tif (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) {\n \t\tif (do_die)\n \t\t\tdie(_(\"missing mapping of %s to %s\"),\n-\t\t\t    oid_to_hex(input_oid), the_hash_algo->name);\n+\t\t\t    oid_to_hex(input_oid), r->hash_algo->name);\n \t\treturn -1;\n \t}\n \n@@ -804,8 +804,8 @@ static int oid_object_info_convert(struct repository *r,\n \t\tif (type == -1)\n \t\t\treturn -1;\n \t\tif (type != OBJ_BLOB) {\n-\t\t\tret = convert_object_file(the_repository, &outbuf,\n-\t\t\t\t\t\t  the_hash_algo, input_algo,\n+\t\t\tret = convert_object_file(r, &outbuf,\n+\t\t\t\t\t\t  r->hash_algo, input_algo,\n \t\t\t\t\t\t  content, size, type, !do_die);\n \t\t\tfree(content);\n \t\t\tif (ret == -1)\n@@ -953,9 +953,9 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + the_hash_algo->hexsz > isize ||\n+\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex((char *) buffer + ref_length, &actual_oid)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517327","messageId":"20250506-pks-object-store-wo-the-repository-v1-13-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 13/17] odb: rename `oid_object_info()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:26Z","receivedAt":"2025-05-06T11:09:31Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `oid_object_info()` to `odb_read_object_info()` as well as their\n`_extended()` variant to match other functions related to the object\ndatabase and our modern coding guidelines.\n\nIntroduce compatibility wrappers so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n archive.c                     |  2 +-\n blame.c                       |  4 +--\n builtin/blame.c               |  4 +--\n builtin/cat-file.c            | 26 ++++++++++---------\n builtin/describe.c            |  3 ++-\n builtin/fast-export.c         |  2 +-\n builtin/fast-import.c         | 17 ++++++------\n builtin/fsck.c                |  7 ++---\n builtin/gc.c                  |  2 +-\n builtin/grep.c                |  2 +-\n builtin/index-pack.c          | 13 +++++-----\n builtin/ls-files.c            |  2 +-\n builtin/ls-tree.c             |  4 +--\n builtin/mktree.c              |  8 +++---\n builtin/pack-objects.c        | 30 ++++++++++++----------\n builtin/prune.c               |  4 +--\n builtin/repack.c              |  2 +-\n builtin/replace.c             | 10 ++++----\n builtin/rev-list.c            |  6 +++--\n builtin/tag.c                 |  4 +--\n builtin/unpack-objects.c      |  2 +-\n commit-graph.c                |  2 +-\n commit.c                      |  3 ++-\n diff.c                        | 18 ++++++-------\n fetch-pack.c                  |  4 +--\n list-objects-filter.c         |  2 +-\n log-tree.c                    |  2 +-\n merge-ort.c                   |  4 +--\n object-file.c                 |  2 +-\n object-file.h                 |  2 +-\n object-name.c                 | 16 ++++++------\n object.c                      |  6 ++---\n odb.c                         | 60 ++++++++++++++++++++++---------------------\n odb.h                         | 46 +++++++++++++++++++++++++++------\n pack-bitmap-write.c           |  4 +--\n pack-bitmap.c                 |  8 +++---\n packfile.c                    |  5 ++--\n promisor-remote.c             |  4 +--\n protocol-caps.c               |  2 +-\n reachable.c                   |  2 +-\n read-cache.c                  |  6 ++---\n ref-filter.c                  |  4 +--\n remote.c                      |  5 ++--\n sequencer.c                   |  5 ++--\n streaming.c                   |  8 +++---\n submodule.c                   |  5 ++--\n t/helper/test-partial-clone.c |  2 +-\n tag.c                         |  2 +-\n 48 files changed, 213 insertions(+), 170 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 7fa2cc2596a..f2511d530d5 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,\n \n \t/* Stream it? */\n \tif (S_ISREG(mode) && !args->convert &&\n-\t    oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&\n+\t    odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&\n \t    size > repo_settings_get_big_file_threshold(the_repository))\n \t\treturn write_entry(args, oid, path.buf, path.len, mode, NULL, size);\n \ndiff --git a/blame.c b/blame.c\nindex 0ceea080a80..97db3355af4 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,\n \t\tunsigned short mode;\n \n \t\tif (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&\n-\t\t    oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)\n+\t\t    odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n \n@@ -1245,7 +1245,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,\n \t\treturn 0;\n \tif (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))\n \t\tgoto error_out;\n-\tif (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)\n+\tif (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\n \treturn 0;\n  error_out:\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 15eda60af90..91586e6852b 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -837,7 +837,7 @@ static int is_a_rev(const char *name)\n \n \tif (repo_get_oid(the_repository, name, &oid))\n \t\treturn 0;\n-\treturn OBJ_NONE < oid_object_info(the_repository, &oid, NULL);\n+\treturn OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);\n }\n \n static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n@@ -848,7 +848,7 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n \toidcpy(&oid, oid_ret);\n \twhile (1) {\n \t\tstruct object *obj;\n-\t\tint kind = oid_object_info(r, &oid, NULL);\n+\t\tint kind = odb_read_object_info(r->objects, &oid, NULL);\n \t\tif (kind == OBJ_COMMIT) {\n \t\t\toidcpy(oid_ret, &oid);\n \t\t\treturn 0;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 2fa5e3f43bd..da172155c85 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -137,7 +137,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tswitch (opt) {\n \tcase 't':\n \t\toi.type_name = &sb;\n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tif (sb.len) {\n \t\t\tprintf(\"%s\\n\", sb.buf);\n@@ -155,7 +155,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\toi.contentp = (void**)&buf;\n \t\t}\n \n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \n \t\tif (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {\n@@ -189,7 +189,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t/* else fallthrough */\n \n \tcase 'p':\n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Not a valid object name %s\", obj_name);\n \n@@ -226,7 +226,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \n \t\tif (exp_type_id == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n-\t\t\tif (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n \t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n \t\t\t\t\t\t\t\t     &oid,\n \t\t\t\t\t\t\t\t     &type,\n@@ -244,7 +245,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t} else\n \t\t\t\toidcpy(&blob_oid, &oid);\n \n-\t\t\tif (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &blob_oid, NULL) == OBJ_BLOB) {\n \t\t\t\tret = stream_blob(&blob_oid);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n@@ -303,7 +305,7 @@ struct expand_data {\n \n \t/*\n \t * After a mark_query run, this object_info is set up to be\n-\t * passed to oid_object_info_extended. It will point to the data\n+\t * passed to odb_read_object_info_extended. It will point to the data\n \t * elements above, so you can retrieve the response from there.\n \t */\n \tstruct object_info info;\n@@ -493,12 +495,12 @@ static void batch_object_write(const char *obj_name,\n \t\t\tdata->info.sizep = &data->size;\n \n \t\tif (pack)\n-\t\t\tret = packed_object_info(the_repository, pack, offset,\n-\t\t\t\t\t\t &data->info);\n+\t\t\tret = packed_object_info(the_repository, pack,\n+\t\t\t\t\t\t offset, &data->info);\n \t\telse\n-\t\t\tret = oid_object_info_extended(the_repository,\n-\t\t\t\t\t\t       &data->oid, &data->info,\n-\t\t\t\t\t\t       OBJECT_INFO_LOOKUP_REPLACE);\n+\t\t\tret = odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t    &data->oid, &data->info,\n+\t\t\t\t\t\t\t    OBJECT_INFO_LOOKUP_REPLACE);\n \t\tif (ret < 0) {\n \t\t\treport_object_status(opt, obj_name, &data->oid, \"missing\");\n \t\t\treturn;\n@@ -881,7 +883,7 @@ static int batch_objects(struct batch_options *opt)\n \n \t/*\n \t * Expand once with our special mark_query flag, which will prime the\n-\t * object_info to be handed to oid_object_info_extended for each\n+\t * object_info to be handed to odb_read_object_info_extended for each\n \t * object.\n \t */\n \tmemset(&data, 0, sizeof(data));\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 96cb68e5e5d..fbf305d7624 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\n-\telse if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)\n+\telse if (odb_read_object_info(the_repository->objects,\n+\t\t\t\t      &oid, NULL) == OBJ_BLOB)\n \t\tdescribe_blob(oid, &sb);\n \telse\n \t\tdie(_(\"%s is neither a commit nor blob\"), arg);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 0505f289a94..6c93cf0a8aa 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\n \n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 413304db9b5..2718376f2c9 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1756,8 +1756,8 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint\n \tstruct object_entry *e;\n \te = find_object(oid);\n \tif (!e) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\toid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\te = insert_object(oid);\n@@ -2416,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)\n \t\tenum object_type expected = S_ISDIR(mode) ?\n \t\t\t\t\t\tOBJ_TREE: OBJ_BLOB;\n \t\tenum object_type type = oe ? oe->type :\n-\t\t\t\t\toid_object_info(the_repository, &oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\t\t\t\todb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"%s not found: %s\",\n \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n@@ -2553,7 +2553,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttype_name(oe->type), command_buf.buf);\n \t} else if (!is_null_oid(&oid)) {\n-\t\tenum object_type type = oid_object_info(the_repository, &oid,\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects, &oid,\n \t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n@@ -2895,7 +2895,8 @@ static void parse_new_tag(const char *arg)\n \t} else if (!repo_get_oid(the_repository, from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n-\t\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t    &oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -3085,8 +3086,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tif (!oe) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex ffae00b1723..f1da67eb26b 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,\n \tconst char *ret;\n \n \tif (type == OBJ_NONE)\n-\t\ttype = oid_object_info(the_repository, oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t    oid, NULL);\n \n \tret = type_name(type);\n \tif (!ret)\n@@ -232,8 +233,8 @@ static void mark_unreachable_referents(const struct object_id *oid)\n \t * (and we want to avoid parsing blobs).\n \t */\n \tif (obj->type == OBJ_NONE) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\t&obj->oid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &obj->oid, NULL);\n \t\tif (type > 0)\n \t\t\tobject_as_type(obj, type, 0);\n \t}\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex ea13660dba1..1876d4b230b 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -1006,7 +1006,7 @@ static int dfs_on_ref(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tcommit = lookup_commit(the_repository, oid);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex e9816cce8cd..83da86405fa 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobj_read_lock();\n-\t\tobject_type = oid_object_info(subrepo, oid, NULL);\n+\t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n \t\tdata = read_object_with_reference(subrepo,\n \t\t\t\t\t\t  oid, OBJ_TREE,\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 8e5acefde40..82cf80b89d1 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -260,7 +260,8 @@ static unsigned check_object(struct object *obj)\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t&obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n \t\t\t      oid_to_hex(&obj->oid));\n@@ -908,7 +909,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\tenum object_type has_type;\n \t\tunsigned long has_size;\n \t\tread_lock();\n-\t\thas_type = oid_object_info(the_repository, oid, &has_size);\n+\t\thas_type = odb_read_object_info(the_repository->objects, oid, &has_size);\n \t\tif (has_type < 0)\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n@@ -1495,9 +1496,9 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \t\tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \t\tfor (i = 0; i < nr_ref_deltas; i++) {\n \t\t\tstruct ref_delta_entry *d = sorted_by_pos[i];\n-\t\t\tif (!oid_object_info_extended(the_repository, &d->oid,\n-\t\t\t\t\t\t      NULL,\n-\t\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t   &d->oid, NULL,\n+\t\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\tcontinue;\n \t\t\toid_array_append(&to_fetch, &d->oid);\n \t\t}\n@@ -1823,7 +1824,7 @@ static void repack_local_links(void)\n \toidset_iter_init(&outgoing_links, &iter);\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct object_info info = OBJECT_INFO_INIT;\n-\t\tif (oid_object_info_extended(the_repository, oid, &info, 0))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))\n \t\t\t/* Missing; assume it is a promisor object */\n \t\t\tcontinue;\n \t\tif (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 821339b07d4..ff975e7be06 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -251,7 +251,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(repo, oid, &size) < 0)\n+\t\tif (odb_read_object_info(repo->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 62b6fd58c16..4d616dd5282 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -27,7 +27,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\n@@ -217,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,\n \n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)\n \t\t\txsnprintf(size_text, sizeof(size_text), \"BAD\");\n \t\telse\n \t\t\txsnprintf(size_text, sizeof(size_text),\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 016b0e5b224..81df7f6099f 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -124,10 +124,10 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)\n \n \t/* Check the type of object identified by oid without fetching objects */\n \toi.typep = &obj_type;\n-\tif (oid_object_info_extended(the_repository, &oid, &oi,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t     OBJECT_INFO_QUICK |\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t  OBJECT_INFO_QUICK |\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n \t\tobj_type = -1;\n \n \tif (obj_type < 0) {\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 99b63cb0980..da35d684081 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2154,10 +2154,10 @@ static void prefetch_to_pack(uint32_t object_index_start) {\n \tfor (i = object_index_start; i < to_pack.nr_objects; i++) {\n \t\tstruct object_entry *entry = to_pack.objects + i;\n \n-\t\tif (!oid_object_info_extended(the_repository,\n-\t\t\t\t\t      &entry->idx.oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &entry->idx.oid,\n+\t\t\t\t\t\t   NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &entry->idx.oid);\n \t}\n@@ -2298,19 +2298,19 @@ static void check_object(struct object_entry *entry, uint32_t object_index)\n \n \t\t/*\n \t\t * No choice but to fall back to the recursive delta walk\n-\t\t * with oid_object_info() to find about the object type\n+\t\t * with odb_read_object_info() to find about the object type\n \t\t * at this point...\n \t\t */\n \t\tgive_up:\n \t\tunuse_pack(&w_curs);\n \t}\n \n-\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n \t\tif (repo_has_promisor_remote(the_repository)) {\n \t\t\tprefetch_to_pack(object_index);\n-\t\t\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\t\t\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\t\t\ttype = -1;\n \t\t} else {\n \t\t\ttype = -1;\n@@ -2384,12 +2384,13 @@ static void drop_reused_delta(struct object_entry *entry)\n \tif (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {\n \t\t/*\n \t\t * We failed to get the info from this pack for some reason;\n-\t\t * fall back to oid_object_info, which may find another copy.\n+\t\t * fall back to odb_read_object_info, which may find another copy.\n \t\t * And if that fails, the error will be recorded in oe_type(entry)\n \t\t * and dealt with in prepare_pack().\n \t\t */\n \t\toe_set_type(entry,\n-\t\t\t    oid_object_info(the_repository, &entry->idx.oid, &size));\n+\t\t\t    odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &entry->idx.oid, &size));\n \t} else {\n \t\toe_set_type(entry, type);\n \t}\n@@ -2677,7 +2678,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n \n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tif (oid_object_info(the_repository, &e->idx.oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &e->idx.oid, &size) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"),\n \t\t\t    oid_to_hex(&e->idx.oid));\n \t\tpacking_data_unlock(&to_pack);\n@@ -4063,7 +4065,7 @@ static void add_objects_in_unpacked_packs(void)\n static int add_loose_object(const struct object_id *oid, const char *path,\n \t\t\t    void *data UNUSED)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\twarning(_(\"loose object at %s could not be examined\"), path);\n@@ -4449,7 +4451,7 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED,\n static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)\n {\n \tstruct object_info info = OBJECT_INFO_INIT;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &info, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))\n \t\tBUG(\"should_include_obj should only be called on existing objects\");\n \treturn info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;\n }\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 7bbfb14c2be..339017c7ccf 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -99,8 +99,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \tif (st.st_mtime > expire)\n \t\treturn 0;\n \tif (show_only || verbose) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tprintf(\"%s %s\\n\", oid_to_hex(oid),\n \t\t       (type > 0) ? type_name(type) : \"unknown\");\n \t}\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 8145474cf8d..a89c2b704fb 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -707,7 +707,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,\n \tif (oidset_insert(&data->seen, oid))\n \t\treturn 0; /* already seen */\n \n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tfprintf(data->f->fp, \"%s%s\\n\", data->preferred ? \"+\" : \"\",\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 11c7e2d4c0c..5ff2ab723cb 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -65,8 +65,8 @@ static int show_reference(const char *refname,\n \t\t\tif (repo_get_oid(data->repo, refname, &object))\n \t\t\t\treturn error(_(\"failed to resolve '%s' as a valid ref\"), refname);\n \n-\t\t\tobj_type = oid_object_info(data->repo, &object, NULL);\n-\t\t\trepl_type = oid_object_info(data->repo, oid, NULL);\n+\t\t\tobj_type = odb_read_object_info(data->repo->objects, &object, NULL);\n+\t\t\trepl_type = odb_read_object_info(data->repo->objects, oid, NULL);\n \n \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, type_name(obj_type),\n \t\t\t       oid_to_hex(oid), type_name(repl_type));\n@@ -185,8 +185,8 @@ static int replace_object_oid(const char *object_ref,\n \tstruct strbuf err = STRBUF_INIT;\n \tint res = 0;\n \n-\tobj_type = oid_object_info(the_repository, object, NULL);\n-\trepl_type = oid_object_info(the_repository, repl, NULL);\n+\tobj_type = odb_read_object_info(the_repository->objects, object, NULL);\n+\trepl_type = odb_read_object_info(the_repository->objects, repl, NULL);\n \tif (!force && obj_type != repl_type)\n \t\treturn error(_(\"Objects must be of the same type.\\n\"\n \t\t\t       \"'%s' points to a replaced object of type '%s'\\n\"\n@@ -334,7 +334,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)\n \tif (repo_get_oid(the_repository, object_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), object_ref);\n \n-\ttype = oid_object_info(the_repository, &old_oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &old_oid, NULL);\n \tif (type < 0)\n \t\treturn error(_(\"unable to get object type for %s\"),\n \t\t\t     oid_to_hex(&old_oid));\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex ee25d61c802..eed73f5fc0b 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -110,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)\n \toff_t size;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \toi.disk_sizep = &size;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\tdie(_(\"unable to get disk usage of %s\"), oid_to_hex(&obj->oid));\n \treturn size;\n }\n@@ -346,7 +347,8 @@ static void show_commit(struct commit *commit, void *data)\n static int finish_object(struct object *obj, const char *name, void *cb_data)\n {\n \tstruct rev_list_info *info = cb_data;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, NULL, 0) < 0) {\n \t\tfinish_object__ma(obj, name);\n \t\treturn 1;\n \t}\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex cf2ea4b4993..e0b27396c6b 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -304,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,\n \tstruct strbuf header = STRBUF_INIT;\n \tint should_edit;\n \n-\ttype = oid_object_info(the_repository, object, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, object, NULL);\n \tif (type <= OBJ_NONE)\n \t\tdie(_(\"bad object type.\"));\n \n@@ -401,7 +401,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 7bf395eec84..405e78bc592 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -232,7 +232,7 @@ static int check_object(struct object *obj, enum object_type type,\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n \t\tobj->flags |= FLAG_WRITTEN;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex ff72f7e32ae..9c2740a8cab 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1862,7 +1862,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT)\n \t\toidset_insert(data->commits, oid);\n \n \tdisplay_progress(data->progress, oidset_size(data->commits));\ndiff --git a/commit.c b/commit.c\nindex aa65183d8b6..d4aa9c7a5f8 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -585,7 +585,8 @@ int repo_parse_commit_internal(struct repository *r,\n \t\treturn 0;\n \t}\n \n-\tif (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)\n+\tif (odb_read_object_info_extended(r->objects, &item->object.oid,\n+\t\t\t\t\t  &oi, flags) < 0)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/diff.c b/diff.c\nindex 193da8bee68..75cfedf18a5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4230,14 +4230,14 @@ int diff_populate_filespec(struct repository *r,\n \t\t\tinfo.contentp = &s->data;\n \n \t\tif (options && options->missing_object_cb) {\n-\t\t\tif (!oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t\t\t      OBJECT_INFO_SKIP_FETCH_OBJECT))\n+\t\t\tif (!odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t   OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t\t\t   OBJECT_INFO_SKIP_FETCH_OBJECT))\n \t\t\t\tgoto object_read;\n \t\t\toptions->missing_object_cb(options->missing_object_data);\n \t\t}\n-\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \n object_read:\n@@ -4252,8 +4252,8 @@ int diff_populate_filespec(struct repository *r,\n \t\t}\n \t\tif (!info.contentp) {\n \t\t\tinfo.contentp = &s->data;\n-\t\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \t\t}\n \t\ts->should_free = 1;\n@@ -7019,8 +7019,8 @@ void diff_add_if_missing(struct repository *r,\n {\n \tif (filespec && filespec->oid_valid &&\n \t    !S_ISGITLINK(filespec->mode) &&\n-\t    oid_object_info_extended(r, &filespec->oid, NULL,\n-\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t    odb_read_object_info_extended(r->objects, &filespec->oid, NULL,\n+\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\toid_array_append(to_fetch, &filespec->oid);\n }\n \ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 47fa7fa4c49..0f5de1c94d1 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -149,8 +149,8 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \t}\n \n \twhile (1) {\n-\t\tif (oid_object_info_extended(the_repository, oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n \t\t\treturn NULL;\n \t\tif (type == OBJ_TAG) {\n \t\t\tstruct tag *tag = (struct tag *)\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex cb9c16734b1..ec7aebaffd0 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -310,7 +310,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \t\tassert(obj->type == OBJ_BLOB);\n \t\tassert((obj->flags & SEEN) == 0);\n \n-\t\tt = oid_object_info(r, &obj->oid, &object_length);\n+\t\tt = odb_read_object_info(r->objects, &obj->oid, &object_length);\n \t\tif (t != OBJ_BLOB) { /* probably OBJ_NONE */\n \t\t\t/*\n \t\t\t * We DO NOT have the blob locally, so we cannot\ndiff --git a/log-tree.c b/log-tree.c\nindex 1d05dc1c701..233bf9f227c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -176,7 +176,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,\n \t\treturn 0;\n \t}\n \n-\tobjtype = oid_object_info(the_repository, oid, NULL);\n+\tobjtype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (objtype < 0)\n \t\treturn 0;\n \tobj = lookup_object_by_type(the_repository, oid, objtype);\ndiff --git a/merge-ort.c b/merge-ort.c\nindex f86c84635f0..5d4501085e9 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -4374,8 +4374,8 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \n \t\t\tif ((ci->filemask & side_mask) &&\n \t\t\t    S_ISREG(vi->mode) &&\n-\t\t\t    oid_object_info_extended(opt->repo, &vi->oid, NULL,\n-\t\t\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t\t\t    odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,\n+\t\t\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\toid_array_append(&to_fetch, &vi->oid);\n \t\t}\n \t}\ndiff --git a/object-file.c b/object-file.c\nindex c70a3fc317a..25db71dc1e6 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1211,7 +1211,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)\n \toi.typep = &type;\n \toi.sizep = &len;\n \toi.contentp = &buf;\n-\tif (oid_object_info_extended(the_repository, oid, &oi, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0))\n \t\treturn error(_(\"cannot read object for %s\"), oid_to_hex(oid));\n \tif (compat) {\n \t\tif (repo_oid_to_algop(repo, oid, compat, &compat_oid))\ndiff --git a/object-file.h b/object-file.h\nindex aff33f61bb4..c7a559a0502 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -8,7 +8,7 @@\n struct index_state;\n \n /*\n- * Set this to 0 to prevent oid_object_info_extended() from fetching missing\n+ * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing\n  * blobs. This has a difference only if extensions.partialClone is set.\n  *\n  * Its default value is 1.\ndiff --git a/object-name.c b/object-name.c\nindex 919a3e7a9f8..1745f97757c 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -251,7 +251,7 @@ static int disambiguate_commit_only(struct repository *r,\n \t\t\t\t    const struct object_id *oid,\n \t\t\t\t    void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_COMMIT;\n }\n \n@@ -262,7 +262,7 @@ static int disambiguate_committish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -279,7 +279,7 @@ static int disambiguate_tree_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_TREE;\n }\n \n@@ -290,7 +290,7 @@ static int disambiguate_treeish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_TREE || kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -307,7 +307,7 @@ static int disambiguate_blob_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_BLOB;\n }\n \n@@ -399,7 +399,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t\treturn 0;\n \n \thash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);\n-\ttype = oid_object_info(ds->repo, oid, NULL);\n+\ttype = odb_read_object_info(ds->repo->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\t/*\n@@ -514,8 +514,8 @@ static int sort_ambiguous(const void *va, const void *vb, void *ctx)\n {\n \tstruct repository *sort_ambiguous_repo = ctx;\n \tconst struct object_id *a = va, *b = vb;\n-\tint a_type = oid_object_info(sort_ambiguous_repo, a, NULL);\n-\tint b_type = oid_object_info(sort_ambiguous_repo, b, NULL);\n+\tint a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL);\n+\tint b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL);\n \tint a_type_sort;\n \tint b_type_sort;\n \ndiff --git a/object.c b/object.c\nindex 3b15469139d..868d89eed42 100644\n--- a/object.c\n+++ b/object.c\n@@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,\n \tstruct object *o = lookup_unknown_object(r, name);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = oid_object_info(r, name, NULL);\n+\t\tint type = odb_read_object_info(r->objects, name, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\n@@ -315,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t}\n \n \tif ((!obj || obj->type == OBJ_BLOB) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_BLOB) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {\n \t\tif (!skip_hash && stream_object_signature(r, repl) < 0) {\n \t\t\terror(_(\"hash mismatch %s\"), oid_to_hex(oid));\n \t\t\treturn NULL;\n@@ -331,7 +331,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t */\n \tif (skip_hash && discard_tree &&\n \t    (!obj || obj->type == OBJ_TREE) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_TREE) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex 8901e3f43a3..919b8772f86 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -647,7 +647,7 @@ static int register_all_submodule_backends(struct object_database *odb)\n \treturn ret;\n }\n \n-static int do_oid_object_info_extended(struct repository *r,\n+static int do_oid_object_info_extended(struct object_database *odb,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n {\n@@ -660,7 +660,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \n \n \tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n-\t\treal = lookup_replace_object(r, oid);\n+\t\treal = lookup_replace_object(odb->repo, oid);\n \n \tif (is_null_oid(real))\n \t\treturn -1;\n@@ -668,7 +668,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \tif (!oi)\n \t\toi = &blank_oi;\n \n-\tco = find_cached_object(r->objects, real);\n+\tco = find_cached_object(odb, real);\n \tif (co) {\n \t\tif (oi->typep)\n \t\t\t*(oi->typep) = co->type;\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, odb->repo->hash_algo);\n \t\tif (oi->type_name)\n \t\t\tstrbuf_addstr(oi->type_name, type_name(co->type));\n \t\tif (oi->contentp)\n@@ -687,17 +687,17 @@ static int do_oid_object_info_extended(struct repository *r,\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(r, real, &e))\n+\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\tbreak;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!loose_object_info(r, real, oi, flags))\n+\t\tif (!loose_object_info(odb->repo, real, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\tif (!(flags & OBJECT_INFO_QUICK)) {\n-\t\t\treprepare_packed_git(r);\n-\t\t\tif (find_pack_entry(r, real, &e))\n+\t\t\treprepare_packed_git(odb->repo);\n+\t\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\t\tbreak;\n \t\t}\n \n@@ -707,15 +707,15 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * `odb_add_submodule_backend_by_path()` on that submodule's\n \t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (register_all_submodule_backends(r->objects))\n+\t\tif (register_all_submodule_backends(odb))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n \t\t/* Check if it is a missing object */\n-\t\tif (fetch_if_missing && repo_has_promisor_remote(r) &&\n+\t\tif (fetch_if_missing && repo_has_promisor_remote(odb->repo) &&\n \t\t    !already_retried &&\n \t\t    !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n-\t\t\tpromisor_remote_get_direct(r, real, 1);\n+\t\t\tpromisor_remote_get_direct(odb->repo, real, 1);\n \t\t\talready_retried = 1;\n \t\t\tcontinue;\n \t\t}\n@@ -725,7 +725,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t\tif ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))\n \t\t\t\tdie(_(\"replacement %s not found for %s\"),\n \t\t\t\t    oid_to_hex(real), oid_to_hex(oid));\n-\t\t\tif ((p = has_packed_and_bad(r, real)))\n+\t\t\tif ((p = has_packed_and_bad(odb->repo, real)))\n \t\t\t\tdie(_(\"packed object %s (stored in %s) is corrupt\"),\n \t\t\t\t    oid_to_hex(real), p->pack_name);\n \t\t}\n@@ -738,10 +738,10 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(r, e.p, e.offset, oi);\n+\trtype = packed_object_info(odb->repo, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real);\n-\t\treturn do_oid_object_info_extended(r, real, oi, 0);\n+\t\treturn do_oid_object_info_extended(odb, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -789,7 +789,7 @@ static int oid_object_info_convert(struct repository *r,\n \t\toi = &new_oi;\n \t}\n \n-\tret = oid_object_info_extended(r, &oid, oi, flags);\n+\tret = odb_read_object_info_extended(r->objects, &oid, oi, flags);\n \tif (ret)\n \t\treturn -1;\n \tif (oi == input_oi)\n@@ -839,33 +839,35 @@ static int oid_object_info_convert(struct repository *r,\n \treturn ret;\n }\n \n-int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n-\t\t\t     struct object_info *oi, unsigned flags)\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags)\n {\n \tint ret;\n \n-\tif (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo))\n-\t\treturn oid_object_info_convert(r, oid, oi, flags);\n+\tif (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo))\n+\t\treturn oid_object_info_convert(odb->repo, oid, oi, flags);\n \n \tobj_read_lock();\n-\tret = do_oid_object_info_extended(r, oid, oi, flags);\n+\tret = do_oid_object_info_extended(odb, oid, oi, flags);\n \tobj_read_unlock();\n \treturn ret;\n }\n \n \n /* returns enum object_type or negative */\n-int oid_object_info(struct repository *r,\n-\t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (odb_read_object_info_extended(odb, oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n@@ -896,7 +898,7 @@ int pretend_object_file(struct repository *repo,\n \n /*\n  * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call oid_object_info_extended() and give\n+ * deal with them should arrange to call odb_read_object_info_extended() and give\n  * error messages themselves.\n  */\n void *repo_read_object_file(struct repository *r,\n@@ -911,7 +913,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (oid_object_info_extended(r, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -977,13 +979,13 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(odb, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex 1558f467425..2613f2c6c03 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -252,9 +252,6 @@ void *repo_read_object_file(struct repository *r,\n \t\t\t    enum object_type *type,\n \t\t\t    unsigned long *size);\n \n-/* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n-\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -326,9 +323,24 @@ struct object_info {\n /* Die if object corruption (not just an object being missing) was detected. */\n #define OBJECT_INFO_DIE_IF_CORRUPT 32\n \n-int oid_object_info_extended(struct repository *r,\n-\t\t\t     const struct object_id *,\n-\t\t\t     struct object_info *, unsigned flags);\n+/*\n+ * Read object info from the object database and populate the `object_info`\n+ * structure. Returns 0 on success, a negative error code otherwise.\n+ */\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags);\n+\n+/*\n+ * Read a subset of object info for the given object ID. Returns an `enum\n+ * object_type` on success, a negative error code otherwise. If successful and\n+ * `sizep` is non-NULL, then the size of the object will be written to the\n+ * pointer.\n+ */\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep);\n \n enum {\n \t/* Retry packed storage after checking packed and loose storage */\n@@ -350,7 +362,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: repo_read_object_file(),\n- * read_object_with_reference(), oid_object_info() and oid_object_info_extended().\n+ * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -358,7 +370,7 @@ void odb_assert_oid_type(struct object_database *odb,\n  * reading functions. However, beware that in these cases zlib inflation won't\n  * be performed in parallel, losing performance.\n  *\n- * TODO: oid_object_info_extended()'s call stack has a recursive behavior. If\n+ * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If\n  * any of its callees end up calling it, this recursive call won't benefit from\n  * parallel inflation.\n  */\n@@ -406,4 +418,22 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n+/* Compatibility wrappers, to be removed once Git 2.50 has been released. */\n+#include \"repository.h\"\n+\n+static inline int oid_object_info_extended(struct repository *r,\n+\t\t\t\t\t   const struct object_id *oid,\n+\t\t\t\t\t   struct object_info *oi,\n+\t\t\t\t\t   unsigned flags)\n+{\n+\treturn odb_read_object_info_extended(r->objects, oid, oi, flags);\n+}\n+\n+static inline int oid_object_info(struct repository *r,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  unsigned long *sizep)\n+{\n+\treturn odb_read_object_info(r->objects, oid, sizep);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex c847369eaaa..c5183b619c1 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -144,8 +144,8 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\treal_type = oid_object_info(writer->to_pack->repo,\n-\t\t\t\t\t\t    &entry->idx.oid, NULL);\n+\t\t\treal_type = odb_read_object_info(writer->to_pack->repo->objects,\n+\t\t\t\t\t\t\t &entry->idx.oid, NULL);\n \t\t\tbreak;\n \t\t}\n \ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex 467a3e91035..0bd6f1c282f 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -1868,8 +1868,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,\n \t\tsize_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git);\n \t\tstruct eindex *eindex = &bitmap_git->ext_index;\n \t\tstruct object *obj = eindex->objects[eindex_pos];\n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid,\n+\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"), oid_to_hex(&obj->oid));\n \t}\n \n@@ -3220,8 +3220,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)\n \t\t\t\t       i)))\n \t\t\tcontinue;\n \n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects,\n+\t\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get disk usage of '%s'\"),\n \t\t\t    oid_to_hex(&obj->oid));\n \ndiff --git a/packfile.c b/packfile.c\nindex 263056a6279..61920744168 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1310,7 +1310,7 @@ static int retry_bad_packed_offset(struct repository *r,\n \t\treturn OBJ_BAD;\n \tnth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));\n \tmark_bad_packed_object(p, &oid);\n-\ttype = oid_object_info(r, &oid, NULL);\n+\ttype = odb_read_object_info(r->objects, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1843,7 +1843,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\t\t\toi.typep = &type;\n \t\t\t\toi.sizep = &base_size;\n \t\t\t\toi.contentp = &base;\n-\t\t\t\tif (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)\n+\t\t\t\tif (odb_read_object_info_extended(r->objects, &base_oid,\n+\t\t\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\t\t\tbase = NULL;\n \n \t\t\t\texternal_base = base;\ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 2baa286bfd0..be6f82d12f8 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -245,8 +245,8 @@ static int remove_fetched_oids(struct repository *repo,\n \tstruct object_id *new_oids;\n \n \tfor (i = 0; i < oid_nr; i++)\n-\t\tif (oid_object_info_extended(repo, &old_oids[i], NULL,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n+\t\tif (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n \t\t\tremaining[i] = 1;\n \t\t\tremaining_nr++;\n \t\t}\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 3022f69a1bd..ecdd0dc58d5 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -64,7 +64,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,\n \t\tstrbuf_addstr(&send_buffer, oid_str);\n \n \t\tif (info->size) {\n-\t\t\tif (oid_object_info(r, &oid, &object_size) < 0) {\n+\t\t\tif (odb_read_object_info(r->objects, &oid, &object_size) < 0) {\n \t\t\t\tstrbuf_addstr(&send_buffer, \" \");\n \t\t\t} else {\n \t\t\t\tstrbuf_addf(&send_buffer, \" %lu\", object_size);\ndiff --git a/reachable.c b/reachable.c\nindex 9dc748f0b9a..e984b68a0c4 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -211,7 +211,7 @@ static void add_recent_object(const struct object_id *oid,\n \t * later processing, and the revision machinery expects\n \t * commits and tags to have been parsed.\n \t */\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object info for %s\", oid_to_hex(oid));\n \ndiff --git a/read-cache.c b/read-cache.c\nindex dce1056ec7c..be664f857b4 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3758,9 +3758,9 @@ void prefetch_cache_entries(const struct index_state *istate,\n \n \t\tif (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))\n \t\t\tcontinue;\n-\t\tif (!oid_object_info_extended(the_repository, &ce->oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &ce->oid, NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &ce->oid);\n \t}\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 4ce45440ad1..f9f2c512a8c 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2302,8 +2302,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj\n \t\toi->info.sizep = &oi->size;\n \t\toi->info.typep = &oi->type;\n \t}\n-\tif (oid_object_info_extended(the_repository, &oi->oid, &oi->info,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\tif (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\treturn strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n \t\t\t\t       oid_to_hex(&oi->oid), ref->refname);\n \tif (oi->info.disk_sizep && oi->disk_size < 0)\ndiff --git a/remote.c b/remote.c\nindex 17a842f5684..72c36239d31 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1182,7 +1182,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,\n \t\tBUG(\"'%s' is not a valid object, \"\n \t\t    \"match_explicit_lhs() should catch this!\",\n \t\t    matched_src_name);\n-\ttype = oid_object_info(the_repository, &oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \tif (type == OBJ_COMMIT) {\n \t\tadvise(_(\"The <src> part of the refspec is a commit object.\\n\"\n \t\t\t \"Did you mean to create a new branch by pushing to\\n\"\n@@ -1412,7 +1412,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &ref->new_oid, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\ndiff --git a/sequencer.c b/sequencer.c\nindex 35f4e68d59f..bb012a4bfd9 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5502,9 +5502,8 @@ int sequencer_pick_revisions(struct repository *r,\n \n \t\tif (!repo_get_oid(r, name, &oid)) {\n \t\t\tif (!lookup_commit_reference_gently(r, &oid, 1)) {\n-\t\t\t\tenum object_type type = oid_object_info(r,\n-\t\t\t\t\t\t\t\t\t&oid,\n-\t\t\t\t\t\t\t\t\tNULL);\n+\t\t\t\tenum object_type type = odb_read_object_info(r->objects,\n+\t\t\t\t\t\t\t\t\t     &oid, NULL);\n \t\t\t\tres = error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\t    name, type_name(type));\n \t\t\t\tgoto out;\ndiff --git a/streaming.c b/streaming.c\nindex 29cc877f22a..032f134dc10 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -44,7 +44,7 @@ struct git_istream {\n \n \tunion {\n \t\tstruct {\n-\t\t\tchar *buf; /* from oid_object_info_extended() */\n+\t\t\tchar *buf; /* from odb_read_object_info_extended() */\n \t\t\tunsigned long read_ptr;\n \t\t} incore;\n \n@@ -403,8 +403,8 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,\n \toi.typep = type;\n \toi.sizep = &st->size;\n \toi.contentp = (void **)&st->u.incore.buf;\n-\treturn oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t\tOBJECT_INFO_DIE_IF_CORRUPT);\n+\treturn odb_read_object_info_extended(r->objects, oid, &oi,\n+\t\t\t\t\t     OBJECT_INFO_DIE_IF_CORRUPT);\n }\n \n /*****************************************************************************\n@@ -422,7 +422,7 @@ static int istream_source(struct git_istream *st,\n \n \toi.typep = type;\n \toi.sizep = &size;\n-\tstatus = oid_object_info_extended(r, oid, &oi, 0);\n+\tstatus = odb_read_object_info_extended(r->objects, oid, &oi, 0);\n \tif (status < 0)\n \t\treturn status;\n \ndiff --git a/submodule.c b/submodule.c\nindex 788c9e55ed3..f8373a9ea7d 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -968,7 +968,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n \t\treturn 0;\n \t}\n \n-\ttype = oid_object_info(&subrepo, oid, NULL);\n+\ttype = odb_read_object_info(subrepo.objects, oid, NULL);\n \n \tswitch (type) {\n \tcase OBJ_COMMIT:\n@@ -1752,8 +1752,7 @@ static int fetch_start_failure(struct strbuf *err UNUSED,\n static int commit_missing_in_sub(const struct object_id *oid, void *data)\n {\n \tstruct repository *subrepo = data;\n-\n-\tenum object_type type = oid_object_info(subrepo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(subrepo->objects, oid, NULL);\n \n \treturn type != OBJ_COMMIT;\n }\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex dba227259a2..d8488007493 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -23,7 +23,7 @@ static void object_info(const char *gitdir, const char *oid_hex)\n \t\tdie(\"could not init repo\");\n \tif (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo))\n \t\tdie(\"could not parse oid\");\n-\tif (oid_object_info_extended(&r, &oid, &oi, 0))\n+\tif (odb_read_object_info_extended(r.objects, &oid, &oi, 0))\n \t\tdie(\"could not obtain object info\");\n \tprintf(\"%d\\n\", (int) size);\n \ndiff --git a/tag.c b/tag.c\nindex 5f6868bf7b1..144048fd5e0 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \tunsigned long size;\n \tint ret;\n \n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517325","messageId":"20250506-pks-object-store-wo-the-repository-v1-14-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 14/17] odb: rename `repo_read_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:27Z","receivedAt":"2025-05-06T11:09:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `repo_read_object_file()` to `odb_read_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  | 10 +++++-----\n archive.c                |  2 +-\n attr.c                   |  2 +-\n bisect.c                 |  6 +++---\n blame.c                  | 13 ++++++-------\n builtin/cat-file.c       | 26 +++++++++++---------------\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  6 +++---\n builtin/fast-import.c    |  8 ++++----\n builtin/grep.c           |  8 ++++----\n builtin/index-pack.c     |  8 ++++----\n builtin/log.c            |  2 +-\n builtin/merge-tree.c     | 12 ++++++------\n builtin/mktag.c          |  4 ++--\n builtin/notes.c          |  6 +++---\n builtin/pack-objects.c   | 30 +++++++++++++++---------------\n builtin/tag.c            |  4 ++--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c |  4 ++--\n bundle.c                 |  2 +-\n combine-diff.c           |  2 +-\n commit.c                 |  6 +++---\n config.c                 |  2 +-\n dir.c                    |  2 +-\n entry.c                  |  4 ++--\n fmt-merge-msg.c          |  4 ++--\n fsck.c                   |  2 +-\n grep.c                   |  4 ++--\n http-push.c              |  4 ++--\n mailmap.c                |  2 +-\n match-trees.c            |  4 ++--\n merge-blobs.c            |  8 ++++----\n merge-ort.c              |  2 +-\n notes-cache.c            |  2 +-\n notes-merge.c            |  2 +-\n notes.c                  | 13 +++++++------\n object.c                 |  2 +-\n odb.c                    | 19 +++++++------------\n odb.h                    | 29 +++++++++++++++++++++++------\n read-cache.c             |  6 +++---\n reflog.c                 |  4 ++--\n rerere.c                 |  5 ++---\n submodule-config.c       |  4 ++--\n tag.c                    |  6 +++---\n tree-walk.c              |  6 +++---\n tree.c                   |  4 ++--\n xdiff-interface.c        |  2 +-\n 47 files changed, 157 insertions(+), 150 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 879f04df31e..56cd0540350 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3210,8 +3210,8 @@ static int apply_binary(struct apply_state *state,\n \t\tunsigned long size;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t       &size);\n+\t\tresult = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t\t &type, &size);\n \t\tif (!result)\n \t\t\treturn error(_(\"the necessary postimage %s for \"\n \t\t\t\t       \"'%s' cannot be read\"),\n@@ -3273,8 +3273,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tunsigned long sz;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t       &sz);\n+\t\tresult = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t &type, &sz);\n \t\tif (!result)\n \t\t\treturn -1;\n \t\t/* XXX read_sha1_file NUL-terminates */\n@@ -3503,7 +3503,7 @@ static int resolve_to(struct image *image, const struct object_id *result_id)\n \n \timage_clear(image);\n \n-\tdata = repo_read_object_file(the_repository, result_id, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, result_id, &type, &size);\n \tif (!data || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(result_id));\n \tstrbuf_attach(&image->buf, data, size, size + 1);\ndiff --git a/archive.c b/archive.c\nindex f2511d530d5..f5a9d45c8d3 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -98,7 +98,7 @@ static void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t       (args->tree ? &args->tree->object.oid : NULL), oid);\n \n \tpath += args->baselen;\n-\tbuffer = repo_read_object_file(the_repository, oid, type, sizep);\n+\tbuffer = odb_read_object(the_repository->objects, oid, type, sizep);\n \tif (buffer && S_ISREG(mode)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tsize_t size = 0;\ndiff --git a/attr.c b/attr.c\nindex e5680db7f65..d1daeb0b4d9 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -779,7 +779,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,\n \tif (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))\n \t\treturn NULL;\n \n-\tbuf = repo_read_object_file(istate->repo, &oid, &type, &sz);\n+\tbuf = odb_read_object(istate->repo->objects, &oid, &type, &sz);\n \tif (!buf || type != OBJ_BLOB) {\n \t\tfree(buf);\n \t\treturn NULL;\ndiff --git a/bisect.c b/bisect.c\nindex a7939216d00..f24474542ec 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -155,9 +155,9 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tunsigned commit_flags = commit->object.flags;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &commit->object.oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &commit->object.oid, &type,\n+\t\t\t\t\t    &size);\n \t\tconst char *subject_start;\n \t\tint subject_len;\n \ndiff --git a/blame.c b/blame.c\nindex 97db3355af4..858d2d74df9 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1041,9 +1041,9 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\t\t\t    &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n-\t\t\tfile->ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t  &o->blob_oid, &type,\n-\t\t\t\t\t\t\t  &file_size);\n+\t\t\tfile->ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t    &o->blob_oid, &type,\n+\t\t\t\t\t\t    &file_size);\n \t\tfile->size = file_size;\n \n \t\tif (!file->ptr)\n@@ -2869,10 +2869,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\n \t\telse\n-\t\t\tsb->final_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &o->blob_oid,\n-\t\t\t\t\t\t\t      &type,\n-\t\t\t\t\t\t\t      &sb->final_buf_size);\n+\t\t\tsb->final_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&o->blob_oid, &type,\n+\t\t\t\t\t\t\t&sb->final_buf_size);\n \n \t\tif (!sb->final_buf)\n \t\t\tdie(_(\"cannot read blob %s for path %s\"),\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex da172155c85..d6b9afca06e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -74,7 +74,7 @@ static int filter_object(const char *path, unsigned mode,\n {\n \tenum object_type type;\n \n-\t*buf = repo_read_object_file(the_repository, oid, &type, size);\n+\t*buf = odb_read_object(the_repository->objects, oid, &type, size);\n \tif (!*buf)\n \t\treturn error(_(\"cannot read object %s '%s'\"),\n \t\t\t     oid_to_hex(oid), path);\n@@ -206,8 +206,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\tret = stream_blob(&oid);\n \t\t\tgoto cleanup;\n \t\t}\n-\t\tbuf = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t      &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"Cannot read object %s\", obj_name);\n \n@@ -228,10 +228,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\tstruct object_id blob_oid;\n \t\t\tif (odb_read_object_info(the_repository->objects,\n \t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n-\t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t     &oid,\n-\t\t\t\t\t\t\t\t     &type,\n-\t\t\t\t\t\t\t\t     &size);\n+\t\t\t\tchar *buffer = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t       &oid, &type, &size);\n \t\t\t\tconst char *target;\n \n \t\t\t\tif (!buffer)\n@@ -412,10 +410,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\t\tif (!textconv_object(the_repository,\n \t\t\t\t\t\t     data->rest, 0100644, oid,\n \t\t\t\t\t\t     1, &contents, &size))\n-\t\t\t\t\tcontents = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t\t oid,\n-\t\t\t\t\t\t\t\t\t &type,\n-\t\t\t\t\t\t\t\t\t &size);\n+\t\t\t\t\tcontents = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t\t   oid, &type, &size);\n \t\t\t\tif (!contents)\n \t\t\t\t\tdie(\"could not convert '%s' %s\",\n \t\t\t\t\t    oid_to_hex(oid), data->rest);\n@@ -432,8 +428,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\tunsigned long size;\n \t\tvoid *contents;\n \n-\t\tcontents = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t &size);\n+\t\tcontents = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &type, &size);\n \t\tif (!contents)\n \t\t\tdie(\"object %s disappeared\", oid_to_hex(oid));\n \n@@ -542,8 +538,8 @@ static void batch_object_write(const char *obj_name,\n \t\t\tsize_t s = data->size;\n \t\t\tchar *buf = NULL;\n \n-\t\t\tbuf = repo_read_object_file(the_repository, &data->oid, &data->type,\n-\t\t\t\t\t\t    &data->size);\n+\t\t\tbuf = odb_read_object(the_repository->objects, &data->oid,\n+\t\t\t\t\t      &data->type, &data->size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"), oid_to_hex(&data->oid));\n \t\t\tbuf = replace_idents_using_mailmap(buf, &s);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex fac613e3bc3..e4bc1f83169 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -320,7 +320,7 @@ static char *get_symlink(struct repository *repo,\n \t} else {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tdata = repo_read_object_file(repo, oid, &type, &size);\n+\t\tdata = odb_read_object(repo->objects, oid, &type, &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\n \t\t\t\toid_to_hex(oid), path);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 6c93cf0a8aa..33f304dd0ad 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -323,7 +323,7 @@ static void export_blob(const struct object_id *oid)\n \t\tobject = (struct object *)lookup_blob(the_repository, oid);\n \t\teaten = 0;\n \t} else {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"could not read blob %s\", oid_to_hex(oid));\n \t\tif (check_object_signature(the_repository, oid, buf, size,\n@@ -869,8 +869,8 @@ static void handle_tag(const char *name, struct tag *tag)\n \t\treturn;\n \t}\n \n-\tbuf = repo_read_object_file(the_repository, &tag->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(\"could not read tag %s\", oid_to_hex(&tag->object.oid));\n \tmessage = memmem(buf, size, \"\\n\\n\", 2);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 2718376f2c9..1973c504e25 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf || type != OBJ_TREE)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t}\n@@ -3002,7 +3002,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \tchar *buf;\n \n \tif (!oe || oe->pack_id == MAX_PACK_ID) {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t} else {\n \t\ttype = oe->type;\n \t\tbuf = gfi_unpack_entry(oe, &size);\n@@ -3110,8 +3110,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \t\tbuf = gfi_unpack_entry(oe, &size);\n \t} else {\n \t\tenum object_type unused;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &unused,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t      &unused, &size);\n \t}\n \tif (!buf)\n \t\tdie(\"Can't load object %s\", oid_to_hex(oid));\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 83da86405fa..45681579b6d 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -573,8 +573,8 @@ static int grep_cache(struct grep_opt *opt,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t     &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t       &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree %s\"), oid_to_hex(&ce->oid));\n \t\t\tinit_tree_desc(&tree, &ce->oid, data, size);\n@@ -666,8 +666,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry.oid, &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry.oid, &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree (%s)\"),\n \t\t\t\t    oid_to_hex(&entry.oid));\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 82cf80b89d1..d33392cab65 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -914,8 +914,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), oid_to_hex(oid));\n-\t\thas_data = repo_read_object_file(the_repository, oid,\n-\t\t\t\t\t\t &has_type, &has_size);\n+\t\thas_data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &has_type, &has_size);\n \t\tread_unlock();\n \t\tif (!data)\n \t\t\tdata = new_data = get_data_from_pack(obj_entry);\n@@ -1515,8 +1515,8 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \n \t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n-\t\tdata = repo_read_object_file(the_repository, &d->oid, &type,\n-\t\t\t\t\t     &size);\n+\t\tdata = odb_read_object(the_repository->objects, &d->oid,\n+\t\t\t\t       &type, &size);\n \t\tif (!data)\n \t\t\tcontinue;\n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex fe9cc5ebecb..f2040b18159 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -714,7 +714,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tunsigned long offset = 0;\n \n \tif (!buf)\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 709ae3966a6..21fb0b2df1d 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -75,9 +75,9 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \tconst char *path = entry->path;\n \n \tif (!entry->stage)\n-\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t     &entry->blob->object.oid, &type,\n-\t\t\t\t\t     size);\n+\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t       &entry->blob->object.oid, &type,\n+\t\t\t\t       size);\n \tbase = NULL;\n \tif (entry->stage == 1) {\n \t\tbase = entry->blob;\n@@ -100,9 +100,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)\n \tenum object_type type;\n \twhile (entry) {\n \t\tif (entry->stage == 2)\n-\t\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry->blob->object.oid,\n-\t\t\t\t\t\t     &type, size);\n+\t\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry->blob->object.oid,\n+\t\t\t\t\t       &type, size);\n \t\tentry = entry->link;\n \t}\n \treturn NULL;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 1809b38f937..1b391119de8 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -54,8 +54,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)\n \tvoid *buffer;\n \tconst struct object_id *repl;\n \n-\tbuffer = repo_read_object_file(the_repository, tagged_oid, &type,\n-\t\t\t\t       &size);\n+\tbuffer = odb_read_object(the_repository->objects, tagged_oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\tdie(_(\"could not read tagged object '%s'\"),\n \t\t    oid_to_hex(tagged_oid));\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 783d4932ca6..a9529b1696a 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -152,7 +152,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (buf) {\n \t\tif (size)\n \t\t\twrite_or_die(fd, buf, size);\n@@ -319,7 +319,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tstrbuf_init(&msg->buf, 0);\n \tif (repo_get_oid(the_repository, arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(value = repo_read_object_file(the_repository, &object, &type, &len)))\n+\tif (!(value = odb_read_object(the_repository->objects, &object, &type, &len)))\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n \tif (type != OBJ_BLOB) {\n \t\tstrbuf_release(&msg->buf);\n@@ -722,7 +722,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,\n \t\tunsigned long size;\n \t\tenum object_type type;\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tchar *prev_buf = repo_read_object_file(the_repository, note, &type, &size);\n+\t\tchar *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \t\tif (!prev_buf)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(note));\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex da35d684081..580a5c1996b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -337,13 +337,13 @@ static void *get_delta(struct object_entry *entry)\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &entry->idx.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &entry->idx.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(_(\"unable to read %s\"), oid_to_hex(&entry->idx.oid));\n-\tbase_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t &DELTA(entry)->idx.oid, &type,\n-\t\t\t\t\t &base_size);\n+\tbase_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t   &DELTA(entry)->idx.oid, &type,\n+\t\t\t\t   &base_size);\n \tif (!base_buf)\n \t\tdie(\"unable to read %s\",\n \t\t    oid_to_hex(&DELTA(entry)->idx.oid));\n@@ -506,9 +506,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \t\t\t\t       &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n-\t\t\tbuf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t    &entry->idx.oid, &type,\n-\t\t\t\t\t\t    &size);\n+\t\t\tbuf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t      &entry->idx.oid, &type,\n+\t\t\t\t\t      &size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&entry->idx.oid));\n@@ -1895,7 +1895,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \t/* Did not find one.  Either we got a bogus request or\n \t * we need to read and perhaps cache.\n \t */\n-\tdata = repo_read_object_file(the_repository, oid, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!data)\n \t\treturn NULL;\n \tif (type != OBJ_TREE) {\n@@ -2762,9 +2762,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t/* Load data if not already done */\n \tif (!trg->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\ttrg->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &trg_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\ttrg->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &trg_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!trg->data)\n \t\t\tdie(_(\"object %s cannot be read\"),\n@@ -2777,9 +2777,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t}\n \tif (!src->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tsrc->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &src_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\tsrc->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &src_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!src->data) {\n \t\t\tif (src_entry->preferred_base) {\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex e0b27396c6b..46cbf892e34 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -244,7 +244,7 @@ static void write_tag_body(int fd, const struct object_id *oid)\n \tstruct strbuf payload = STRBUF_INIT;\n \tstruct strbuf signature = STRBUF_INIT;\n \n-\torig = buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\torig = buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn;\n \tif (parse_signature(buf, size, &payload, &signature)) {\n@@ -407,7 +407,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {\n+\t\tif ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) {\n \t\t\tsubject_len = find_commit_subject(buf, &subject_start);\n \t\t\tstrbuf_insert(sb, sb->len, subject_start, subject_len);\n \t\t} else {\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex b92fd4710a9..4360872ae07 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -14,7 +14,7 @@ static char *create_temp_file(struct object_id *oid)\n \tunsigned long size;\n \tint fd;\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 405e78bc592..4bc6575a574 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -516,8 +516,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \tif (resolve_against_held(nr, &base_oid, delta_data, delta_size))\n \t\treturn;\n \n-\tbase = repo_read_object_file(the_repository, &base_oid, &type,\n-\t\t\t\t     &base_size);\n+\tbase = odb_read_object(the_repository->objects, &base_oid,\n+\t\t\t       &type, &base_size);\n \tif (!base) {\n \t\terror(\"failed to read delta-pack base object %s\",\n \t\t      oid_to_hex(&base_oid));\ndiff --git a/bundle.c b/bundle.c\nindex 90c8ec4166a..cca561308a0 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -305,7 +305,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n \tif (revs->max_age == -1 && revs->min_age == -1)\n \t\tgoto out;\n \n-\tbuf = repo_read_object_file(the_repository, &tag->oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->oid, &type, &size);\n \tif (!buf)\n \t\tgoto out;\n \tline = memmem(buf, size, \"\\ntagger \", 8);\ndiff --git a/combine-diff.c b/combine-diff.c\nindex cf23a753407..4ea2dc93c4f 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -325,7 +325,7 @@ static char *grab_blob(struct repository *r,\n \t\t*size = fill_textconv(r, textconv, df, &blob);\n \t\tfree_filespec(df);\n \t} else {\n-\t\tblob = repo_read_object_file(r, oid, &type, size);\n+\t\tblob = odb_read_object(r->objects, oid, &type, size);\n \t\tif (!blob)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(oid));\n \t\tif (type != OBJ_BLOB)\ndiff --git a/commit.c b/commit.c\nindex d4aa9c7a5f8..28ee6b73ae6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -374,7 +374,7 @@ const void *repo_get_commit_buffer(struct repository *r,\n \tif (!ret) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n+\t\tret = odb_read_object(r->objects, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n \t\t\t    oid_to_hex(&commit->object.oid));\n@@ -1275,8 +1275,8 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h\n \tdesc = merge_remote_util(parent);\n \tif (!desc || !desc->obj)\n \t\treturn;\n-\tbuf = repo_read_object_file(the_repository, &desc->obj->oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &desc->obj->oid,\n+\t\t\t      &type, &size);\n \tif (!buf || type != OBJ_TAG)\n \t\tgoto free_return;\n \tif (!parse_signature(buf, size, &payload, &signature))\ndiff --git a/config.c b/config.c\nindex 883dd066827..142c37215a8 100644\n--- a/config.c\n+++ b/config.c\n@@ -1942,7 +1942,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n \tunsigned long size;\n \tint ret;\n \n-\tbuf = repo_read_object_file(repo, oid, &type, &size);\n+\tbuf = odb_read_object(repo->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(_(\"unable to load config blob object '%s'\"), name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/dir.c b/dir.c\nindex e11342e1366..251dedf1f5e 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -302,7 +302,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t*size_out = 0;\n \t*data_out = NULL;\n \n-\tdata = repo_read_object_file(the_repository, oid, &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn -1;\ndiff --git a/entry.c b/entry.c\nindex 75d55038d7c..cae02eb5039 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -93,8 +93,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tunsigned long ul;\n-\tvoid *blob_data = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t&type, &ul);\n+\tvoid *blob_data = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t  &type, &ul);\n \n \t*size = ul;\n \tif (blob_data) {\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 1a8c972adf3..40174efa3de 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -526,8 +526,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t    &type, &size);\n \t\tchar *origbuf = buf;\n \t\tunsigned long len = size;\n \t\tstruct signature_check sigc = { NULL };\ndiff --git a/fsck.c b/fsck.c\nindex e69baab3af7..23965e1880f 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1293,7 +1293,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,\n \t\tif (oidset_contains(blobs_done, oid))\n \t\t\tcontinue;\n \n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf) {\n \t\t\tif (is_promisor_object(the_repository, oid))\n \t\t\t\tcontinue;\ndiff --git a/grep.c b/grep.c\nindex dc77e6c4631..932647e4a65 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1931,8 +1931,8 @@ static int grep_source_load_oid(struct grep_source *gs)\n {\n \tenum object_type type;\n \n-\tgs->buf = repo_read_object_file(gs->repo, gs->identifier, &type,\n-\t\t\t\t\t&gs->size);\n+\tgs->buf = odb_read_object(gs->repo->objects, gs->identifier,\n+\t\t\t\t  &type, &gs->size);\n \tif (!gs->buf)\n \t\treturn error(_(\"'%s': unable to read %s\"),\n \t\t\t     gs->name,\ndiff --git a/http-push.c b/http-push.c\nindex d1b1bb23711..9481825abfb 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -369,8 +369,8 @@ static void start_put(struct transfer_request *request)\n \tssize_t size;\n \tgit_zstream stream;\n \n-\tunpacked = repo_read_object_file(the_repository, &request->obj->oid,\n-\t\t\t\t\t &type, &len);\n+\tunpacked = odb_read_object(the_repository->objects, &request->obj->oid,\n+\t\t\t\t   &type, &len);\n \thdrlen = format_object_header(hdr, sizeof(hdr), type, len);\n \n \t/* Set it up */\ndiff --git a/mailmap.c b/mailmap.c\nindex b18e74c2110..56c72102d9e 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -196,7 +196,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \tif (repo_get_oid(the_repository, name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = repo_read_object_file(the_repository, &oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/match-trees.c b/match-trees.c\nindex 4704f95c340..5a8a5c39b04 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -63,7 +63,7 @@ static void *fill_tree_desc_strict(struct repository *r,\n \tenum object_type type;\n \tunsigned long size;\n \n-\tbuffer = repo_read_object_file(r, hash, &type, &size);\n+\tbuffer = odb_read_object(r->objects, hash, &type, &size);\n \tif (!buffer)\n \t\tdie(\"unable to read tree (%s)\", oid_to_hex(hash));\n \tif (type != OBJ_TREE)\n@@ -199,7 +199,7 @@ static int splice_tree(struct repository *r,\n \tif (*subpath)\n \t\tsubpath++;\n \n-\tbuf = repo_read_object_file(r, oid1, &type, &sz);\n+\tbuf = odb_read_object(r->objects, oid1, &type, &sz);\n \tif (!buf)\n \t\tdie(\"cannot read tree %s\", oid_to_hex(oid1));\n \tinit_tree_desc(&desc, oid1, buf, sz);\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex ba8a3fdfd82..6fc27994171 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -12,8 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n \tunsigned long size;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &obj->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &obj->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\treturn -1;\n \tif (type != OBJ_BLOB) {\n@@ -79,8 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path,\n \t\t\treturn NULL;\n \t\tif (!our)\n \t\t\tour = their;\n-\t\treturn repo_read_object_file(the_repository, &our->object.oid,\n-\t\t\t\t\t     &type, size);\n+\t\treturn odb_read_object(the_repository->objects, &our->object.oid,\n+\t\t\t\t       &type, size);\n \t}\n \n \tif (fill_mmfile_blob(&f1, our) < 0)\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 5d4501085e9..53417d399c7 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -3624,7 +3624,7 @@ static int read_oid_strbuf(struct merge_options *opt,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf) {\n \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n \t\t\t path, NULL, NULL, NULL,\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 344f67762b8..dd56feed6e8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -87,7 +87,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\n \t\treturn NULL;\n-\tvalue = repo_read_object_file(the_repository, value_oid, &type, &size);\n+\tvalue = odb_read_object(the_repository->objects, value_oid, &type, &size);\n \n \t*outsize = size;\n \treturn value;\ndiff --git a/notes-merge.c b/notes-merge.c\nindex de6a52e2e7f..586939939f2 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -340,7 +340,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n {\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buf = repo_read_object_file(the_repository, note, &type, &size);\n+\tvoid *buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"cannot read note %s for object %s\",\ndiff --git a/notes.c b/notes.c\nindex fc000e501d2..73eb5f00cf5 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -816,15 +816,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \n \t/* read in both note blob objects */\n \tif (!is_null_oid(new_oid))\n-\t\tnew_msg = repo_read_object_file(the_repository, new_oid,\n-\t\t\t\t\t\t&new_type, &new_len);\n+\t\tnew_msg = odb_read_object(the_repository->objects, new_oid,\n+\t\t\t\t\t  &new_type, &new_len);\n \tif (!new_msg || !new_len || new_type != OBJ_BLOB) {\n \t\tfree(new_msg);\n \t\treturn 0;\n \t}\n \tif (!is_null_oid(cur_oid))\n-\t\tcur_msg = repo_read_object_file(the_repository, cur_oid,\n-\t\t\t\t\t\t&cur_type, &cur_len);\n+\t\tcur_msg = odb_read_object(the_repository->objects, cur_oid,\n+\t\t\t\t\t  &cur_type, &cur_len);\n \tif (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {\n \t\tfree(cur_msg);\n \t\tfree(new_msg);\n@@ -880,7 +880,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\treturn 0;\n \n \t/* read_sha1_file NUL-terminates */\n-\tdata = repo_read_object_file(the_repository, oid, &t, &len);\n+\tdata = odb_read_object(the_repository->objects, oid, &t, &len);\n \tif (t != OBJ_BLOB || !data || !len) {\n \t\tfree(data);\n \t\treturn t != OBJ_BLOB || !data;\n@@ -1290,7 +1290,8 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tif (!oid)\n \t\treturn;\n \n-\tif (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {\n+\tif (!(msg = odb_read_object(the_repository->objects, oid, &type, &msglen)) ||\n+\t    type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn;\n \t}\ndiff --git a/object.c b/object.c\nindex 868d89eed42..c1553ee4330 100644\n--- a/object.c\n+++ b/object.c\n@@ -335,7 +335,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \n-\tbuffer = repo_read_object_file(r, oid, &type, &size);\n+\tbuffer = odb_read_object(r->objects, oid, &type, &size);\n \tif (buffer) {\n \t\tif (!skip_hash &&\n \t\t    check_object_signature(r, repl, buffer, size, type) < 0) {\ndiff --git a/odb.c b/odb.c\nindex 919b8772f86..4a8b7e7df56 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -30,7 +30,7 @@ KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n- * want repo_read_object_file() to be able to return, but yet you do not want\n+ * want odb_read_object() to be able to return, but yet you do not want\n  * to write them into the object store (e.g. a browse-only\n  * application).\n  */\n@@ -896,15 +896,10 @@ int pretend_object_file(struct repository *repo,\n \treturn 0;\n }\n \n-/*\n- * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call odb_read_object_info_extended() and give\n- * error messages themselves.\n- */\n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size)\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tunsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE;\n@@ -913,7 +908,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(odb, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -935,7 +930,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = repo_read_object_file(r, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\ndiff --git a/odb.h b/odb.h\nindex 2613f2c6c03..6b5286a8bd6 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -128,7 +128,7 @@ struct object_database {\n \n \t/*\n \t * This is meant to hold a *small* number of objects that you would\n-\t * want repo_read_object_file() to be able to return, but yet you do not want\n+\t * want odb_read_object() to be able to return, but yet you do not want\n \t * to write them into the object store (e.g. a browse-only\n \t * application).\n \t */\n@@ -247,10 +247,19 @@ void odb_add_to_alternates_file(struct object_database *odb,\n void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t\t  const char *dir);\n \n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size);\n+/*\n+ * Read an object from the database. Returns the object data and assigns object\n+ * type and size to the `type` and `size` pointers, if these pointers are\n+ * non-NULL. Returns a `NULL` pointer in case the object does not exist.\n+ *\n+ * This function dies on corrupt objects; the callers who want to deal with\n+ * them should arrange to call odb_read_object_info_extended() and give error\n+ * messages themselves.\n+ */\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size);\n \n /*\n  * Add an object file to the in-memory object store, without writing it\n@@ -361,7 +370,7 @@ void odb_assert_oid_type(struct object_database *odb,\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n- * following functions in parallel: repo_read_object_file(),\n+ * following functions in parallel: odb_read_object(),\n  * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n@@ -436,4 +445,12 @@ static inline int oid_object_info(struct repository *r,\n \treturn odb_read_object_info(r->objects, oid, sizep);\n }\n \n+static inline void *repo_read_object_file(struct repository *r,\n+\t\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t\t  enum object_type *type,\n+\t\t\t\t\t  unsigned long *size)\n+{\n+\treturn odb_read_object(r->objects, oid, type, size);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/read-cache.c b/read-cache.c\nindex be664f857b4..46986798a38 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -254,7 +254,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n \tif (strbuf_readlink(&sb, ce->name, expected_size))\n \t\treturn -1;\n \n-\tbuffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &ce->oid, &type, &size);\n \tif (buffer) {\n \t\tif (size == sb.len)\n \t\t\tmatch = memcmp(buffer, sb.buf, size);\n@@ -3514,8 +3514,8 @@ void *read_blob_data_from_index(struct index_state *istate,\n \t}\n \tif (pos < 0)\n \t\treturn NULL;\n-\tdata = repo_read_object_file(the_repository, &istate->cache[pos]->oid,\n-\t\t\t\t     &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, &istate->cache[pos]->oid,\n+\t\t\t       &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn NULL;\ndiff --git a/reflog.c b/reflog.c\nindex 4f8a3b717cd..747b82eada8 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -140,8 +140,8 @@ static int tree_is_complete(const struct object_id *oid)\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t   &size);\n+\t\tvoid *data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t     &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\treturn 0;\ndiff --git a/rerere.c b/rerere.c\nindex 951e4bf8b41..8bb97c98229 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -1000,9 +1000,8 @@ static int handle_cache(struct index_state *istate,\n \t\t\tbreak;\n \t\ti = ce_stage(ce) - 1;\n \t\tif (!mmfile[i].ptr) {\n-\t\t\tmmfile[i].ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &ce->oid, &type,\n-\t\t\t\t\t\t\t      &size);\n+\t\t\tmmfile[i].ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&ce->oid, &type, &size);\n \t\t\tif (!mmfile[i].ptr)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&ce->oid));\ndiff --git a/submodule-config.c b/submodule-config.c\nindex ed4bb32dc37..c13d60d217b 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -743,8 +743,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \tif (submodule)\n \t\tgoto out;\n \n-\tconfig = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t       &config_size);\n+\tconfig = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t &type, &config_size);\n \tif (!config || type != OBJ_BLOB)\n \t\tgoto out;\n \ndiff --git a/tag.c b/tag.c\nindex 144048fd5e0..1d52686ee10 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -60,7 +60,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\t\t\trepo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),\n \t\t\t\ttype_name(type));\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n@@ -222,8 +222,8 @@ int parse_tag(struct tag *item)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tdata = repo_read_object_file(the_repository, &item->object.oid, &type,\n-\t\t\t\t     &size);\n+\tdata = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t       &type, &size);\n \tif (!data)\n \t\treturn error(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 34b0fff4873..766af99f466 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -795,9 +795,9 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\t */\n \t\t\tretval = DANGLING_SYMLINK;\n \n-\t\t\tcontents = repo_read_object_file(r,\n-\t\t\t\t\t\t    &current_tree_oid, &type,\n-\t\t\t\t\t\t    &link_len);\n+\t\t\tcontents = odb_read_object(r->objects,\n+\t\t\t\t\t\t   &current_tree_oid, &type,\n+\t\t\t\t\t\t   &link_len);\n \n \t\t\tif (!contents)\n \t\t\t\tgoto done;\ndiff --git a/tree.c b/tree.c\nindex 341b7c2ff3f..1ef743d90f4 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -193,8 +193,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tbuffer = repo_read_object_file(the_repository, &item->object.oid,\n-\t\t\t\t       &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 01e6e378ea6..0e5d38c9600 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -187,7 +187,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n \t\treturn;\n \t}\n \n-\tptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);\n+\tptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!ptr->ptr || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \tptr->size = size;\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517326","messageId":"20250506-pks-object-store-wo-the-repository-v1-15-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 15/17] odb: rename `has_object()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:28Z","receivedAt":"2025-05-06T11:09:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `has_object()` to `odb_has_object()` to match other functions\nrelated to the object database and our modern coding guidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  |  2 +-\n builtin/backfill.c       |  4 ++--\n builtin/cat-file.c       |  4 ++--\n builtin/clone.c          |  2 +-\n builtin/fetch.c          | 17 +++++++++--------\n builtin/fsck.c           |  2 +-\n builtin/index-pack.c     |  4 ++--\n builtin/pack-objects.c   |  4 ++--\n builtin/receive-pack.c   |  4 ++--\n builtin/remote.c         |  4 ++--\n builtin/show-ref.c       |  4 ++--\n builtin/unpack-objects.c |  4 ++--\n bulk-checkin.c           |  4 ++--\n cache-tree.c             | 15 ++++++++-------\n commit-graph.c           |  2 +-\n commit.c                 |  2 +-\n fetch-pack.c             |  8 ++++----\n http-push.c              | 14 ++++++++------\n http-walker.c            |  8 ++++----\n list-objects.c           |  4 ++--\n notes.c                  |  4 ++--\n odb.c                    |  6 +++---\n odb.h                    | 12 ++++++++++--\n reflog.c                 |  2 +-\n refs.c                   |  3 ++-\n remote.c                 |  2 +-\n send-pack.c              |  2 +-\n shallow.c                | 12 ++++++------\n upload-pack.c            |  2 +-\n walker.c                 |  4 ++--\n 30 files changed, 87 insertions(+), 74 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 56cd0540350..7fb56517649 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3204,7 +3204,7 @@ static int apply_binary(struct apply_state *state,\n \t\treturn 0; /* deletion patch */\n \t}\n \n-\tif (has_object(the_repository, &oid, 0)) {\n+\tif (odb_has_object(the_repository->objects, &oid, 0)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n \t\tunsigned long size;\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex 0b49baa39fa..80056abe473 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -67,8 +67,8 @@ static int fill_missing_blobs(const char *path UNUSED,\n \t\treturn 0;\n \n \tfor (size_t i = 0; i < list->nr; i++) {\n-\t\tif (!has_object(ctx->repo, &list->oid[i],\n-\t\t\t\tOBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_has_object(ctx->repo->objects, &list->oid[i],\n+\t\t\t\t    OBJECT_INFO_FOR_PREFETCH))\n \t\t\toid_array_append(&ctx->current_batch, &list->oid[i]);\n \t}\n \ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex d6b9afca06e..571b5cc2ad5 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -169,8 +169,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\tgoto cleanup;\n \n \tcase 'e':\n-\t\tret = !has_object(the_repository, &oid,\n-\t\t\t\t  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n+\t\tret = !odb_has_object(the_repository->objects, &oid,\n+\t\t\t\t      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n \t\tgoto cleanup;\n \n \tcase 'w':\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 3aabdf6570b..6d08abed37c 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -506,7 +506,7 @@ static void write_followtags(const struct ref *refs, const char *msg)\n \t\t\tcontinue;\n \t\tif (ends_with(ref->name, \"^{}\"))\n \t\t\tcontinue;\n-\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\tcontinue;\n \t\trefs_update_ref(get_main_ref_store(the_repository), msg,\n \t\t\t\tref->name, &ref->old_oid, NULL, 0,\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 851c0a9419e..8e1d30fc33e 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -366,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t */\n \t\tif (ends_with(ref->name, \"^{}\")) {\n \t\t\tif (item &&\n-\t\t\t    !has_object(the_repository, &ref->old_oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &ref->old_oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &ref->old_oid) &&\n-\t\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\t\tclear_item(item);\n \t\t\titem = NULL;\n@@ -382,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t * fetch.\n \t\t */\n \t\tif (item &&\n-\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\tclear_item(item);\n \n@@ -403,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t * checked to see if it needs fetching.\n \t */\n \tif (item &&\n-\t    !has_object(the_repository, &item->oid, 0) &&\n+\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t    !oidset_contains(&fetch_oids, &item->oid))\n \t\tclear_item(item);\n \n@@ -910,8 +910,8 @@ static int update_local_ref(struct ref *ref,\n \tstruct commit *current = NULL, *updated;\n \tint fast_forward = 0;\n \n-\tif (!has_object(the_repository, &ref->new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, &ref->new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \n \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n@@ -1330,7 +1330,8 @@ static int check_exist_and_connected(struct ref *ref_map)\n \t * we need all direct targets to exist.\n \t */\n \tfor (r = rm; r; r = r->next) {\n-\t\tif (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (!odb_has_object(the_repository->objects, &r->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED))\n \t\t\treturn -1;\n \t}\n \n@@ -1485,7 +1486,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)\n \t\t\tstruct object_id oid;\n \t\t\tif (repo_get_oid(the_repository, s, &oid))\n \t\t\t\tdie(_(\"%s is not a valid object\"), s);\n-\t\t\tif (!has_object(the_repository, &oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &oid, 0))\n \t\t\t\tdie(_(\"the object %s does not exist\"), s);\n \t\t\toid_array_append(oids, &oid);\n \t\t\tcontinue;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex f1da67eb26b..397abfa1216 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -161,7 +161,7 @@ static int mark_object(struct object *obj, enum object_type type,\n \t\treturn 0;\n \n \tif (!(obj->flags & HAS_OBJ)) {\n-\t\tif (parent && !has_object(the_repository, &obj->oid, 1)) {\n+\t\tif (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {\n \t\t\tprintf_ln(_(\"broken link from %7s %s\\n\"\n \t\t\t\t    \"              to %7s %s\"),\n \t\t\t\t  printable_type(&parent->oid, parent->type),\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d33392cab65..0aa2f099cbe 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -893,8 +893,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \n \tif (startup_info->have_repository) {\n \t\tread_lock();\n-\t\tcollision_test_needed = has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_FETCH_PROMISOR);\n+\t\tcollision_test_needed = odb_has_object(the_repository->objects, oid,\n+\t\t\t\t\t\t       HAS_OBJECT_FETCH_PROMISOR);\n \t\tread_unlock();\n \t}\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 580a5c1996b..06bdeb4223b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3968,7 +3968,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void\n \t * Quietly ignore ALL missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0))\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0))\n \t\treturn;\n \n \tshow_object(obj, name, data);\n@@ -3982,7 +3982,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,\n \t * Quietly ignore EXPECTED missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0) &&\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0) &&\n \t    is_promisor_object(to_pack.repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 8c157ea7d1b..27684dce3a4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1508,8 +1508,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \t}\n \n \tif (!is_null_oid(new_oid) &&\n-\t    !has_object(the_repository, new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(\"unpack should have generated %s, \"\n \t\t      \"but I can't find it!\", oid_to_hex(new_oid));\n \t\tret = \"bad pack\";\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex ac5b8d2a1a6..7cbda285ebe 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -454,8 +454,8 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \t\t\tinfo->status = PUSH_STATUS_UPTODATE;\n \t\telse if (is_null_oid(&ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_CREATE;\n-\t\telse if (has_object(the_repository, &ref->old_oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t\telse if (odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t\t\t ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_FASTFORWARD;\n \t\telse\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 90ec1de78f9..117709cb076 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -35,8 +35,8 @@ static void show_one(const struct show_one_options *opts,\n \tconst char *hex;\n \tstruct object_id peeled;\n \n-\tif (!has_object(the_repository, oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(\"git show-ref: bad ref %s (%s)\", refname,\n \t\t    oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 4bc6575a574..a69d59eb50c 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -449,8 +449,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\tdelta_data = get_data(delta_size);\n \t\tif (!delta_data)\n \t\t\treturn;\n-\t\tif (has_object(the_repository, &base_oid,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, &base_oid,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t; /* Ok we have this one */\n \t\telse if (resolve_against_held(nr, &base_oid,\n \t\t\t\t\t      delta_data, delta_size))\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 55406a539e7..16df86c0ba8 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -130,8 +130,8 @@ static void flush_batch_fsync(void)\n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n \t/* The object may already exist in the repository */\n-\tif (has_object(the_repository, oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 1;\n \n \t/* Might want to keep the list sorted */\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 9786b32b3a1..a4bc14ad15c 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -239,8 +239,8 @@ int cache_tree_fully_valid(struct cache_tree *it)\n \tif (!it)\n \t\treturn 0;\n \tif (it->entry_count < 0 ||\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0;\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tif (!cache_tree_fully_valid(it->down[i]->cache_tree))\n@@ -292,8 +292,8 @@ static int update_one(struct cache_tree *it,\n \t}\n \n \tif (0 <= it->entry_count &&\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn it->entry_count;\n \n \t/*\n@@ -399,8 +399,9 @@ static int update_one(struct cache_tree *it,\n \t\tce_missing_ok = mode == S_IFGITLINK || missing_ok ||\n \t\t\t!must_check_existence(ce);\n \t\tif (is_null_oid(oid) ||\n-\t\t    (!ce_missing_ok && !has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n+\t\t    (!ce_missing_ok &&\n+\t\t     !odb_has_object(the_repository->objects, oid,\n+\t\t\t\t     HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n \t\t\tstrbuf_release(&buffer);\n \t\t\tif (expected_missing)\n \t\t\t\treturn -1;\n@@ -448,7 +449,7 @@ static int update_one(struct cache_tree *it,\n \t\tstruct object_id oid;\n \t\thash_object_file(the_hash_algo, buffer.buf, buffer.len,\n \t\t\t\t OBJ_TREE, &oid);\n-\t\tif (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\toidcpy(&it->oid, &oid);\n \t\telse\n \t\t\tto_invalidate = 1;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 9c2740a8cab..1597b831d8c 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1040,7 +1040,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje\n \t\treturn NULL;\n \tif (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos))\n \t\treturn NULL;\n-\tif (commit_graph_paranoia && !has_object(repo, id, 0))\n+\tif (commit_graph_paranoia && !odb_has_object(repo->objects, id, 0))\n \t\treturn NULL;\n \n \tcommit = lookup_commit(repo, id);\ndiff --git a/commit.c b/commit.c\nindex 28ee6b73ae6..15115125c36 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -575,7 +575,7 @@ int repo_parse_commit_internal(struct repository *r,\n \t\tif (commit_graph_paranoia == -1)\n \t\t\tcommit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);\n \n-\t\tif (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {\n+\t\tif (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {\n \t\t\tunparse_commit(r, &item->object.oid);\n \t\t\treturn quiet_on_missing ? -1 :\n \t\t\t\terror(_(\"commit %s exists in commit-graph but not in the object database\"),\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 0f5de1c94d1..5e74235fc06 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -142,7 +142,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \tcommit = lookup_commit_in_graph(the_repository, oid);\n \tif (commit) {\n \t\tif (mark_tags_complete_and_check_obj_db) {\n-\t\t\tif (!has_object(the_repository, oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\t\t\tdie_in_commit_graph_only(oid);\n \t\t}\n \t\treturn commit;\n@@ -770,7 +770,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,\n \t\tif (!commit) {\n \t\t\tstruct object *o;\n \n-\t\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\t\tcontinue;\n \t\t\to = parse_object(the_repository, &ref->old_oid);\n \t\t\tif (!o || o->type != OBJ_COMMIT)\n@@ -1984,8 +1984,8 @@ static void update_shallow(struct fetch_pack_args *args,\n \t\tstruct oid_array extra = OID_ARRAY_INIT;\n \t\tstruct object_id *oid = si->shallow->oid;\n \t\tfor (i = 0; i < si->shallow->nr; i++)\n-\t\t\tif (has_object(the_repository, &oid[i],\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &oid[i],\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\toid_array_append(&extra, &oid[i]);\n \t\tif (extra.nr) {\n \t\t\tsetup_alternate_shallow(&shallow_lock,\ndiff --git a/http-push.c b/http-push.c\nindex 9481825abfb..beb41732fb6 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1447,8 +1447,8 @@ static void one_remote_ref(const char *refname)\n \t * may be required for updating server info later.\n \t */\n \tif (repo->can_update_info_refs &&\n-\t    !has_object(the_repository, &ref->old_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tobj = lookup_unknown_object(the_repository, &ref->old_oid);\n \t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n \t\t\toid_to_hex(&ref->old_oid), refname);\n@@ -1653,14 +1653,16 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t\treturn error(\"Remote HEAD symrefs too deep\");\n \t\tif (is_null_oid(&head_oid))\n \t\t\treturn error(\"Unable to resolve remote HEAD\");\n-\t\tif (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &head_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", oid_to_hex(&head_oid));\n \n \t\t/* Remote branch must resolve to a known object */\n \t\tif (is_null_oid(&remote_ref->old_oid))\n \t\t\treturn error(\"Unable to resolve remote branch %s\",\n \t\t\t\t     remote_ref->name);\n-\t\tif (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &remote_ref->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, oid_to_hex(&remote_ref->old_oid));\n \n \t\t/* Remote branch must be an ancestor of remote HEAD */\n@@ -1881,8 +1883,8 @@ int cmd_main(int argc, const char **argv)\n \t\tif (!force_all &&\n \t\t    !is_null_oid(&ref->old_oid) &&\n \t\t    !ref->force) {\n-\t\t\tif (!has_object(the_repository, &ref->old_oid,\n-\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t\t    !ref_newer(&ref->peer_ref->new_oid,\n \t\t\t\t       &ref->old_oid)) {\n \t\t\t\t/*\ndiff --git a/http-walker.c b/http-walker.c\nindex 12767e65a79..91a6de2126d 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -138,8 +138,8 @@ static int fill_active_slot(void *data UNUSED)\n \tlist_for_each_safe(pos, tmp, head) {\n \t\tobj_req = list_entry(pos, struct object_request, node);\n \t\tif (obj_req->state == WAITING) {\n-\t\t\tif (has_object(the_repository, &obj_req->oid,\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\tobj_req->state = COMPLETE;\n \t\t\telse {\n \t\t\t\tstart_object_request(obj_req);\n@@ -497,8 +497,8 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \tif (!obj_req)\n \t\treturn error(\"Couldn't find request for %s in the queue\", hex);\n \n-\tif (has_object(the_repository, &obj_req->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tif (obj_req->req)\n \t\t\tabort_http_object_request(&obj_req->req);\n \t\tabort_object_request(obj_req);\ndiff --git a/list-objects.c b/list-objects.c\nindex c50b9578584..42c17d95739 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -74,8 +74,8 @@ static void process_blob(struct traversal_context *ctx,\n \t * of missing objects.\n \t */\n \tif (ctx->revs->exclude_promisor_objects &&\n-\t    !has_object(the_repository, &obj->oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t    !odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t    is_promisor_object(ctx->revs->repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/notes.c b/notes.c\nindex 73eb5f00cf5..97b995f3f2d 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -794,8 +794,8 @@ static int prune_notes_helper(const struct object_id *object_oid,\n \tstruct note_delete_list **l = (struct note_delete_list **) cb_data;\n \tstruct note_delete_list *n;\n \n-\tif (has_object(the_repository, object_oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, object_oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0; /* nothing to do for this note */\n \n \t/* failed to find object => prune this note */\ndiff --git a/odb.c b/odb.c\nindex 4a8b7e7df56..e7c83d96361 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -880,7 +880,7 @@ int pretend_object_file(struct repository *repo,\n \tchar *co_buf;\n \n \thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (has_object(repo, oid, 0) ||\n+\tif (odb_has_object(repo->objects, oid, 0) ||\n \t    find_cached_object(repo->objects, oid))\n \t\treturn 0;\n \n@@ -962,7 +962,7 @@ void *read_object_with_reference(struct repository *r,\n \t}\n }\n \n-int has_object(struct repository *r, const struct object_id *oid,\n+int odb_has_object(struct object_database *odb, const struct object_id *oid,\n \t       unsigned flags)\n {\n \tunsigned object_info_flags = 0;\n@@ -974,7 +974,7 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\ndiff --git a/odb.h b/odb.h\nindex 6b5286a8bd6..fd4f1c55b6d 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -362,8 +362,9 @@ enum {\n  * Returns 1 if the object exists. This function will not lazily fetch objects\n  * in a partial clone by default.\n  */\n-int has_object(struct repository *r, const struct object_id *oid,\n-\t       unsigned flags);\n+int odb_has_object(struct object_database *odb,\n+\t\t   const struct object_id *oid,\n+\t\t   unsigned flags);\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect);\n@@ -453,4 +454,11 @@ static inline void *repo_read_object_file(struct repository *r,\n \treturn odb_read_object(r->objects, oid, type, size);\n }\n \n+static inline int has_object(struct repository *r,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     unsigned flags)\n+{\n+\treturn odb_has_object(r->objects, oid, flags);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/reflog.c b/reflog.c\nindex 747b82eada8..39c205fd26e 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -152,7 +152,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tinit_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size);\n \tcomplete = 1;\n \twhile (tree_entry(&desc, &entry)) {\n-\t\tif (!has_object(the_repository, &entry.oid,\n+\t\tif (!odb_has_object(the_repository->objects, &entry.oid,\n \t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/refs.c b/refs.c\nindex d91063bab09..567fff3cc34 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -376,7 +376,8 @@ int ref_resolves_to_object(const char *refname,\n {\n \tif (flags & REF_ISBROKEN)\n \t\treturn 0;\n-\tif (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (!odb_has_object(repo->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(_(\"%s does not point to a valid object!\"), refname);\n \t\treturn 0;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 72c36239d31..5edf2a9f4b2 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1703,7 +1703,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\tif (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {\n \t\t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n-\t\t\telse if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\t\telse if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n \t\t\telse if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||\n \t\t\t\t !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))\ndiff --git a/send-pack.c b/send-pack.c\nindex abca2dd38a7..d029f748232 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -45,7 +45,7 @@ int option_parse_push_signed(const struct option *opt,\n static void feed_object(struct repository *r,\n \t\t\tconst struct object_id *oid, FILE *fh, int negative)\n {\n-\tif (negative && !has_object(r, oid, 0))\n+\tif (negative && !odb_has_object(r->objects, oid, 0))\n \t\treturn;\n \n \tif (negative)\ndiff --git a/shallow.c b/shallow.c\nindex d379756e39a..ef3adb635fd 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -310,8 +310,8 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n \tif (graft->nr_parent != -1)\n \t\treturn 0;\n \tif (data->flags & QUICK) {\n-\t\tif (!has_object(the_repository, &graft->oid,\n-\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &graft->oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn 0;\n \t} else if (data->flags & SEEN_ONLY) {\n \t\tstruct commit *c = lookup_commit(the_repository, &graft->oid);\n@@ -477,8 +477,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)\n \tALLOC_ARRAY(info->ours, sa->nr);\n \tALLOC_ARRAY(info->theirs, sa->nr);\n \tfor (size_t i = 0; i < sa->nr; i++) {\n-\t\tif (has_object(the_repository, sa->oid + i,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\tif (odb_has_object(the_repository->objects, sa->oid + i,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t\tstruct commit_graft *graft;\n \t\t\tgraft = lookup_commit_graft(the_repository,\n \t\t\t\t\t\t    &sa->oid[i]);\n@@ -515,8 +515,8 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)\n \tfor (i = dst = 0; i < info->nr_theirs; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->theirs[dst] = info->theirs[i];\n-\t\tif (has_object(the_repository, oid + info->theirs[i],\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, oid + info->theirs[i],\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\tdst++;\n \t}\n \tinfo->nr_theirs = dst;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex cec12cb478a..98cda156434 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -509,7 +509,7 @@ static int got_oid(struct upload_pack_data *data,\n {\n \tif (get_oid_hex(hex, oid))\n \t\tdie(\"git upload-pack: expected SHA1 object, got '%s'\", hex);\n-\tif (!has_object(the_repository, oid, 0))\n+\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\treturn -1;\n \treturn do_got_oid(data, oid);\n }\ndiff --git a/walker.c b/walker.c\nindex a8abe8a2e78..d131af04c7b 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -150,8 +150,8 @@ static int process(struct walker *walker, struct object *obj)\n \t\treturn 0;\n \tobj->flags |= SEEN;\n \n-\tif (has_object(the_repository, &obj->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t/* We already have it, so we should scan it now. */\n \t\tobj->flags |= TO_SCAN;\n \t}\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517328","messageId":"20250506-pks-object-store-wo-the-repository-v1-16-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 16/17] odb: rename `pretend_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:29Z","receivedAt":"2025-05-06T11:09:33Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `pretend_object_file()` to `odb_pretend_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nNo compatibility wrapper is introduces as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n blame.c |  3 ++-\n odb.c   | 18 +++++++++---------\n odb.h   |  6 +++---\n 3 files changed, 14 insertions(+), 13 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 858d2d74df9..dce5c8d855c 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -277,7 +277,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \tconvert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);\n \torigin->file.ptr = buf.buf;\n \torigin->file.size = buf.len;\n-\tpretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);\n+\todb_pretend_object(the_repository->objects, buf.buf, buf.len,\n+\t\t\t   OBJ_BLOB, &origin->blob_oid);\n \n \t/*\n \t * Read the current index, replace the path entry with\ndiff --git a/odb.c b/odb.c\nindex e7c83d96361..3931020fa80 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -872,21 +872,21 @@ int odb_read_object_info(struct object_database *odb,\n \treturn type;\n }\n \n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid)\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid)\n {\n \tstruct cached_object_entry *co;\n \tchar *co_buf;\n \n-\thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (odb_has_object(repo->objects, oid, 0) ||\n-\t    find_cached_object(repo->objects, oid))\n+\thash_object_file(odb->repo->hash_algo, buf, len, type, oid);\n+\tif (odb_has_object(odb, oid, 0) ||\n+\t    find_cached_object(odb, oid))\n \t\treturn 0;\n \n-\tALLOC_GROW(repo->objects->cached_objects,\n-\t\t   repo->objects->cached_object_nr + 1, repo->objects->cached_object_alloc);\n-\tco = &repo->objects->cached_objects[repo->objects->cached_object_nr++];\n+\tALLOC_GROW(odb->cached_objects,\n+\t\t   odb->cached_object_nr + 1, odb->cached_object_alloc);\n+\tco = &odb->cached_objects[odb->cached_object_nr++];\n \tco->value.size = len;\n \tco->value.type = type;\n \tco_buf = xmalloc(len);\ndiff --git a/odb.h b/odb.h\nindex fd4f1c55b6d..b9aefca639c 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -269,9 +269,9 @@ void *odb_read_object(struct object_database *odb,\n  * object in persistent storage before writing any other new objects\n  * that reference it.\n  */\n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid);\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid);\n \n struct object_info {\n \t/* Request */\n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517329","messageId":"20250506-pks-object-store-wo-the-repository-v1-17-c05b82e7b126@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH 17/17] odb: rename `read_object_with_reference()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-06T11:09:30Z","receivedAt":"2025-05-06T11:09:35Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `read_object_with_reference()` to `odb_read_object_peeled()` to\nmatch other functions related to the object database and our modern\ncoding guidelines. Furthermore though, the old name didn't really\ndescribe very well what this function actually does, which is to walk\ndown any commit and tag objects until an object of the required type has\nbeen found. This is generally referred to as \"peeling\", so the new name\nshould be way more descriptive.\n\nNo compatibility wrapper is introduces as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/user-manual.adoc |  4 ++--\n builtin/cat-file.c             |  4 ++--\n builtin/fast-import.c          | 19 ++++++++-----------\n builtin/grep.c                 |  9 +++------\n builtin/pack-objects.c         |  4 ++--\n odb.c                          | 17 +++++++++--------\n odb.h                          | 15 +++++++--------\n tree-walk.c                    | 10 ++++------\n 8 files changed, 37 insertions(+), 45 deletions(-)\n\ndiff --git a/Documentation/user-manual.adoc b/Documentation/user-manual.adoc\nindex d2b478ad232..e86b2ad9f8a 100644\n--- a/Documentation/user-manual.adoc\n+++ b/Documentation/user-manual.adoc\n@@ -4301,11 +4301,11 @@ Now, for the meat:\n \n -----------------------------------------------------------------------------\n         case 0:\n-                buf = read_object_with_reference(sha1, argv[1], &size, NULL);\n+                buf = odb_read_object_peeled(r->objects, sha1, argv[1], &size, NULL);\n -----------------------------------------------------------------------------\n \n This is how you read a blob (actually, not only a blob, but any type of\n-object).  To know how the function `read_object_with_reference()` actually\n+object).  To know how the function `odb_read_object_peeled()` actually\n works, find the source code for it (something like `git grep\n read_object_with | grep \":[a-z]\"` in the Git repository), and read\n the source.\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 571b5cc2ad5..ed0fce9b490 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -255,8 +255,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t * fall-back to the usual case.\n \t\t\t */\n \t\t}\n-\t\tbuf = read_object_with_reference(the_repository, &oid,\n-\t\t\t\t\t\t exp_type_id, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &oid,\n+\t\t\t\t\t     exp_type_id, &size, NULL);\n \n \t\tif (use_mailmap) {\n \t\t\tsize_t s = size;\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 1973c504e25..b1389c59211 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -2535,10 +2535,9 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!repo_get_oid(the_repository, p, &commit_oid)) {\n \t\tunsigned long size;\n-\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t       &commit_oid,\n-\t\t\t\t\t\t       OBJ_COMMIT, &size,\n-\t\t\t\t\t\t       &commit_oid);\n+\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t   &commit_oid, OBJ_COMMIT, &size,\n+\t\t\t\t\t\t   &commit_oid);\n \t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\tdie(\"Not a valid commit: %s\", p);\n \t\tfree(buf);\n@@ -2604,9 +2603,8 @@ static void parse_from_existing(struct branch *b)\n \t\tunsigned long size;\n \t\tchar *buf;\n \n-\t\tbuf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t &b->oid, OBJ_COMMIT, &size,\n-\t\t\t\t\t\t &b->oid);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &b->oid,\n+\t\t\t\t\t     OBJ_COMMIT, &size, &b->oid);\n \t\tparse_from_commit(b, buf, size);\n \t\tfree(buf);\n \t}\n@@ -2699,10 +2697,9 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!repo_get_oid(the_repository, from, &n->oid)) {\n \t\t\tunsigned long size;\n-\t\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t\t       &n->oid,\n-\t\t\t\t\t\t\t       OBJ_COMMIT,\n-\t\t\t\t\t\t\t       &size, &n->oid);\n+\t\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t\t   &n->oid, OBJ_COMMIT,\n+\t\t\t\t\t\t\t   &size, &n->oid);\n \t\t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\t\tdie(\"Not a valid commit: %s\", from);\n \t\t\tfree(buf);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 45681579b6d..d49c7002037 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -522,9 +522,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tobj_read_lock();\n \t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n-\t\tdata = read_object_with_reference(subrepo,\n-\t\t\t\t\t\t  oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(subrepo->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \n@@ -705,9 +703,8 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \n-\t\tdata = read_object_with_reference(opt->repo,\n-\t\t\t\t\t\t  &obj->oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(opt->repo->objects, &obj->oid,\n+\t\t\t\t\t      OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(&obj->oid));\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 06bdeb4223b..e88a13dbb9f 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2055,8 +2055,8 @@ static void add_preferred_base(struct object_id *oid)\n \tif (window <= num_preferred_base++)\n \t\treturn;\n \n-\tdata = read_object_with_reference(the_repository, oid,\n-\t\t\t\t\t  OBJ_TREE, &size, &tree_oid);\n+\tdata = odb_read_object_peeled(the_repository->objects, oid,\n+\t\t\t\t      OBJ_TREE, &size, &tree_oid);\n \tif (!data)\n \t\treturn;\n \ndiff --git a/odb.c b/odb.c\nindex 3931020fa80..8b4f18f9ffb 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -914,11 +914,11 @@ void *odb_read_object(struct object_database *odb,\n \treturn data;\n }\n \n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *actual_oid_return)\n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *actual_oid_return)\n {\n \tenum object_type type;\n \tvoid *buffer;\n@@ -930,7 +930,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(odb, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\n@@ -950,9 +950,10 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n+\t\tif (ref_length + odb->repo->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid,\n+\t\t\t\t      odb->repo->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\ndiff --git a/odb.h b/odb.h\nindex b9aefca639c..03f269c4e82 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -261,6 +261,12 @@ void *odb_read_object(struct object_database *odb,\n \t\t      enum object_type *type,\n \t\t      unsigned long *size);\n \n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *oid_ret);\n+\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -372,7 +378,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: odb_read_object(),\n- * read_object_with_reference(), odb_read_object_info() and odb().\n+ * odb_read_object_peeled(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -421,13 +427,6 @@ enum for_each_object_flags {\n \tFOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),\n };\n \n-\n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *oid_ret);\n-\n /* Compatibility wrappers, to be removed once Git 2.50 has been released. */\n #include \"repository.h\"\n \ndiff --git a/tree-walk.c b/tree-walk.c\nindex 766af99f466..e449a1320e5 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -90,7 +90,7 @@ void *fill_tree_descriptor(struct repository *r,\n \tvoid *buf = NULL;\n \n \tif (oid) {\n-\t\tbuf = read_object_with_reference(r, oid, OBJ_TREE, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(r->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!buf)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \t}\n@@ -611,7 +611,7 @@ int get_tree_entry(struct repository *r,\n \tunsigned long size;\n \tstruct object_id root;\n \n-\ttree = read_object_with_reference(r, tree_oid, OBJ_TREE, &size, &root);\n+\ttree = odb_read_object_peeled(r->objects, tree_oid, OBJ_TREE, &size, &root);\n \tif (!tree)\n \t\treturn -1;\n \n@@ -681,10 +681,8 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n \t\t\tunsigned long size;\n-\t\t\ttree = read_object_with_reference(r,\n-\t\t\t\t\t\t\t  &current_tree_oid,\n-\t\t\t\t\t\t\t  OBJ_TREE, &size,\n-\t\t\t\t\t\t\t  &root);\n+\t\t\ttree = odb_read_object_peeled(r->objects, &current_tree_oid,\n+\t\t\t\t\t\t      OBJ_TREE, &size, &root);\n \t\t\tif (!tree)\n \t\t\t\tgoto done;\n \n\n-- \n2.49.0.1045.g170613ef41.dirty\n\n"},{"id":"517374","messageId":"a6b1bb83-02e1-4589-92b2-e005673a3c42@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-3-c05b82e7b126@pks.im","subject":"Re: [PATCH 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-06T18:06:14Z","receivedAt":"2025-05-06T18:06:15Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/2025 7:09 AM, Patrick Steinhardt wrote:\n> In the preceding commits we have renamed the structures contained in\n> \"object-store.h\" to `struct object_database` and `struct odb_backend`.\n> As such, the code files \"object-store.{c,h}\" are confusingly named now.\n> Rename them to \"odb.{c,h}\" accordingly.\nWhile I appreciate the goal of this series, I'm not sold on the need to\nrename these files. Not only is it a tree-wide change to the headers, but\nit now requires tracking changes across the rename which can complicate\nhistory spelunking.\n\nAt minimum, the method renames are likely to create semantic merge issues\nwith parallel work. If the rename is truly valuable, then maybe it could\nbe done in an isolated change after the method renames are landed?\n\nThanks,\n-Stolee\n\n"},{"id":"517405","messageId":"3317228e-e1c8-4b69-9f03-f344f5a6a0cb@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-1-c05b82e7b126@pks.im","subject":"Re: [PATCH 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T00:47:53Z","receivedAt":"2025-05-07T00:47:55Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n\n> Instead, rename the structure to `object_database`. This term is already\n> used a lot throughout our codebase, and it cannot easily be mistaken for\n> \"object directories\", either. Furthermore, its acronym ODB is already\n> well-known and works well as part of a function's name, like for example\n> `odb_has_object()`.\n\nThe patch is the kind where \"it's correct if and only if it compiles,\"\nwhich is good!\n\nI just wanted to chime in to approve of the term \"object database\" and\nusing ODB for short.\n\nThanks,\n-Stolee\n\n"},{"id":"517406","messageId":"e23e7e63-1d66-4a5c-8c4e-19b5078a75ad@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-2-c05b82e7b126@pks.im","subject":"Re: [PATCH 02/17] object-store: rename `object_directory` to `odb_backend`","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T00:51:54Z","receivedAt":"2025-05-07T00:51:56Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> The `object_directory` structure is used as an access point for a single\n> object directory like \".git/objects\". While the structure isn't yet\n> fully self-contained, the intent is for it to eventually contain all\n> information required to access objects in one specific location.\n> \n> While the name \"object directory\" is a good fit for now, this will\n> change over time as we continue with the agenda to make pluggable object\n> databases a thing. Eventually, objects may not be accessed via any kind\n> of directory at all anymore, but they could instead be backed by any\n> kind of durable storage mechanism. While it seems quite far-fetched for\n> now, it is thinkable that eventually this might even be some form of a\n> database, for example.\n\nI agree that \"object directory\" is leaking some of the abstraction, and\nthat we'd want to be able to have pluggable ODB backends.\n\n> As such, the current name of this structure will become worse over time\n> as we evolve into the direction of pluggable ODBs. Immediate next steps\n> will start to carve out proper self-contained object directories, which\n> requires us to pass in these object directories as parameters. Based on\n> our modern naming schema this means that those functions should then be\n> named after their subsystem, which means that we would start to bake the\n> current name into the codebase more and more.\n> \n> Let's preempt this by renaming the structure to `odb_backend` now\n> already. This name is agnostic of how exactly objects are stored and\n> allows us to easily introduce e.g. a `files_odb_backend` and other\n> specific implementations over time.\n\nBut here's where I'll get a little nitpicky and say that these are\n\"odb\"s not \"odb_backend\"s.\n\n* odb: a single object database. A repo can have multiple, currently\n   only one that is read/write and multiple read-only alternates.\n\n* odb backend: an _implementation_ of an object database. This would\n   be the structure that containts a vtable of implementation methods.\n   Each individual 'odb' would point to a single backend describing\n   how to access the data in it.\n\nDoes that make sense? If we are going through the effort of renaming\nthings, I think it's worth being a little more future-proof here.\n\nThanks,\n-Stolee\n\n"},{"id":"517412","messageId":"41f4a9f0-e758-49e5-8e88-4659966547c1@gmail.com","threadId":"63403","inReplyTo":"e23e7e63-1d66-4a5c-8c4e-19b5078a75ad@gmail.com","subject":"Re: [PATCH 02/17] object-store: rename `object_directory` to `odb_backend`","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:00:04Z","receivedAt":"2025-05-07T01:00:06Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 8:51 PM, Derrick Stolee wrote:\n> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n\n>> Let's preempt this by renaming the structure to `odb_backend` now\n>> already. This name is agnostic of how exactly objects are stored and\n>> allows us to easily introduce e.g. a `files_odb_backend` and other\n>> specific implementations over time.\n> \n> But here's where I'll get a little nitpicky and say that these are\n> \"odb\"s not \"odb_backend\"s.\n> \n> * odb: a single object database. A repo can have multiple, currently\n>    only one that is read/write and multiple read-only alternates.\n> \n> * odb backend: an _implementation_ of an object database. This would\n>    be the structure that containts a vtable of implementation methods.\n>    Each individual 'odb' would point to a single backend describing\n>    how to access the data in it.\n> \n> Does that make sense? If we are going through the effort of renaming\n> things, I think it's worth being a little more future-proof here.\nAnd immediately upon sending this message, I went and looked at\nanother patch and realized that the rename in Patch 1 would be\nconfusing with 'struct object_database' containing a list of\n'struct odb's.\n\nPerhaps in my head I was thinking that each repository has an\n\"object store\" which is an abstraction over possibly multiple\n\"odb\"s which each are interacted with via one \"odb backend\"\n(and there may be multiple potential odb backends in the future,\nbut only one right now).\n\nIf we want to keep the 'object_database' name from patch 1 (or\nreplace it with 'odb' for brevity) then we might want a different\nname for each sub-odb. Perhaps 'odb_shard'? 'odb_slice'? Do any\nof these sound better?\n\nThanks,\n-Stolee\n\n"},{"id":"517413","messageId":"d731678d-bda2-474d-81e8-39da85bd9038@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-5-c05b82e7b126@pks.im","subject":"Re: [PATCH 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:10:06Z","receivedAt":"2025-05-07T01:10:08Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n\n> diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\n> index 0a184d39720..28550d3bcc9 100644\n> --- a/builtin/commit-graph.c\n> +++ b/builtin/commit-graph.c\n> @@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n>   \t\t\tstruct repository *repo UNUSED)\n>   {\n>   \tstruct commit_graph *graph = NULL;\n> -\tstruct odb_backend *odb = NULL;\n> +\tstruct odb_backend *backend = NULL;\n\nnit: this looks like a misplaced variable rename that should be in\nan earlier patch.\n\n> @@ -101,9 +101,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n>   \tif (opts.progress)\n>   \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n>   \n> -\todb = find_odb(the_repository, opts.obj_dir);\n> -\tgraph_name = get_commit_graph_filename(odb);\n> -\tchain_name = get_commit_graph_chain_filename(odb);\n> +\tbackend = odb_find_backend(the_repository->objects, opts.obj_dir);\n> +\tgraph_name = get_commit_graph_filename(backend);\n> +\tchain_name = get_commit_graph_chain_filename(backend);\n\nI like how your use of specific backends here cleaans up a lot of\ngarbage around the --object-dir parameter of the commit-graph\nbuiltin.\n\nThis is a real structural improvement that is made possible by\nthis refactoring.\n\n> @@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n>   \tstruct string_list pack_indexes = STRING_LIST_INIT_DUP;\n>   \tstruct strbuf buf = STRBUF_INIT;\n>   \tstruct oidset commits = OIDSET_INIT;\n> -\tstruct odb_backend *odb = NULL;\n> +\tstruct odb_backend *backend = NULL;\n\nHere's another of those delayed renames.\n\n> -struct odb_backend *find_odb(struct repository *r, const char *obj_dir)\n> +struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir)\n\nI was looking at this implementation and wondering why it wasn't\nrenamed earlier, but upon closer inspection I agree that the\nrename is worthwhile _and_ the method shouldn't have been\nchanged until now.\n\n>   {\n> -\tstruct odb_backend *odb;\n> +\tstruct odb_backend *backend;\n>   \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n>   \tstruct strbuf odb_path_real = STRBUF_INIT;\n>   \n> -\tprepare_alt_odb(r);\n> -\tfor (odb = r->objects->backends; odb; odb = odb->next) {\n> -\t\tstrbuf_realpath(&odb_path_real, odb->path, 1);\n> +\tprepare_alt_odb(odb->repo);\nThis does make me wonder if we should be able to prepare the\nalternates for a given odb without using an owning repo. Yes,\nwe'd need to assign the repo parent when creating new odbs, but\nthe info/alternates file is in the object dir.\n\nPerhaps this is waiting for me in a later patch...\n\nThanks,\n-Stolee\n\n"},{"id":"517414","messageId":"9cd68129-1166-4f80-9b89-8f12c9d118c7@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-7-c05b82e7b126@pks.im","subject":"Re: [PATCH 07/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:12:34Z","receivedAt":"2025-05-07T01:12:36Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> Get rid of our dependency on `the_repository` in `assert_oid_type()` by\n> passing in the object database as a parameter and adjusting all callers.\n\nOops! This patch has the same message as patch 6 but is actually a\ndifferent change, removing the_repository from odb_mkstemp():\n\n> -\tpack_fd = odb_mkstemp(&tmp_file, \"pack/tmp_pack_XXXXXX\");\n> +\tpack_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n> +\t\t\t      \"pack/tmp_pack_XXXXXX\");\n...\n>   /*\n> - * Create a temporary file rooted in the object database directory, or\n> - * die on failure. The filename is taken from \"pattern\", which should have the\n> - * usual \"XXXXXX\" trailer, and the resulting filename is written into the\n> - * \"template\" buffer. Returns the open descriptor.\n> + * Create a temporary file rooted in the primary object database backend's\n> + * directory, or die on failure. The filename is taken from \"pattern\", which\n> + * should have the usual \"XXXXXX\" trailer, and the resulting filename is\n> + * written into the \"template\" buffer. Returns the open descriptor.\n>    */\n> -int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);\n> +int odb_mkstemp(struct object_database *odb,\n> +\t\tstruct strbuf *temp_filename, const char *pattern);\n\nI'm happy with the code change, though.\n\nThanks,\n-Stolee\n\n"},{"id":"517416","messageId":"8c4841eb-473d-483b-a5cf-15bd41ba890c@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-8-c05b82e7b126@pks.im","subject":"Re: [PATCH 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:14:48Z","receivedAt":"2025-05-07T01:14:50Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> The functions to manage alternates all depend on `the_repository`.\n> Refactor them to accept an object database as parameter and adjusting\n> all callers. The functions are renamed accordingly.\n\n...\n\n> -\tprepare_alt_odb(odb->repo);\n> +\todb_prepare_alternates(odb);\n\nI was looking forward to this change in an earlier patch that\nintroduced the line being edited here. Thanks for making this\ncleaner (and the other callers will get cleaner eventually,\ntoo).\n\nThanks,\n-Stolee\n\n"},{"id":"517417","messageId":"d3524839-a982-4be3-93ba-c35fdde3726f@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-9-c05b82e7b126@pks.im","subject":"Re: [PATCH 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:21:15Z","receivedAt":"2025-05-07T01:21:16Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n > There are a couple of iterator-style functions that execute a callback\n > for each instance of a given set, all of which currently depend on\n > `the_repository`. Refactor them to instead take an object database as\n > parameter so that we can get rid of this dependency.\n...\n > +/*\n > + * Iterate through all backends of the database and execute the provided\n > + * callback function for each of them. Stop iterating once the callback\n > + * function returns a non-zero value, in which case the value is bubbled up\n > + * from the callback.\n > + */\n > +typedef int odb_for_each_backend_fn(struct odb_backend *, void *);\n > +int odb_for_each_backend(struct object_database *odb,\n > +\t\t\t odb_for_each_backend_fn cb, void *payload);\n > +\n > +/*\n > + * Iterate through all alternative object backends of the database and yield\n > + * their respective references.\n > + */\n > +typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n > +void odb_for_each_alternate_ref(struct object_database *odb,\n > +\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n > +\n\nHere's another occasion where we should be careful about how we rename\nan \"alternate odb\". What is an \"alternate ref\" if we have different 'odb\nbackend's (or slices/shards/odbs etc.). Should we be updating the term\n\"alternate ref\" here?\n\nChanging 'alternate ref' would be quite difficult seeing how it is based\non the 'core.alternateRefsCommand' and 'core.alternateRefsPrefix' config\nkeys.\n\nPerhaps this is motivation to keep the word 'alternate' but as a way to\ndifferentiate the repo's odb from ones it is borrowing.\n\nI'm sorry to nitpick so much here, but your thorough series is helping\nto bring to mind all of the different aspects that are being conflated\nby our current nomenclature that grew organically and is now being\ncarefully designed for the better.\n\nThanks,\n-Stolee\n"},{"id":"517419","messageId":"a715e7c7-20a7-4a2f-95e3-28d4d4bc8995@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-11-c05b82e7b126@pks.im","subject":"Re: [PATCH 11/17] odb: get rid of `the_repository` when handling submodule backends","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:25:00Z","receivedAt":"2025-05-07T01:25:02Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> The \"--recursive\" flag for git-grep(1) allows users to grep for a string\n> across submodule boundaries. To make this work we add each submodule's\n> object backend to our own object database so that the objects can be\n> accessed directly.\n\n\n> +static int register_all_submodule_backends(struct object_database *odb)\n> +{\n> +\tint ret = odb->submodule_backend_paths.nr;\n> +\n> +\tfor (size_t i = 0; i < odb->submodule_backend_paths.nr; i++)\n> +\t\todb_add_to_alternates_memory(odb,\n> +\t\t\t\t\t     odb->submodule_backend_paths.items[i].string);\n> +\tif (ret) {\n> +\t\tstring_list_clear(&odb->submodule_backend_paths, 0);\n> +\t\ttrace2_data_intmax(\"submodule\", odb->repo,\n> +\t\t\t\t   \"register_all_submodule_backends/registered\", ret);\n> +\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n> +\t\t\tBUG(\"register_all_submodule_backends() called\");\n\nDid you plan to create a test around this test variable?\n\nThanks,\n-Stolee\n\n"},{"id":"517420","messageId":"728e13e3-b563-4d66-bc00-b3320b76ec9f@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-12-c05b82e7b126@pks.im","subject":"Re: [PATCH 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:25:47Z","receivedAt":"2025-05-07T01:25:49Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> All of the external functions provided by the object database subsystem\n> don't depend on `the_repository` anymore, but some internal functions\n> still do. Refactor those cases by plumbing through the repository that\n> owns the object database.\n> \n> This change allows us to get rid of the `USE_THE_REPOSITORY_VARIABLE`\n> preprocessor define.\n\n> --- a/odb.c\n> +++ b/odb.c\n> @@ -1,5 +1,3 @@\n> -#define USE_THE_REPOSITORY_VARIABLE\n> -\n\nVery satisfying! Thanks,\n-Stolee\n\n"},{"id":"517421","messageId":"0f885626-d676-45b1-b8be-1ef5e63ffb78@gmail.com","threadId":"63403","inReplyTo":"a715e7c7-20a7-4a2f-95e3-28d4d4bc8995@gmail.com","subject":"Re: [PATCH 11/17] odb: get rid of `the_repository` when handling submodule backends","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:29:12Z","receivedAt":"2025-05-07T01:29:14Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 9:25 PM, Derrick Stolee wrote:\n> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n\n>> +        if (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n>> +            BUG(\"register_all_submodule_backends() called\");\n> \n> Did you plan to create a test around this test variable?\nPlease ignore me. This was re-used from before. It was just in\ncode that looks like a new hunk.\n\n-Stolee\n\n"},{"id":"517425","messageId":"5bea19fe-6616-4f01-a78d-9b7da94db899@gmail.com","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"Re: [PATCH 00/17] object-store: carve out the object database subsystem","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-07T01:40:16Z","receivedAt":"2025-05-07T01:40:19Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n\n> this patch series refactors the object store subsystem to become more\n> self-contained by getting rid of `the_repository`. Instead of passing in\n> the repository explicitly, we start to pass in the object store itself,\n> which is in contrast to many other refactorings we did, but in line with\n> what we did for the ref store, as well.\n> \n> This series also starts to properly scope functions to the carved out\n> object database subsystem, which requires a bit of shuffling. This\n> allows us to have a short-and-sweet `odb_` prefix for functions and\n> prepares us for a future with pluggable object backends.\n> \n> The series is structured as follows:\n> \n>    - Patches 1 to 3 rename `struct object_store` and `struct\n>      object_directory` as well as the code files.\n\nPatches 1 and 2 involve renaming some core structures, and I had\nsome questions around these names (since we hope to be stuck with\nthe new names for a long time). I was thinking out loud on a per-\npatch basis, but now want to collect my thoughts around these:\n\n  * raw_object_store currently describes the abstraction that contains\n    all objects that can be accessed within the repository. This may\n    include multiple alternates. Patch 1 renames this to\n    'object_database'.\n\n  * object_directory currently describes a single directory that\n    has the same structure as $GIT_DIR/objects/ but may be an alternate\n    or a submodule object directory. Patch 2 renames this to\n    'odb_backend'.\n\nMy concerns around this are basically around not liking \"backend\" for\nthis purpose. When I think of a backend, I'm thinking about the\nimplementation details (like the refs backend being files or reftable)\nand not multiple distinct locations that have their own objects.\n\nIn this sense, I'm partial to being brief for the most-common structure\nthat will be passed around and then more descriptive about the smaller\npieces:\n\n  * 'struct raw_object_store' could be renamed to 'struct odb' to match\n    its use in all of the new odb_*() methods. This represents the\n    \"object database abstraction\" and consumers don't care if this is\n    one or many object directories in a trench coat.\n\n  * 'struct object_directory' could be renamed to 'struct odb_shard' or\n    'struct odb_slice' or similar. I may even recommend 'odb_partition'\n    though that does imply some disjointness that is not guaranteed (an\n    object can exist in multiple parts).\n\n  * In the event that we create multiple implementations for storing\n    objects, then a 'struct odb_shard' could point to a backend to help\n    find the appropriate methods for interacting with its storage.\n\n  * \"alternate refs\" are locked in as names based on the following\n    config key names:\n\n    - core.alternateRefsCommand\n    - core.alternateRefsPrefix\n\n    These user-facing names should not change. This may be valuable to\n    make sure that the 'odb_shard's still have a state of \"I'm an\n    alternate\" or \"I'm the base read/write shard for this repo\".\n\n>    - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n\nThese are carefully done. Thanks. I only have a few nitpicks here\nand there.\n\n>    - Patches 13 to 17 adjust the name of remaining functions so that they\n>      can be clearly attributed to the ODB. I'm happy to kick these\n>      patches out of this series and resend them at a later point in case\n>      they create too much turmoil.\n\nI like that these are present, especially because you included\ncompatibility macros for in-flight topics.\n\nI do mention that the rename of the object-store.[c|h] files may be\nunnecessary, or perhaps could be delayed until this series is merged\nand the collateral is calmed.\n\n---\n\nThis was clearly a lot of work to put together. Thanks for working\nhard to thoughtfully rename things while refactoring to reduce our\ndependence on global state.\n\nThanks,\n-Stolee\n\n"},{"id":"517499","messageId":"xmqqv7qce915.fsf@gitster.g","threadId":"63403","inReplyTo":"3317228e-e1c8-4b69-9f03-f344f5a6a0cb@gmail.com","subject":"Re: [PATCH 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-07T15:27:02Z","receivedAt":"2025-05-07T15:27:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n>\n>> Instead, rename the structure to `object_database`. This term is already\n>> used a lot throughout our codebase, and it cannot easily be mistaken for\n>> \"object directories\", either. Furthermore, its acronym ODB is already\n>> well-known and works well as part of a function's name, like for example\n>> `odb_has_object()`.\n>\n> The patch is the kind where \"it's correct if and only if it compiles,\"\n> which is good!\n\nYes, unless there are topics in flight that adds more uses\nindependently; I think there weren't any, though, which is good.\n"},{"id":"517502","messageId":"xmqqecx0e5pf.fsf@gitster.g","threadId":"63403","inReplyTo":"728e13e3-b563-4d66-bc00-b3320b76ec9f@gmail.com","subject":"Re: [PATCH 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-07T16:38:52Z","receivedAt":"2025-05-07T16:38:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n>> All of the external functions provided by the object database subsystem\n>> don't depend on `the_repository` anymore, but some internal functions\n>> still do. Refactor those cases by plumbing through the repository that\n>> owns the object database.\n>> This change allows us to get rid of the\n>> `USE_THE_REPOSITORY_VARIABLE`\n>> preprocessor define.\n>\n>> --- a/odb.c\n>> +++ b/odb.c\n>> @@ -1,5 +1,3 @@\n>> -#define USE_THE_REPOSITORY_VARIABLE\n>> -\n>\n> Very satisfying! Thanks,\n\nYes, nice outcome.  I looked at the resulting odb.c and was a bit\nunhappy to see that we still need to pass \"struct repository *\"\n(instead of \"struct object_database *\") around.  But that is not\nbecause we assume we can get to an odb via repo, but primarily\nbecause repo has many things like config access and hash-algo that\nwe rely on, so it is perfectly OK.\n\nAt some places, where we pass odb around, we can and do go from it\nto its repository (e.g. odb->repo->hash_algo), which was what I am\nexpecting to see more of in the future.\n\nThanks.\n\n"},{"id":"517504","messageId":"xmqqa57oe4mj.fsf@gitster.g","threadId":"63403","inReplyTo":"5bea19fe-6616-4f01-a78d-9b7da94db899@gmail.com","subject":"Re: [PATCH 00/17] object-store: carve out the object database subsystem","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-07T17:02:12Z","receivedAt":"2025-05-07T17:02:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n> Patches 1 and 2 involve renaming some core structures, and I had\n> some questions around these names (since we hope to be stuck with\n> the new names for a long time). I was thinking out loud on a per-\n> patch basis, but now want to collect my thoughts around these:\n>\n>  * raw_object_store currently describes the abstraction that contains\n>    all objects that can be accessed within the repository. This may\n>    include multiple alternates. Patch 1 renames this to\n>    'object_database'.\n>\n>  * object_directory currently describes a single directory that\n>    has the same structure as $GIT_DIR/objects/ but may be an alternate\n>    or a submodule object directory. Patch 2 renames this to\n>    'odb_backend'.\n>\n> My concerns around this are basically around not liking \"backend\" for\n> this purpose. When I think of a backend, I'm thinking about the\n> implementation details (like the refs backend being files or reftable)\n> and not multiple distinct locations that have their own objects.\n\nYup, odb_backend_files (aot odb_backend_redis) or something?\n\n>  * 'struct object_directory' could be renamed to 'struct odb_shard' or\n>    'struct odb_slice' or similar. I may even recommend 'odb_partition'\n>    though that does imply some disjointness that is not guaranteed (an\n>    object can exist in multiple parts).\n>\n>  * In the event that we create multiple implementations for storing\n>    objects, then a 'struct odb_shard' could point to a backend to help\n>    find the appropriate methods for interacting with its storage.\n\nHmph, I do not have strong opinions, but I consider it an\nimplementation detail of one particular backend, namely, the\nfilesystem based backend, that it can link together multiple\nobject_directory instances and present them as if they form a single\nobject database, just like all files within a single object_directory\nform an illusion of a single object database (aka key-value store) even\nthough some objects are stored in individual loose object files while\nmany others are packed in a single packfile.\n\nI did not expect you would want to go to the world where a single\n\"shard\" consists of an object_directory backed by the filesystem and\nsome other more database-y backend.  It is an interesting idea, but\nwe'd need to worry about many things we do not have to worry about\nright now.  E.g. what do the precedence rules among different\ncomponents within a single \"shard\" look like?  How do we express \"in\nthis repository, local filesystem-backed piece is consulted first,\nand then check this piece backed by low-cost but high-latency\nstorage backend\"?\n\n> I do mention that the rename of the object-store.[c|h] files may be\n> unnecessary, or perhaps could be delayed until this series is merged\n> and the collateral is calmed.\n\nRight now, merge-fix needed against all other topics in flight look\nlike this, in order to merge it to 'seen'.\n\n$ git show --oneline -U0 merge-fix/ps/object-store\nc8afa0ab8e merge-fix/ps/object-store\ndiff --git a/fetch-object-info.c b/fetch-object-info.c\nindex 1b2c6c4d27..6c2abb7805 100644\n--- a/fetch-object-info.c\n+++ b/fetch-object-info.c\n@@ -7 +7 @@\n-#include \"object-store.h\"\n+#include \"odb.h\"\ndiff --git a/fetch-object-info.h b/fetch-object-info.h\nindex 7910d7f153..d35284bd6b 100644\n--- a/fetch-object-info.h\n+++ b/fetch-object-info.h\n@@ -6 +6 @@\n-#include \"object-store.h\"\n+#include \"odb.h\"\ndiff --git a/transport.h b/transport.h\nindex 5a4f27451a..3ef3acf865 100644\n--- a/transport.h\n+++ b/transport.h\n@@ -8 +8 @@\n-#include \"object-store.h\"\n+#include \"odb.h\"\n\nIOW, not too horrible.\n"},{"id":"517526","messageId":"xmqqh61w9fax.fsf@gitster.g","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"Re: [PATCH 00/17] object-store: carve out the object database subsystem","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-07T23:22:46Z","receivedAt":"2025-05-07T23:22:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> this patch series refactors the object store subsystem to become more\n> self-contained by getting rid of `the_repository`. Instead of passing in\n> the repository explicitly, we start to pass in the object store itself,\n> which is in contrast to many other refactorings we did, but in line with\n> what we did for the ref store, as well.\n\nNice.  I do prefer to keep the scope of the \"what's affected\" object\nsmaller than just assume that passing a repository is fine.  The\ninteraction among object database, the index and the ref database is\na bit subtle, in that the former should mostly be usable without the\nlatter (i.e. \"you throw a stream of data at it, and it registers it\nas an object and returns an object name\") but some operations you'd\nneed all (e.g. prunability).  With use of alternate object store, we\ncannot say \"by specifying a repository, we can specify its object\nstore\", as there is no \"the single object store\" linked to the\nrepository.\n\n> This series also starts to properly scope functions to the carved out\n> object database subsystem, which requires a bit of shuffling. This\n> allows us to have a short-and-sweet `odb_` prefix for functions and\n> prepares us for a future with pluggable object backends.\n\nGood.\n\n> The series is structured as follows:\n>\n>   - Patches 1 to 3 rename `struct object_store` and `struct\n>     object_directory` as well as the code files.\n>\n>   - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n>\n>   - Patches 13 to 17 adjust the name of remaining functions so that they\n>     can be clearly attributed to the ODB. I'm happy to kick these\n>     patches out of this series and resend them at a later point in case\n>     they create too much turmoil.\n>\n> This series is built on top of 6f84262c44a (The eleventh batch,\n> 2025-05-05) with ps/object-store-cleanup at 8a9e27be821 (object-store:\n> drop `repo_has_object_file()`, 2025-04-29) merged into it. There are a\n> couple of trivial conflicts when merged with \"seen\", I have appended the\n> merge conflict resolution as a patch at the end of this mail.\n>\n> Thanks!\n>\n> Patrick\n>\n> -- >8 --\n>\n> diff --cc builtin/pack-objects.c\n> index e88a13dbb9f,2936a08e130..00000000000\n> --- a/builtin/pack-objects.c\n> +++ b/builtin/pack-objects.c\n> @@@ -4063,9 -4318,10 +4320,10 @@@ static void add_objects_in_unpacked_pac\n>   }\n>   \n>   static int add_loose_object(const struct object_id *oid, const char *path,\n> - \t\t\t    void *data UNUSED)\n> + \t\t\t    void *data)\n>   {\n> + \tstruct rev_info *revs = data;\n>  -\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n>  +\tenum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);\n>   \n>   \tif (type < 0) {\n>   \t\twarning(_(\"loose object at %s could not be examined\"), path);\n> diff --cc odb.h\n> index 03f269c4e82,af0b3d856f5..00000000000\n> --- a/odb.h\n> +++ b/odb.h\n> @@@ -338,25 -258,10 +338,28 @@@ struct object_info \n>   /* Die if object corruption (not just an object being missing) was detected. */\n>   #define OBJECT_INFO_DIE_IF_CORRUPT 32\n>   \n>  -int oid_object_info_extended(struct repository *r,\n>  -\t\t\t     const struct object_id *,\n>  -\t\t\t     struct object_info *, unsigned flags);\n>  +/*\n>  + * Read object info from the object database and populate the `object_info`\n>  + * structure. Returns 0 on success, a negative error code otherwise.\n>  + */\n>  +int odb_read_object_info_extended(struct object_database *odb,\n>  +\t\t\t\t  const struct object_id *oid,\n>  +\t\t\t\t  struct object_info *oi,\n>  +\t\t\t\t  unsigned flags);\n>  +\n>  +/*\n>  + * Read a subset of object info for the given object ID. Returns an `enum\n>  + * object_type` on success, a negative error code otherwise. If successful and\n>  + * `sizep` is non-NULL, then the size of the object will be written to the\n>  + * pointer.\n>  + */\n>  +int odb_read_object_info(struct object_database *odb,\n>  +\t\t\t const struct object_id *oid,\n>  +\t\t\t unsigned long *sizep);\n>  +\n> ++/* Free pointers inside of object_info, but not object_info itself */\n> ++void free_object_info_contents(struct object_info *object_info);\n> + \n>   enum {\n>   \t/* Retry packed storage after checking packed and loose storage */\n>   \tHAS_OBJECT_RECHECK_PACKED = (1 << 0),\n> diff --git a/fetch-object-info.c b/fetch-object-info.c\n> index 1b2c6c4d27c..6c2abb78055 100644\n> --- a/fetch-object-info.c\n> +++ b/fetch-object-info.c\n> @@ -4,7 +4,7 @@\n>  #include \"pkt-line.h\"\n>  #include \"connect.h\"\n>  #include \"oid-array.h\"\n> -#include \"object-store.h\"\n> +#include \"odb.h\"\n>  #include \"fetch-object-info.h\"\n>  #include \"string-list.h\"\n>  \n> diff --git a/fetch-object-info.h b/fetch-object-info.h\n> index 7910d7f1532..d35284bd6bc 100644\n> --- a/fetch-object-info.h\n> +++ b/fetch-object-info.h\n> @@ -3,7 +3,7 @@\n>  \n>  #include \"pkt-line.h\"\n>  #include \"protocol.h\"\n> -#include \"object-store.h\"\n> +#include \"odb.h\"\n>  \n>  struct object_info_args {\n>  \tstruct string_list *object_info_options;\n> diff --git a/transport.h b/transport.h\n> index 5a4f27451ae..3ef3acf8650 100644\n> --- a/transport.h\n> +++ b/transport.h\n> @@ -5,7 +5,7 @@\n>  #include \"remote.h\"\n>  #include \"list-objects-filter-options.h\"\n>  #include \"string-list.h\"\n> -#include \"object-store.h\"\n> +#include \"odb.h\"\n>  \n>  struct git_transport_options {\n>  \tunsigned thin : 1;\n>\n> ---\n> Patrick Steinhardt (17):\n>       object-store: rename `raw_object_store` to `object_database`\n>       object-store: rename `object_directory` to `odb_backend`\n>       object-store: rename files to \"odb.{c,h}\"\n>       odb: introduce parent pointers\n>       odb: get rid of `the_repository` in `find_odb()`\n>       odb: get rid of `the_repository` in `assert_oid_type()`\n>       odb: get rid of `the_repository` in `assert_oid_type()`\n>       odb: get rid of `the_repository` when handling alternates\n>       odb: get rid of `the_repository`  in `for_each()` functions\n>       odb: get rid of `the_repository` when handling the primary backend\n>       odb: get rid of `the_repository` when handling submodule backends\n>       odb: trivial refactorings to get rid of `the_repository`\n>       odb: rename `oid_object_info()`\n>       odb: rename `repo_read_object_file()`\n>       odb: rename `has_object()`\n>       odb: rename `pretend_object_file()`\n>       odb: rename `read_object_with_reference()`\n>\n>  Documentation/user-manual.adoc          |   4 +-\n>  Makefile                                |   2 +-\n>  apply.c                                 |  14 +-\n>  archive-tar.c                           |   2 +-\n>  archive-zip.c                           |   2 +-\n>  archive.c                               |   6 +-\n>  attr.c                                  |   4 +-\n>  bisect.c                                |   8 +-\n>  blame.c                                 |  22 +-\n>  builtin/backfill.c                      |   6 +-\n>  builtin/blame.c                         |   6 +-\n>  builtin/cat-file.c                      |  62 +++--\n>  builtin/checkout.c                      |   2 +-\n>  builtin/clone.c                         |  14 +-\n>  builtin/commit-graph.c                  |  20 +-\n>  builtin/commit-tree.c                   |   4 +-\n>  builtin/count-objects.c                 |   4 +-\n>  builtin/describe.c                      |   5 +-\n>  builtin/difftool.c                      |   4 +-\n>  builtin/fast-export.c                   |  10 +-\n>  builtin/fast-import.c                   |  49 ++--\n>  builtin/fetch.c                         |  21 +-\n>  builtin/fsck.c                          |  31 +--\n>  builtin/gc.c                            |  16 +-\n>  builtin/grep.c                          |  26 +--\n>  builtin/hash-object.c                   |   2 +-\n>  builtin/index-pack.c                    |  29 +--\n>  builtin/log.c                           |   4 +-\n>  builtin/ls-files.c                      |   4 +-\n>  builtin/ls-tree.c                       |   6 +-\n>  builtin/merge-file.c                    |   2 +-\n>  builtin/merge-tree.c                    |  14 +-\n>  builtin/mktag.c                         |   6 +-\n>  builtin/mktree.c                        |  10 +-\n>  builtin/multi-pack-index.c              |   6 +-\n>  builtin/notes.c                         |   8 +-\n>  builtin/pack-objects.c                  |  70 +++---\n>  builtin/pack-redundant.c                |   2 +-\n>  builtin/prune.c                         |   6 +-\n>  builtin/receive-pack.c                  |   9 +-\n>  builtin/remote.c                        |   6 +-\n>  builtin/repack.c                        |   7 +-\n>  builtin/replace.c                       |  12 +-\n>  builtin/rev-list.c                      |   8 +-\n>  builtin/show-ref.c                      |   6 +-\n>  builtin/submodule--helper.c             |   7 +-\n>  builtin/tag.c                           |  10 +-\n>  builtin/unpack-file.c                   |   4 +-\n>  builtin/unpack-objects.c                |  12 +-\n>  bulk-checkin.c                          |   6 +-\n>  bundle-uri.c                            |   5 +-\n>  bundle.c                                |   6 +-\n>  cache-tree.c                            |  17 +-\n>  combine-diff.c                          |   4 +-\n>  commit-graph.c                          |  56 ++---\n>  commit-graph.h                          |  20 +-\n>  commit.c                                |  15 +-\n>  config.c                                |   4 +-\n>  connected.c                             |   2 +-\n>  contrib/coccinelle/the_repository.cocci |   2 +-\n>  diagnose.c                              |   8 +-\n>  diff.c                                  |  20 +-\n>  dir.c                                   |   2 +-\n>  entry.c                                 |   6 +-\n>  fetch-pack.c                            |  17 +-\n>  fmt-merge-msg.c                         |   6 +-\n>  fsck.c                                  |   4 +-\n>  grep.c                                  |   6 +-\n>  http-backend.c                          |   2 +-\n>  http-push.c                             |  20 +-\n>  http-walker.c                           |  12 +-\n>  http.c                                  |   6 +-\n>  list-objects-filter.c                   |   4 +-\n>  list-objects.c                          |   6 +-\n>  log-tree.c                              |   2 +-\n>  loose.c                                 |  24 +-\n>  mailmap.c                               |   4 +-\n>  match-trees.c                           |   6 +-\n>  merge-blobs.c                           |  10 +-\n>  merge-ort.c                             |   8 +-\n>  meson.build                             |   2 +-\n>  midx-write.c                            |   2 +-\n>  midx.c                                  |   6 +-\n>  notes-cache.c                           |   4 +-\n>  notes-merge.c                           |   4 +-\n>  notes.c                                 |  19 +-\n>  object-file.c                           |  60 ++---\n>  object-file.h                           |  12 +-\n>  object-name.c                           |  24 +-\n>  object.c                                |   8 +-\n>  object-store.c => odb.c                 | 395 +++++++++++++++++---------------\n>  object-store.h => odb.h                 | 271 ++++++++++++++++------\n>  oss-fuzz/fuzz-pack-idx.c                |   2 +-\n>  pack-bitmap-write.c                     |   9 +-\n>  pack-bitmap.c                           |  10 +-\n>  pack-check.c                            |   2 +-\n>  pack-mtimes.c                           |   2 +-\n>  pack-objects.h                          |   2 +-\n>  pack-revindex.c                         |   2 +-\n>  pack-write.c                            |  10 +-\n>  packfile.c                              |  29 +--\n>  packfile.h                              |   8 +-\n>  path.c                                  |   4 +-\n>  promisor-remote.c                       |   6 +-\n>  protocol-caps.c                         |   4 +-\n>  reachable.c                             |   2 +-\n>  read-cache.c                            |  14 +-\n>  ref-filter.c                            |   6 +-\n>  reflog.c                                |   8 +-\n>  refs.c                                  |   7 +-\n>  remote.c                                |   9 +-\n>  replace-object.c                        |   2 +-\n>  replace-object.h                        |   2 +-\n>  repository.c                            |  21 +-\n>  repository.h                            |   4 +-\n>  rerere.c                                |   7 +-\n>  revision.c                              |   5 +-\n>  send-pack.c                             |   4 +-\n>  sequencer.c                             |   7 +-\n>  server-info.c                           |   2 +-\n>  shallow.c                               |  14 +-\n>  streaming.c                             |  10 +-\n>  submodule-config.c                      |   9 +-\n>  submodule.c                             |  32 +--\n>  submodule.h                             |   9 -\n>  t/helper/test-find-pack.c               |   2 +-\n>  t/helper/test-pack-mtimes.c             |   2 +-\n>  t/helper/test-partial-clone.c           |   4 +-\n>  t/helper/test-read-graph.c              |   8 +-\n>  t/helper/test-read-midx.c               |   2 +-\n>  t/helper/test-ref-store.c               |   4 +-\n>  tag.c                                   |  10 +-\n>  tmp-objdir.c                            |  18 +-\n>  tree-walk.c                             |  18 +-\n>  tree.c                                  |   6 +-\n>  unpack-trees.c                          |   2 +-\n>  upload-pack.c                           |   4 +-\n>  walker.c                                |   6 +-\n>  xdiff-interface.c                       |   4 +-\n>  139 files changed, 1104 insertions(+), 961 deletions(-)\n>\n>\n> ---\n> base-commit: 046efb6f2b050efd580e1c1750b77328a1790c0e\n> change-id: 20250505-pks-object-store-wo-the-repository-9c6cbdf8d4b1\n"},{"id":"517654","messageId":"aB3mE2DW0bcmc_WK@pks.im","threadId":"63403","inReplyTo":"41f4a9f0-e758-49e5-8e88-4659966547c1@gmail.com","subject":"Re: [PATCH 02/17] object-store: rename `object_directory` to `odb_backend`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T11:25:07Z","receivedAt":"2025-05-09T11:25:12Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 06, 2025 at 09:00:04PM -0400, Derrick Stolee wrote:\n> On 5/6/25 8:51 PM, Derrick Stolee wrote:\n> > On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> \n> > > Let's preempt this by renaming the structure to `odb_backend` now\n> > > already. This name is agnostic of how exactly objects are stored and\n> > > allows us to easily introduce e.g. a `files_odb_backend` and other\n> > > specific implementations over time.\n> > \n> > But here's where I'll get a little nitpicky and say that these are\n> > \"odb\"s not \"odb_backend\"s.\n> > \n> > * odb: a single object database. A repo can have multiple, currently\n> >    only one that is read/write and multiple read-only alternates.\n> > \n> > * odb backend: an _implementation_ of an object database. This would\n> >    be the structure that containts a vtable of implementation methods.\n> >    Each individual 'odb' would point to a single backend describing\n> >    how to access the data in it.\n> > \n> > Does that make sense? If we are going through the effort of renaming\n> > things, I think it's worth being a little more future-proof here.\n\nYeah, I agree with you that this can be somewhat confusing indeed. The\nproblem is that we basically have a database of databases, and that\nmakes it somewhat awkward to name things.\n\n> And immediately upon sending this message, I went and looked at\n> another patch and realized that the rename in Patch 1 would be\n> confusing with 'struct object_database' containing a list of\n> 'struct odb's.\n> \n> Perhaps in my head I was thinking that each repository has an\n> \"object store\" which is an abstraction over possibly multiple\n> \"odb\"s which each are interacted with via one \"odb backend\"\n> (and there may be multiple potential odb backends in the future,\n> but only one right now).\n\nI don't think that \"store\" buys us much over \"database\" -- it's\nultimately the same thing, from my perspective. The only reason why I\ndecided to drop \"store\" in favor of \"database\" is that it allows us to\nuse the `odb_` prefix in many places, which is nice.\n\n> If we want to keep the 'object_database' name from patch 1 (or\n> replace it with 'odb' for brevity) then we might want a different\n> name for each sub-odb. Perhaps 'odb_shard'? 'odb_slice'? Do any\n> of these sound better?\n\nI don't quite like either of them. \"shard\" is a bit too close to the\nshards we have in \".git/objects/[0-9a-f]{2}\" and may thus easily cause\nconfusion. And \"slice\" feels a bit weird because... I dunno. I have to\nthink too much about slices in Golang.\n\nHow about `odb_alternate`? That's exactly what this is -- an alternate\npart of the object database. We already use this term, and it does make\nsense even in the future once we have pluggable ODBs. Honestly, now that\nI think about it's kind of the obvious choice. Lots of the parts of the\ncodebase were already called accordingly.\n\nPatrick\n"},{"id":"517655","messageId":"aB3mHVX0A_ADYLKM@pks.im","threadId":"63403","inReplyTo":"d731678d-bda2-474d-81e8-39da85bd9038@gmail.com","subject":"Re: [PATCH 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T11:25:17Z","receivedAt":"2025-05-09T11:25:20Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 06, 2025 at 09:10:06PM -0400, Derrick Stolee wrote:\n> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> \n> > diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\n> > index 0a184d39720..28550d3bcc9 100644\n> > --- a/builtin/commit-graph.c\n> > +++ b/builtin/commit-graph.c\n> > @@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n> >   \t\t\tstruct repository *repo UNUSED)\n> >   {\n> >   \tstruct commit_graph *graph = NULL;\n> > -\tstruct odb_backend *odb = NULL;\n> > +\tstruct odb_backend *backend = NULL;\n> \n> nit: this looks like a misplaced variable rename that should be in\n> an earlier patch.\n\nFixed.\n\n> > @@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n> >   \tstruct string_list pack_indexes = STRING_LIST_INIT_DUP;\n> >   \tstruct strbuf buf = STRBUF_INIT;\n> >   \tstruct oidset commits = OIDSET_INIT;\n> > -\tstruct odb_backend *odb = NULL;\n> > +\tstruct odb_backend *backend = NULL;\n> \n> Here's another of those delayed renames.\n\nFixed.\n\n> > -struct odb_backend *find_odb(struct repository *r, const char *obj_dir)\n> > +struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir)\n> \n> I was looking at this implementation and wondering why it wasn't\n> renamed earlier, but upon closer inspection I agree that the\n> rename is worthwhile _and_ the method shouldn't have been\n> changed until now.\n> \n> >   {\n> > -\tstruct odb_backend *odb;\n> > +\tstruct odb_backend *backend;\n> >   \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n> >   \tstruct strbuf odb_path_real = STRBUF_INIT;\n> > -\tprepare_alt_odb(r);\n> > -\tfor (odb = r->objects->backends; odb; odb = odb->next) {\n> > -\t\tstrbuf_realpath(&odb_path_real, odb->path, 1);\n> > +\tprepare_alt_odb(odb->repo);\n> This does make me wonder if we should be able to prepare the\n> alternates for a given odb without using an owning repo. Yes,\n> we'd need to assign the repo parent when creating new odbs, but\n> the info/alternates file is in the object dir.\n> \n> Perhaps this is waiting for me in a later patch...\n\nThings are still somewhat mixed at the end of this patch series, but we\ndo reduce the dependency over time. Eventually, the goal is that we only\nneed a repository to read its configuration, which may even happen once\nand then never again for the object database so that we can stop\ntracking the parent repository.\n\nPatrick\n"},{"id":"517656","messageId":"aB3mIZaniXI6zkH6@pks.im","threadId":"63403","inReplyTo":"9cd68129-1166-4f80-9b89-8f12c9d118c7@gmail.com","subject":"Re: [PATCH 07/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T11:25:21Z","receivedAt":"2025-05-09T11:25:24Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 06, 2025 at 09:12:34PM -0400, Derrick Stolee wrote:\n> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> > Get rid of our dependency on `the_repository` in `assert_oid_type()` by\n> > passing in the object database as a parameter and adjusting all callers.\n> \n> Oops! This patch has the same message as patch 6 but is actually a\n> different change, removing the_repository from odb_mkstemp():\n\nGood catch. Repetetive changes invite copy & paste invite errors.\n\nPatrick\n"},{"id":"517657","messageId":"aB3mKS2aSQMKB0xo@pks.im","threadId":"63403","inReplyTo":"d3524839-a982-4be3-93ba-c35fdde3726f@gmail.com","subject":"Re: [PATCH 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T11:25:29Z","receivedAt":"2025-05-09T11:25:31Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 06, 2025 at 09:21:15PM -0400, Derrick Stolee wrote:\n> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> > There are a couple of iterator-style functions that execute a callback\n> > for each instance of a given set, all of which currently depend on\n> > `the_repository`. Refactor them to instead take an object database as\n> > parameter so that we can get rid of this dependency.\n> ...\n> > +/*\n> > + * Iterate through all backends of the database and execute the provided\n> > + * callback function for each of them. Stop iterating once the callback\n> > + * function returns a non-zero value, in which case the value is bubbled up\n> > + * from the callback.\n> > + */\n> > +typedef int odb_for_each_backend_fn(struct odb_backend *, void *);\n> > +int odb_for_each_backend(struct object_database *odb,\n> > +\t\t\t odb_for_each_backend_fn cb, void *payload);\n> > +\n> > +/*\n> > + * Iterate through all alternative object backends of the database and yield\n> > + * their respective references.\n> > + */\n> > +typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n> > +void odb_for_each_alternate_ref(struct object_database *odb,\n> > +\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n> > +\n> \n> Here's another occasion where we should be careful about how we rename\n> an \"alternate odb\". What is an \"alternate ref\" if we have different 'odb\n> backend's (or slices/shards/odbs etc.). Should we be updating the term\n> \"alternate ref\" here?\n> \n> Changing 'alternate ref' would be quite difficult seeing how it is based\n> on the 'core.alternateRefsCommand' and 'core.alternateRefsPrefix' config\n> keys.\n> \n> Perhaps this is motivation to keep the word 'alternate' but as a way to\n> differentiate the repo's odb from ones it is borrowing.\n\nYeah, the next iteration will call things `odb_alternate` instead of\n`odb_backend`, which I think makes a lot of the terminology fall out\nnaturally. The only thing that may be confusing at first is that we also\nhave a \"primary alternate\" now, but I think that's bearable.\n\n> I'm sorry to nitpick so much here, but your thorough series is helping\n> to bring to mind all of the different aspects that are being conflated\n> by our current nomenclature that grew organically and is now being\n> carefully designed for the better.\n\nI very much invite this nitpicking on this series, so please don't be\nsorry.\n\nPatrick\n"},{"id":"517658","messageId":"aB3mLhsG8UhgfhmO@pks.im","threadId":"63403","inReplyTo":"xmqqecx0e5pf.fsf@gitster.g","subject":"Re: [PATCH 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T11:25:34Z","receivedAt":"2025-05-09T11:25:38Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, May 07, 2025 at 09:38:52AM -0700, Junio C Hamano wrote:\n> Derrick Stolee <stolee@gmail.com> writes:\n> \n> > On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> >> All of the external functions provided by the object database subsystem\n> >> don't depend on `the_repository` anymore, but some internal functions\n> >> still do. Refactor those cases by plumbing through the repository that\n> >> owns the object database.\n> >> This change allows us to get rid of the\n> >> `USE_THE_REPOSITORY_VARIABLE`\n> >> preprocessor define.\n> >\n> >> --- a/odb.c\n> >> +++ b/odb.c\n> >> @@ -1,5 +1,3 @@\n> >> -#define USE_THE_REPOSITORY_VARIABLE\n> >> -\n> >\n> > Very satisfying! Thanks,\n> \n> Yes, nice outcome.  I looked at the resulting odb.c and was a bit\n> unhappy to see that we still need to pass \"struct repository *\"\n> (instead of \"struct object_database *\") around.  But that is not\n> because we assume we can get to an odb via repo, but primarily\n> because repo has many things like config access and hash-algo that\n> we rely on, so it is perfectly OK.\n> \n> At some places, where we pass odb around, we can and do go from it\n> to its repository (e.g. odb->repo->hash_algo), which was what I am\n> expecting to see more of in the future.\n\nYup. Over time I very much have the intent to reduce the reliance on\n`odb->repo` even further. Ideally, the object database should have all\ninfo, or at least almost all of it, to function correctly.\n\nPatrick\n"},{"id":"517659","messageId":"aB3mMtoxCcaOFn0W@pks.im","threadId":"63403","inReplyTo":"5bea19fe-6616-4f01-a78d-9b7da94db899@gmail.com","subject":"Re: [PATCH 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T11:25:38Z","receivedAt":"2025-05-09T11:25:41Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 06, 2025 at 09:40:16PM -0400, Derrick Stolee wrote:\n> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n> \n> > this patch series refactors the object store subsystem to become more\n> > self-contained by getting rid of `the_repository`. Instead of passing in\n> > the repository explicitly, we start to pass in the object store itself,\n> > which is in contrast to many other refactorings we did, but in line with\n> > what we did for the ref store, as well.\n> > \n> > This series also starts to properly scope functions to the carved out\n> > object database subsystem, which requires a bit of shuffling. This\n> > allows us to have a short-and-sweet `odb_` prefix for functions and\n> > prepares us for a future with pluggable object backends.\n> > \n> > The series is structured as follows:\n> > \n> >    - Patches 1 to 3 rename `struct object_store` and `struct\n> >      object_directory` as well as the code files.\n> \n> Patches 1 and 2 involve renaming some core structures, and I had\n> some questions around these names (since we hope to be stuck with\n> the new names for a long time). I was thinking out loud on a per-\n> patch basis, but now want to collect my thoughts around these:\n> \n>  * raw_object_store currently describes the abstraction that contains\n>    all objects that can be accessed within the repository. This may\n>    include multiple alternates. Patch 1 renames this to\n>    'object_database'.\n> \n>  * object_directory currently describes a single directory that\n>    has the same structure as $GIT_DIR/objects/ but may be an alternate\n>    or a submodule object directory. Patch 2 renames this to\n>    'odb_backend'.\n> \n> My concerns around this are basically around not liking \"backend\" for\n> this purpose. When I think of a backend, I'm thinking about the\n> implementation details (like the refs backend being files or reftable)\n> and not multiple distinct locations that have their own objects.\n\nThat is very much the intent eventually. Right now the backend is always\nthe one that uses loose objects and packfiles. But eventually, the goal\nis to introduce different backends.\n\nBut regardless of that, ...\n\n> In this sense, I'm partial to being brief for the most-common structure\n> that will be passed around and then more descriptive about the smaller\n> pieces:\n> \n>  * 'struct raw_object_store' could be renamed to 'struct odb' to match\n>    its use in all of the new odb_*() methods. This represents the\n>    \"object database abstraction\" and consumers don't care if this is\n>    one or many object directories in a trench coat.\n\n    NB: I think having a long name here is nicer, even if it's\n    abbreviated in the functions. But that's mostly my own preference, I\n    don't care too much. I'll keep this as-is in the next iteration, but\n    if you feel strongly I'm certainly happy to rename it to `struct\n    odb`. Just give me a ping and I'll do so.\n\n>  * 'struct object_directory' could be renamed to 'struct odb_shard' or\n>    'struct odb_slice' or similar. I may even recommend 'odb_partition'\n>    though that does imply some disjointness that is not guaranteed (an\n>    object can exist in multiple parts).\n> \n>  * In the event that we create multiple implementations for storing\n>    objects, then a 'struct odb_shard' could point to a backend to help\n>    find the appropriate methods for interacting with its storage.\n\n... I have decided to rename this to `odb_alternate`. I don't think\n\"shard\" works well, as shard is an extremely generic term that doesn't\nreally convey much meaning.\n\nOn the other hand, I think that `odb_alternate` is quite a good fit. We\nalready use it all over the place to mean almost exactly what we are\nafter here. And it doesn't seem far-fetched to have an\n`odb_packed_alternate`, `odb_loose_alternate` and `odb_redis_alternate`\nfor different backends.\n\nThe only stretch is that the primary object directory is now the primary\nalternate. I think that this is acceptable though'\n\n>  * \"alternate refs\" are locked in as names based on the following\n>    config key names:\n> \n>    - core.alternateRefsCommand\n>    - core.alternateRefsPrefix\n> \n>    These user-facing names should not change. This may be valuable to\n>    make sure that the 'odb_shard's still have a state of \"I'm an\n>    alternate\" or \"I'm the base read/write shard for this repo\".\n\nAgreed.\n\n> >    - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n> \n> These are carefully done. Thanks. I only have a few nitpicks here\n> and there.\n> \n> >    - Patches 13 to 17 adjust the name of remaining functions so that they\n> >      can be clearly attributed to the ODB. I'm happy to kick these\n> >      patches out of this series and resend them at a later point in case\n> >      they create too much turmoil.\n> \n> I like that these are present, especially because you included\n> compatibility macros for in-flight topics.\n> \n> I do mention that the rename of the object-store.[c|h] files may be\n> unnecessary, or perhaps could be delayed until this series is merged\n> and the collateral is calmed.\n> \n> ---\n> \n> This was clearly a lot of work to put together. Thanks for working\n> hard to thoughtfully rename things while refactoring to reduce our\n> dependence on global state.\n\nWell. Frankly, the hard work is only just starting. Next step: push down\n`struct packed_git` from `struct object_database` to `odb_alternate`.\nI'm scared what I'll find there.\n\nPatrick\n"},{"id":"517660","messageId":"aB3mNiiAGE2KHbGY@pks.im","threadId":"63403","inReplyTo":"xmqqa57oe4mj.fsf@gitster.g","subject":"Re: [PATCH 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T11:25:42Z","receivedAt":"2025-05-09T11:25:44Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, May 07, 2025 at 10:02:12AM -0700, Junio C Hamano wrote:\n> Derrick Stolee <stolee@gmail.com> writes:\n> \n> > Patches 1 and 2 involve renaming some core structures, and I had\n> > some questions around these names (since we hope to be stuck with\n> > the new names for a long time). I was thinking out loud on a per-\n> > patch basis, but now want to collect my thoughts around these:\n> >\n> >  * raw_object_store currently describes the abstraction that contains\n> >    all objects that can be accessed within the repository. This may\n> >    include multiple alternates. Patch 1 renames this to\n> >    'object_database'.\n> >\n> >  * object_directory currently describes a single directory that\n> >    has the same structure as $GIT_DIR/objects/ but may be an alternate\n> >    or a submodule object directory. Patch 2 renames this to\n> >    'odb_backend'.\n> >\n> > My concerns around this are basically around not liking \"backend\" for\n> > this purpose. When I think of a backend, I'm thinking about the\n> > implementation details (like the refs backend being files or reftable)\n> > and not multiple distinct locations that have their own objects.\n> \n> Yup, odb_backend_files (aot odb_backend_redis) or something?\n\nYeah, that was my vision indeed. I think it works equally well though in\ncase we name this `odb_alternate`. The benefit of the \"alternate\"\nterminology is that we already use it and it's almost a perfect fit, and\nit gives the reader a hint that we may have multiple alternates. On the\nother hand, `odb_backend` sounds as if there would only be a single\nbackend for a `struct object_database`.\n\nSo Stolee caused me to reconsider and favor `odb_alternate`. But in the\nend I guess that both names would work alright.\n\n> >  * 'struct object_directory' could be renamed to 'struct odb_shard' or\n> >    'struct odb_slice' or similar. I may even recommend 'odb_partition'\n> >    though that does imply some disjointness that is not guaranteed (an\n> >    object can exist in multiple parts).\n> >\n> >  * In the event that we create multiple implementations for storing\n> >    objects, then a 'struct odb_shard' could point to a backend to help\n> >    find the appropriate methods for interacting with its storage.\n> \n> Hmph, I do not have strong opinions, but I consider it an\n> implementation detail of one particular backend, namely, the\n> filesystem based backend, that it can link together multiple\n> object_directory instances and present them as if they form a single\n> object database, just like all files within a single object_directory\n> form an illusion of a single object database (aka key-value store) even\n> though some objects are stored in individual loose object files while\n> many others are packed in a single packfile.\n> \n> I did not expect you would want to go to the world where a single\n> \"shard\" consists of an object_directory backed by the filesystem and\n> some other more database-y backend.  It is an interesting idea, but\n> we'd need to worry about many things we do not have to worry about\n> right now.  E.g. what do the precedence rules among different\n> components within a single \"shard\" look like?  How do we express \"in\n> this repository, local filesystem-backed piece is consulted first,\n> and then check this piece backed by low-cost but high-latency\n> storage backend\"?\n\nWell, in fact I want to design this from the start so that you can mix\nand match different backends. I think it falls out naturally from the\ndesign if an alternate can be backed by anything, and it has a lot of\nvery interesting features.\n\nFurthermore, it would cause a bunch of problems if we _didn't_ allow for\nthis, at least for hosting providers:\n\n  - Migrations would now need to be atomic across fork networks where\n    all forks need to be migrated at once so that we don't mix backends.\n\n  - Migrations in general would be a pain if we had to do an atomic\n    migration even for a single object directory. With mixed backends we\n    can already make a partially-migrated backend available while the\n    old backend is still in use.\n\n  - High-latency storage backends may work well for binary files, but\n    not for smallish text files. \n\nThis all of course still needs to be hashed out. I do want to send an\nRFC document to the mailing list soonish, probably in the first half of\nthe Git 2.51 release cycle, so that we can discuss where to go.\n\n> > I do mention that the rename of the object-store.[c|h] files may be\n> > unnecessary, or perhaps could be delayed until this series is merged\n> > and the collateral is calmed.\n> \n> Right now, merge-fix needed against all other topics in flight look\n> like this, in order to merge it to 'seen'.\n\nOkay. In that case I'll keep that patch for now.\n\nPatrick\n"},{"id":"517664","messageId":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH v2 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:00Z","receivedAt":"2025-05-09T14:12:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series refactors the object store subsystem to become more\nself-contained by getting rid of `the_repository`. Instead of passing in\nthe repository explicitly, we start to pass in the object store itself,\nwhich is in contrast to many other refactorings we did, but in line with\nwhat we did for the ref store, as well.\n\nThis series also starts to properly scope functions to the carved out\nobject database subsystem, which requires a bit of shuffling. This\nallows us to have a short-and-sweet `odb_` prefix for functions and\nprepares us for a future with pluggable object backends.\n\nThe series is structured as follows:\n\n  - Patches 1 to 3 rename `struct object_store` and `struct\n    object_directory` as well as the code files.\n\n  - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n\n  - Patches 13 to 17 adjust the name of remaining functions so that they\n    can be clearly attributed to the ODB. I'm happy to kick these\n    patches out of this series and resend them at a later point in case\n    they create too much turmoil.\n\nThis series is built on top of 6f84262c44a (The eleventh batch,\n2025-05-05) with ps/object-store-cleanup at 8a9e27be821 (object-store:\ndrop `repo_has_object_file()`, 2025-04-29) merged into it. There are a\ncouple of trivial conflicts when merged with \"seen\", I have appended the\nmerge conflict resolution as a patch at the end of this mail.\n\nChanges in v2:\n  - Fix for a copy-and-pasted commit message.\n  - Rename `struct odb_backend` to `struct odb_alternate`. I'm happy to\n    revert to the previous name if we ultimately think it's the better\n    suited one.\n  - A couple of fixes to move changes into the correct commit. `git\n    rebase -x 'meson compile -C build'` is now clean.\n  - I _didn't_ back out the rename to \"odb.{c,h}\". Junio has already\n    fixed the fallout, so it's probably more work for him to kick it out\n    again than to just leave it in.\n  - Link to v1: https://lore.kernel.org/r/20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (17):\n      object-store: rename `raw_object_store` to `object_database`\n      object-store: rename `object_directory` to `odb_alternate`\n      object-store: rename files to \"odb.{c,h}\"\n      odb: introduce parent pointers\n      odb: get rid of `the_repository` in `find_odb()`\n      odb: get rid of `the_repository` in `assert_oid_type()`\n      odb: get rid of `the_repository` in `odb_mkstemp()`\n      odb: get rid of `the_repository` when handling alternates\n      odb: get rid of `the_repository`  in `for_each()` functions\n      odb: get rid of `the_repository` when handling the primary alternate\n      odb: get rid of `the_repository` when handling submodule alternates\n      odb: trivial refactorings to get rid of `the_repository`\n      odb: rename `oid_object_info()`\n      odb: rename `repo_read_object_file()`\n      odb: rename `has_object()`\n      odb: rename `pretend_object_file()`\n      odb: rename `read_object_with_reference()`\n\n Documentation/user-manual.adoc          |   4 +-\n Makefile                                |   2 +-\n apply.c                                 |  14 +-\n archive-tar.c                           |   2 +-\n archive-zip.c                           |   2 +-\n archive.c                               |   6 +-\n attr.c                                  |   4 +-\n bisect.c                                |   8 +-\n blame.c                                 |  22 +-\n builtin/backfill.c                      |   6 +-\n builtin/blame.c                         |   6 +-\n builtin/cat-file.c                      |  62 +++--\n builtin/checkout.c                      |   2 +-\n builtin/clone.c                         |  14 +-\n builtin/commit-graph.c                  |  20 +-\n builtin/commit-tree.c                   |   4 +-\n builtin/count-objects.c                 |   6 +-\n builtin/describe.c                      |   5 +-\n builtin/difftool.c                      |   4 +-\n builtin/fast-export.c                   |  10 +-\n builtin/fast-import.c                   |  49 ++--\n builtin/fetch.c                         |  21 +-\n builtin/fsck.c                          |  31 +--\n builtin/gc.c                            |  16 +-\n builtin/grep.c                          |  26 +-\n builtin/hash-object.c                   |   2 +-\n builtin/index-pack.c                    |  29 +--\n builtin/log.c                           |   4 +-\n builtin/ls-files.c                      |   4 +-\n builtin/ls-tree.c                       |   6 +-\n builtin/merge-file.c                    |   2 +-\n builtin/merge-tree.c                    |  14 +-\n builtin/mktag.c                         |   6 +-\n builtin/mktree.c                        |  10 +-\n builtin/multi-pack-index.c              |   6 +-\n builtin/notes.c                         |   8 +-\n builtin/pack-objects.c                  |  70 +++---\n builtin/pack-redundant.c                |   2 +-\n builtin/prune.c                         |   6 +-\n builtin/receive-pack.c                  |   9 +-\n builtin/remote.c                        |   6 +-\n builtin/repack.c                        |   7 +-\n builtin/replace.c                       |  12 +-\n builtin/rev-list.c                      |   8 +-\n builtin/show-ref.c                      |   6 +-\n builtin/submodule--helper.c             |  11 +-\n builtin/tag.c                           |  10 +-\n builtin/unpack-file.c                   |   4 +-\n builtin/unpack-objects.c                |  12 +-\n bulk-checkin.c                          |   6 +-\n bundle-uri.c                            |   5 +-\n bundle.c                                |   6 +-\n cache-tree.c                            |  17 +-\n combine-diff.c                          |   4 +-\n commit-graph.c                          | 106 ++++----\n commit-graph.h                          |  20 +-\n commit.c                                |  15 +-\n config.c                                |   4 +-\n connected.c                             |   2 +-\n contrib/coccinelle/the_repository.cocci |   2 +-\n diagnose.c                              |  12 +-\n diff.c                                  |  20 +-\n dir.c                                   |   2 +-\n entry.c                                 |   6 +-\n fetch-pack.c                            |  17 +-\n fmt-merge-msg.c                         |   6 +-\n fsck.c                                  |   4 +-\n grep.c                                  |   6 +-\n http-backend.c                          |   2 +-\n http-push.c                             |  20 +-\n http-walker.c                           |  12 +-\n http.c                                  |   6 +-\n list-objects-filter.c                   |   4 +-\n list-objects.c                          |   6 +-\n log-tree.c                              |   2 +-\n loose.c                                 |  46 ++--\n mailmap.c                               |   4 +-\n match-trees.c                           |   6 +-\n merge-blobs.c                           |  10 +-\n merge-ort.c                             |   8 +-\n meson.build                             |   2 +-\n midx-write.c                            |   2 +-\n midx.c                                  |   6 +-\n notes-cache.c                           |   4 +-\n notes-merge.c                           |   4 +-\n notes.c                                 |  19 +-\n object-file.c                           |  94 ++++----\n object-file.h                           |  12 +-\n object-name.c                           |  24 +-\n object.c                                |   8 +-\n object-store.c => odb.c                 | 413 +++++++++++++++++---------------\n object-store.h => odb.h                 | 269 +++++++++++++++------\n oss-fuzz/fuzz-pack-idx.c                |   2 +-\n pack-bitmap-write.c                     |   9 +-\n pack-bitmap.c                           |  10 +-\n pack-check.c                            |   2 +-\n pack-mtimes.c                           |   2 +-\n pack-objects.h                          |   2 +-\n pack-revindex.c                         |   2 +-\n pack-write.c                            |  10 +-\n packfile.c                              |  29 +--\n packfile.h                              |   8 +-\n path.c                                  |   4 +-\n promisor-remote.c                       |   6 +-\n protocol-caps.c                         |   4 +-\n reachable.c                             |   2 +-\n read-cache.c                            |  14 +-\n ref-filter.c                            |   6 +-\n reflog.c                                |   8 +-\n refs.c                                  |   7 +-\n remote.c                                |   9 +-\n replace-object.c                        |   2 +-\n replace-object.h                        |   2 +-\n repository.c                            |  21 +-\n repository.h                            |   4 +-\n rerere.c                                |   7 +-\n revision.c                              |   5 +-\n send-pack.c                             |   4 +-\n sequencer.c                             |   7 +-\n server-info.c                           |   2 +-\n shallow.c                               |  14 +-\n streaming.c                             |  10 +-\n submodule-config.c                      |   9 +-\n submodule.c                             |  32 +--\n submodule.h                             |   9 -\n t/helper/test-find-pack.c               |   2 +-\n t/helper/test-pack-mtimes.c             |   2 +-\n t/helper/test-partial-clone.c           |   4 +-\n t/helper/test-read-graph.c              |   8 +-\n t/helper/test-read-midx.c               |   2 +-\n t/helper/test-ref-store.c               |   4 +-\n tag.c                                   |  10 +-\n tmp-objdir.c                            |  30 +--\n tree-walk.c                             |  18 +-\n tree.c                                  |   6 +-\n unpack-trees.c                          |   2 +-\n upload-pack.c                           |   4 +-\n walker.c                                |   6 +-\n xdiff-interface.c                       |   4 +-\n 139 files changed, 1177 insertions(+), 1032 deletions(-)\n\nRange-diff versus v1:\n\n 1:  83f6482bffd =  1:  683857de5d7 object-store: rename `raw_object_store` to `object_database`\n 2:  1009722a206 <  -:  ----------- object-store: rename `object_directory` to `odb_backend`\n -:  ----------- >  2:  5b13164e353 object-store: rename `object_directory` to `odb_alternate`\n 3:  fd36b863411 =  3:  abd9ecd1589 object-store: rename files to \"odb.{c,h}\"\n 4:  910ef0beb61 !  4:  25e30b9040b odb: introduce parent pointers\n    @@ Commit message\n     \n         In subsequent commits we'll get rid of our use of `the_repository` in\n         \"odb.c\" in favor of explicitly passing in a `struct object_database` or\n    -    a `struct odb_backend`. In some cases though we'll need access to the\n    +    a `struct odb_alternate`. In some cases though we'll need access to the\n         repository, for example to read a config value from it, but we don't\n         have a way to access the repository owning a specific object database.\n     \n         Introduce parent pointers for `struct object_database` to its owning\n    -    repository as well as for `struct odb_backend` to its owning object\n    +    repository as well as for `struct odb_alternate` to its owning object\n         database, which will allow us to adapt those use cases.\n     \n         Note that this change requires us to pass through the object database to\n         `link_alt_odb_entry()` so that we can set up the parent pointers for any\n    -    alternative backends there. The callchain is adapted to pass through the\n    -    object database accordingly.\n    +    alternate there. The callchain is adapted to pass through the object\n    +    database accordingly.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n     \n    @@ odb.c: static int alt_odb_usable(struct object_database *o,\n     +\t\t\t      int depth,\n     +\t\t\t      const char *normalized_objdir)\n      {\n    - \tstruct odb_backend *backend;\n    + \tstruct odb_alternate *alternate;\n      \tstruct strbuf pathbuf = STRBUF_INIT;\n     @@ odb.c: static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n      \twhile (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')\n    @@ odb.c: static int link_alt_odb_entry(struct repository *r, const struct strbuf *\n     +\tif (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))\n      \t\tgoto error;\n      \n    - \tCALLOC_ARRAY(backend, 1);\n    -+\tbackend->odb = odb;\n    - \t/* pathbuf.buf is already in r->objects->backend_by_path */\n    - \tbackend->path = strbuf_detach(&pathbuf, NULL);\n    + \tCALLOC_ARRAY(alternate, 1);\n    ++\talternate->odb = odb;\n    + \t/* pathbuf.buf is already in r->objects->alternate_by_path */\n    + \talternate->path = strbuf_detach(&pathbuf, NULL);\n      \n      \t/* add the alternate entry */\n    --\t*r->objects->backends_tail = backend;\n    --\tr->objects->backends_tail = &(backend->next);\n    -+\t*odb->backends_tail = backend;\n    -+\todb->backends_tail = &(backend->next);\n    - \tbackend->next = NULL;\n    --\tassert(r->objects->backend_by_path);\n    --\tkh_value(r->objects->backend_by_path, pos) = backend;\n    -+\tassert(odb->backend_by_path);\n    -+\tkh_value(odb->backend_by_path, pos) = backend;\n    +-\t*r->objects->alternates_tail = alternate;\n    +-\tr->objects->alternates_tail = &(alternate->next);\n    ++\t*odb->alternates_tail = alternate;\n    ++\todb->alternates_tail = &(alternate->next);\n    + \talternate->next = NULL;\n    +-\tassert(r->objects->alternate_by_path);\n    +-\tkh_value(r->objects->alternate_by_path, pos) = alternate;\n    ++\tassert(odb->alternate_by_path);\n    ++\tkh_value(odb->alternate_by_path, pos) = alternate;\n      \n      \t/* recursively add alternates */\n    --\tread_info_alternates(r, backend->path, depth + 1);\n    -+\tread_info_alternates(odb, backend->path, depth + 1);\n    +-\tread_info_alternates(r, alternate->path, depth + 1);\n    ++\tread_info_alternates(odb, alternate->path, depth + 1);\n      \tret = 0;\n       error:\n      \tstrbuf_release(&tmp);\n    @@ odb.c: static void link_alt_odb_entries(struct repository *r, const char *alt,\n      \t\treturn;\n      \t}\n      \n    --\tstrbuf_realpath(&objdirbuf, r->objects->backends->path, 1);\n    -+\tstrbuf_realpath(&objdirbuf, odb->backends->path, 1);\n    +-\tstrbuf_realpath(&objdirbuf, r->objects->alternates->path, 1);\n    ++\tstrbuf_realpath(&objdirbuf, odb->alternates->path, 1);\n      \n      \twhile (*alt) {\n      \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n    @@ odb.c: void add_to_alternates_memory(const char *reference)\n      \t\t\t     '\\n', NULL, 0);\n      }\n      \n    -@@ odb.c: struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy)\n    +@@ odb.c: struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n      \t * alternate\n      \t */\n    - \tbackend = xcalloc(1, sizeof(*backend));\n    -+\tbackend->odb = the_repository->objects;\n    - \tbackend->path = xstrdup(dir);\n    + \talternate = xcalloc(1, sizeof(*alternate));\n    ++\talternate->odb = the_repository->objects;\n    + \talternate->path = xstrdup(dir);\n      \n      \t/*\n     @@ odb.c: void prepare_alt_odb(struct repository *r)\n    @@ odb.c: void prepare_alt_odb(struct repository *r)\n     -\tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n     +\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n      \n    --\tread_info_alternates(r, r->objects->backends->path, 0);\n    -+\tread_info_alternates(r->objects, r->objects->backends->path, 0);\n    +-\tread_info_alternates(r, r->objects->alternates->path, 0);\n    ++\tread_info_alternates(r->objects, r->objects->alternates->path, 0);\n      \tr->objects->loaded_alternates = 1;\n      }\n      \n    -@@ odb.c: struct object_database *odb_new(struct repository *repo)\n    +@@ odb.c: void assert_oid_type(const struct object_id *oid, enum object_type expect)\n    + \t\t    type_name(expect));\n    + }\n    + \n    +-struct object_database *odb_new(void)\n    ++struct object_database *odb_new(struct repository *repo)\n    + {\n      \tstruct object_database *o = xmalloc(sizeof(*o));\n      \n      \tmemset(o, 0, sizeof(*o));\n    @@ odb.c: struct object_database *odb_new(struct repository *repo)\n     \n      ## odb.h ##\n     @@ odb.h: struct repository;\n    - struct odb_backend {\n    - \tstruct odb_backend *next;\n    + struct odb_alternate {\n    + \tstruct odb_alternate *next;\n      \n    -+\t/* Object database that owns this backend. */\n    ++\t/* Object database that owns this alternate. */\n     +\tstruct object_database *odb;\n     +\n      \t/*\n    @@ odb.h: struct cached_object_entry;\n      \t/*\n      \t * Set of all object directories; the main directory is first (and\n      \t * cannot be NULL after initialization). Subsequent directories are\n    +@@ odb.h: struct object_database {\n    + \tunsigned packed_git_initialized : 1;\n    + };\n    + \n    +-struct object_database *odb_new(void);\n    ++struct object_database *odb_new(struct repository *repo);\n    + void odb_clear(struct object_database *o);\n    + \n    + /*\n    +\n    + ## repository.c ##\n    +@@ repository.c: static void set_default_hash_algo(struct repository *repo)\n    + \n    + void initialize_repository(struct repository *repo)\n    + {\n    +-\trepo->objects = odb_new();\n    ++\trepo->objects = odb_new(repo);\n    + \trepo->remote_state = remote_state_new();\n    + \trepo->parsed_objects = parsed_object_pool_new(repo);\n    + \tALLOC_ARRAY(repo->index, 1);\n    +@@ repository.c: void repo_set_gitdir(struct repository *repo,\n    + \n    + \tif (!repo->objects->alternates) {\n    + \t\tCALLOC_ARRAY(repo->objects->alternates, 1);\n    ++\t\trepo->objects->alternates->odb = repo->objects;\n    + \t\trepo->objects->alternates_tail = &repo->objects->alternates->next;\n    + \t}\n    + \texpand_base_dir(&repo->objects->alternates->path, o->object_dir,\n 5:  a045ad2f30e <  -:  ----------- odb: get rid of `the_repository` in `find_odb()`\n -:  ----------- >  5:  b642cc5bb8b odb: get rid of `the_repository` in `find_odb()`\n 6:  e408fb9a963 =  6:  188240381ce odb: get rid of `the_repository` in `assert_oid_type()`\n 7:  f2da8b8d507 !  7:  61a27202f3e odb: get rid of `the_repository` in `assert_oid_type()`\n    @@ Metadata\n     Author: Patrick Steinhardt <ps@pks.im>\n     \n      ## Commit message ##\n    -    odb: get rid of `the_repository` in `assert_oid_type()`\n    +    odb: get rid of `the_repository` in `odb_mkstemp()`\n     \n    -    Get rid of our dependency on `the_repository` in `assert_oid_type()` by\n    +    Get rid of our dependency on `the_repository` in `odb_mkstemp()` by\n         passing in the object database as a parameter and adjusting all callers.\n     \n    -    Rename the function to `odb_assert_oid_type()`.\n    -\n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n     \n      ## builtin/fast-import.c ##\n    @@ odb.c: int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n     \n      ## odb.h ##\n     @@ odb.h: void odb_clear(struct object_database *o);\n    - struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir);\n    + struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n      \n      /*\n     - * Create a temporary file rooted in the object database directory, or\n     - * die on failure. The filename is taken from \"pattern\", which should have the\n    -- * usual \"XXXXXX\" trailer, and the resulting filename is written into the\n    -- * \"template\" buffer. Returns the open descriptor.\n    -+ * Create a temporary file rooted in the primary object database backend's\n    -+ * directory, or die on failure. The filename is taken from \"pattern\", which\n    -+ * should have the usual \"XXXXXX\" trailer, and the resulting filename is\n    -+ * written into the \"template\" buffer. Returns the open descriptor.\n    ++ * Create a temporary file rooted in the primary alternate's directory, or die\n    ++ * on failure. The filename is taken from \"pattern\", which should have the\n    +  * usual \"XXXXXX\" trailer, and the resulting filename is written into the\n    +  * \"template\" buffer. Returns the open descriptor.\n       */\n     -int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);\n     +int odb_mkstemp(struct object_database *odb,\n 8:  852ff66ec5e !  8:  8b6801ea2dd odb: get rid of `the_repository` when handling alternates\n    @@ builtin/fsck.c: int cmd_fsck(int argc,\n      \t} else {\n     -\t\tprepare_alt_odb(the_repository);\n     +\t\todb_prepare_alternates(the_repository->objects);\n    - \t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next)\n    - \t\t\tfsck_object_dir(backend->path);\n    + \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next)\n    + \t\t\tfsck_object_dir(alternate->path);\n      \n     @@ builtin/fsck.c: int cmd_fsck(int argc,\n      \tif (the_repository->settings.core_commit_graph) {\n    @@ builtin/fsck.c: int cmd_fsck(int argc,\n      \n     -\t\tprepare_alt_odb(the_repository);\n     +\t\todb_prepare_alternates(the_repository->objects);\n    - \t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n    + \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n      \t\t\tchild_process_init(&commit_graph_verify);\n      \t\t\tcommit_graph_verify.git_cmd = 1;\n     @@ builtin/fsck.c: int cmd_fsck(int argc,\n    @@ builtin/fsck.c: int cmd_fsck(int argc,\n      \n     -\t\tprepare_alt_odb(the_repository);\n     +\t\todb_prepare_alternates(the_repository->objects);\n    - \t\tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n    + \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n      \t\t\tchild_process_init(&midx_verify);\n      \t\t\tmidx_verify.git_cmd = 1;\n     \n    @@ commit-graph.c: struct commit_graph *load_commit_graph_chain_fd_st(struct reposi\n     +\todb_prepare_alternates(r->objects);\n      \n      \tfor (i = 0; i < count; i++) {\n    - \t\tstruct odb_backend *backend;\n    + \t\tstruct odb_alternate *alternate;\n     @@ commit-graph.c: static int prepare_commit_graph(struct repository *r)\n      \tif (!commit_graph_compatible(r))\n      \t\treturn 0;\n      \n     -\tprepare_alt_odb(r);\n     +\todb_prepare_alternates(r->objects);\n    - \tfor (backend = r->objects->backends;\n    - \t     !r->objects->commit_graph && backend;\n    - \t     backend = backend->next)\n    + \tfor (alternate = r->objects->alternates;\n    + \t     !r->objects->commit_graph && alternate;\n    + \t     alternate = alternate->next)\n     \n      ## loose.c ##\n     @@ loose.c: int repo_read_loose_object_map(struct repository *repo)\n    @@ loose.c: int repo_read_loose_object_map(struct repository *repo)\n     -\tprepare_alt_odb(repo);\n     +\todb_prepare_alternates(repo->objects);\n      \n    - \tfor (backend = repo->objects->backends; backend; backend = backend->next) {\n    - \t\tif (load_one_loose_object_map(repo, backend) < 0) {\n    + \tfor (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n    + \t\tif (load_one_loose_object_map(repo, alternate) < 0) {\n     \n      ## object-file.c ##\n     @@ object-file.c: static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n      {\n    - \tstruct odb_backend *backend;\n    + \tstruct odb_alternate *alternate;\n      \n     -\tprepare_alt_odb(the_repository);\n     +\todb_prepare_alternates(the_repository->objects);\n    - \tfor (backend = the_repository->objects->backends->next; backend; backend = backend->next) {\n    - \t\tif (check_and_freshen_odb(backend, oid, freshen))\n    + \tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n    + \t\tif (check_and_freshen_odb(alternate, oid, freshen))\n      \t\t\treturn 1;\n     @@ object-file.c: static int stat_loose_object(struct repository *r, const struct object_id *oid,\n    - \tstruct odb_backend *backend;\n    + \tstruct odb_alternate *alternate;\n      \tstatic struct strbuf buf = STRBUF_INIT;\n      \n     -\tprepare_alt_odb(r);\n     +\todb_prepare_alternates(r->objects);\n    - \tfor (backend = r->objects->backends; backend; backend = backend->next) {\n    - \t\t*path = odb_loose_path(backend, &buf, oid);\n    + \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    + \t\t*path = odb_loose_path(alternate, &buf, oid);\n      \t\tif (!lstat(*path, st))\n     @@ object-file.c: static int open_loose_object(struct repository *r,\n      \tint most_interesting_errno = ENOENT;\n    @@ object-file.c: static int open_loose_object(struct repository *r,\n      \n     -\tprepare_alt_odb(r);\n     +\todb_prepare_alternates(r->objects);\n    - \tfor (backend = r->objects->backends; backend; backend = backend->next) {\n    - \t\t*path = odb_loose_path(backend, &buf, oid);\n    + \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    + \t\t*path = odb_loose_path(alternate, &buf, oid);\n      \t\tfd = git_open(*path);\n     @@ object-file.c: static int quick_has_loose(struct repository *r,\n      {\n    - \tstruct odb_backend *backend;\n    + \tstruct odb_alternate *alternate;\n      \n     -\tprepare_alt_odb(r);\n     +\todb_prepare_alternates(r->objects);\n    - \tfor (backend = r->objects->backends; backend; backend = backend->next) {\n    - \t\tif (oidtree_contains(odb_loose_cache(backend, oid), oid))\n    + \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    + \t\tif (oidtree_contains(odb_loose_cache(alternate, oid), oid))\n      \t\t\treturn 1;\n     @@ object-file.c: int for_each_loose_object(each_loose_object_fn cb, void *data,\n      {\n    - \tstruct odb_backend *backend;\n    + \tstruct odb_alternate *alternate;\n      \n     -\tprepare_alt_odb(the_repository);\n     +\todb_prepare_alternates(the_repository->objects);\n    - \tfor (backend = the_repository->objects->backends; backend; backend = backend->next) {\n    - \t\tint r = for_each_loose_file_in_objdir(backend->path, cb, NULL,\n    + \tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n    + \t\tint r = for_each_loose_file_in_objdir(alternate->path, cb, NULL,\n      \t\t\t\t\t\t      NULL, data);\n     \n      ## object-name.c ##\n    @@ odb.c: void add_to_alternates_file(const char *reference)\n      \t\t\t     '\\n', NULL, 0);\n      }\n      \n    -@@ odb.c: struct odb_backend *set_temporary_primary_odb(const char *dir, int will_destroy)\n    +@@ odb.c: struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n      \t * Make sure alternates are initialized, or else our entry may be\n      \t * overwritten when they are.\n      \t */\n    @@ odb.c: struct odb_backend *set_temporary_primary_odb(const char *dir, int will_d\n      \n      \t/*\n      \t * Make a new primary odb and link the old primary ODB in as an\n    -@@ odb.c: void restore_primary_odb(struct odb_backend *restore_odb, const char *old_path)\n    - \tfree_object_directory(cur_odb);\n    +@@ odb.c: void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path\n    + \tfree_object_directory(cur_alt);\n      }\n      \n     -/*\n    @@ odb.c: void restore_primary_odb(struct odb_backend *restore_odb, const char *old\n      char *compute_alternate_path(const char *path, struct strbuf *err)\n      {\n      \tchar *ref_git = NULL;\n    -@@ odb.c: struct odb_backend *odb_find_backend(struct object_database *odb, const char *ob\n    +@@ odb.c: struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n      \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n      \tstruct strbuf odb_path_real = STRBUF_INIT;\n      \n     -\tprepare_alt_odb(odb->repo);\n     +\todb_prepare_alternates(odb);\n    - \tfor (backend = odb->backends; backend; backend = backend->next) {\n    - \t\tstrbuf_realpath(&odb_path_real, backend->path, 1);\n    + \tfor (alternate = odb->alternates; alternate; alternate = alternate->next) {\n    + \t\tstrbuf_realpath(&odb_path_real, alternate->path, 1);\n      \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n     @@ odb.c: int foreach_alt_odb(alt_odb_fn fn, void *cb)\n    - \tstruct odb_backend *backend;\n    + \tstruct odb_alternate *alternate;\n      \tint r = 0;\n      \n     -\tprepare_alt_odb(the_repository);\n     +\todb_prepare_alternates(the_repository->objects);\n    - \tfor (backend = the_repository->objects->backends->next; backend; backend = backend->next) {\n    - \t\tr = fn(backend, cb);\n    + \tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n    + \t\tr = fn(alternate, cb);\n      \t\tif (r)\n     @@ odb.c: int foreach_alt_odb(alt_odb_fn fn, void *cb)\n      \treturn r;\n    @@ odb.c: int foreach_alt_odb(alt_odb_fn fn, void *cb)\n     -\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n     +\tlink_alt_odb_entries(odb, odb->alternate_db, PATH_SEP, NULL, 0);\n      \n    --\tread_info_alternates(r->objects, r->objects->backends->path, 0);\n    +-\tread_info_alternates(r->objects, r->objects->alternates->path, 0);\n     -\tr->objects->loaded_alternates = 1;\n    -+\tread_info_alternates(odb, odb->backends->path, 0);\n    ++\tread_info_alternates(odb, odb->alternates->path, 0);\n     +\todb->loaded_alternates = 1;\n      }\n      \n    @@ odb.c: int foreach_alt_odb(alt_odb_fn fn, void *cb)\n     +int odb_has_alternates(struct object_database *odb)\n      {\n     -\tprepare_alt_odb(r);\n    --\treturn !!r->objects->backends->next;\n    +-\treturn !!r->objects->alternates->next;\n     +\todb_prepare_alternates(odb);\n    -+\treturn !!odb->backends->next;\n    ++\treturn !!odb->alternates->next;\n      }\n      \n      int obj_read_use_lock = 0;\n    @@ odb.h: struct oidtree;\n     + */\n     +char *compute_alternate_path(const char *path, struct strbuf *err);\n     +\n    - /* The backend used to access objects in a specific object directory. */\n    - struct odb_backend {\n    - \tstruct odb_backend *next;\n    -@@ odb.h: struct odb_backend {\n    + /*\n    +  * An alternate part of an object database that stores the actual objects.\n    +  */\n    +@@ odb.h: struct odb_alternate {\n      \tchar *path;\n      };\n      \n     -void prepare_alt_odb(struct repository *r);\n     -int has_alt_odb(struct repository *r);\n     -char *compute_alternate_path(const char *path, struct strbuf *err);\n    - typedef int alt_odb_fn(struct odb_backend *, void *);\n    + typedef int alt_odb_fn(struct odb_alternate *, void *);\n      int foreach_alt_odb(alt_odb_fn, void*);\n      typedef void alternate_ref_fn(const struct object_id *oid, void *);\n      void for_each_alternate_ref(alternate_ref_fn, void *);\n    @@ odb.h: struct object_database {\n      \t/*\n      \t * A list of alternate object directories loaded from the environment;\n      \t * this should not generally need to be accessed directly, but will\n    --\t * populate the \"backends\" list when prepare_alt_odb() is run.\n    -+\t * populate the \"backends\" list when odb_prepare_alternates() is run.\n    +-\t * populate the \"alternates\" list when prepare_alt_odb() is run.\n    ++\t * populate the \"alternates\" list when odb_prepare_alternates() is run.\n      \t */\n      \tchar *alternate_db;\n      \n    -@@ odb.h: struct odb_backend *odb_find_backend(struct object_database *odb, const char *ob\n    +@@ odb.h: struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n      int odb_mkstemp(struct object_database *odb,\n      \t\tstruct strbuf *temp_filename, const char *pattern);\n      \n     +/*\n     + * Prepare alternate object backends for the given database by reading\n    -+ * \"objects/info/alternates\" and opening the respective backends.\n    ++ * \"objects/info/alternates\" and opening the respective alternates.\n     + */\n     +void odb_prepare_alternates(struct object_database *odb);\n     +\n     +/*\n    -+ * Check whether the object database has any alternate backends. The primary\n    -+ * object backend does not count as alternate.\n    ++ * Check whether the object database has any alternates. The primary object\n    ++ * backend does not count as alternate.\n     + */\n     +int odb_has_alternates(struct object_database *odb);\n     +\n    @@ packfile.c: static void prepare_packed_git(struct repository *r)\n      \n     -\tprepare_alt_odb(r);\n     +\todb_prepare_alternates(r->objects);\n    - \tfor (backend = r->objects->backends; backend; backend = backend->next) {\n    - \t\tint local = (backend == r->objects->backends);\n    - \t\tprepare_multi_pack_index_one(r, backend->path, local);\n    + \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    + \t\tint local = (alternate == r->objects->alternates);\n    + \t\tprepare_multi_pack_index_one(r, alternate->path, local);\n     @@ packfile.c: void reprepare_packed_git(struct repository *r)\n      \t * the lifetime of the process.\n      \t */\n    @@ packfile.c: void reprepare_packed_git(struct repository *r)\n     -\tprepare_alt_odb(r);\n     +\todb_prepare_alternates(r->objects);\n      \n    - \tfor (backend = r->objects->backends; backend; backend = backend->next)\n    - \t\todb_clear_loose_cache(backend);\n    + \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next)\n    + \t\todb_clear_loose_cache(alternate);\n     \n      ## submodule.c ##\n     @@ submodule.c: int register_all_submodule_odb_as_alternates(void)\n 9:  00c4884c796 !  9:  cfaf09542ca odb: get rid of `the_repository`  in `for_each()` functions\n    @@ builtin/count-objects.c: int cmd_count_objects(int argc,\n      \t\tprintf(\"garbage: %lu\\n\", garbage);\n      \t\tprintf(\"size-garbage: %s\\n\", garbage_buf.buf);\n     -\t\tforeach_alt_odb(print_alternate, NULL);\n    -+\t\todb_for_each_backend(the_repository->objects, print_alternate, NULL);\n    ++\t\todb_for_each_alternate(the_repository->objects, print_alternate, NULL);\n      \t\tstrbuf_release(&loose_buf);\n      \t\tstrbuf_release(&pack_buf);\n      \t\tstrbuf_release(&garbage_buf);\n    @@ builtin/submodule--helper.c: static void prepare_possible_alternates(const char\n      \n      \tif (!strcmp(sm_alternate, \"superproject\"))\n     -\t\tforeach_alt_odb(add_possible_reference_from_superproject, &sas);\n    -+\t\todb_for_each_backend(the_repository->objects,\n    -+\t\t\t\t     add_possible_reference_from_superproject, &sas);\n    ++\t\todb_for_each_alternate(the_repository->objects,\n    ++\t\t\t\t       add_possible_reference_from_superproject, &sas);\n      \telse if (!strcmp(sm_alternate, \"no\"))\n      \t\t; /* do nothing */\n      \telse\n    @@ diagnose.c\n     @@ diagnose.c: int create_diagnostics_archive(struct repository *r,\n      \tstrbuf_reset(&buf);\n      \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n    - \tdir_file_stats(r->objects->backends, &buf);\n    + \tdir_file_stats(r->objects->alternates, &buf);\n     -\tforeach_alt_odb(dir_file_stats, &buf);\n    -+\todb_for_each_backend(r->objects, dir_file_stats, &buf);\n    ++\todb_for_each_alternate(r->objects, dir_file_stats, &buf);\n      \tstrvec_push(&archiver_args, buf.buf);\n      \n      \tstrbuf_reset(&buf);\n    @@ odb.c: static void read_alternate_refs(const char *path,\n     +\tvoid *payload;\n      };\n      \n    - static int refs_from_alternate_cb(struct odb_backend *e,\n    + static int refs_from_alternate_cb(struct odb_alternate *alternate,\n     -\t\t\t\t  void *data)\n     +\t\t\t\t  void *payload)\n      {\n    @@ odb.c: static void read_alternate_refs(const char *path,\n     -\tstruct alternate_refs_data *cb = data;\n     +\tstruct alternate_refs_data *cb = payload;\n      \n    - \tif (!strbuf_realpath(&path, e->path, 0))\n    + \tif (!strbuf_realpath(&path, alternate->path, 0))\n      \t\tgoto out;\n    -@@ odb.c: static int refs_from_alternate_cb(struct odb_backend *e,\n    +@@ odb.c: static int refs_from_alternate_cb(struct odb_alternate *alternate,\n      \t\tgoto out;\n      \tstrbuf_setlen(&path, base_len);\n      \n    @@ odb.c: static int refs_from_alternate_cb(struct odb_backend *e,\n     +\tstruct alternate_refs_data data;\n     +\tdata.fn = cb;\n     +\tdata.payload = payload;\n    -+\todb_for_each_backend(odb, refs_from_alternate_cb, &data);\n    ++\todb_for_each_alternate(odb, refs_from_alternate_cb, &data);\n      }\n      \n     -int foreach_alt_odb(alt_odb_fn fn, void *cb)\n    -+int odb_for_each_backend(struct object_database *odb,\n    -+\t\t\t odb_for_each_backend_fn cb, void *payload)\n    ++int odb_for_each_alternate(struct object_database *odb,\n    ++\t\t\t odb_for_each_alternate_fn cb, void *payload)\n      {\n    - \tstruct odb_backend *backend;\n    + \tstruct odb_alternate *alternate;\n      \tint r = 0;\n      \n     -\todb_prepare_alternates(the_repository->objects);\n    --\tfor (backend = the_repository->objects->backends->next; backend; backend = backend->next) {\n    --\t\tr = fn(backend, cb);\n    +-\tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n    +-\t\tr = fn(alternate, cb);\n     +\todb_prepare_alternates(odb);\n    -+\tfor (backend = odb->backends->next; backend; backend = backend->next) {\n    -+\t\tr = cb(backend, payload);\n    ++\tfor (alternate = odb->alternates->next; alternate; alternate = alternate->next) {\n    ++\t\tr = cb(alternate, payload);\n      \t\tif (r)\n      \t\t\tbreak;\n      \t}\n     \n      ## odb.h ##\n    -@@ odb.h: struct odb_backend {\n    +@@ odb.h: struct odb_alternate {\n      \tchar *path;\n      };\n      \n    --typedef int alt_odb_fn(struct odb_backend *, void *);\n    +-typedef int alt_odb_fn(struct odb_alternate *, void *);\n     -int foreach_alt_odb(alt_odb_fn, void*);\n     -typedef void alternate_ref_fn(const struct object_id *oid, void *);\n     -void for_each_alternate_ref(alternate_ref_fn, void *);\n    @@ odb.h: struct odb_backend {\n       * object directory; returns the former primary object directory.\n     @@ odb.h: void odb_clear(struct object_database *o);\n       */\n    - struct odb_backend *odb_find_backend(struct object_database *odb, const char *obj_dir);\n    + struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n      \n     +/*\n    -+ * Iterate through all backends of the database and execute the provided\n    ++ * Iterate through all alternates of the database and execute the provided\n     + * callback function for each of them. Stop iterating once the callback\n     + * function returns a non-zero value, in which case the value is bubbled up\n     + * from the callback.\n     + */\n    -+typedef int odb_for_each_backend_fn(struct odb_backend *, void *);\n    -+int odb_for_each_backend(struct object_database *odb,\n    -+\t\t\t odb_for_each_backend_fn cb, void *payload);\n    ++typedef int odb_for_each_alternate_fn(struct odb_alternate *, void *);\n    ++int odb_for_each_alternate(struct object_database *odb,\n    ++\t\t\t   odb_for_each_alternate_fn cb, void *payload);\n     +\n     +/*\n    -+ * Iterate through all alternative object backends of the database and yield\n    -+ * their respective references.\n    ++ * Iterate through all alternates of the database and yield their respective\n    ++ * references.\n     + */\n     +typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n     +void odb_for_each_alternate_ref(struct object_database *odb,\n     +\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n     +\n      /*\n    -  * Create a temporary file rooted in the primary object database backend's\n    -  * directory, or die on failure. The filename is taken from \"pattern\", which\n    +  * Create a temporary file rooted in the primary alternate's directory, or die\n    +  * on failure. The filename is taken from \"pattern\", which should have the\n     \n      ## revision.c ##\n     @@ revision.c: static void add_alternate_refs_to_pending(struct rev_info *revs,\n10:  758255fd936 <  -:  ----------- odb: get rid of `the_repository` when handling the primary backend\n -:  ----------- > 10:  bc8c73b140d odb: get rid of `the_repository` when handling the primary alternate\n11:  d07a78aa858 ! 11:  b0fb9566ae1 odb: get rid of `the_repository` when handling submodule backends\n    @@ Metadata\n     Author: Patrick Steinhardt <ps@pks.im>\n     \n      ## Commit message ##\n    -    odb: get rid of `the_repository` when handling submodule backends\n    +    odb: get rid of `the_repository` when handling submodule alternates\n     \n         The \"--recursive\" flag for git-grep(1) allows users to grep for a string\n         across submodule boundaries. To make this work we add each submodule's\n    -    object backend to our own object database so that the objects can be\n    +    object alternate to our own object database so that the objects can be\n         accessed directly.\n     \n         The infrastructure for this depends on a global string list of submodule\n         paths. The caller is expected to call `add_submodule_odb_by_path()` for\n    -    each backend and the object database will then eventually register all\n    -    submodule backends via `do_oid_object_info_extended()` in case it isn't\n    -    able to look up a specific object.\n    +    each alternate and the object database will then eventually register all\n    +    submodule alternates via `do_oid_object_info_extended()` in case it\n    +    isn't able to look up a specific object.\n     \n         This reliance on global state is of course suboptimal with regards to\n         our libification efforts.\n     \n    -    Refactor the logic so that the list of submodule backends is instead\n    +    Refactor the logic so that the list of submodule alternates is instead\n         tracked in the object database itself. This allows us to lose the\n    -    condition of `r == the_repository` before registering submodule backends\n    -    as we only ever add submodule backends to `the_repository` anyway. As\n    -    such, behaviour before and after this refactoring should always be the\n    -    same.\n    +    condition of `r == the_repository` before registering submodule\n    +    alternates as we only ever add submodule alternates to `the_repository`\n    +    anyway. As such, behaviour before and after this refactoring should\n    +    always be the same.\n     \n         Rename the functions accordingly.\n     \n    @@ builtin/grep.c: static int grep_submodule(struct grep_opt *opt,\n      \t * lazily registered as alternates when needed (and except in an\n      \t * unexpected code interaction, it won't be needed).\n      \t */\n    --\tadd_submodule_odb_by_path(subrepo->objects->backends->path);\n    -+\todb_add_submodule_backend_by_path(the_repository->objects,\n    -+\t\t\t\t\t  subrepo->objects->backends->path);\n    +-\tadd_submodule_odb_by_path(subrepo->objects->alternates->path);\n    ++\todb_add_submodule_alternate_by_path(the_repository->objects,\n    ++\t\t\t\t\t    subrepo->objects->alternates->path);\n      \tobj_read_unlock();\n      \n      \tmemcpy(&subopt, opt, sizeof(subopt));\n    @@ odb.c\n      #include \"write-or-die.h\"\n      \n      KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n    -@@ odb.c: struct odb_backend *odb_find_backend(struct object_database *odb, const char *ob\n    - \treturn backend;\n    +@@ odb.c: struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n    + \treturn alternate;\n      }\n      \n    -+void odb_add_submodule_backend_by_path(struct object_database *odb,\n    -+\t\t\t\t       const char *path)\n    ++void odb_add_submodule_alternate_by_path(struct object_database *odb,\n    ++\t\t\t\t\t const char *path)\n     +{\n    -+\tstring_list_insert(&odb->submodule_backend_paths, path);\n    ++\tstring_list_insert(&odb->submodule_alternate_paths, path);\n     +}\n     +\n      static void fill_alternate_refs_command(struct child_process *cmd,\n    @@ odb.c: void disable_obj_read_lock(void)\n      \n      int fetch_if_missing = 1;\n      \n    -+static int register_all_submodule_backends(struct object_database *odb)\n    ++static int register_all_submodule_alternates(struct object_database *odb)\n     +{\n    -+\tint ret = odb->submodule_backend_paths.nr;\n    ++\tint ret = odb->submodule_alternate_paths.nr;\n     +\n    -+\tfor (size_t i = 0; i < odb->submodule_backend_paths.nr; i++)\n    ++\tfor (size_t i = 0; i < odb->submodule_alternate_paths.nr; i++)\n     +\t\todb_add_to_alternates_memory(odb,\n    -+\t\t\t\t\t     odb->submodule_backend_paths.items[i].string);\n    ++\t\t\t\t\t     odb->submodule_alternate_paths.items[i].string);\n     +\tif (ret) {\n    -+\t\tstring_list_clear(&odb->submodule_backend_paths, 0);\n    ++\t\tstring_list_clear(&odb->submodule_alternate_paths, 0);\n     +\t\ttrace2_data_intmax(\"submodule\", odb->repo,\n    -+\t\t\t\t   \"register_all_submodule_backends/registered\", ret);\n    ++\t\t\t\t   \"register_all_submodule_alternates/registered\", ret);\n     +\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n    -+\t\t\tBUG(\"register_all_submodule_backends() called\");\n    ++\t\t\tBUG(\"register_all_submodule_alternates() called\");\n     +\t}\n     +\treturn ret;\n     +}\n    @@ odb.c: static int do_oid_object_info_extended(struct repository *r,\n     -\t\t * If any such ODBs exist, register them and try again.\n     +\t\t * This might be an attempt at accessing a submodule object as\n     +\t\t * if it were in main object store (having called\n    -+\t\t * `odb_add_submodule_backend_by_path()` on that submodule's\n    ++\t\t * `odb_add_submodule_alternate_by_path()` on that submodule's\n     +\t\t * ODB). If any such ODBs exist, register them and try again.\n      \t\t */\n     -\t\tif (r == the_repository &&\n     -\t\t    register_all_submodule_odb_as_alternates())\n    -+\t\tif (register_all_submodule_backends(r->objects))\n    ++\t\tif (register_all_submodule_alternates(r->objects))\n      \t\t\t/* We added some alternates; retry */\n      \t\t\tcontinue;\n      \n    @@ odb.c: struct object_database *odb_new(struct repository *repo)\n      \tINIT_LIST_HEAD(&o->packed_git_mru);\n      \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n      \tpthread_mutex_init(&o->replace_mutex, NULL);\n    -+\tstring_list_init_dup(&o->submodule_backend_paths);\n    ++\tstring_list_init_dup(&o->submodule_alternate_paths);\n      \treturn o;\n      }\n      \n    @@ odb.c: void odb_clear(struct object_database *o)\n      \to->packed_git = NULL;\n      \n      \thashmap_clear(&o->pack_map);\n    -+\tstring_list_clear(&o->submodule_backend_paths, 0);\n    ++\tstring_list_clear(&o->submodule_alternate_paths, 0);\n      }\n     \n      ## odb.h ##\n    @@ odb.h: struct object_database {\n      \tunsigned packed_git_initialized : 1;\n     +\n     +\t/*\n    -+\t * Submodule backend paths that will be added as alternatives to allow\n    -+\t * lookup of submodule objects via the main object database.\n    ++\t * Submodule alternate paths that will be added as alternatives to\n    ++\t * allow lookup of submodule objects via the main object database.\n     +\t */\n    -+\tstruct string_list submodule_backend_paths;\n    ++\tstruct string_list submodule_alternate_paths;\n      };\n      \n      struct object_database *odb_new(struct repository *repo);\n    -@@ odb.h: void odb_restore_primary_backend(struct object_database *odb,\n    - \t\t\t\t struct odb_backend *restore_odb,\n    - \t\t\t\t const char *old_path);\n    +@@ odb.h: void odb_restore_primary_alternate(struct object_database *odb,\n    + \t\t\t\t   struct odb_alternate *restore_alt,\n    + \t\t\t\t   const char *old_path);\n      \n     +/*\n    -+ * Call odb_add_submodule_backend_by_path() to add the submodule at the given\n    ++ * Call odb_add_submodule_alternate_by_path() to add the submodule at the given\n     + * path to a list. The object stores of all submodules in that list will be\n     + * added as alternates in the object store when looking up objects.\n     + */\n    -+void odb_add_submodule_backend_by_path(struct object_database *odb,\n    -+\t\t\t\t       const char *path);\n    ++void odb_add_submodule_alternate_by_path(struct object_database *odb,\n    ++\t\t\t\t\t  const char *path);\n     +\n      /*\n    -  * Iterate through all backends of the database and execute the provided\n    +  * Iterate through all alternates of the database and execute the provided\n       * callback function for each of them. Stop iterating once the callback\n     \n      ## submodule-config.c ##\n    @@ submodule-config.c: static void config_from_gitmodules(config_fn_t fn, struct re\n      \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n      \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n      \t\t\tif (repo != the_repository)\n    --\t\t\t\tadd_submodule_odb_by_path(repo->objects->backends->path);\n    -+\t\t\t\todb_add_submodule_backend_by_path(the_repository->objects,\n    -+\t\t\t\t\t\t\t\t  repo->objects->backends->path);\n    +-\t\t\t\tadd_submodule_odb_by_path(repo->objects->alternates->path);\n    ++\t\t\t\todb_add_submodule_alternate_by_path(the_repository->objects,\n    ++\t\t\t\t\t\t\t\t    repo->objects->alternates->path);\n      \t\t} else {\n      \t\t\tgoto out;\n      \t\t}\n12:  2d431604aa8 ! 12:  193f65f87e6 odb: trivial refactorings to get rid of `the_repository`\n    @@ odb.c\n      #include \"git-compat-util.h\"\n      #include \"abspath.h\"\n      #include \"commit-graph.h\"\n    -@@ odb.c: void odb_add_submodule_backend_by_path(struct object_database *odb,\n    - \tstring_list_insert(&odb->submodule_backend_paths, path);\n    +@@ odb.c: void odb_add_submodule_alternate_by_path(struct object_database *odb,\n    + \tstring_list_insert(&odb->submodule_alternate_paths, path);\n      }\n      \n     -static void fill_alternate_refs_command(struct child_process *cmd,\n    @@ odb.c: static void read_alternate_refs(const char *path,\n      \t\t\twarning(_(\"invalid line while parsing alternate refs: %s\"),\n      \t\t\t\tline.buf);\n      \t\t\tbreak;\n    -@@ odb.c: static int refs_from_alternate_cb(struct odb_backend *e,\n    +@@ odb.c: static int refs_from_alternate_cb(struct odb_alternate *alternate,\n      \t\tgoto out;\n      \tstrbuf_setlen(&path, base_len);\n      \n     -\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n    -+\tread_alternate_refs(e->odb->repo, path.buf, cb->fn, cb->payload);\n    ++\tread_alternate_refs(alternate->odb->repo, path.buf, cb->fn, cb->payload);\n      \n      out:\n      \tstrbuf_release(&path);\n13:  b1182ab2498 ! 13:  24e46223958 odb: rename `oid_object_info()`\n    @@ object.c: struct object *parse_object_with_flags(struct repository *r,\n      \n     \n      ## odb.c ##\n    -@@ odb.c: static int register_all_submodule_backends(struct object_database *odb)\n    +@@ odb.c: static int register_all_submodule_alternates(struct object_database *odb)\n      \treturn ret;\n      }\n      \n    @@ odb.c: static int do_oid_object_info_extended(struct repository *r,\n      \t\t}\n      \n     @@ odb.c: static int do_oid_object_info_extended(struct repository *r,\n    - \t\t * `odb_add_submodule_backend_by_path()` on that submodule's\n    + \t\t * `odb_add_submodule_alternate_by_path()` on that submodule's\n      \t\t * ODB). If any such ODBs exist, register them and try again.\n      \t\t */\n    --\t\tif (register_all_submodule_backends(r->objects))\n    -+\t\tif (register_all_submodule_backends(odb))\n    +-\t\tif (register_all_submodule_alternates(r->objects))\n    ++\t\tif (register_all_submodule_alternates(odb))\n      \t\t\t/* We added some alternates; retry */\n      \t\t\tcontinue;\n      \n14:  bdbd97d77a9 = 14:  42978727ce8 odb: rename `repo_read_object_file()`\n15:  ec2bb725b91 = 15:  a793e6c0768 odb: rename `has_object()`\n16:  c576c9d1ccf = 16:  00e0f063635 odb: rename `pretend_object_file()`\n17:  d1dd84b5901 = 17:  8888b3320fb odb: rename `read_object_with_reference()`\n\n---\nbase-commit: 046efb6f2b050efd580e1c1750b77328a1790c0e\nchange-id: 20250505-pks-object-store-wo-the-repository-9c6cbdf8d4b1\n\n"},{"id":"517665","messageId":"20250509-pks-object-store-wo-the-repository-v2-1-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:01Z","receivedAt":"2025-05-09T14:12:16Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `raw_object_store` structure is the central entry point for reading\nand writing objects in a repository. The main purpose of this structure\nis to manage object directories and provide an interface to access and\nwrite objects in those object directories.\n\nRight now, many of the functions associated with the raw object store\nimplicitly rely on `the_repository` to get access to its `objects`\npointer, which is the `raw_object_store`. As we want to generally get\nrid of using `the_repository` across our codebase we will have to\nconvert this implicit dependency on this global variable into an\nexplicit parameter.\n\nThis conversion can be done by simply passing in an explicit pointer to\na repository and then using its `->objects` pointer. But there is a\nsecond effort underway, which is to make the object subsystem more\nselfcontained so that we can eventually have pluggale object backends.\nAs such, passing in a repository wouldn't make a ton of sense, and the\ngoal is to convert the object store interfaces such that we always pass\nin a reference to the `raw_object_store` instead.\n\nThis will expose the `raw_object_store` type to a lot more callers\nthough, which surfaces that this type is named somewhat awkwardly. The\n\"raw_\" prefix makes readers wonder whether there is a non-raw variant of\nthe object store, but there isn't. Furthermore, we nowadays want to name\nfunctions in a way that they can be clearly attributed to a specific\nsubsystem, but calling them e.g. `raw_object_store_has_object()` is just\ntoo unwieldy, even when dropping the \"raw_\" prefix.\n\nInstead, rename the structure to `object_database`. This term is already\nused a lot throughout our codebase, and it cannot easily be mistaken for\n\"object directories\", either. Furthermore, its acronym ODB is already\nwell-known and works well as part of a function's name, like for example\n`odb_has_object()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n commit-graph.c |  2 +-\n commit-graph.h |  4 ++--\n object-store.c | 12 ++++++------\n object-store.h | 11 ++++++++---\n packfile.c     |  2 +-\n packfile.h     |  4 ++--\n repository.c   |  4 ++--\n repository.h   |  4 ++--\n 8 files changed, 24 insertions(+), 19 deletions(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 6394752b0b0..1b66486b9c9 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -829,7 +829,7 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)\n \treturn NULL;\n }\n \n-void close_commit_graph(struct raw_object_store *o)\n+void close_commit_graph(struct object_database *o)\n {\n \tif (!o->commit_graph)\n \t\treturn;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 13f662827d4..20d38c100ce 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -26,7 +26,7 @@ void git_test_write_commit_graph_or_die(void);\n struct commit;\n struct bloom_filter_settings;\n struct repository;\n-struct raw_object_store;\n+struct object_database;\n struct string_list;\n \n char *get_commit_graph_filename(struct object_directory *odb);\n@@ -186,7 +186,7 @@ int write_commit_graph(struct object_directory *odb,\n \n int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags);\n \n-void close_commit_graph(struct raw_object_store *);\n+void close_commit_graph(struct object_database *);\n void free_commit_graph(struct commit_graph *);\n \n /*\ndiff --git a/object-store.c b/object-store.c\nindex 2f51d0e3b03..1effcb12273 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -44,7 +44,7 @@ struct cached_object_entry {\n \t} value;\n };\n \n-static const struct cached_object *find_cached_object(struct raw_object_store *object_store,\n+static const struct cached_object *find_cached_object(struct object_database *object_store,\n \t\t\t\t\t\t      const struct object_id *oid)\n {\n \tstatic const struct cached_object empty_tree = {\n@@ -86,7 +86,7 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n /*\n  * Return non-zero iff the path is usable as an alternate object database.\n  */\n-static int alt_odb_usable(struct raw_object_store *o,\n+static int alt_odb_usable(struct object_database *o,\n \t\t\t  struct strbuf *path,\n \t\t\t  const char *normalized_objdir, khiter_t *pos)\n {\n@@ -959,9 +959,9 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct raw_object_store *raw_object_store_new(void)\n+struct object_database *odb_new(void)\n {\n-\tstruct raw_object_store *o = xmalloc(sizeof(*o));\n+\tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n@@ -970,7 +970,7 @@ struct raw_object_store *raw_object_store_new(void)\n \treturn o;\n }\n \n-static void free_object_directories(struct raw_object_store *o)\n+static void free_object_directories(struct object_database *o)\n {\n \twhile (o->odb) {\n \t\tstruct object_directory *next;\n@@ -983,7 +983,7 @@ static void free_object_directories(struct raw_object_store *o)\n \to->odb_by_path = NULL;\n }\n \n-void raw_object_store_clear(struct raw_object_store *o)\n+void odb_clear(struct object_database *o)\n {\n \tFREE_AND_NULL(o->alternate_db);\n \ndiff --git a/object-store.h b/object-store.h\nindex c2fe5a19605..34b8efbbb83 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -86,7 +86,12 @@ struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n \n-struct raw_object_store {\n+/*\n+ * The object database encapsulates access to objects in a repository. It\n+ * manages one or more backends that store the actual objects which are\n+ * configured via alternates.\n+ */\n+struct object_database {\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -168,8 +173,8 @@ struct raw_object_store {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct raw_object_store *raw_object_store_new(void);\n-void raw_object_store_clear(struct raw_object_store *o);\n+struct object_database *odb_new(void);\n+void odb_clear(struct object_database *o);\n \n /*\n  * Create a temporary file rooted in the object database directory, or\ndiff --git a/packfile.c b/packfile.c\nindex d91016f1c7f..8f51665266d 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -359,7 +359,7 @@ void close_pack(struct packed_git *p)\n \toidset_clear(&p->bad_objects);\n }\n \n-void close_object_store(struct raw_object_store *o)\n+void close_object_store(struct object_database *o)\n {\n \tstruct packed_git *p;\n \ndiff --git a/packfile.h b/packfile.h\nindex 3a3c77cf05a..826eb7f475f 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -183,12 +183,12 @@ int close_pack_fd(struct packed_git *p);\n \n uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);\n \n-struct raw_object_store;\n+struct object_database;\n \n unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);\n void close_pack_windows(struct packed_git *);\n void close_pack(struct packed_git *);\n-void close_object_store(struct raw_object_store *o);\n+void close_object_store(struct object_database *o);\n void unuse_pack(struct pack_window **);\n void clear_delta_base_cache(void);\n struct packed_git *add_packed_git(struct repository *r, const char *path,\ndiff --git a/repository.c b/repository.c\nindex 9b3d6665fc6..07757e6e0c9 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = raw_object_store_new();\n+\trepo->objects = odb_new();\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -374,7 +374,7 @@ void repo_clear(struct repository *repo)\n \tFREE_AND_NULL(repo->worktree);\n \tFREE_AND_NULL(repo->submodule_prefix);\n \n-\traw_object_store_clear(repo->objects);\n+\todb_clear(repo->objects);\n \tFREE_AND_NULL(repo->objects);\n \n \tparsed_object_pool_clear(repo->parsed_objects);\ndiff --git a/repository.h b/repository.h\nindex c4c92b2ab9c..3a5ef9c781e 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -9,7 +9,7 @@ struct git_hash_algo;\n struct index_state;\n struct lock_file;\n struct pathspec;\n-struct raw_object_store;\n+struct object_database;\n struct submodule_cache;\n struct promisor_remote_config;\n struct remote_state;\n@@ -47,7 +47,7 @@ struct repository {\n \t/*\n \t * Holds any information related to accessing the raw object content.\n \t */\n-\tstruct raw_object_store *objects;\n+\tstruct object_database *objects;\n \n \t/*\n \t * All objects in this repository that have been parsed. This structure\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517667","messageId":"20250509-pks-object-store-wo-the-repository-v2-3-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:03Z","receivedAt":"2025-05-09T14:12:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In the preceding commits we have renamed the structures contained in\n\"object-store.h\" to `struct object_database` and `struct odb_backend`.\nAs such, the code files \"object-store.{c,h}\" are confusingly named now.\nRename them to \"odb.{c,h}\" accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile                                | 2 +-\n apply.c                                 | 2 +-\n archive-tar.c                           | 2 +-\n archive-zip.c                           | 2 +-\n archive.c                               | 2 +-\n attr.c                                  | 2 +-\n bisect.c                                | 2 +-\n blame.c                                 | 2 +-\n builtin/backfill.c                      | 2 +-\n builtin/blame.c                         | 2 +-\n builtin/cat-file.c                      | 2 +-\n builtin/checkout.c                      | 2 +-\n builtin/clone.c                         | 2 +-\n builtin/commit-graph.c                  | 2 +-\n builtin/commit-tree.c                   | 2 +-\n builtin/describe.c                      | 2 +-\n builtin/difftool.c                      | 2 +-\n builtin/fast-export.c                   | 2 +-\n builtin/fast-import.c                   | 2 +-\n builtin/fetch.c                         | 2 +-\n builtin/fsck.c                          | 2 +-\n builtin/grep.c                          | 2 +-\n builtin/hash-object.c                   | 2 +-\n builtin/index-pack.c                    | 2 +-\n builtin/log.c                           | 2 +-\n builtin/ls-files.c                      | 2 +-\n builtin/ls-tree.c                       | 2 +-\n builtin/merge-file.c                    | 2 +-\n builtin/merge-tree.c                    | 2 +-\n builtin/mktag.c                         | 2 +-\n builtin/mktree.c                        | 2 +-\n builtin/multi-pack-index.c              | 2 +-\n builtin/notes.c                         | 2 +-\n builtin/pack-objects.c                  | 2 +-\n builtin/pack-redundant.c                | 2 +-\n builtin/prune.c                         | 2 +-\n builtin/receive-pack.c                  | 2 +-\n builtin/remote.c                        | 2 +-\n builtin/repack.c                        | 2 +-\n builtin/replace.c                       | 2 +-\n builtin/rev-list.c                      | 2 +-\n builtin/show-ref.c                      | 2 +-\n builtin/submodule--helper.c             | 2 +-\n builtin/tag.c                           | 2 +-\n builtin/unpack-file.c                   | 2 +-\n builtin/unpack-objects.c                | 2 +-\n bulk-checkin.c                          | 2 +-\n bundle-uri.c                            | 2 +-\n bundle.c                                | 2 +-\n cache-tree.c                            | 2 +-\n combine-diff.c                          | 2 +-\n commit-graph.c                          | 2 +-\n commit-graph.h                          | 2 +-\n commit.c                                | 2 +-\n config.c                                | 2 +-\n connected.c                             | 2 +-\n contrib/coccinelle/the_repository.cocci | 2 +-\n diagnose.c                              | 2 +-\n diff.c                                  | 2 +-\n entry.c                                 | 2 +-\n fetch-pack.c                            | 2 +-\n fmt-merge-msg.c                         | 2 +-\n fsck.c                                  | 2 +-\n grep.c                                  | 2 +-\n http-backend.c                          | 2 +-\n http-push.c                             | 2 +-\n http-walker.c                           | 2 +-\n http.c                                  | 2 +-\n list-objects-filter.c                   | 2 +-\n list-objects.c                          | 2 +-\n loose.c                                 | 2 +-\n mailmap.c                               | 2 +-\n match-trees.c                           | 2 +-\n merge-blobs.c                           | 2 +-\n merge-ort.c                             | 2 +-\n meson.build                             | 2 +-\n notes-cache.c                           | 2 +-\n notes-merge.c                           | 2 +-\n notes.c                                 | 2 +-\n object-file.c                           | 2 +-\n object-file.h                           | 2 +-\n object-store.c => odb.c                 | 2 +-\n object-store.h => odb.h                 | 6 +++---\n oss-fuzz/fuzz-pack-idx.c                | 2 +-\n pack-bitmap-write.c                     | 2 +-\n pack-bitmap.c                           | 2 +-\n pack-check.c                            | 2 +-\n pack-mtimes.c                           | 2 +-\n pack-objects.h                          | 2 +-\n pack-revindex.c                         | 2 +-\n packfile.c                              | 2 +-\n packfile.h                              | 4 ++--\n path.c                                  | 2 +-\n promisor-remote.c                       | 2 +-\n protocol-caps.c                         | 2 +-\n read-cache.c                            | 2 +-\n ref-filter.c                            | 2 +-\n reflog.c                                | 2 +-\n refs.c                                  | 2 +-\n remote.c                                | 2 +-\n replace-object.c                        | 2 +-\n replace-object.h                        | 2 +-\n repository.c                            | 2 +-\n rerere.c                                | 2 +-\n revision.c                              | 2 +-\n send-pack.c                             | 2 +-\n sequencer.c                             | 2 +-\n server-info.c                           | 2 +-\n shallow.c                               | 2 +-\n streaming.c                             | 2 +-\n submodule-config.c                      | 2 +-\n submodule.c                             | 2 +-\n t/helper/test-find-pack.c               | 2 +-\n t/helper/test-pack-mtimes.c             | 2 +-\n t/helper/test-partial-clone.c           | 2 +-\n t/helper/test-read-graph.c              | 2 +-\n t/helper/test-read-midx.c               | 2 +-\n t/helper/test-ref-store.c               | 2 +-\n tag.c                                   | 2 +-\n tmp-objdir.c                            | 2 +-\n tree-walk.c                             | 2 +-\n tree.c                                  | 2 +-\n unpack-trees.c                          | 2 +-\n upload-pack.c                           | 2 +-\n walker.c                                | 2 +-\n xdiff-interface.c                       | 2 +-\n 126 files changed, 129 insertions(+), 129 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8a7f1c76543..d2d65f30907 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1083,8 +1083,8 @@ LIB_OBJS += notes.o\n LIB_OBJS += object-file-convert.o\n LIB_OBJS += object-file.o\n LIB_OBJS += object-name.o\n-LIB_OBJS += object-store.o\n LIB_OBJS += object.o\n+LIB_OBJS += odb.o\n LIB_OBJS += oid-array.o\n LIB_OBJS += oidmap.o\n LIB_OBJS += oidset.o\ndiff --git a/apply.c b/apply.c\nindex 381d2e3652f..879f04df31e 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -14,7 +14,7 @@\n #include \"abspath.h\"\n #include \"base85.h\"\n #include \"config.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"delta.h\"\n #include \"diff.h\"\n #include \"dir.h\"\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 282b48196f9..249164ea77d 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -11,7 +11,7 @@\n #include \"hex.h\"\n #include \"tar.h\"\n #include \"archive.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"streaming.h\"\n #include \"run-command.h\"\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 405da6f3d83..df8866d5bae 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -12,7 +12,7 @@\n #include \"hex.h\"\n #include \"streaming.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"userdiff.h\"\n #include \"write-or-die.h\"\ndiff --git a/archive.c b/archive.c\nindex 8309ea213e6..7fa2cc2596a 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -14,7 +14,7 @@\n #include \"pretty.h\"\n #include \"setup.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/attr.c b/attr.c\nindex 86b6109fc4e..e5680db7f65 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -22,7 +22,7 @@\n #include \"read-cache-ll.h\"\n #include \"refs.h\"\n #include \"revision.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/bisect.c b/bisect.c\nindex a327468c75b..a7939216d00 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -20,7 +20,7 @@\n #include \"commit-slab.h\"\n #include \"commit-reach.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"dir.h\"\n \ndiff --git a/blame.c b/blame.c\nindex 57daa45e899..0ceea080a80 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -3,7 +3,7 @@\n \n #include \"git-compat-util.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"cache-tree.h\"\n #include \"mergesort.h\"\n #include \"commit.h\"\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex fa82ad2f6ff..0b49baa39fa 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -13,7 +13,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"promisor-remote.h\"\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 944952e30eb..15eda60af90 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -28,7 +28,7 @@\n #include \"line-log.h\"\n #include \"progress.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"blame.h\"\n #include \"refs.h\"\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 3914a2a3f61..2fa5e3f43bd 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -24,7 +24,7 @@\n #include \"pack-bitmap.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"promisor-remote.h\"\n #include \"mailmap.h\"\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex d185982f3a6..e7dd66173dd 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -20,7 +20,7 @@\n #include \"merge-ort-wrappers.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"path.h\"\n #include \"preload-index.h\"\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 91b9cd0d164..1eafeefb48d 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -25,7 +25,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 628d3a1e92e..ae8ac52a975 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -6,7 +6,7 @@\n #include \"hex.h\"\n #include \"parse-options.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"progress.h\"\n #include \"replace-object.h\"\n #include \"strbuf.h\"\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex ad6b2c93209..546069f8682 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -9,7 +9,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n #include \"commit.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 2d50883b729..96cb68e5e5d 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -19,7 +19,7 @@\n #include \"setup.h\"\n #include \"strvec.h\"\n #include \"run-command.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects.h\"\n #include \"commit-slab.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex a3b64ce6942..fac613e3bc3 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -30,7 +30,7 @@\n #include \"strbuf.h\"\n #include \"lockfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"entry.h\"\n #include \"setup.h\"\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 37c01d6c6fe..0505f289a94 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"object.h\"\n #include \"tag.h\"\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex b2839c5f439..52c792488e1 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -24,7 +24,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"mem-pool.h\"\n #include \"commit-reach.h\"\n #include \"khash.h\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 4de6d3206d4..82e9603ccab 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"oid-array.h\"\n #include \"commit.h\"\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 9c54286540c..6a5181393a2 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3c51a39c10d..3858df2a82e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -26,7 +26,7 @@\n #include \"submodule-config.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pager.h\"\n #include \"path.h\"\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex cd53fa3bde8..9ce0b87c30b 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -11,7 +11,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 147e9b8b479..8ce446064e8 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -21,7 +21,7 @@\n #include \"packfile.h\"\n #include \"pack-revindex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"path.h\"\ndiff --git a/builtin/log.c b/builtin/log.c\nindex b450cd3bde8..fe9cc5ebecb 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -15,7 +15,7 @@\n #include \"hex.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"color.h\"\n #include \"commit.h\"\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex be74f0a03b2..821339b07d4 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -25,7 +25,7 @@\n #include \"setup.h\"\n #include \"sparse-index.h\"\n #include \"submodule.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n \n \ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 8aafc30ca48..62b6fd58c16 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -10,7 +10,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"path.h\"\n #include \"quote.h\"\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 2b16b10d2ca..9464f275629 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -7,7 +7,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"setup.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 4aafa73c615..709ae3966a6 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -10,7 +10,7 @@\n #include \"commit-reach.h\"\n #include \"merge-ort.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 7ac11c46d53..1809b38f937 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -6,7 +6,7 @@\n #include \"strbuf.h\"\n #include \"replace-object.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"fsck.h\"\n #include \"config.h\"\n \ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 4b478034675..016b0e5b224 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -12,7 +12,7 @@\n #include \"tree.h\"\n #include \"parse-options.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct treeent {\n \tunsigned mode;\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex a77ae465d48..01c4c8e62e3 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -7,7 +7,7 @@\n #include \"midx.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex a3f433ca4c0..783d4932ca6 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -16,7 +16,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n \n #include \"pretty.h\"\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8b33edc2ff5..99b63cb0980 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -32,7 +32,7 @@\n #include \"list.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"dir.h\"\n #include \"midx.h\"\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 5d1fc781761..3134cb8c689 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -13,7 +13,7 @@\n #include \"hex.h\"\n \n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n \n #define BLKSIZE 512\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex e930caa0c0a..7bbfb14c2be 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -17,7 +17,7 @@\n #include \"replace-object.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"shallow.h\"\n \n static const char * const prune_usage[] = {\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex c92e57ba188..cb5fd55a8e4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -33,7 +33,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"protocol.h\"\n #include \"commit-reach.h\"\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 0d6755bcb71..ac5b8d2a1a6 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -14,7 +14,7 @@\n #include \"rebase.h\"\n #include \"refs.h\"\n #include \"refspec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strvec.h\"\n #include \"commit-reach.h\"\n #include \"progress.h\"\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 59214dbdfdf..16782320058 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -17,7 +17,7 @@\n #include \"midx.h\"\n #include \"packfile.h\"\n #include \"prune-packed.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"shallow.h\"\n #include \"pack.h\"\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 48c7c6a2d56..11c7e2d4c0c 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"tag.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex c4cd4ed5c81..ee25d61c802 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -14,7 +14,7 @@\n #include \"object.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"parse-options.h\"\n #include \"log-tree.h\"\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 623a52a45f8..90ec1de78f9 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"refs/refs-internal.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"string-list.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex cd7db11d825..a6c936fb2bd 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -28,7 +28,7 @@\n #include \"diff.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"advice.h\"\n #include \"branch.h\"\n #include \"list-objects-filter-options.h\"\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 4742b27d16e..cf2ea4b4993 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -19,7 +19,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"tag.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex e33acfc4ee4..b92fd4710a9 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static char *create_temp_file(struct object_id *oid)\n {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex e905d5f4e19..7bf395eec84 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -9,7 +9,7 @@\n #include \"git-zlib.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"delta.h\"\n #include \"pack.h\"\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 678e2ecc2c2..55406a539e7 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -17,7 +17,7 @@\n #include \"tmp-objdir.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int odb_transaction_nesting;\n \ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 96d2ba726d9..993ac62c271 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -14,7 +14,7 @@\n #include \"fetch-pack.h\"\n #include \"remote.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct {\n \tenum bundle_list_heuristic heuristic;\ndiff --git a/bundle.c b/bundle.c\nindex 0c7cd15bb12..c67f85126da 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -7,7 +7,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/cache-tree.c b/cache-tree.c\nindex fa3858e2829..9786b32b3a1 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -10,7 +10,7 @@\n #include \"cache-tree.h\"\n #include \"bulk-checkin.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\ndiff --git a/combine-diff.c b/combine-diff.c\nindex dfae9f7995d..cf23a753407 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -2,7 +2,7 @@\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"convert.h\"\n #include \"diff.h\"\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 58d1eeedb1a..4848198d7bf 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -13,7 +13,7 @@\n #include \"refs.h\"\n #include \"hash-lookup.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"alloc.h\"\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 19d95ade6ea..0be594e2638 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -1,7 +1,7 @@\n #ifndef COMMIT_GRAPH_H\n #define COMMIT_GRAPH_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n #define GIT_TEST_COMMIT_GRAPH \"GIT_TEST_COMMIT_GRAPH\"\ndiff --git a/commit.c b/commit.c\nindex e915b2b9a12..1d30f8ce15a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -9,7 +9,7 @@\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/config.c b/config.c\nindex b18b5617fcd..883dd066827 100644\n--- a/config.c\n+++ b/config.c\n@@ -31,7 +31,7 @@\n #include \"hashmap.h\"\n #include \"string-list.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"path.h\"\n #include \"utf8.h\"\ndiff --git a/connected.c b/connected.c\nindex 4415388beba..18c13245d8e 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"run-command.h\"\n #include \"sigchain.h\"\n #include \"connected.h\"\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 765ad689678..ea7fe1c8db7 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -77,7 +77,7 @@\n |\n - diff_setup\n + repo_diff_setup\n-// object-store.h\n+// odb.h\n |\n - read_object_file\n + repo_read_object_file\ndiff --git a/diagnose.c b/diagnose.c\nindex 50129cf4be3..d407c98d094 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -7,7 +7,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"strvec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"repository.h\"\ndiff --git a/diff.c b/diff.c\nindex 63e9ecb30c6..193da8bee68 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -23,7 +23,7 @@\n #include \"color.h\"\n #include \"run-command.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"userdiff.h\"\n #include \"submodule.h\"\n #include \"hashmap.h\"\ndiff --git a/entry.c b/entry.c\nindex f36ec5ad242..75d55038d7c 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -1,7 +1,7 @@\n #define USE_THE_REPOSITORY_VARIABLE\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex fa4231fee74..cf157f5d7e5 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -24,7 +24,7 @@\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"connected.h\"\n #include \"fetch-negotiator.h\"\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 501b5acdd44..1a8c972adf3 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -6,7 +6,7 @@\n #include \"environment.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"diff.h\"\n #include \"diff-merges.h\"\n #include \"hex.h\"\ndiff --git a/fsck.c b/fsck.c\nindex 8dc8472ceb3..e69baab3af7 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"dir.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"object.h\"\ndiff --git a/grep.c b/grep.c\nindex f8d535182c3..dc77e6c4631 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"grep.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\ndiff --git a/http-backend.c b/http-backend.c\nindex 0c575aa88aa..ad8c4037493 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -18,7 +18,7 @@\n #include \"url.h\"\n #include \"strvec.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"protocol.h\"\n #include \"date.h\"\n #include \"write-or-die.h\"\ndiff --git a/http-push.c b/http-push.c\nindex f9e67cabd4b..d1b1bb23711 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -20,7 +20,7 @@\n #include \"url.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n \n #ifdef EXPAT_NEEDS_XMLPARSE_H\ndiff --git a/http-walker.c b/http-walker.c\nindex 9e7bc37f02e..4b1cdd25a80 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -10,7 +10,7 @@\n #include \"transport.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct alt_base {\n \tchar *base;\ndiff --git a/http.c b/http.c\nindex 8ce2ec73947..e639d9fafef 100644\n--- a/http.c\n+++ b/http.c\n@@ -19,7 +19,7 @@\n #include \"packfile.h\"\n #include \"string-list.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tempfile.h\"\n \n static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 7765761b3c6..cb9c16734b1 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -12,7 +12,7 @@\n #include \"oidmap.h\"\n #include \"oidset.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n /* Remember to update object flag allocation in object.h */\n /*\ndiff --git a/list-objects.c b/list-objects.c\nindex 597114281f6..c50b9578584 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -14,7 +14,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace.h\"\n #include \"environment.h\"\n \ndiff --git a/loose.c b/loose.c\nindex bce4e1c3ee7..9febd1f3e9a 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"hash.h\"\n #include \"path.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"wrapper.h\"\ndiff --git a/mailmap.c b/mailmap.c\nindex 9e2642a043b..b18e74c2110 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -6,7 +6,7 @@\n #include \"string-list.h\"\n #include \"mailmap.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n char *git_mailmap_file;\ndiff --git a/match-trees.c b/match-trees.c\nindex 72922d5d64e..4704f95c340 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -7,7 +7,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n static int score_missing(unsigned mode)\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 53f36dbc175..ba8a3fdfd82 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -4,7 +4,7 @@\n #include \"merge-ll.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 77310a4a52c..f86c84635f0 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -39,7 +39,7 @@\n #include \"mem-pool.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/meson.build b/meson.build\nindex 270ce933d0f..a3c917b1345 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -394,8 +394,8 @@ libgit_sources = [\n   'object-file-convert.c',\n   'object-file.c',\n   'object-name.c',\n-  'object-store.c',\n   'object.c',\n+  'odb.c',\n   'oid-array.c',\n   'oidmap.c',\n   'oidset.c',\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 150241b15e0..344f67762b8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"notes-cache.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"repository.h\"\n #include \"commit.h\"\ndiff --git a/notes-merge.c b/notes-merge.c\nindex dae8e6a281a..de6a52e2e7f 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -8,7 +8,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"diff.h\"\ndiff --git a/notes.c b/notes.c\nindex 0a128f1de98..fc000e501d2 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -8,7 +8,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"strbuf.h\"\n #include \"tree-walk.h\"\ndiff --git a/object-file.c b/object-file.c\nindex e48d968c0e0..dabc238447a 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -21,7 +21,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidtree.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/object-file.h b/object-file.h\nindex f1601200938..e4810eee449 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -3,7 +3,7 @@\n \n #include \"git-zlib.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct index_state;\n \ndiff --git a/object-store.c b/odb.c\nsimilarity index 99%\nrename from object-store.c\nrename to odb.c\nindex 673a9c6006b..81281db7e0a 100644\n--- a/object-store.c\n+++ b/odb.c\n@@ -13,7 +13,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/object-store.h b/odb.h\nsimilarity index 99%\nrename from object-store.h\nrename to odb.h\nindex 2dda6e85388..465820a3d5c 100644\n--- a/object-store.h\n+++ b/odb.h\n@@ -1,5 +1,5 @@\n-#ifndef OBJECT_STORE_H\n-#define OBJECT_STORE_H\n+#ifndef ODB_H\n+#define ODB_H\n \n #include \"hashmap.h\"\n #include \"object.h\"\n@@ -345,4 +345,4 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n-#endif /* OBJECT_STORE_H */\n+#endif /* ODB_H */\ndiff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c\nindex 609a343ee3e..d2a92f34d98 100644\n--- a/oss-fuzz/fuzz-pack-idx.c\n+++ b/oss-fuzz/fuzz-pack-idx.c\n@@ -1,5 +1,5 @@\n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n \n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 7f400ee0121..37648b57125 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -4,7 +4,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex b9f1d866046..467a3e91035 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"repository.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects-filter-options.h\"\n #include \"midx.h\"\n #include \"config.h\"\ndiff --git a/pack-check.c b/pack-check.c\nindex 874897d6cba..67cb2cf72f2 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -8,7 +8,7 @@\n #include \"progress.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct idx_entry {\n \toff_t                offset;\ndiff --git a/pack-mtimes.c b/pack-mtimes.c\nindex 20900ca88d3..8e1f2dec0ef 100644\n--- a/pack-mtimes.c\n+++ b/pack-mtimes.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-mtimes.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 475a2d67ce3..1ac8644201b 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -1,7 +1,7 @@\n #ifndef PACK_OBJECTS_H\n #define PACK_OBJECTS_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"thread-utils.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex ffcde48870d..0cc422a1e67 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-revindex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\ndiff --git a/packfile.c b/packfile.c\nindex e31e55f0c02..8133948b58f 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -19,7 +19,7 @@\n #include \"tree-walk.h\"\n #include \"tree.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"midx.h\"\n #include \"commit-graph.h\"\n #include \"pack-revindex.h\"\ndiff --git a/packfile.h b/packfile.h\nindex 826eb7f475f..53c3b7d3b43 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -3,10 +3,10 @@\n \n #include \"list.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n-/* in object-store.h */\n+/* in odb.h */\n struct object_info;\n \n struct packed_git {\ndiff --git a/path.c b/path.c\nindex 7be0e0214df..36ddfb24701 100644\n--- a/path.c\n+++ b/path.c\n@@ -15,7 +15,7 @@\n #include \"submodule-config.h\"\n #include \"path.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"lockfile.h\"\n #include \"exec-cmd.h\"\n \ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 9d058586dfa..2baa286bfd0 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"config.h\"\n #include \"trace2.h\"\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 9b8db37a210..3022f69a1bd 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -6,7 +6,7 @@\n #include \"hash.h\"\n #include \"hex.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"string-list.h\"\n #include \"strbuf.h\"\ndiff --git a/read-cache.c b/read-cache.c\nindex 73f83a7e7a1..dce1056ec7c 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -20,7 +20,7 @@\n #include \"refs.h\"\n #include \"dir.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 7a274633cfc..4ce45440ad1 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"wildmatch.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"repo-settings.h\"\n #include \"repository.h\"\ndiff --git a/reflog.c b/reflog.c\nindex 15d81ebea97..4f8a3b717cd 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -5,7 +5,7 @@\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"parse-options.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"reflog.h\"\n #include \"refs.h\"\n #include \"revision.h\"\ndiff --git a/refs.c b/refs.c\nindex 27325d2f3c6..82a70b502f8 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"hook.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"path.h\"\n #include \"submodule.h\"\ndiff --git a/remote.c b/remote.c\nindex 4099183cacd..17a842f5684 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/replace-object.c b/replace-object.c\nindex 7b8a09b5cb4..65b3c108629 100644\n--- a/replace-object.c\n+++ b/replace-object.c\n@@ -2,7 +2,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"oidmap.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"refs.h\"\n #include \"repository.h\"\ndiff --git a/replace-object.h b/replace-object.h\nindex ba478eb30c4..b1b059ed2fe 100644\n--- a/replace-object.h\n+++ b/replace-object.h\n@@ -3,7 +3,7 @@\n \n #include \"oidmap.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct replace_object {\n \tstruct oidmap_entry original;\ndiff --git a/repository.c b/repository.c\nindex dcc03fd9e0a..dbc7fa8685f 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"object.h\"\n #include \"lockfile.h\"\ndiff --git a/rerere.c b/rerere.c\nindex 3cd37c5f0ae..951e4bf8b41 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -18,7 +18,7 @@\n #include \"path.h\"\n #include \"pathspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strmap.h\"\n \n #define RESOLVED 0\ndiff --git a/revision.c b/revision.c\nindex 2c36a9c179e..cdefe7d6e48 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -8,7 +8,7 @@\n #include \"hex.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"tag.h\"\n #include \"blob.h\"\ndiff --git a/send-pack.c b/send-pack.c\nindex 86592ce526d..abca2dd38a7 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"run-command.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex b5c4043757e..35f4e68d59f 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -13,7 +13,7 @@\n #include \"dir.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"pager.h\"\n #include \"commit.h\"\ndiff --git a/server-info.c b/server-info.c\nindex d6cd20a39d7..9bb30d9ab71 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -11,7 +11,7 @@\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"server-info.h\"\n #include \"strbuf.h\"\n #include \"tempfile.h\"\ndiff --git a/shallow.c b/shallow.c\nindex faeeeb45f98..d379756e39a 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -5,7 +5,7 @@\n #include \"repository.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"pkt-line.h\"\ndiff --git a/streaming.c b/streaming.c\nindex 127d6b5d6ac..29cc877f22a 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -10,7 +10,7 @@\n #include \"streaming.h\"\n #include \"repository.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"packfile.h\"\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex 0ee0a2884ef..09034a587f1 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -13,7 +13,7 @@\n #include \"submodule.h\"\n #include \"strbuf.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/submodule.c b/submodule.c\nindex ead3fb5dadc..9b1018877df 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -27,7 +27,7 @@\n #include \"parse-options.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c\nindex 76c2f4eba85..611a13a3261 100644\n--- a/t/helper/test-find-pack.c\n+++ b/t/helper/test-find-pack.c\n@@ -2,7 +2,7 @@\n \n #include \"test-tool.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c\nindex fdf1b13437b..d51aaa3dc40 100644\n--- a/t/helper/test-pack-mtimes.c\n+++ b/t/helper/test-pack-mtimes.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"strbuf.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pack-mtimes.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex 34f1aee5581..dba227259a2 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -1,7 +1,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n /*\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex cd8ba0c54e7..bc37c00a3bd 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"commit-graph.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"bloom.h\"\n #include \"setup.h\"\n \ndiff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c\nindex ac81390899a..da2aa036b57 100644\n--- a/t/helper/test-read-midx.c\n+++ b/t/helper/test-read-midx.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"midx.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"packfile.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 4cfc7c90b59..2920ca59d72 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -5,7 +5,7 @@\n #include \"refs.h\"\n #include \"setup.h\"\n #include \"worktree.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"strbuf.h\"\ndiff --git a/tag.c b/tag.c\nindex 05be39067cf..5f6868bf7b1 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -5,7 +5,7 @@\n #include \"environment.h\"\n #include \"tag.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"blob.h\"\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex b8fe0fdd7d4..9e05fcbddd0 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -10,7 +10,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"quote.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n struct tmp_objdir {\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 90655d52378..34b0fff4873 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -6,7 +6,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace2.h\"\n #include \"tree.h\"\n #include \"pathspec.h\"\ndiff --git a/tree.c b/tree.c\nindex b85f56267fb..341b7c2ff3f 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"tree.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"alloc.h\"\n #include \"tree-walk.h\"\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 471837f0329..f38c761ab98 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -26,7 +26,7 @@\n #include \"symlinks.h\"\n #include \"trace2.h\"\n #include \"fsmonitor.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"entry.h\"\n #include \"parallel-checkout.h\"\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 956da5b061a..cec12cb478a 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -10,7 +10,7 @@\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/walker.c b/walker.c\nindex b470d43e54d..a8abe8a2e78 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"walker.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"strbuf.h\"\n #include \"tree.h\"\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 1edcd319e6e..01e6e378ea6 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"config.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"xdiff-interface.h\"\n #include \"xdiff/xtypes.h\"\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517668","messageId":"20250509-pks-object-store-wo-the-repository-v2-2-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:02Z","receivedAt":"2025-05-09T14:12:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `object_directory` structure is used as an access point for a single\nobject directory like \".git/objects\". While the structure isn't yet\nfully self-contained, the intent is for it to eventually contain all\ninformation required to access objects in one specific location.\n\nWhile the name \"object directory\" is a good fit for now, this will\nchange over time as we continue with the agenda to make pluggable object\ndatabases a thing. Eventually, objects may not be accessed via any kind\nof directory at all anymore, but they could instead be backed by any\nkind of durable storage mechanism. While it seems quite far-fetched for\nnow, it is thinkable that eventually this might even be some form of a\ndatabase, for example.\n\nAs such, the current name of this structure will become worse over time\nas we evolve into the direction of pluggable ODBs. Immediate next steps\nwill start to carve out proper self-contained object directories, which\nrequires us to pass in these object directories as parameters. Based on\nour modern naming schema this means that those functions should then be\nnamed after their subsystem, which means that we would start to bake the\ncurrent name into the codebase more and more.\n\nLet's preempt this by renaming the structure to `odb_alternate` now\nalready. This name is agnostic of how exactly objects are stored while\nstill specifically pinpointing that this is about an alternate object\ndatabase. In the future, it allows us to easily introduce e.g. a\n`odb_files_alternate` and other specific implementations over time.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c      |  18 +++----\n builtin/count-objects.c     |   4 +-\n builtin/fetch.c             |   2 +-\n builtin/fsck.c              |  14 ++---\n builtin/gc.c                |  14 ++---\n builtin/grep.c              |   2 +-\n builtin/multi-pack-index.c  |   4 +-\n builtin/submodule--helper.c |   6 +--\n bundle.c                    |   2 +-\n commit-graph.c              |  94 +++++++++++++++++-----------------\n commit-graph.h              |  14 ++---\n diagnose.c                  |   8 +--\n http-walker.c               |   2 +-\n http.c                      |   4 +-\n loose.c                     |  42 +++++++--------\n midx.c                      |   6 +--\n object-file.c               |  80 ++++++++++++++---------------\n object-file.h               |   8 +--\n object-name.c               |   6 +--\n object-store.c              | 122 ++++++++++++++++++++++----------------------\n object-store.h              |  25 +++++----\n packfile.c                  |  16 +++---\n path.c                      |   2 +-\n refs.c                      |   2 +-\n repository.c                |  14 ++---\n submodule-config.c          |   2 +-\n t/helper/test-read-graph.c  |   6 +--\n tmp-objdir.c                |  24 ++++-----\n 28 files changed, 273 insertions(+), 270 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex a783a86e797..628d3a1e92e 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \t\t\tstruct repository *repo UNUSED)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_alternate *alternate = NULL;\n \tchar *graph_name;\n \tchar *chain_name;\n \tenum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;\n@@ -101,9 +101,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n-\tgraph_name = get_commit_graph_filename(odb);\n-\tchain_name = get_commit_graph_chain_filename(odb);\n+\talternate = find_odb(the_repository, opts.obj_dir);\n+\tgraph_name = get_commit_graph_filename(alternate);\n+\tchain_name = get_commit_graph_chain_filename(alternate);\n \tif (open_commit_graph(graph_name, &fd, &st))\n \t\topened = OPENED_GRAPH;\n \telse if (errno != ENOENT)\n@@ -120,7 +120,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opened == OPENED_NONE)\n \t\treturn 0;\n \telse if (opened == OPENED_GRAPH)\n-\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);\n+\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, alternate);\n \telse\n \t\tgraph = load_commit_graph_chain_fd_st(the_repository, fd, &st,\n \t\t\t\t\t\t      &incomplete_chain);\n@@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \tstruct string_list pack_indexes = STRING_LIST_INIT_DUP;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct oidset commits = OIDSET_INIT;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_alternate *alternate = NULL;\n \tint result = 0;\n \tenum commit_graph_write_flags flags = 0;\n \tstruct progress *progress = NULL;\n@@ -289,10 +289,10 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n+\talternate = find_odb(the_repository, opts.obj_dir);\n \n \tif (opts.reachable) {\n-\t\tif (write_commit_graph_reachable(odb, flags, &write_opts))\n+\t\tif (write_commit_graph_reachable(alternate, flags, &write_opts))\n \t\t\tresult = 1;\n \t\tgoto cleanup;\n \t}\n@@ -318,7 +318,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t\tstop_progress(&progress);\n \t}\n \n-\tif (write_commit_graph(odb,\n+\tif (write_commit_graph(alternate,\n \t\t\t       opts.stdin_packs ? &pack_indexes : NULL,\n \t\t\t       opts.stdin_commits ? &commits : NULL,\n \t\t\t       flags,\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex a88c0c9c09a..da830fcee57 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -80,10 +80,10 @@ static int count_cruft(const char *basename UNUSED, const char *path,\n \treturn 0;\n }\n \n-static int print_alternate(struct object_directory *odb, void *data UNUSED)\n+static int print_alternate(struct odb_alternate *alternate, void *data UNUSED)\n {\n \tprintf(\"alternate: \");\n-\tquote_c_style(odb->path, NULL, stdout, 0);\n+\tquote_c_style(alternate->path, NULL, stdout, 0);\n \tputchar('\\n');\n \treturn 0;\n }\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex cda6eaf1fd6..4de6d3206d4 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2652,7 +2652,7 @@ int cmd_fetch(int argc,\n \t\t\tcommit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n \t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\", the_repository);\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->alternates,\n \t\t\t\t\t     commit_graph_flags,\n \t\t\t\t\t     NULL);\n \t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\", the_repository);\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6cac28356ce..9c54286540c 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -965,7 +965,7 @@ int cmd_fsck(int argc,\n \t     struct repository *repo UNUSED)\n {\n \tint i;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \t/* fsck knows how to handle missing promisor objects */\n \tfetch_if_missing = 0;\n@@ -1007,8 +1007,8 @@ int cmd_fsck(int argc,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next)\n-\t\t\tfsck_object_dir(odb->path);\n+\t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next)\n+\t\t\tfsck_object_dir(alternate->path);\n \n \t\tif (check_full) {\n \t\t\tstruct packed_git *p;\n@@ -1118,11 +1118,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&commit_graph_verify.args, \"commit-graph\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", alternate->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&commit_graph_verify.args, \"--progress\");\n \t\t\telse\n@@ -1136,11 +1136,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&midx_verify.args, \"multi-pack-index\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", alternate->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&midx_verify.args, \"--progress\");\n \t\t\telse\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 78a2751aa8a..9e9d31c1f39 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -944,7 +944,7 @@ struct repository *repo UNUSED)\n \t}\n \n \tif (the_repository->settings.gc_write_commit_graph == 1)\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->alternates,\n \t\t\t\t\t     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,\n \t\t\t\t\t     NULL);\n \n@@ -1197,7 +1197,7 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)\n \tif (loose_object_auto_limit < 0)\n \t\treturn 1;\n \n-\treturn for_each_loose_file_in_objdir(the_repository->objects->odb->path,\n+\treturn for_each_loose_file_in_objdir(the_repository->objects->alternates->path,\n \t\t\t\t\t     loose_object_count,\n \t\t\t\t\t     NULL, NULL, &count);\n }\n@@ -1232,7 +1232,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t * Do not start pack-objects process\n \t * if there are no loose objects.\n \t */\n-\tif (!for_each_loose_file_in_objdir(r->objects->odb->path,\n+\tif (!for_each_loose_file_in_objdir(r->objects->alternates->path,\n \t\t\t\t\t   bail_on_loose,\n \t\t\t\t\t   NULL, NULL, NULL))\n \t\treturn 0;\n@@ -1244,7 +1244,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t\tstrvec_push(&pack_proc.args, \"--quiet\");\n \telse\n \t\tstrvec_push(&pack_proc.args, \"--no-quiet\");\n-\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->odb->path);\n+\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->alternates->path);\n \n \tpack_proc.in = -1;\n \n@@ -1272,7 +1272,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \telse if (data.batch_size > 0)\n \t\tdata.batch_size--; /* Decrease for equality on limit. */\n \n-\tfor_each_loose_file_in_objdir(r->objects->odb->path,\n+\tfor_each_loose_file_in_objdir(r->objects->alternates->path,\n \t\t\t\t      write_loose_object_to_stdin,\n \t\t\t\t      NULL,\n \t\t\t\t      NULL,\n@@ -1525,7 +1525,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,\n \tint result = 0;\n \tstruct lock_file lk;\n \tstruct repository *r = the_repository;\n-\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->alternates->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\t/*\n@@ -2997,7 +2997,7 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,\n \tunsigned int i;\n \tint result = 0;\n \tstruct lock_file lk;\n-\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->alternates->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\tif (errno == EEXIST)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ce574a605b..3c51a39c10d 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->odb->path);\n+\tadd_submodule_odb_by_path(subrepo->objects->alternates->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex 69a97507324..a77ae465d48 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -294,8 +294,8 @@ int cmd_multi_pack_index(int argc,\n \n \tif (the_repository &&\n \t    the_repository->objects &&\n-\t    the_repository->objects->odb)\n-\t\topts.object_dir = xstrdup(the_repository->objects->odb->path);\n+\t    the_repository->objects->alternates)\n+\t\topts.object_dir = xstrdup(the_repository->objects->alternates->path);\n \n \targc = parse_options(argc, argv, prefix, options,\n \t\t\t     builtin_multi_pack_index_usage, 0);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 53da2116ddf..cd7db11d825 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1582,7 +1582,7 @@ static const char alternate_error_advice[] = N_(\n );\n \n static int add_possible_reference_from_superproject(\n-\t\tstruct object_directory *odb, void *sas_cb)\n+\t\tstruct odb_alternate *alt_odb, void *sas_cb)\n {\n \tstruct submodule_alternate_setup *sas = sas_cb;\n \tsize_t len;\n@@ -1591,12 +1591,12 @@ static int add_possible_reference_from_superproject(\n \t * If the alternate object store is another repository, try the\n \t * standard layout with .git/(modules/<name>)+/objects\n \t */\n-\tif (strip_suffix(odb->path, \"/objects\", &len)) {\n+\tif (strip_suffix(alt_odb->path, \"/objects\", &len)) {\n \t\tstruct repository alternate;\n \t\tchar *sm_alternate;\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstruct strbuf err = STRBUF_INIT;\n-\t\tstrbuf_add(&sb, odb->path, len);\n+\t\tstrbuf_add(&sb, alt_odb->path, len);\n \n \t\tif (repo_init(&alternate, sb.buf, NULL) < 0)\n \t\t\tdie(_(\"could not get a repository handle for gitdir '%s'\"),\ndiff --git a/bundle.c b/bundle.c\nindex b0a3fee2efa..0c7cd15bb12 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -233,7 +233,7 @@ int verify_bundle(struct repository *r,\n \t\t.quiet = 1,\n \t};\n \n-\tif (!r || !r->objects || !r->objects->odb)\n+\tif (!r || !r->objects || !r->objects->alternates)\n \t\treturn error(_(\"need a repository to verify a bundle\"));\n \n \tfor (i = 0; i < p->nr; i++) {\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 1b66486b9c9..58d1eeedb1a 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -37,7 +37,7 @@ void git_test_write_commit_graph_or_die(void)\n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph_reachable(the_repository->objects->odb,\n+\tif (write_commit_graph_reachable(the_repository->objects->alternates,\n \t\t\t\t\t flags, NULL))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n@@ -191,21 +191,21 @@ static int commit_gen_cmp(const void *va, const void *vb)\n \treturn 0;\n }\n \n-char *get_commit_graph_filename(struct object_directory *obj_dir)\n+char *get_commit_graph_filename(struct odb_alternate *alternate)\n {\n-\treturn xstrfmt(\"%s/info/commit-graph\", obj_dir->path);\n+\treturn xstrfmt(\"%s/info/commit-graph\", alternate->path);\n }\n \n-static char *get_split_graph_filename(struct object_directory *odb,\n+static char *get_split_graph_filename(struct odb_alternate *alternate,\n \t\t\t\t      const char *oid_hex)\n {\n-\treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", odb->path,\n+\treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", alternate->path,\n \t\t       oid_hex);\n }\n \n-char *get_commit_graph_chain_filename(struct object_directory *odb)\n+char *get_commit_graph_chain_filename(struct odb_alternate *alternate)\n {\n-\treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", odb->path);\n+\treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", alternate->path);\n }\n \n static struct commit_graph *alloc_commit_graph(void)\n@@ -250,7 +250,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_alternate *alternate)\n {\n \tvoid *graph_map;\n \tsize_t graph_size;\n@@ -269,7 +269,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \tret = parse_commit_graph(&r->settings, graph_map, graph_size);\n \n \tif (ret)\n-\t\tret->odb = odb;\n+\t\tret->alternate = alternate;\n \telse\n \t\tmunmap(graph_map, graph_size);\n \n@@ -487,7 +487,7 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s,\n \n static struct commit_graph *load_commit_graph_one(struct repository *r,\n \t\t\t\t\t\t  const char *graph_file,\n-\t\t\t\t\t\t  struct object_directory *odb)\n+\t\t\t\t\t\t  struct odb_alternate *alternate)\n {\n \n \tstruct stat st;\n@@ -498,7 +498,7 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n \tif (!open_ok)\n \t\treturn NULL;\n \n-\tg = load_commit_graph_one_fd_st(r, fd, &st, odb);\n+\tg = load_commit_graph_one_fd_st(r, fd, &st, alternate);\n \n \tif (g)\n \t\tg->filename = xstrdup(graph_file);\n@@ -507,10 +507,10 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_v1(struct repository *r,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_alternate *alternate)\n {\n-\tchar *graph_name = get_commit_graph_filename(odb);\n-\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\tchar *graph_name = get_commit_graph_filename(alternate);\n+\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, alternate);\n \tfree(graph_name);\n \n \treturn g;\n@@ -652,7 +652,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tprepare_alt_odb(r);\n \n \tfor (i = 0; i < count; i++) {\n-\t\tstruct object_directory *odb;\n+\t\tstruct odb_alternate *alternate;\n \n \t\tif (strbuf_getline_lf(&line, fp) == EOF)\n \t\t\tbreak;\n@@ -665,9 +665,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t}\n \n \t\tvalid = 0;\n-\t\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t\tchar *graph_name = get_split_graph_filename(odb, line.buf);\n-\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\t\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\t\tchar *graph_name = get_split_graph_filename(alternate, line.buf);\n+\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, alternate);\n \n \t\t\tfree(graph_name);\n \n@@ -701,9 +701,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_chain(struct repository *r,\n-\t\t\t\t\t\t    struct object_directory *odb)\n+\t\t\t\t\t\t    struct odb_alternate *alternate)\n {\n-\tchar *chain_file = get_commit_graph_chain_filename(odb);\n+\tchar *chain_file = get_commit_graph_chain_filename(alternate);\n \tstruct stat st;\n \tint fd;\n \tstruct commit_graph *g = NULL;\n@@ -719,24 +719,24 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,\n }\n \n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb)\n+\t\t\t\t\t   struct odb_alternate *alternate)\n {\n-\tstruct commit_graph *g = load_commit_graph_v1(r, odb);\n+\tstruct commit_graph *g = load_commit_graph_v1(r, alternate);\n \n \tif (!g)\n-\t\tg = load_commit_graph_chain(r, odb);\n+\t\tg = load_commit_graph_chain(r, alternate);\n \n \treturn g;\n }\n \n static void prepare_commit_graph_one(struct repository *r,\n-\t\t\t\t     struct object_directory *odb)\n+\t\t\t\t     struct odb_alternate *alternate)\n {\n \n \tif (r->objects->commit_graph)\n \t\treturn;\n \n-\tr->objects->commit_graph = read_commit_graph_one(r, odb);\n+\tr->objects->commit_graph = read_commit_graph_one(r, alternate);\n }\n \n /*\n@@ -747,7 +747,7 @@ static void prepare_commit_graph_one(struct repository *r,\n  */\n static int prepare_commit_graph(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \t/*\n \t * Early return if there is no git dir or if the commit graph is\n@@ -779,10 +779,10 @@ static int prepare_commit_graph(struct repository *r)\n \t\treturn 0;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb;\n-\t     !r->objects->commit_graph && odb;\n-\t     odb = odb->next)\n-\t\tprepare_commit_graph_one(r, odb);\n+\tfor (alternate = r->objects->alternates;\n+\t     !r->objects->commit_graph && alternate;\n+\t     alternate = alternate->next)\n+\t\tprepare_commit_graph_one(r, alternate);\n \treturn !!r->objects->commit_graph;\n }\n \n@@ -1137,7 +1137,7 @@ struct packed_commit_list {\n \n struct write_commit_graph_context {\n \tstruct repository *r;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tchar *graph_name;\n \tstruct oid_array oids;\n \tstruct packed_commit_list commits;\n@@ -1870,7 +1870,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \treturn 0;\n }\n \n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_alternate *alternate,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts)\n {\n@@ -1890,7 +1890,7 @@ int write_commit_graph_reachable(struct object_directory *odb,\n \n \tstop_progress(&data.progress);\n \n-\tresult = write_commit_graph(odb, NULL, &commits,\n+\tresult = write_commit_graph(alternate, NULL, &commits,\n \t\t\t\t    flags, opts);\n \n \toidset_clear(&commits);\n@@ -1906,7 +1906,7 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,\n \tint dirlen;\n \tint ret = 0;\n \n-\tstrbuf_addf(&packname, \"%s/pack/\", ctx->odb->path);\n+\tstrbuf_addf(&packname, \"%s/pack/\", ctx->alternate->path);\n \tdirlen = packname.len;\n \tif (ctx->report_progress) {\n \t\tstrbuf_addf(&progress_title,\n@@ -2058,10 +2058,10 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \n \t\tstrbuf_addf(&tmp_file,\n \t\t\t    \"%s/info/commit-graphs/tmp_graph_XXXXXX\",\n-\t\t\t    ctx->odb->path);\n+\t\t\t    ctx->alternate->path);\n \t\tctx->graph_name = strbuf_detach(&tmp_file, NULL);\n \t} else {\n-\t\tctx->graph_name = get_commit_graph_filename(ctx->odb);\n+\t\tctx->graph_name = get_commit_graph_filename(ctx->alternate);\n \t}\n \n \tif (safe_create_leading_directories(the_repository, ctx->graph_name)) {\n@@ -2071,7 +2071,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t}\n \n \tif (ctx->split) {\n-\t\tchar *lock_name = get_commit_graph_chain_filename(ctx->odb);\n+\t\tchar *lock_name = get_commit_graph_chain_filename(ctx->alternate);\n \n \t\thold_lock_file_for_update_mode(&lk, lock_name,\n \t\t\t\t\t       LOCK_DIE_ON_ERROR, 0444);\n@@ -2159,7 +2159,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \n \tif (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {\n \t\tchar *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));\n-\t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb, new_base_hash);\n+\t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->alternate, new_base_hash);\n \n \t\tfree(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]);\n \t\tfree(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]);\n@@ -2199,14 +2199,14 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\t\t\t}\n \t\t\t}\n \t\t} else {\n-\t\t\tchar *graph_name = get_commit_graph_filename(ctx->odb);\n+\t\t\tchar *graph_name = get_commit_graph_filename(ctx->alternate);\n \t\t\tunlink(graph_name);\n \t\t\tfree(graph_name);\n \t\t}\n \n \t\tfree(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);\n \t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));\n-\t\tfinal_graph_name = get_split_graph_filename(ctx->odb,\n+\t\tfinal_graph_name = get_split_graph_filename(ctx->alternate,\n \t\t\t\t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);\n \t\tfree(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);\n \t\tctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;\n@@ -2257,7 +2257,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)\n \t    flags != COMMIT_GRAPH_SPLIT_REPLACE) {\n \t\twhile (g && (g->num_commits <= st_mult(size_mult, num_commits) ||\n \t\t\t    (max_commits && num_commits > max_commits))) {\n-\t\t\tif (g->odb != ctx->odb)\n+\t\t\tif (g->alternate != ctx->alternate)\n \t\t\t\tbreak;\n \n \t\t\tif (unsigned_add_overflows(num_commits, g->num_commits))\n@@ -2279,10 +2279,10 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)\n \t\t    \"should be 1 with --split=replace\");\n \n \tif (ctx->num_commit_graphs_after == 2) {\n-\t\tchar *old_graph_name = get_commit_graph_filename(g->odb);\n+\t\tchar *old_graph_name = get_commit_graph_filename(g->alternate);\n \n \t\tif (!strcmp(g->filename, old_graph_name) &&\n-\t\t    g->odb != ctx->odb) {\n+\t\t    g->alternate != ctx->alternate) {\n \t\t\tctx->num_commit_graphs_after = 1;\n \t\t\tctx->new_base_graph = NULL;\n \t\t}\n@@ -2454,13 +2454,13 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tif (ctx->opts && ctx->opts->expire_time)\n \t\texpire_time = ctx->opts->expire_time;\n \tif (!ctx->split) {\n-\t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->odb);\n+\t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->alternate);\n \t\tunlink(chain_file_name);\n \t\tfree(chain_file_name);\n \t\tctx->num_commit_graphs_after = 0;\n \t}\n \n-\tstrbuf_addstr(&path, ctx->odb->path);\n+\tstrbuf_addstr(&path, ctx->alternate->path);\n \tstrbuf_addstr(&path, \"/info/commit-graphs\");\n \tdir = opendir(path.buf);\n \n@@ -2502,7 +2502,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tstrbuf_release(&path);\n }\n \n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_alternate *alternate,\n \t\t       const struct string_list *const pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\n@@ -2533,7 +2533,7 @@ int write_commit_graph(struct object_directory *odb,\n \n \tCALLOC_ARRAY(ctx, 1);\n \tctx->r = r;\n-\tctx->odb = odb;\n+\tctx->alternate = alternate;\n \tctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;\n \tctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;\n \tctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 20d38c100ce..19d95ade6ea 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -29,8 +29,8 @@ struct repository;\n struct object_database;\n struct string_list;\n \n-char *get_commit_graph_filename(struct object_directory *odb);\n-char *get_commit_graph_chain_filename(struct object_directory *odb);\n+char *get_commit_graph_filename(struct odb_alternate *alternate);\n+char *get_commit_graph_chain_filename(struct odb_alternate *alternate);\n int open_commit_graph(const char *graph_file, int *fd, struct stat *st);\n int open_commit_graph_chain(const char *chain_file, int *fd, struct stat *st);\n \n@@ -89,7 +89,7 @@ struct commit_graph {\n \tuint32_t num_commits;\n \tstruct object_id oid;\n \tchar *filename;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tuint32_t num_commits_in_base;\n \tunsigned int read_generation_data;\n@@ -115,12 +115,12 @@ struct commit_graph {\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb);\n+\t\t\t\t\t\t struct odb_alternate *alternate);\n struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t\t\t\t\t   int fd, struct stat *st,\n \t\t\t\t\t\t   int *incomplete_chain);\n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb);\n+\t\t\t\t\t   struct odb_alternate *alternate);\n \n struct repo_settings;\n \n@@ -173,10 +173,10 @@ struct commit_graph_opts {\n  * is not compatible with the commit-graph feature, then the\n  * methods will return 0 without writing a commit-graph.\n  */\n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_alternate *alternate,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts);\n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_alternate *alternate,\n \t\t       const struct string_list *pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\ndiff --git a/diagnose.c b/diagnose.c\nindex b1be74be983..50129cf4be3 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -59,13 +59,13 @@ static void dir_file_stats_objects(const char *full_path,\n \t\t\t    (uintmax_t)st.st_size);\n }\n \n-static int dir_file_stats(struct object_directory *object_dir, void *data)\n+static int dir_file_stats(struct odb_alternate *alternate, void *data)\n {\n \tstruct strbuf *buf = data;\n \n-\tstrbuf_addf(buf, \"Contents of %s:\\n\", object_dir->path);\n+\tstrbuf_addf(buf, \"Contents of %s:\\n\", alternate->path);\n \n-\tfor_each_file_in_pack_dir(object_dir->path, dir_file_stats_objects,\n+\tfor_each_file_in_pack_dir(alternate->path, dir_file_stats_objects,\n \t\t\t\t  data);\n \n \treturn 0;\n@@ -228,7 +228,7 @@ int create_diagnostics_archive(struct repository *r,\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n-\tdir_file_stats(r->objects->odb, &buf);\n+\tdir_file_stats(r->objects->alternates, &buf);\n \tforeach_alt_odb(dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \ndiff --git a/http-walker.c b/http-walker.c\nindex 463f7b119ad..9e7bc37f02e 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -543,7 +543,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \t\tret = error(\"File %s has bad hash\", hex);\n \t} else if (req->rename < 0) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\todb_loose_path(the_repository->objects->odb, &buf, &req->oid);\n+\t\todb_loose_path(the_repository->objects->alternates, &buf, &req->oid);\n \t\tret = error(\"unable to write sha1 filename %s\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\ndiff --git a/http.c b/http.c\nindex 3c029cf8947..8ce2ec73947 100644\n--- a/http.c\n+++ b/http.c\n@@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \toidcpy(&freq->oid, oid);\n \tfreq->localfile = -1;\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->alternates, &filename, oid);\n \tstrbuf_addf(&freq->tmpfile, \"%s.temp\", filename.buf);\n \n \tstrbuf_addf(&prevfile, \"%s.prev\", filename.buf);\n@@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)\n \t\tunlink_or_warn(freq->tmpfile.buf);\n \t\treturn -1;\n \t}\n-\todb_loose_path(the_repository->objects->odb, &filename, &freq->oid);\n+\todb_loose_path(the_repository->objects->alternates, &filename, &freq->oid);\n \tfreq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);\n \tstrbuf_release(&filename);\n \ndiff --git a/loose.c b/loose.c\nindex bb602aaa366..bce4e1c3ee7 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -44,36 +44,36 @@ static int insert_oid_pair(kh_oid_map_t *map, const struct object_id *key, const\n \treturn 1;\n }\n \n-static int insert_loose_map(struct object_directory *odb,\n+static int insert_loose_map(struct odb_alternate *alternate,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\n {\n-\tstruct loose_object_map *map = odb->loose_map;\n+\tstruct loose_object_map *map = alternate->loose_map;\n \tint inserted = 0;\n \n \tinserted |= insert_oid_pair(map->to_compat, oid, compat_oid);\n \tinserted |= insert_oid_pair(map->to_storage, compat_oid, oid);\n \tif (inserted)\n-\t\toidtree_insert(odb->loose_objects_cache, compat_oid);\n+\t\toidtree_insert(alternate->loose_objects_cache, compat_oid);\n \n \treturn inserted;\n }\n \n-static int load_one_loose_object_map(struct repository *repo, struct object_directory *dir)\n+static int load_one_loose_object_map(struct repository *repo, struct odb_alternate *alternate)\n {\n \tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n \tFILE *fp;\n \n-\tif (!dir->loose_map)\n-\t\tloose_object_map_init(&dir->loose_map);\n-\tif (!dir->loose_objects_cache) {\n-\t\tALLOC_ARRAY(dir->loose_objects_cache, 1);\n-\t\toidtree_init(dir->loose_objects_cache);\n+\tif (!alternate->loose_map)\n+\t\tloose_object_map_init(&alternate->loose_map);\n+\tif (!alternate->loose_objects_cache) {\n+\t\tALLOC_ARRAY(alternate->loose_objects_cache, 1);\n+\t\toidtree_init(alternate->loose_objects_cache);\n \t}\n \n-\tinsert_loose_map(dir, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);\n-\tinsert_loose_map(dir, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);\n-\tinsert_loose_map(dir, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);\n+\tinsert_loose_map(alternate, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);\n+\tinsert_loose_map(alternate, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);\n+\tinsert_loose_map(alternate, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);\n \n \trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n \tfp = fopen(path.buf, \"rb\");\n@@ -93,7 +93,7 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \t\t    parse_oid_hex_algop(p, &compat_oid, &p, repo->compat_hash_algo) ||\n \t\t    p != buf.buf + buf.len)\n \t\t\tgoto err;\n-\t\tinsert_loose_map(dir, &oid, &compat_oid);\n+\t\tinsert_loose_map(alternate, &oid, &compat_oid);\n \t}\n \n \tstrbuf_release(&buf);\n@@ -107,15 +107,15 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \n int repo_read_loose_object_map(struct repository *repo)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_alternate *alternate;\n \n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n \tprepare_alt_odb(repo);\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tif (load_one_loose_object_map(repo, dir) < 0) {\n+\tfor (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tif (load_one_loose_object_map(repo, alternate) < 0) {\n \t\t\treturn -1;\n \t\t}\n \t}\n@@ -124,7 +124,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \n int repo_write_loose_object_map(struct repository *repo)\n {\n-\tkh_oid_map_t *map = repo->objects->odb->loose_map->to_compat;\n+\tkh_oid_map_t *map = repo->objects->alternates->loose_map->to_compat;\n \tstruct lock_file lock;\n \tint fd;\n \tkhiter_t iter;\n@@ -212,7 +212,7 @@ int repo_add_loose_object_map(struct repository *repo, const struct object_id *o\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tinserted = insert_loose_map(repo->objects->odb, oid, compat_oid);\n+\tinserted = insert_loose_map(repo->objects->alternates, oid, compat_oid);\n \tif (inserted)\n \t\treturn write_one_object(repo, oid, compat_oid);\n \treturn 0;\n@@ -223,12 +223,12 @@ int repo_loose_object_map_oid(struct repository *repo,\n \t\t\t      const struct git_hash_algo *to,\n \t\t\t      struct object_id *dest)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_alternate *alternate;\n \tkh_oid_map_t *map;\n \tkhiter_t pos;\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tstruct loose_object_map *loose_map = dir->loose_map;\n+\tfor (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tstruct loose_object_map *loose_map = alternate->loose_map;\n \t\tif (!loose_map)\n \t\t\tcontinue;\n \t\tmap = (to == repo->compat_hash_algo) ?\ndiff --git a/midx.c b/midx.c\nindex 3d0015f7828..c1adff4404e 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -824,7 +824,7 @@ void clear_midx_file(struct repository *r)\n {\n \tstruct strbuf midx = STRBUF_INIT;\n \n-\tget_midx_filename(r->hash_algo, &midx, r->objects->odb->path);\n+\tget_midx_filename(r->hash_algo, &midx, r->objects->alternates->path);\n \n \tif (r->objects && r->objects->multi_pack_index) {\n \t\tclose_midx(r->objects->multi_pack_index);\n@@ -834,8 +834,8 @@ void clear_midx_file(struct repository *r)\n \tif (remove_path(midx.buf))\n \t\tdie(_(\"failed to clear multi-pack-index at %s\"), midx.buf);\n \n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_BITMAP, NULL);\n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_REV, NULL);\n+\tclear_midx_files_ext(r->objects->alternates->path, MIDX_EXT_BITMAP, NULL);\n+\tclear_midx_files_ext(r->objects->alternates->path, MIDX_EXT_REV, NULL);\n \n \tstrbuf_release(&midx);\n }\ndiff --git a/object-file.c b/object-file.c\nindex dc56a4766df..e48d968c0e0 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -55,12 +55,12 @@ static void fill_loose_path(struct strbuf *buf, const struct object_id *oid)\n \t}\n }\n \n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_alternate *alternate,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid)\n {\n \tstrbuf_reset(buf);\n-\tstrbuf_addstr(buf, odb->path);\n+\tstrbuf_addstr(buf, alternate->path);\n \tstrbuf_addch(buf, '/');\n \tfill_loose_path(buf, oid);\n \treturn buf->buf;\n@@ -88,27 +88,27 @@ int check_and_freshen_file(const char *fn, int freshen)\n \treturn 1;\n }\n \n-static int check_and_freshen_odb(struct object_directory *odb,\n+static int check_and_freshen_odb(struct odb_alternate *alternate,\n \t\t\t\t const struct object_id *oid,\n \t\t\t\t int freshen)\n {\n \tstatic struct strbuf path = STRBUF_INIT;\n-\todb_loose_path(odb, &path, oid);\n+\todb_loose_path(alternate, &path, oid);\n \treturn check_and_freshen_file(path.buf, freshen);\n }\n \n static int check_and_freshen_local(const struct object_id *oid, int freshen)\n {\n-\treturn check_and_freshen_odb(the_repository->objects->odb, oid, freshen);\n+\treturn check_and_freshen_odb(the_repository->objects->alternates, oid, freshen);\n }\n \n static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb->next; odb; odb = odb->next) {\n-\t\tif (check_and_freshen_odb(odb, oid, freshen))\n+\tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n+\t\tif (check_and_freshen_odb(alternate, oid, freshen))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -208,12 +208,12 @@ int stream_object_signature(struct repository *r, const struct object_id *oid)\n static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \t\t\t     struct stat *st, const char **path)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\t*path = odb_loose_path(alternate, &buf, oid);\n \t\tif (!lstat(*path, st))\n \t\t\treturn 0;\n \t}\n@@ -229,13 +229,13 @@ static int open_loose_object(struct repository *r,\n \t\t\t     const struct object_id *oid, const char **path)\n {\n \tint fd;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\t*path = odb_loose_path(alternate, &buf, oid);\n \t\tfd = git_open(*path);\n \t\tif (fd >= 0)\n \t\t\treturn fd;\n@@ -250,11 +250,11 @@ static int open_loose_object(struct repository *r,\n static int quick_has_loose(struct repository *r,\n \t\t\t   const struct object_id *oid)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tif (oidtree_contains(odb_loose_cache(odb, oid), oid))\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tif (oidtree_contains(odb_loose_cache(alternate, oid), oid))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -750,7 +750,7 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,\n /* Finalize a file on disk, and close it. */\n static void close_loose_object(int fd, const char *filename)\n {\n-\tif (the_repository->objects->odb->will_destroy)\n+\tif (the_repository->objects->alternates->will_destroy)\n \t\tgoto out;\n \n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n@@ -932,7 +932,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,\n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n \t\tprepare_loose_object_bulk_checkin();\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->alternates, &filename, oid);\n \n \tfd = start_loose_object_common(&tmp_file, filename.buf, flags,\n \t\t\t\t       &stream, compressed, sizeof(compressed),\n@@ -1079,7 +1079,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,\n \t\tgoto cleanup;\n \t}\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->alternates, &filename, oid);\n \n \t/* We finally know the object path, and create the missing dir. */\n \tdirlen = directory_size(filename.buf);\n@@ -1540,11 +1540,11 @@ int for_each_loose_file_in_objdir(const char *path,\n int for_each_loose_object(each_loose_object_fn cb, void *data,\n \t\t\t  enum for_each_object_flags flags)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n-\t\tint r = for_each_loose_file_in_objdir(odb->path, cb, NULL,\n+\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tint r = for_each_loose_file_in_objdir(alternate->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\n \t\tif (r)\n \t\t\treturn r;\n@@ -1564,43 +1564,43 @@ static int append_loose_object(const struct object_id *oid,\n \treturn 0;\n }\n \n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n-\t\t\t\t  const struct object_id *oid)\n+struct oidtree *odb_loose_cache(struct odb_alternate *alternate,\n+\t\t\t\tconst struct object_id *oid)\n {\n \tint subdir_nr = oid->hash[0];\n \tstruct strbuf buf = STRBUF_INIT;\n-\tsize_t word_bits = bitsizeof(odb->loose_objects_subdir_seen[0]);\n+\tsize_t word_bits = bitsizeof(alternate->loose_objects_subdir_seen[0]);\n \tsize_t word_index = subdir_nr / word_bits;\n \tsize_t mask = (size_t)1u << (subdir_nr % word_bits);\n \tuint32_t *bitmap;\n \n \tif (subdir_nr < 0 ||\n-\t    subdir_nr >= bitsizeof(odb->loose_objects_subdir_seen))\n+\t    subdir_nr >= bitsizeof(alternate->loose_objects_subdir_seen))\n \t\tBUG(\"subdir_nr out of range\");\n \n-\tbitmap = &odb->loose_objects_subdir_seen[word_index];\n+\tbitmap = &alternate->loose_objects_subdir_seen[word_index];\n \tif (*bitmap & mask)\n-\t\treturn odb->loose_objects_cache;\n-\tif (!odb->loose_objects_cache) {\n-\t\tALLOC_ARRAY(odb->loose_objects_cache, 1);\n-\t\toidtree_init(odb->loose_objects_cache);\n+\t\treturn alternate->loose_objects_cache;\n+\tif (!alternate->loose_objects_cache) {\n+\t\tALLOC_ARRAY(alternate->loose_objects_cache, 1);\n+\t\toidtree_init(alternate->loose_objects_cache);\n \t}\n-\tstrbuf_addstr(&buf, odb->path);\n+\tstrbuf_addstr(&buf, alternate->path);\n \tfor_each_file_in_obj_subdir(subdir_nr, &buf,\n \t\t\t\t    append_loose_object,\n \t\t\t\t    NULL, NULL,\n-\t\t\t\t    odb->loose_objects_cache);\n+\t\t\t\t    alternate->loose_objects_cache);\n \t*bitmap |= mask;\n \tstrbuf_release(&buf);\n-\treturn odb->loose_objects_cache;\n+\treturn alternate->loose_objects_cache;\n }\n \n-void odb_clear_loose_cache(struct object_directory *odb)\n+void odb_clear_loose_cache(struct odb_alternate *alternate)\n {\n-\toidtree_clear(odb->loose_objects_cache);\n-\tFREE_AND_NULL(odb->loose_objects_cache);\n-\tmemset(&odb->loose_objects_subdir_seen, 0,\n-\t       sizeof(odb->loose_objects_subdir_seen));\n+\toidtree_clear(alternate->loose_objects_cache);\n+\tFREE_AND_NULL(alternate->loose_objects_cache);\n+\tmemset(&alternate->loose_objects_subdir_seen, 0,\n+\t       sizeof(alternate->loose_objects_subdir_seen));\n }\n \n static int check_stream_oid(git_zstream *stream,\ndiff --git a/object-file.h b/object-file.h\nindex a85b2e5b494..f1601200938 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -24,23 +24,23 @@ enum {\n int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n \n-struct object_directory;\n+struct odb_alternate;\n \n /*\n  * Populate and return the loose object cache array corresponding to the\n  * given object ID.\n  */\n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n+struct oidtree *odb_loose_cache(struct odb_alternate *alternate,\n \t\t\t\tconst struct object_id *oid);\n \n /* Empty the loose object cache for the specified object directory. */\n-void odb_clear_loose_cache(struct object_directory *odb);\n+void odb_clear_loose_cache(struct odb_alternate *alternate);\n \n /*\n  * Put in `buf` the name of the file in the local object database that\n  * would be used to store a loose object with the specified oid.\n  */\n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_alternate *alternate,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid);\n \ndiff --git a/object-name.c b/object-name.c\nindex 9288b2dd245..b83ba882b9e 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -112,10 +112,10 @@ static enum cb_next match_prefix(const struct object_id *oid, void *arg)\n \n static void find_short_object_filename(struct disambiguate_state *ds)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n-\tfor (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next)\n-\t\toidtree_each(odb_loose_cache(odb, &ds->bin_pfx),\n+\tfor (alternate = ds->repo->objects->alternates; alternate && !ds->ambiguous; alternate = alternate->next)\n+\t\toidtree_each(odb_loose_cache(alternate, &ds->bin_pfx),\n \t\t\t\t&ds->bin_pfx, ds->len, match_prefix, ds);\n }\n \ndiff --git a/object-store.c b/object-store.c\nindex 1effcb12273..673a9c6006b 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -27,7 +27,7 @@\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n-\tstruct object_directory *, 1, fspathhash, fspatheq)\n+\tstruct odb_alternate *, 1, fspathhash, fspatheq)\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n@@ -104,18 +104,18 @@ static int alt_odb_usable(struct object_database *o,\n \t * Prevent the common mistake of listing the same\n \t * thing twice, or object directory itself.\n \t */\n-\tif (!o->odb_by_path) {\n+\tif (!o->alternate_by_path) {\n \t\tkhiter_t p;\n \n-\t\to->odb_by_path = kh_init_odb_path_map();\n-\t\tassert(!o->odb->next);\n-\t\tp = kh_put_odb_path_map(o->odb_by_path, o->odb->path, &r);\n+\t\to->alternate_by_path = kh_init_odb_path_map();\n+\t\tassert(!o->alternates->next);\n+\t\tp = kh_put_odb_path_map(o->alternate_by_path, o->alternates->path, &r);\n \t\tassert(r == 1); /* never used */\n-\t\tkh_value(o->odb_by_path, p) = o->odb;\n+\t\tkh_value(o->alternate_by_path, p) = o->alternates;\n \t}\n \tif (fspatheq(path->buf, normalized_objdir))\n \t\treturn 0;\n-\t*pos = kh_put_odb_path_map(o->odb_by_path, path->buf, &r);\n+\t*pos = kh_put_odb_path_map(o->alternate_by_path, path->buf, &r);\n \t/* r: 0 = exists, 1 = never used, 2 = deleted */\n \treturn r == 0 ? 0 : 1;\n }\n@@ -124,7 +124,7 @@ static int alt_odb_usable(struct object_database *o,\n  * Prepare alternate object database registry.\n  *\n  * The variable alt_odb_list points at the list of struct\n- * object_directory.  The elements on this list come from\n+ * odb_alternate.  The elements on this list come from\n  * non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT\n  * environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates,\n  * whose contents is similar to that environment variable but can be\n@@ -141,7 +141,7 @@ static void read_info_alternates(struct repository *r,\n static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tconst char *relative_base, int depth, const char *normalized_objdir)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_alternate *alternate;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n \tstruct strbuf tmp = STRBUF_INIT;\n \tkhiter_t pos;\n@@ -170,19 +170,19 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n-\tCALLOC_ARRAY(ent, 1);\n-\t/* pathbuf.buf is already in r->objects->odb_by_path */\n-\tent->path = strbuf_detach(&pathbuf, NULL);\n+\tCALLOC_ARRAY(alternate, 1);\n+\t/* pathbuf.buf is already in r->objects->alternate_by_path */\n+\talternate->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->odb_tail = ent;\n-\tr->objects->odb_tail = &(ent->next);\n-\tent->next = NULL;\n-\tassert(r->objects->odb_by_path);\n-\tkh_value(r->objects->odb_by_path, pos) = ent;\n+\t*r->objects->alternates_tail = alternate;\n+\tr->objects->alternates_tail = &(alternate->next);\n+\talternate->next = NULL;\n+\tassert(r->objects->alternate_by_path);\n+\tkh_value(r->objects->alternate_by_path, pos) = alternate;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, ent->path, depth + 1);\n+\tread_info_alternates(r, alternate->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -234,7 +234,7 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->odb->path, 1);\n+\tstrbuf_realpath(&objdirbuf, r->objects->alternates->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n@@ -321,9 +321,9 @@ void add_to_alternates_memory(const char *reference)\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy)\n {\n-\tstruct object_directory *new_odb;\n+\tstruct odb_alternate *alternate;\n \n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n@@ -335,41 +335,41 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n-\tnew_odb = xcalloc(1, sizeof(*new_odb));\n-\tnew_odb->path = xstrdup(dir);\n+\talternate = xcalloc(1, sizeof(*alternate));\n+\talternate->path = xstrdup(dir);\n \n \t/*\n \t * Disable ref updates while a temporary odb is active, since\n \t * the objects in the database may roll back.\n \t */\n-\tnew_odb->disable_ref_updates = 1;\n-\tnew_odb->will_destroy = will_destroy;\n-\tnew_odb->next = the_repository->objects->odb;\n-\tthe_repository->objects->odb = new_odb;\n-\treturn new_odb->next;\n+\talternate->disable_ref_updates = 1;\n+\talternate->will_destroy = will_destroy;\n+\talternate->next = the_repository->objects->alternates;\n+\tthe_repository->objects->alternates = alternate;\n+\treturn alternate->next;\n }\n \n-static void free_object_directory(struct object_directory *odb)\n+static void free_object_directory(struct odb_alternate *alternate)\n {\n-\tfree(odb->path);\n-\todb_clear_loose_cache(odb);\n-\tloose_object_map_clear(&odb->loose_map);\n-\tfree(odb);\n+\tfree(alternate->path);\n+\todb_clear_loose_cache(alternate);\n+\tloose_object_map_clear(&alternate->loose_map);\n+\tfree(alternate);\n }\n \n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path)\n+void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path)\n {\n-\tstruct object_directory *cur_odb = the_repository->objects->odb;\n+\tstruct odb_alternate *cur_alt = the_repository->objects->alternates;\n \n-\tif (strcmp(old_path, cur_odb->path))\n+\tif (strcmp(old_path, cur_alt->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n-\t\t    old_path, cur_odb->path);\n+\t\t    old_path, cur_alt->path);\n \n-\tif (cur_odb->next != restore_odb)\n+\tif (cur_alt->next != restore_alt)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->odb = restore_odb;\n-\tfree_object_directory(cur_odb);\n+\tthe_repository->objects->alternates = restore_alt;\n+\tfree_object_directory(cur_alt);\n }\n \n /*\n@@ -442,15 +442,15 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_alternate *find_odb(struct repository *r, const char *obj_dir)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tstrbuf_realpath(&odb_path_real, odb->path, 1);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tstrbuf_realpath(&odb_path_real, alternate->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\n \t}\n@@ -458,9 +458,9 @@ struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n \tfree(obj_dir_real);\n \tstrbuf_release(&odb_path_real);\n \n-\tif (!odb)\n+\tif (!alternate)\n \t\tdie(_(\"could not find object directory matching %s\"), obj_dir);\n-\treturn odb;\n+\treturn alternate;\n }\n \n static void fill_alternate_refs_command(struct child_process *cmd,\n@@ -527,14 +527,14 @@ struct alternate_refs_data {\n \tvoid *data;\n };\n \n-static int refs_from_alternate_cb(struct object_directory *e,\n+static int refs_from_alternate_cb(struct odb_alternate *alternate,\n \t\t\t\t  void *data)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n \tstruct alternate_refs_data *cb = data;\n \n-\tif (!strbuf_realpath(&path, e->path, 0))\n+\tif (!strbuf_realpath(&path, alternate->path, 0))\n \t\tgoto out;\n \tif (!strbuf_strip_suffix(&path, \"/objects\"))\n \t\tgoto out;\n@@ -563,12 +563,12 @@ void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n \n int foreach_alt_odb(alt_odb_fn fn, void *cb)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_alternate *alternate;\n \tint r = 0;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (ent = the_repository->objects->odb->next; ent; ent = ent->next) {\n-\t\tr = fn(ent, cb);\n+\tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n+\t\tr = fn(alternate, cb);\n \t\tif (r)\n \t\t\tbreak;\n \t}\n@@ -582,14 +582,14 @@ void prepare_alt_odb(struct repository *r)\n \n \tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->odb->path, 0);\n+\tread_info_alternates(r, r->objects->alternates->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n int has_alt_odb(struct repository *r)\n {\n \tprepare_alt_odb(r);\n-\treturn !!r->objects->odb->next;\n+\treturn !!r->objects->alternates->next;\n }\n \n int obj_read_use_lock = 0;\n@@ -972,15 +972,15 @@ struct object_database *odb_new(void)\n \n static void free_object_directories(struct object_database *o)\n {\n-\twhile (o->odb) {\n-\t\tstruct object_directory *next;\n+\twhile (o->alternates) {\n+\t\tstruct odb_alternate *next;\n \n-\t\tnext = o->odb->next;\n-\t\tfree_object_directory(o->odb);\n-\t\to->odb = next;\n+\t\tnext = o->alternates->next;\n+\t\tfree_object_directory(o->alternates);\n+\t\to->alternates = next;\n \t}\n-\tkh_destroy_odb_path_map(o->odb_by_path);\n-\to->odb_by_path = NULL;\n+\tkh_destroy_odb_path_map(o->alternate_by_path);\n+\to->alternate_by_path = NULL;\n }\n \n void odb_clear(struct object_database *o)\n@@ -996,7 +996,7 @@ void odb_clear(struct object_database *o)\n \to->commit_graph_attempted = 0;\n \n \tfree_object_directories(o);\n-\to->odb_tail = NULL;\n+\to->alternates_tail = NULL;\n \to->loaded_alternates = 0;\n \n \tfor (size_t i = 0; i < o->cached_object_nr; i++)\ndiff --git a/object-store.h b/object-store.h\nindex 34b8efbbb83..2dda6e85388 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -12,8 +12,11 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n-struct object_directory {\n-\tstruct object_directory *next;\n+/*\n+ * An alternate part of an object database that stores the actual objects.\n+ */\n+struct odb_alternate {\n+\tstruct odb_alternate *next;\n \n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n@@ -52,8 +55,8 @@ struct object_directory {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct object_directory *find_odb(struct repository *r, const char *obj_dir);\n-typedef int alt_odb_fn(struct object_directory *, void *);\n+struct odb_alternate *find_odb(struct repository *r, const char *obj_dir);\n+typedef int alt_odb_fn(struct odb_alternate *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n@@ -75,12 +78,12 @@ void add_to_alternates_memory(const char *dir);\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n  */\n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy);\n+struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy);\n \n /*\n  * Restore a previous ODB replaced by set_temporary_main_odb.\n  */\n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);\n+void restore_primary_odb(struct odb_alternate *restore_alternate, const char *old_path);\n \n struct packed_git;\n struct multi_pack_index;\n@@ -88,7 +91,7 @@ struct cached_object_entry;\n \n /*\n  * The object database encapsulates access to objects in a repository. It\n- * manages one or more backends that store the actual objects which are\n+ * manages one or more alternates that store the actual objects which are\n  * configured via alternates.\n  */\n struct object_database {\n@@ -97,16 +100,16 @@ struct object_database {\n \t * cannot be NULL after initialization). Subsequent directories are\n \t * alternates.\n \t */\n-\tstruct object_directory *odb;\n-\tstruct object_directory **odb_tail;\n-\tstruct kh_odb_path_map *odb_by_path;\n+\tstruct odb_alternate *alternates;\n+\tstruct odb_alternate **alternates_tail;\n+\tstruct kh_odb_path_map *alternate_by_path;\n \n \tint loaded_alternates;\n \n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"odb\" list when prepare_alt_odb() is run.\n+\t * populate the \"alternates\" list when prepare_alt_odb() is run.\n \t */\n \tchar *alternate_db;\n \ndiff --git a/packfile.c b/packfile.c\nindex 8f51665266d..e31e55f0c02 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1018,16 +1018,16 @@ static void prepare_packed_git_mru(struct repository *r)\n \n static void prepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tint local = (odb == r->objects->odb);\n-\t\tprepare_multi_pack_index_one(r, odb->path, local);\n-\t\tprepare_packed_git_one(r, odb->path, local);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tint local = (alternate == r->objects->alternates);\n+\t\tprepare_multi_pack_index_one(r, alternate->path, local);\n+\t\tprepare_packed_git_one(r, alternate->path, local);\n \t}\n \trearrange_packed_git(r);\n \n@@ -1037,7 +1037,7 @@ static void prepare_packed_git(struct repository *r)\n \n void reprepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tobj_read_lock();\n \n@@ -1050,8 +1050,8 @@ void reprepare_packed_git(struct repository *r)\n \tr->objects->loaded_alternates = 0;\n \tprepare_alt_odb(r);\n \n-\tfor (odb = r->objects->odb; odb; odb = odb->next)\n-\t\todb_clear_loose_cache(odb);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next)\n+\t\todb_clear_loose_cache(alternate);\n \n \tr->objects->approximate_object_count_valid = 0;\n \tr->objects->packed_git_initialized = 0;\ndiff --git a/path.c b/path.c\nindex 3b598b2847f..7be0e0214df 100644\n--- a/path.c\n+++ b/path.c\n@@ -397,7 +397,7 @@ static void adjust_git_path(struct repository *repo,\n \t\tstrbuf_splice(buf, 0, buf->len,\n \t\t\t      repo->index_file, strlen(repo->index_file));\n \telse if (dir_prefix(base, \"objects\"))\n-\t\treplace_dir(buf, git_dir_len + 7, repo->objects->odb->path);\n+\t\treplace_dir(buf, git_dir_len + 7, repo->objects->alternates->path);\n \telse if (repo_settings_get_hooks_path(repo) && dir_prefix(base, \"hooks\"))\n \t\treplace_dir(buf, git_dir_len + 5, repo_settings_get_hooks_path(repo));\n \telse if (repo->different_commondir)\ndiff --git a/refs.c b/refs.c\nindex dce5c49ca2b..27325d2f3c6 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -2477,7 +2477,7 @@ int ref_transaction_prepare(struct ref_transaction *transaction,\n \t\tbreak;\n \t}\n \n-\tif (refs->repo->objects->odb->disable_ref_updates) {\n+\tif (refs->repo->objects->alternates->disable_ref_updates) {\n \t\tstrbuf_addstr(err,\n \t\t\t      _(\"ref updates forbidden inside quarantine environment\"));\n \t\treturn -1;\ndiff --git a/repository.c b/repository.c\nindex 07757e6e0c9..dcc03fd9e0a 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -107,9 +107,9 @@ const char *repo_get_common_dir(struct repository *repo)\n \n const char *repo_get_object_directory(struct repository *repo)\n {\n-\tif (!repo->objects->odb)\n+\tif (!repo->objects->alternates)\n \t\tBUG(\"repository hasn't been set up\");\n-\treturn repo->objects->odb->path;\n+\treturn repo->objects->alternates->path;\n }\n \n const char *repo_get_index_file(struct repository *repo)\n@@ -165,14 +165,14 @@ void repo_set_gitdir(struct repository *repo,\n \n \trepo_set_commondir(repo, o->commondir);\n \n-\tif (!repo->objects->odb) {\n-\t\tCALLOC_ARRAY(repo->objects->odb, 1);\n-\t\trepo->objects->odb_tail = &repo->objects->odb->next;\n+\tif (!repo->objects->alternates) {\n+\t\tCALLOC_ARRAY(repo->objects->alternates, 1);\n+\t\trepo->objects->alternates_tail = &repo->objects->alternates->next;\n \t}\n-\texpand_base_dir(&repo->objects->odb->path, o->object_dir,\n+\texpand_base_dir(&repo->objects->alternates->path, o->object_dir,\n \t\t\trepo->commondir, \"objects\");\n \n-\trepo->objects->odb->disable_ref_updates = o->disable_ref_updates;\n+\trepo->objects->alternates->disable_ref_updates = o->disable_ref_updates;\n \n \tfree(repo->objects->alternate_db);\n \trepo->objects->alternate_db = xstrdup_or_null(o->alternate_db);\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 8630e27947d..0ee0a2884ef 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,7 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->odb->path);\n+\t\t\t\tadd_submodule_odb_by_path(repo->objects->alternates->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 8b413b644be..cd8ba0c54e7 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -73,15 +73,15 @@ static void dump_graph_bloom_filters(struct commit_graph *graph)\n int cmd__read_graph(int argc, const char **argv)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tint ret = 0;\n \n \tsetup_git_directory();\n-\todb = the_repository->objects->odb;\n+\talternate = the_repository->objects->alternates;\n \n \tprepare_repo_settings(the_repository);\n \n-\tgraph = read_commit_graph_one(the_repository, odb);\n+\tgraph = read_commit_graph_one(the_repository, alternate);\n \tif (!graph) {\n \t\tret = 1;\n \t\tgoto done;\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex c38fbeb5e8a..b8fe0fdd7d4 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -17,7 +17,7 @@ struct tmp_objdir {\n \tstruct repository *repo;\n \tstruct strbuf path;\n \tstruct strvec env;\n-\tstruct object_directory *prev_odb;\n+\tstruct odb_alternate *prev_alt;\n \tint will_destroy;\n };\n \n@@ -46,8 +46,8 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \tif (t == the_tmp_objdir)\n \t\tthe_tmp_objdir = NULL;\n \n-\tif (t->prev_odb)\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n+\tif (t->prev_alt)\n+\t\trestore_primary_odb(t->prev_alt, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -276,11 +276,11 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (!t)\n \t\treturn 0;\n \n-\tif (t->prev_odb) {\n-\t\tif (t->repo->objects->odb->will_destroy)\n+\tif (t->prev_alt) {\n+\t\tif (t->repo->objects->alternates->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n-\t\tt->prev_odb = NULL;\n+\t\trestore_primary_odb(t->prev_alt, t->path.buf);\n+\t\tt->prev_alt = NULL;\n \t}\n \n \tstrbuf_addbuf(&src, &t->path);\n@@ -309,19 +309,19 @@ void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n-\tif (t->prev_odb)\n+\tif (t->prev_alt)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_odb = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_alt = set_temporary_primary_odb(t->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n {\n-\tif (!the_tmp_objdir || !the_tmp_objdir->prev_odb)\n+\tif (!the_tmp_objdir || !the_tmp_objdir->prev_alt)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf);\n-\tthe_tmp_objdir->prev_odb = NULL;\n+\trestore_primary_odb(the_tmp_objdir->prev_alt, the_tmp_objdir->path.buf);\n+\tthe_tmp_objdir->prev_alt = NULL;\n \treturn the_tmp_objdir;\n }\n \n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517666","messageId":"20250509-pks-object-store-wo-the-repository-v2-4-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 04/17] odb: introduce parent pointers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:04Z","receivedAt":"2025-05-09T14:12:18Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In subsequent commits we'll get rid of our use of `the_repository` in\n\"odb.c\" in favor of explicitly passing in a `struct object_database` or\na `struct odb_alternate`. In some cases though we'll need access to the\nrepository, for example to read a config value from it, but we don't\nhave a way to access the repository owning a specific object database.\n\nIntroduce parent pointers for `struct object_database` to its owning\nrepository as well as for `struct odb_alternate` to its owning object\ndatabase, which will allow us to adapt those use cases.\n\nNote that this change requires us to pass through the object database to\n`link_alt_odb_entry()` so that we can set up the parent pointers for any\nalternate there. The callchain is adapted to pass through the object\ndatabase accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 45 ++++++++++++++++++++++++++-------------------\n odb.h        |  8 +++++++-\n repository.c |  3 ++-\n 3 files changed, 35 insertions(+), 21 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex 81281db7e0a..2b36735087e 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -135,11 +135,15 @@ static int alt_odb_usable(struct object_database *o,\n  * of the object ID, an extra slash for the first level indirection, and\n  * the terminating NUL.\n  */\n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth);\n-static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n-\tconst char *relative_base, int depth, const char *normalized_objdir)\n+\n+static int link_alt_odb_entry(struct object_database *odb,\n+\t\t\t      const struct strbuf *entry,\n+\t\t\t      const char *relative_base,\n+\t\t\t      int depth,\n+\t\t\t      const char *normalized_objdir)\n {\n \tstruct odb_alternate *alternate;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n@@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \twhile (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')\n \t\tstrbuf_setlen(&pathbuf, pathbuf.len - 1);\n \n-\tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n+\tif (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n \tCALLOC_ARRAY(alternate, 1);\n+\talternate->odb = odb;\n \t/* pathbuf.buf is already in r->objects->alternate_by_path */\n \talternate->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->alternates_tail = alternate;\n-\tr->objects->alternates_tail = &(alternate->next);\n+\t*odb->alternates_tail = alternate;\n+\todb->alternates_tail = &(alternate->next);\n \talternate->next = NULL;\n-\tassert(r->objects->alternate_by_path);\n-\tkh_value(r->objects->alternate_by_path, pos) = alternate;\n+\tassert(odb->alternate_by_path);\n+\tkh_value(odb->alternate_by_path, pos) = alternate;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, alternate->path, depth + 1);\n+\tread_info_alternates(odb, alternate->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -219,7 +224,7 @@ static const char *parse_alt_odb_entry(const char *string,\n \treturn end;\n }\n \n-static void link_alt_odb_entries(struct repository *r, const char *alt,\n+static void link_alt_odb_entries(struct object_database *odb, const char *alt,\n \t\t\t\t int sep, const char *relative_base, int depth)\n {\n \tstruct strbuf objdirbuf = STRBUF_INIT;\n@@ -234,20 +239,20 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->alternates->path, 1);\n+\tstrbuf_realpath(&objdirbuf, odb->alternates->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n \t\tif (!entry.len)\n \t\t\tcontinue;\n-\t\tlink_alt_odb_entry(r, &entry,\n+\t\tlink_alt_odb_entry(odb, &entry,\n \t\t\t\t   relative_base, depth, objdirbuf.buf);\n \t}\n \tstrbuf_release(&entry);\n \tstrbuf_release(&objdirbuf);\n }\n \n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth)\n {\n@@ -261,7 +266,7 @@ static void read_info_alternates(struct repository *r,\n \t\treturn;\n \t}\n \n-\tlink_alt_odb_entries(r, buf.buf, '\\n', relative_base, depth);\n+\tlink_alt_odb_entries(odb, buf.buf, '\\n', relative_base, depth);\n \tstrbuf_release(&buf);\n \tfree(path);\n }\n@@ -303,7 +308,7 @@ void add_to_alternates_file(const char *reference)\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n \t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository, reference,\n+\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n@@ -317,7 +322,7 @@ void add_to_alternates_memory(const char *reference)\n \t */\n \tprepare_alt_odb(the_repository);\n \n-\tlink_alt_odb_entries(the_repository, reference,\n+\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -336,6 +341,7 @@ struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n \t * alternate\n \t */\n \talternate = xcalloc(1, sizeof(*alternate));\n+\talternate->odb = the_repository->objects;\n \talternate->path = xstrdup(dir);\n \n \t/*\n@@ -580,9 +586,9 @@ void prepare_alt_odb(struct repository *r)\n \tif (r->objects->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->alternates->path, 0);\n+\tread_info_alternates(r->objects, r->objects->alternates->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n@@ -959,11 +965,12 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct object_database *odb_new(void)\n+struct object_database *odb_new(struct repository *repo)\n {\n \tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n+\to->repo = repo;\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\ndiff --git a/odb.h b/odb.h\nindex 465820a3d5c..745e38c1931 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -18,6 +18,9 @@ struct repository;\n struct odb_alternate {\n \tstruct odb_alternate *next;\n \n+\t/* Object database that owns this alternate. */\n+\tstruct object_database *odb;\n+\n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n \t * sacrificing accuracy due to races for speed. That includes\n@@ -95,6 +98,9 @@ struct cached_object_entry;\n  * configured via alternates.\n  */\n struct object_database {\n+\t/* Repository that owns this database. */\n+\tstruct repository *repo;\n+\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -176,7 +182,7 @@ struct object_database {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct object_database *odb_new(void);\n+struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n /*\ndiff --git a/repository.c b/repository.c\nindex dbc7fa8685f..36c508f7cb2 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = odb_new();\n+\trepo->objects = odb_new(repo);\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -167,6 +167,7 @@ void repo_set_gitdir(struct repository *repo,\n \n \tif (!repo->objects->alternates) {\n \t\tCALLOC_ARRAY(repo->objects->alternates, 1);\n+\t\trepo->objects->alternates->odb = repo->objects;\n \t\trepo->objects->alternates_tail = &repo->objects->alternates->next;\n \t}\n \texpand_base_dir(&repo->objects->alternates->path, o->object_dir,\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517669","messageId":"20250509-pks-object-store-wo-the-repository-v2-5-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:05Z","receivedAt":"2025-05-09T14:12:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `find_odb()` by passing\nin the object database in which we want to search for the alternate and\nadjusting all callers.\n\nRename the function to `odb_find_alternate()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c | 4 ++--\n midx-write.c           | 2 +-\n odb.c                  | 6 +++---\n odb.h                  | 7 ++++++-\n 4 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex ae8ac52a975..90c767797e2 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -101,7 +101,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\talternate = find_odb(the_repository, opts.obj_dir);\n+\talternate = odb_find_alternate(the_repository->objects, opts.obj_dir);\n \tgraph_name = get_commit_graph_filename(alternate);\n \tchain_name = get_commit_graph_chain_filename(alternate);\n \tif (open_commit_graph(graph_name, &fd, &st))\n@@ -289,7 +289,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\talternate = find_odb(the_repository, opts.obj_dir);\n+\talternate = odb_find_alternate(the_repository->objects, opts.obj_dir);\n \n \tif (opts.reachable) {\n \t\tif (write_commit_graph_reachable(alternate, flags, &write_opts))\ndiff --git a/midx-write.c b/midx-write.c\nindex dd3b3070e55..dd65800e8b3 100644\n--- a/midx-write.c\n+++ b/midx-write.c\n@@ -922,7 +922,7 @@ static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,\n \tstruct strbuf cur_path_real = STRBUF_INIT;\n \n \t/* Ensure the given object_dir is local, or a known alternate. */\n-\tfind_odb(r, obj_dir_real);\n+\todb_find_alternate(r->objects, obj_dir_real);\n \n \tfor (cur = get_multi_pack_index(r); cur; cur = cur->next) {\n \t\tstrbuf_realpath(&cur_path_real, cur->object_dir, 1);\ndiff --git a/odb.c b/odb.c\nindex 2b36735087e..621a16b35ea 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -448,14 +448,14 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct odb_alternate *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir)\n {\n \tstruct odb_alternate *alternate;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n-\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\tprepare_alt_odb(odb->repo);\n+\tfor (alternate = odb->alternates; alternate; alternate = alternate->next) {\n \t\tstrbuf_realpath(&odb_path_real, alternate->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\ndiff --git a/odb.h b/odb.h\nindex 745e38c1931..60d6358c2c6 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -58,7 +58,6 @@ struct odb_alternate {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct odb_alternate *find_odb(struct repository *r, const char *obj_dir);\n typedef int alt_odb_fn(struct odb_alternate *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n@@ -185,6 +184,12 @@ struct object_database {\n struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n+/*\n+ * Find backend by its object directory path. Dies in case the object directory\n+ * couldn't be found.\n+ */\n+struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n+\n /*\n  * Create a temporary file rooted in the object database directory, or\n  * die on failure. The filename is taken from \"pattern\", which should have the\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517670","messageId":"20250509-pks-object-store-wo-the-repository-v2-6-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 06/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:06Z","receivedAt":"2025-05-09T14:12:20Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `assert_oid_type()` by\npassing in the object database as a parameter and adjusting all callers.\n\nRename the function to `odb_assert_oid_type()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-tree.c | 2 +-\n commit.c              | 2 +-\n odb.c                 | 5 +++--\n odb.h                 | 3 ++-\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 546069f8682..31cfd9bd15d 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -48,7 +48,7 @@ static int parse_parent_arg_callback(const struct option *opt,\n \tif (repo_get_oid_commit(the_repository, arg, &oid))\n \t\tdie(_(\"not a valid object name %s\"), arg);\n \n-\tassert_oid_type(&oid, OBJ_COMMIT);\n+\todb_assert_oid_type(the_repository->objects, &oid, OBJ_COMMIT);\n \tnew_parent(lookup_commit(the_repository, &oid), parents);\n \treturn 0;\n }\ndiff --git a/commit.c b/commit.c\nindex 1d30f8ce15a..aa65183d8b6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1706,7 +1706,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,\n \t/* Not having i18n.commitencoding is the same as having utf-8 */\n \tencoding_is_utf8 = is_encoding_utf8(git_commit_encoding);\n \n-\tassert_oid_type(tree, OBJ_TREE);\n+\todb_assert_oid_type(the_repository->objects, tree, OBJ_TREE);\n \n \tif (memchr(msg, '\\0', msg_len))\n \t\treturn error(\"a NUL byte in commit log message not allowed.\");\ndiff --git a/odb.c b/odb.c\nindex 621a16b35ea..d09b8bf00cc 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -955,9 +955,10 @@ int has_object(struct repository *r, const struct object_id *oid,\n \treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n }\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect)\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex 60d6358c2c6..39d896ecd3f 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -295,7 +295,8 @@ enum {\n int has_object(struct repository *r, const struct object_id *oid,\n \t       unsigned flags);\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect);\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect);\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517671","messageId":"20250509-pks-object-store-wo-the-repository-v2-7-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 07/17] odb: get rid of `the_repository` in `odb_mkstemp()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:07Z","receivedAt":"2025-05-09T14:12:20Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `odb_mkstemp()` by\npassing in the object database as a parameter and adjusting all callers.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/fast-import.c |  3 ++-\n builtin/index-pack.c  |  2 +-\n bundle-uri.c          |  3 ++-\n odb.c                 |  9 +++++----\n odb.h                 |  7 ++++---\n pack-bitmap-write.c   |  3 ++-\n pack-write.c          | 10 ++++++----\n 7 files changed, 22 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 52c792488e1..413304db9b5 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -763,7 +763,8 @@ static void start_packfile(void)\n \tstruct packed_git *p;\n \tint pack_fd;\n \n-\tpack_fd = odb_mkstemp(&tmp_file, \"pack/tmp_pack_XXXXXX\");\n+\tpack_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n+\t\t\t      \"pack/tmp_pack_XXXXXX\");\n \tFLEX_ALLOC_STR(p, pack_name, tmp_file.buf);\n \tstrbuf_release(&tmp_file);\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 8ce446064e8..8e5acefde40 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -362,7 +362,7 @@ static const char *open_pack_file(const char *pack_name)\n \t\tinput_fd = 0;\n \t\tif (!pack_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\toutput_fd = odb_mkstemp(&tmp_file,\n+\t\t\toutput_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n \t\t\t\t\t\t\"pack/tmp_pack_XXXXXX\");\n \t\t\tpack_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 993ac62c271..87a5ba50945 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -278,7 +278,8 @@ static char *find_temp_filename(void)\n \t * Find a temporary filename that is available. This is briefly\n \t * racy, but unlikely to collide.\n \t */\n-\tfd = odb_mkstemp(&name, \"bundles/tmp_uri_XXXXXX\");\n+\tfd = odb_mkstemp(the_repository->objects, &name,\n+\t\t\t \"bundles/tmp_uri_XXXXXX\");\n \tif (fd < 0) {\n \t\twarning(_(\"failed to create temporary file\"));\n \t\treturn NULL;\ndiff --git a/odb.c b/odb.c\nindex d09b8bf00cc..7ff614fb0c7 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -63,7 +63,8 @@ static const struct cached_object *find_cached_object(struct object_database *ob\n \treturn NULL;\n }\n \n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern)\n {\n \tint fd;\n \t/*\n@@ -71,15 +72,15 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n \t * restrictive except to remove write permission.\n \t */\n \tint mode = 0444;\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n \tfd = git_mkstemp_mode(temp_filename->buf, mode);\n \tif (0 <= fd)\n \t\treturn fd;\n \n \t/* slow path */\n \t/* some mkstemp implementations erase temp_filename on failure */\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n-\tsafe_create_leading_directories(the_repository, temp_filename->buf);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n+\tsafe_create_leading_directories(odb->repo, temp_filename->buf);\n \treturn xmkstemp_mode(temp_filename->buf, mode);\n }\n \ndiff --git a/odb.h b/odb.h\nindex 39d896ecd3f..3430089803b 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -191,12 +191,13 @@ void odb_clear(struct object_database *o);\n struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n \n /*\n- * Create a temporary file rooted in the object database directory, or\n- * die on failure. The filename is taken from \"pattern\", which should have the\n+ * Create a temporary file rooted in the primary alternate's directory, or die\n+ * on failure. The filename is taken from \"pattern\", which should have the\n  * usual \"XXXXXX\" trailer, and the resulting filename is written into the\n  * \"template\" buffer. Returns the open descriptor.\n  */\n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern);\n \n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 37648b57125..c847369eaaa 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1052,7 +1052,8 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n \n \tstruct bitmap_disk_header header;\n \n-\tint fd = odb_mkstemp(&tmp_file, \"pack/tmp_bitmap_XXXXXX\");\n+\tint fd = odb_mkstemp(writer->repo->objects, &tmp_file,\n+\t\t\t     \"pack/tmp_bitmap_XXXXXX\");\n \n \tif (writer->pseudo_merges_nr)\n \t\toptions |= BITMAP_OPT_PSEUDO_MERGES;\ndiff --git a/pack-write.c b/pack-write.c\nindex 6b06315f80a..eccdc798e36 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -84,7 +84,8 @@ const char *write_idx_file(struct repository *repo,\n \t} else {\n \t\tif (!index_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_idx_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_idx_XXXXXX\");\n \t\t\tindex_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(index_name);\n@@ -259,7 +260,8 @@ char *write_rev_file_order(struct repository *repo,\n \tif (flags & WRITE_REV) {\n \t\tif (!rev_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_rev_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_rev_XXXXXX\");\n \t\t\tpath = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(rev_name);\n@@ -342,7 +344,7 @@ static char *write_mtimes_file(struct repository *repo,\n \tif (!to_pack)\n \t\tBUG(\"cannot call write_mtimes_file with NULL packing_data\");\n \n-\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n \tmtimes_name = strbuf_detach(&tmp_file, NULL);\n \tf = hashfd(repo->hash_algo, fd, mtimes_name);\n \n@@ -531,7 +533,7 @@ struct hashfile *create_tmp_packfile(struct repository *repo,\n \tstruct strbuf tmpname = STRBUF_INIT;\n \tint fd;\n \n-\tfd = odb_mkstemp(&tmpname, \"pack/tmp_pack_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmpname, \"pack/tmp_pack_XXXXXX\");\n \t*pack_tmp_name = strbuf_detach(&tmpname, NULL);\n \treturn hashfd(repo->hash_algo, fd, *pack_tmp_name);\n }\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517672","messageId":"20250509-pks-object-store-wo-the-repository-v2-8-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:08Z","receivedAt":"2025-05-09T14:12:21Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions to manage alternates all depend on `the_repository`.\nRefactor them to accept an object database as parameter and adjusting\nall callers. The functions are renamed accordingly.\n\nNote that right now the situation is still somewhat weird because we end\nup using the path provided by the object store's repository anyway. This\nwill be adapted over time though so that we instead store the path to\nthe primary object directory in the object database itself.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/clone.c           | 10 +++++----\n builtin/fsck.c            |  6 +++---\n builtin/grep.c            |  2 +-\n builtin/repack.c          |  3 ++-\n commit-graph.c            |  4 ++--\n loose.c                   |  2 +-\n object-file.c             | 10 ++++-----\n object-name.c             |  2 +-\n odb.c                     | 44 ++++++++++++++++++---------------------\n odb.h                     | 53 ++++++++++++++++++++++++++++++++---------------\n packfile.c                |  4 ++--\n submodule.c               |  3 ++-\n t/helper/test-ref-store.c |  2 +-\n tmp-objdir.c              |  2 +-\n 14 files changed, 83 insertions(+), 64 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 1eafeefb48d..3aabdf6570b 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -171,7 +171,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)\n \t} else {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstrbuf_addf(&sb, \"%s/objects\", ref_git);\n-\t\tadd_to_alternates_file(sb.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \t}\n \n@@ -212,12 +212,14 @@ static void copy_alternates(struct strbuf *src, const char *src_repo)\n \t\tif (!line.len || line.buf[0] == '#')\n \t\t\tcontinue;\n \t\tif (is_absolute_path(line.buf)) {\n-\t\t\tadd_to_alternates_file(line.buf);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   line.buf);\n \t\t\tcontinue;\n \t\t}\n \t\tabs_path = mkpathdup(\"%s/objects/%s\", src_repo, line.buf);\n \t\tif (!normalize_path_copy(abs_path, abs_path))\n-\t\t\tadd_to_alternates_file(abs_path);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   abs_path);\n \t\telse\n \t\t\twarning(\"skipping invalid relative alternate: %s/%s\",\n \t\t\t\tsrc_repo, line.buf);\n@@ -352,7 +354,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)\n \t\tstruct strbuf alt = STRBUF_INIT;\n \t\tget_common_dir(&alt, src_repo);\n \t\tstrbuf_addstr(&alt, \"/objects\");\n-\t\tadd_to_alternates_file(alt.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, alt.buf);\n \t\tstrbuf_release(&alt);\n \t} else {\n \t\tstruct strbuf src = STRBUF_INIT;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6a5181393a2..b961c2caa22 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -1006,7 +1006,7 @@ int cmd_fsck(int argc,\n \t\tfor_each_packed_object(the_repository,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next)\n \t\t\tfsck_object_dir(alternate->path);\n \n@@ -1117,7 +1117,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_commit_graph) {\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n@@ -1135,7 +1135,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_multi_pack_index) {\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3858df2a82e..b19fee20425 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -462,7 +462,7 @@ static int grep_submodule(struct grep_opt *opt,\n \n \t/*\n \t * NEEDSWORK: repo_read_gitmodules() might call\n-\t * add_to_alternates_memory() via config_from_gitmodules(). This\n+\t * odb_add_to_alternates_memory() via config_from_gitmodules(). This\n \t * operation causes a race condition with concurrent object readings\n \t * performed by the worker threads. That's why we need obj_read_lock()\n \t * here. It should be removed once it's no longer necessary to add the\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 16782320058..8145474cf8d 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -1256,7 +1256,8 @@ int cmd_repack(int argc,\n \tif (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)\n \t\tdie(_(incremental_bitmap_conflict_error));\n \n-\tif (write_bitmaps && po_args.local && has_alt_odb(the_repository)) {\n+\tif (write_bitmaps && po_args.local &&\n+\t    odb_has_alternates(the_repository->objects)) {\n \t\t/*\n \t\t * When asked to do a local repack, but we have\n \t\t * packfiles that are inherited from an alternate, then\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 4848198d7bf..cd34b71d270 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -649,7 +649,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tcount = st->st_size / (the_hash_algo->hexsz + 1);\n \tCALLOC_ARRAY(oids, count);\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (i = 0; i < count; i++) {\n \t\tstruct odb_alternate *alternate;\n@@ -778,7 +778,7 @@ static int prepare_commit_graph(struct repository *r)\n \tif (!commit_graph_compatible(r))\n \t\treturn 0;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates;\n \t     !r->objects->commit_graph && alternate;\n \t     alternate = alternate->next)\ndiff --git a/loose.c b/loose.c\nindex 9febd1f3e9a..9fbf2336822 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -112,7 +112,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tprepare_alt_odb(repo);\n+\todb_prepare_alternates(repo->objects);\n \n \tfor (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n \t\tif (load_one_loose_object_map(repo, alternate) < 0) {\ndiff --git a/object-file.c b/object-file.c\nindex dabc238447a..9e8649135ce 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -106,7 +106,7 @@ static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n \tstruct odb_alternate *alternate;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n \t\tif (check_and_freshen_odb(alternate, oid, freshen))\n \t\t\treturn 1;\n@@ -211,7 +211,7 @@ static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \tstruct odb_alternate *alternate;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n \t\t*path = odb_loose_path(alternate, &buf, oid);\n \t\tif (!lstat(*path, st))\n@@ -233,7 +233,7 @@ static int open_loose_object(struct repository *r,\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n \t\t*path = odb_loose_path(alternate, &buf, oid);\n \t\tfd = git_open(*path);\n@@ -252,7 +252,7 @@ static int quick_has_loose(struct repository *r,\n {\n \tstruct odb_alternate *alternate;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n \t\tif (oidtree_contains(odb_loose_cache(alternate, oid), oid))\n \t\t\treturn 1;\n@@ -1542,7 +1542,7 @@ int for_each_loose_object(each_loose_object_fn cb, void *data,\n {\n \tstruct odb_alternate *alternate;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\tint r = for_each_loose_file_in_objdir(alternate->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\ndiff --git a/object-name.c b/object-name.c\nindex b83ba882b9e..2b757eb7948 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -376,7 +376,7 @@ static int init_object_disambiguation(struct repository *r,\n \tds->hex_pfx[len] = '\\0';\n \tds->repo = r;\n \tds->bin_pfx.algo = algo ? hash_algo_by_ptr(algo) : GIT_HASH_UNKNOWN;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \treturn 0;\n }\n \ndiff --git a/odb.c b/odb.c\nindex 7ff614fb0c7..bd601471cd7 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -272,10 +272,11 @@ static void read_info_alternates(struct object_database *odb,\n \tfree(path);\n }\n \n-void add_to_alternates_file(const char *reference)\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *reference)\n {\n \tstruct lock_file lock = LOCK_INIT;\n-\tchar *alts = repo_git_path(the_repository, \"objects/info/alternates\");\n+\tchar *alts = repo_git_path(odb->repo, \"objects/info/alternates\");\n \tFILE *in, *out;\n \tint found = 0;\n \n@@ -308,22 +309,23 @@ void add_to_alternates_file(const char *reference)\n \t\tfprintf_or_die(out, \"%s\\n\", reference);\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n-\t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n+\t\tif (odb->loaded_alternates)\n+\t\t\tlink_alt_odb_entries(odb, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n }\n \n-void add_to_alternates_memory(const char *reference)\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *reference)\n {\n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(odb);\n \n-\tlink_alt_odb_entries(the_repository->objects, reference,\n+\tlink_alt_odb_entries(odb, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -335,7 +337,7 @@ struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n@@ -379,12 +381,6 @@ void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path\n \tfree_object_directory(cur_alt);\n }\n \n-/*\n- * Compute the exact path an alternate is at and returns it. In case of\n- * error NULL is returned and the human readable error is added to `err`\n- * `path` may be relative and should point to $GIT_DIR.\n- * `err` must not be null.\n- */\n char *compute_alternate_path(const char *path, struct strbuf *err)\n {\n \tchar *ref_git = NULL;\n@@ -455,7 +451,7 @@ struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(odb->repo);\n+\todb_prepare_alternates(odb);\n \tfor (alternate = odb->alternates; alternate; alternate = alternate->next) {\n \t\tstrbuf_realpath(&odb_path_real, alternate->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n@@ -573,7 +569,7 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \tstruct odb_alternate *alternate;\n \tint r = 0;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n \t\tr = fn(alternate, cb);\n \t\tif (r)\n@@ -582,21 +578,21 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \treturn r;\n }\n \n-void prepare_alt_odb(struct repository *r)\n+void odb_prepare_alternates(struct object_database *odb)\n {\n-\tif (r->objects->loaded_alternates)\n+\tif (odb->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(odb, odb->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r->objects, r->objects->alternates->path, 0);\n-\tr->objects->loaded_alternates = 1;\n+\tread_info_alternates(odb, odb->alternates->path, 0);\n+\todb->loaded_alternates = 1;\n }\n \n-int has_alt_odb(struct repository *r)\n+int odb_has_alternates(struct object_database *odb)\n {\n-\tprepare_alt_odb(r);\n-\treturn !!r->objects->alternates->next;\n+\todb_prepare_alternates(odb);\n+\treturn !!odb->alternates->next;\n }\n \n int obj_read_use_lock = 0;\ndiff --git a/odb.h b/odb.h\nindex 3430089803b..443af1b6154 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -12,6 +12,14 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n+/*\n+ * Compute the exact path an alternate is at and returns it. In case of\n+ * error NULL is returned and the human readable error is added to `err`\n+ * `path` may be relative and should point to $GIT_DIR.\n+ * `err` must not be null.\n+ */\n+char *compute_alternate_path(const char *path, struct strbuf *err);\n+\n /*\n  * An alternate part of an object database that stores the actual objects.\n  */\n@@ -55,27 +63,11 @@ struct odb_alternate {\n \tchar *path;\n };\n \n-void prepare_alt_odb(struct repository *r);\n-int has_alt_odb(struct repository *r);\n-char *compute_alternate_path(const char *path, struct strbuf *err);\n typedef int alt_odb_fn(struct odb_alternate *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n \n-/*\n- * Add the directory to the on-disk alternates file; the new entry will also\n- * take effect in the current process.\n- */\n-void add_to_alternates_file(const char *dir);\n-\n-/*\n- * Add the directory to the in-memory list of alternates (along with any\n- * recursive alternates it points to), but do not modify the on-disk alternates\n- * file.\n- */\n-void add_to_alternates_memory(const char *dir);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -114,7 +106,7 @@ struct object_database {\n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"alternates\" list when prepare_alt_odb() is run.\n+\t * populate the \"alternates\" list when odb_prepare_alternates() is run.\n \t */\n \tchar *alternate_db;\n \n@@ -199,6 +191,33 @@ struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n int odb_mkstemp(struct object_database *odb,\n \t\tstruct strbuf *temp_filename, const char *pattern);\n \n+/*\n+ * Prepare alternate object backends for the given database by reading\n+ * \"objects/info/alternates\" and opening the respective alternates.\n+ */\n+void odb_prepare_alternates(struct object_database *odb);\n+\n+/*\n+ * Check whether the object database has any alternates. The primary object\n+ * backend does not count as alternate.\n+ */\n+int odb_has_alternates(struct object_database *odb);\n+\n+/*\n+ * Add the directory to the on-disk alternates file; the new entry will also\n+ * take effect in the current process.\n+ */\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *dir);\n+\n+/*\n+ * Add the directory to the in-memory list of alternates (along with any\n+ * recursive alternates it points to), but do not modify the on-disk alternates\n+ * file.\n+ */\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *dir);\n+\n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\n \t\t\t    enum object_type *type,\ndiff --git a/packfile.c b/packfile.c\nindex 8133948b58f..ab9628eb3d4 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1023,7 +1023,7 @@ static void prepare_packed_git(struct repository *r)\n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n \t\tint local = (alternate == r->objects->alternates);\n \t\tprepare_multi_pack_index_one(r, alternate->path, local);\n@@ -1048,7 +1048,7 @@ void reprepare_packed_git(struct repository *r)\n \t * the lifetime of the process.\n \t */\n \tr->objects->loaded_alternates = 0;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next)\n \t\todb_clear_loose_cache(alternate);\ndiff --git a/submodule.c b/submodule.c\nindex 9b1018877df..386be234230 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -189,7 +189,8 @@ int register_all_submodule_odb_as_alternates(void)\n \tint ret = added_submodule_odb_paths.nr;\n \n \tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\tadd_to_alternates_memory(added_submodule_odb_paths.items[i].string);\n+\t\todb_add_to_alternates_memory(the_repository->objects,\n+\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n \tif (ret) {\n \t\tstring_list_clear(&added_submodule_odb_paths, 0);\n \t\ttrace2_data_intmax(\"submodule\", the_repository,\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 2920ca59d72..8d9a271845c 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -79,7 +79,7 @@ static const char **get_store(const char **argv, struct ref_store **refs)\n \t\tif (!repo_submodule_path_append(the_repository,\n \t\t\t\t\t\t&sb, gitdir, \"objects/\"))\n \t\t\tdie(\"computing submodule path failed\");\n-\t\tadd_to_alternates_memory(sb.buf);\n+\t\todb_add_to_alternates_memory(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \n \t\t*refs = repo_get_submodule_ref_store(the_repository, gitdir);\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex 9e05fcbddd0..cbb50438d16 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -304,7 +304,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)\n \n void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n {\n-\tadd_to_alternates_memory(t->path.buf);\n+\todb_add_to_alternates_memory(t->repo->objects, t->path.buf);\n }\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517673","messageId":"20250509-pks-object-store-wo-the-repository-v2-9-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:09Z","receivedAt":"2025-05-09T14:12:22Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"There are a couple of iterator-style functions that execute a callback\nfor each instance of a given set, all of which currently depend on\n`the_repository`. Refactor them to instead take an object database as\nparameter so that we can get rid of this dependency.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/count-objects.c     |  2 +-\n builtin/receive-pack.c      |  3 ++-\n builtin/submodule--helper.c |  3 ++-\n diagnose.c                  |  2 +-\n fetch-pack.c                |  3 ++-\n odb.c                       | 36 +++++++++++++++++++-----------------\n odb.h                       | 23 ++++++++++++++++++-----\n revision.c                  |  3 ++-\n 8 files changed, 47 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex da830fcee57..2752a9b02f4 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -159,7 +159,7 @@ int cmd_count_objects(int argc,\n \t\tprintf(\"prune-packable: %lu\\n\", packed_loose);\n \t\tprintf(\"garbage: %lu\\n\", garbage);\n \t\tprintf(\"size-garbage: %s\\n\", garbage_buf.buf);\n-\t\tforeach_alt_odb(print_alternate, NULL);\n+\t\todb_for_each_alternate(the_repository->objects, print_alternate, NULL);\n \t\tstrbuf_release(&loose_buf);\n \t\tstrbuf_release(&pack_buf);\n \t\tstrbuf_release(&garbage_buf);\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex cb5fd55a8e4..8c157ea7d1b 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -358,7 +358,8 @@ static void write_head_info(void)\n \n \trefs_for_each_fullref_in(get_main_ref_store(the_repository), \"\",\n \t\t\t\t exclude_patterns, show_ref_cb, &seen);\n-\tfor_each_alternate_ref(show_one_alternate_ref, &seen);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   show_one_alternate_ref, &seen);\n \n \toidset_clear(&seen);\n \tstrvec_clear(&excludes_vector);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex a6c936fb2bd..88bbd97820a 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1668,7 +1668,8 @@ static void prepare_possible_alternates(const char *sm_name,\n \t\tdie(_(\"Value '%s' for submodule.alternateErrorStrategy is not recognized\"), error_strategy);\n \n \tif (!strcmp(sm_alternate, \"superproject\"))\n-\t\tforeach_alt_odb(add_possible_reference_from_superproject, &sas);\n+\t\todb_for_each_alternate(the_repository->objects,\n+\t\t\t\t       add_possible_reference_from_superproject, &sas);\n \telse if (!strcmp(sm_alternate, \"no\"))\n \t\t; /* do nothing */\n \telse\ndiff --git a/diagnose.c b/diagnose.c\nindex d407c98d094..0405368f178 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -229,7 +229,7 @@ int create_diagnostics_archive(struct repository *r,\n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n \tdir_file_stats(r->objects->alternates, &buf);\n-\tforeach_alt_odb(dir_file_stats, &buf);\n+\todb_for_each_alternate(r->objects, dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \n \tstrbuf_reset(&buf);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex cf157f5d7e5..47fa7fa4c49 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -115,7 +115,8 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,\n \tsize_t i;\n \n \tif (!initialized) {\n-\t\tfor_each_alternate_ref(cache_one_alternate, &cache);\n+\t\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t\t   cache_one_alternate, &cache);\n \t\tinitialized = 1;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex bd601471cd7..feca14d9683 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -494,8 +494,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n }\n \n static void read_alternate_refs(const char *path,\n-\t\t\t\talternate_ref_fn *cb,\n-\t\t\t\tvoid *data)\n+\t\t\t\todb_for_each_alternate_ref_fn *cb,\n+\t\t\t\tvoid *payload)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tstruct strbuf line = STRBUF_INIT;\n@@ -517,7 +517,7 @@ static void read_alternate_refs(const char *path,\n \t\t\tbreak;\n \t\t}\n \n-\t\tcb(&oid, data);\n+\t\tcb(&oid, payload);\n \t}\n \n \tfclose(fh);\n@@ -526,16 +526,16 @@ static void read_alternate_refs(const char *path,\n }\n \n struct alternate_refs_data {\n-\talternate_ref_fn *fn;\n-\tvoid *data;\n+\todb_for_each_alternate_ref_fn *fn;\n+\tvoid *payload;\n };\n \n static int refs_from_alternate_cb(struct odb_alternate *alternate,\n-\t\t\t\t  void *data)\n+\t\t\t\t  void *payload)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n-\tstruct alternate_refs_data *cb = data;\n+\tstruct alternate_refs_data *cb = payload;\n \n \tif (!strbuf_realpath(&path, alternate->path, 0))\n \t\tgoto out;\n@@ -549,29 +549,31 @@ static int refs_from_alternate_cb(struct odb_alternate *alternate,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->data);\n+\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n \treturn 0;\n }\n \n-void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload)\n {\n-\tstruct alternate_refs_data cb;\n-\tcb.fn = fn;\n-\tcb.data = data;\n-\tforeach_alt_odb(refs_from_alternate_cb, &cb);\n+\tstruct alternate_refs_data data;\n+\tdata.fn = cb;\n+\tdata.payload = payload;\n+\todb_for_each_alternate(odb, refs_from_alternate_cb, &data);\n }\n \n-int foreach_alt_odb(alt_odb_fn fn, void *cb)\n+int odb_for_each_alternate(struct object_database *odb,\n+\t\t\t odb_for_each_alternate_fn cb, void *payload)\n {\n \tstruct odb_alternate *alternate;\n \tint r = 0;\n \n-\todb_prepare_alternates(the_repository->objects);\n-\tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n-\t\tr = fn(alternate, cb);\n+\todb_prepare_alternates(odb);\n+\tfor (alternate = odb->alternates->next; alternate; alternate = alternate->next) {\n+\t\tr = cb(alternate, payload);\n \t\tif (r)\n \t\t\tbreak;\n \t}\ndiff --git a/odb.h b/odb.h\nindex 443af1b6154..03ac369bca9 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -63,11 +63,6 @@ struct odb_alternate {\n \tchar *path;\n };\n \n-typedef int alt_odb_fn(struct odb_alternate *, void *);\n-int foreach_alt_odb(alt_odb_fn, void*);\n-typedef void alternate_ref_fn(const struct object_id *oid, void *);\n-void for_each_alternate_ref(alternate_ref_fn, void *);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -182,6 +177,24 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Iterate through all alternates of the database and execute the provided\n+ * callback function for each of them. Stop iterating once the callback\n+ * function returns a non-zero value, in which case the value is bubbled up\n+ * from the callback.\n+ */\n+typedef int odb_for_each_alternate_fn(struct odb_alternate *, void *);\n+int odb_for_each_alternate(struct object_database *odb,\n+\t\t\t   odb_for_each_alternate_fn cb, void *payload);\n+\n+/*\n+ * Iterate through all alternates of the database and yield their respective\n+ * references.\n+ */\n+typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n+\n /*\n  * Create a temporary file rooted in the primary alternate's directory, or die\n  * on failure. The filename is taken from \"pattern\", which should have the\ndiff --git a/revision.c b/revision.c\nindex cdefe7d6e48..b0364f556ee 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1907,7 +1907,8 @@ static void add_alternate_refs_to_pending(struct rev_info *revs,\n \tstruct add_alternate_refs_data data;\n \tdata.revs = revs;\n \tdata.flags = flags;\n-\tfor_each_alternate_ref(add_one_alternate_ref, &data);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   add_one_alternate_ref, &data);\n }\n \n static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517674","messageId":"20250509-pks-object-store-wo-the-repository-v2-10-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 10/17] odb: get rid of `the_repository` when handling the primary alternate","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:10Z","receivedAt":"2025-05-09T14:12:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions `set_temporary_primary_odb()` and `restore_primary_odb()`\nare responsible for managing a temporary primary alternate for the\ndatabase. Both of these functions implicitly rely on `the_repository`.\n\nRefactor them to instead take an explicit object database parameter as\nargument and adjust callers. Rename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 19 +++++++++++--------\n odb.h        | 25 ++++++++++++++-----------\n tmp-objdir.c | 10 ++++++----\n 3 files changed, 31 insertions(+), 23 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex feca14d9683..100dd39cbe8 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -329,7 +329,8 @@ void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_alternate *odb_set_temporary_primary_alternate(struct object_database *odb,\n+\t\t\t\t\t\t\t  const char *dir, int will_destroy)\n {\n \tstruct odb_alternate *alternate;\n \n@@ -337,14 +338,14 @@ struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\todb_prepare_alternates(the_repository->objects);\n+\todb_prepare_alternates(odb);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n \talternate = xcalloc(1, sizeof(*alternate));\n-\talternate->odb = the_repository->objects;\n+\talternate->odb = odb;\n \talternate->path = xstrdup(dir);\n \n \t/*\n@@ -353,8 +354,8 @@ struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n \t */\n \talternate->disable_ref_updates = 1;\n \talternate->will_destroy = will_destroy;\n-\talternate->next = the_repository->objects->alternates;\n-\tthe_repository->objects->alternates = alternate;\n+\talternate->next = odb->alternates;\n+\todb->alternates = alternate;\n \treturn alternate->next;\n }\n \n@@ -366,9 +367,11 @@ static void free_object_directory(struct odb_alternate *alternate)\n \tfree(alternate);\n }\n \n-void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path)\n+void odb_restore_primary_alternate(struct object_database *odb,\n+\t\t\t\t   struct odb_alternate *restore_alt,\n+\t\t\t\t   const char *old_path)\n {\n-\tstruct odb_alternate *cur_alt = the_repository->objects->alternates;\n+\tstruct odb_alternate *cur_alt = odb->alternates;\n \n \tif (strcmp(old_path, cur_alt->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n@@ -377,7 +380,7 @@ void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path\n \tif (cur_alt->next != restore_alt)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->alternates = restore_alt;\n+\todb->alternates = restore_alt;\n \tfree_object_directory(cur_alt);\n }\n \ndiff --git a/odb.h b/odb.h\nindex 03ac369bca9..f61b391764f 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -63,17 +63,6 @@ struct odb_alternate {\n \tchar *path;\n };\n \n-/*\n- * Replace the current writable object directory with the specified temporary\n- * object directory; returns the former primary object directory.\n- */\n-struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy);\n-\n-/*\n- * Restore a previous ODB replaced by set_temporary_main_odb.\n- */\n-void restore_primary_odb(struct odb_alternate *restore_alternate, const char *old_path);\n-\n struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n@@ -177,6 +166,20 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Replace the current writable object directory with the specified temporary\n+ * object directory; returns the former primary alternate.\n+ */\n+struct odb_alternate *odb_set_temporary_primary_alternate(struct object_database *odb,\n+\t\t\t\t\t\t\t  const char *dir, int will_destroy);\n+\n+/*\n+ * Restore a previous bakcend replaced by `odb_set_temporary_primary_alternate()`.\n+ */\n+void odb_restore_primary_alternate(struct object_database *odb,\n+\t\t\t\t   struct odb_alternate *restore_alt,\n+\t\t\t\t   const char *old_path);\n+\n /*\n  * Iterate through all alternates of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex cbb50438d16..c2e58c4be5c 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -47,7 +47,7 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \t\tthe_tmp_objdir = NULL;\n \n \tif (t->prev_alt)\n-\t\trestore_primary_odb(t->prev_alt, t->path.buf);\n+\t\todb_restore_primary_alternate(t->repo->objects, t->prev_alt, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -279,7 +279,7 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (t->prev_alt) {\n \t\tif (t->repo->objects->alternates->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_alt, t->path.buf);\n+\t\todb_restore_primary_alternate(t->repo->objects, t->prev_alt, t->path.buf);\n \t\tt->prev_alt = NULL;\n \t}\n \n@@ -311,7 +311,8 @@ void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n \tif (t->prev_alt)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_alt = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_alt = odb_set_temporary_primary_alternate(t->repo->objects,\n+\t\t\t\t\t\t\t  t->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n@@ -320,7 +321,8 @@ struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n \tif (!the_tmp_objdir || !the_tmp_objdir->prev_alt)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_alt, the_tmp_objdir->path.buf);\n+\todb_restore_primary_alternate(the_tmp_objdir->repo->objects,\n+\t\t\t\t      the_tmp_objdir->prev_alt, the_tmp_objdir->path.buf);\n \tthe_tmp_objdir->prev_alt = NULL;\n \treturn the_tmp_objdir;\n }\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517675","messageId":"20250509-pks-object-store-wo-the-repository-v2-11-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 11/17] odb: get rid of `the_repository` when handling submodule alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:11Z","receivedAt":"2025-05-09T14:12:25Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"--recursive\" flag for git-grep(1) allows users to grep for a string\nacross submodule boundaries. To make this work we add each submodule's\nobject alternate to our own object database so that the objects can be\naccessed directly.\n\nThe infrastructure for this depends on a global string list of submodule\npaths. The caller is expected to call `add_submodule_odb_by_path()` for\neach alternate and the object database will then eventually register all\nsubmodule alternates via `do_oid_object_info_extended()` in case it\nisn't able to look up a specific object.\n\nThis reliance on global state is of course suboptimal with regards to\nour libification efforts.\n\nRefactor the logic so that the list of submodule alternates is instead\ntracked in the object database itself. This allows us to lose the\ncondition of `r == the_repository` before registering submodule\nalternates as we only ever add submodule alternates to `the_repository`\nanyway. As such, behaviour before and after this refactoring should\nalways be the same.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/grep.c     |  3 ++-\n odb.c              | 37 +++++++++++++++++++++++++++++++------\n odb.h              | 15 +++++++++++++++\n submodule-config.c |  3 ++-\n submodule.c        | 26 --------------------------\n submodule.h        |  9 ---------\n 6 files changed, 50 insertions(+), 43 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex b19fee20425..277bc121e4e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,8 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->alternates->path);\n+\todb_add_submodule_alternate_by_path(the_repository->objects,\n+\t\t\t\t\t    subrepo->objects->alternates->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/odb.c b/odb.c\nindex 100dd39cbe8..72ff1ab5a7d 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -24,6 +24,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"submodule.h\"\n+#include \"trace2.h\"\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n@@ -469,6 +470,12 @@ struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n \treturn alternate;\n }\n \n+void odb_add_submodule_alternate_by_path(struct object_database *odb,\n+\t\t\t\t\t const char *path)\n+{\n+\tstring_list_insert(&odb->submodule_alternate_paths, path);\n+}\n+\n static void fill_alternate_refs_command(struct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n@@ -623,6 +630,23 @@ void disable_obj_read_lock(void)\n \n int fetch_if_missing = 1;\n \n+static int register_all_submodule_alternates(struct object_database *odb)\n+{\n+\tint ret = odb->submodule_alternate_paths.nr;\n+\n+\tfor (size_t i = 0; i < odb->submodule_alternate_paths.nr; i++)\n+\t\todb_add_to_alternates_memory(odb,\n+\t\t\t\t\t     odb->submodule_alternate_paths.items[i].string);\n+\tif (ret) {\n+\t\tstring_list_clear(&odb->submodule_alternate_paths, 0);\n+\t\ttrace2_data_intmax(\"submodule\", odb->repo,\n+\t\t\t\t   \"register_all_submodule_alternates/registered\", ret);\n+\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n+\t\t\tBUG(\"register_all_submodule_alternates() called\");\n+\t}\n+\treturn ret;\n+}\n+\n static int do_oid_object_info_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n@@ -678,13 +702,12 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t}\n \n \t\t/*\n-\t\t * If r is the_repository, this might be an attempt at\n-\t\t * accessing a submodule object as if it were in the_repository\n-\t\t * (having called add_submodule_odb() on that submodule's ODB).\n-\t\t * If any such ODBs exist, register them and try again.\n+\t\t * This might be an attempt at accessing a submodule object as\n+\t\t * if it were in main object store (having called\n+\t\t * `odb_add_submodule_alternate_by_path()` on that submodule's\n+\t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (r == the_repository &&\n-\t\t    register_all_submodule_odb_as_alternates())\n+\t\tif (register_all_submodule_alternates(r->objects))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n@@ -977,6 +1000,7 @@ struct object_database *odb_new(struct repository *repo)\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n+\tstring_list_init_dup(&o->submodule_alternate_paths);\n \treturn o;\n }\n \n@@ -1027,4 +1051,5 @@ void odb_clear(struct object_database *o)\n \to->packed_git = NULL;\n \n \thashmap_clear(&o->pack_map);\n+\tstring_list_clear(&o->submodule_alternate_paths, 0);\n }\ndiff --git a/odb.h b/odb.h\nindex f61b391764f..ef8a8a544b2 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -5,6 +5,7 @@\n #include \"object.h\"\n #include \"list.h\"\n #include \"oidset.h\"\n+#include \"string-list.h\"\n #include \"thread-utils.h\"\n \n struct oidmap;\n@@ -155,6 +156,12 @@ struct object_database {\n \t * packs.\n \t */\n \tunsigned packed_git_initialized : 1;\n+\n+\t/*\n+\t * Submodule alternate paths that will be added as alternatives to\n+\t * allow lookup of submodule objects via the main object database.\n+\t */\n+\tstruct string_list submodule_alternate_paths;\n };\n \n struct object_database *odb_new(struct repository *repo);\n@@ -180,6 +187,14 @@ void odb_restore_primary_alternate(struct object_database *odb,\n \t\t\t\t   struct odb_alternate *restore_alt,\n \t\t\t\t   const char *old_path);\n \n+/*\n+ * Call odb_add_submodule_alternate_by_path() to add the submodule at the given\n+ * path to a list. The object stores of all submodules in that list will be\n+ * added as alternates in the object store when looking up objects.\n+ */\n+void odb_add_submodule_alternate_by_path(struct object_database *odb,\n+\t\t\t\t\t  const char *path);\n+\n /*\n  * Iterate through all alternates of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 09034a587f1..0f775f93259 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,8 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->alternates->path);\n+\t\t\t\todb_add_submodule_alternate_by_path(the_repository->objects,\n+\t\t\t\t\t\t\t\t    repo->objects->alternates->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/submodule.c b/submodule.c\nindex 386be234230..788c9e55ed3 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -31,7 +31,6 @@\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\n-#include \"trace2.h\"\n \n static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;\n static int initialized_fetch_ref_tips;\n@@ -176,31 +175,6 @@ void stage_updated_gitmodules(struct index_state *istate)\n \t\tdie(_(\"staging updated .gitmodules failed\"));\n }\n \n-static struct string_list added_submodule_odb_paths = STRING_LIST_INIT_DUP;\n-\n-void add_submodule_odb_by_path(const char *path)\n-{\n-\tstring_list_insert(&added_submodule_odb_paths, path);\n-}\n-\n-int register_all_submodule_odb_as_alternates(void)\n-{\n-\tint i;\n-\tint ret = added_submodule_odb_paths.nr;\n-\n-\tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\todb_add_to_alternates_memory(the_repository->objects,\n-\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n-\tif (ret) {\n-\t\tstring_list_clear(&added_submodule_odb_paths, 0);\n-\t\ttrace2_data_intmax(\"submodule\", the_repository,\n-\t\t\t\t   \"register_all_submodule_odb_as_alternates/registered\", ret);\n-\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n-\t\t\tBUG(\"register_all_submodule_odb_as_alternates() called\");\n-\t}\n-\treturn ret;\n-}\n-\n void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\t\t\t\t     const char *path)\n {\ndiff --git a/submodule.h b/submodule.h\nindex db980c1d083..b10e16e6c06 100644\n--- a/submodule.h\n+++ b/submodule.h\n@@ -104,15 +104,6 @@ int submodule_uses_gitfile(const char *path);\n #define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)\n int bad_to_remove_submodule(const char *path, unsigned flags);\n \n-/*\n- * Call add_submodule_odb_by_path() to add the submodule at the given\n- * path to a list. When register_all_submodule_odb_as_alternates() is\n- * called, the object stores of all submodules in that list will be\n- * added as alternates in the_repository.\n- */\n-void add_submodule_odb_by_path(const char *path);\n-int register_all_submodule_odb_as_alternates(void);\n-\n /*\n  * Checks if there are submodule changes in a..b. If a is the null OID,\n  * checks b and all its ancestors instead.\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517676","messageId":"20250509-pks-object-store-wo-the-repository-v2-12-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:12Z","receivedAt":"2025-05-09T14:12:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"All of the external functions provided by the object database subsystem\ndon't depend on `the_repository` anymore, but some internal functions\nstill do. Refactor those cases by plumbing through the repository that\nowns the object database.\n\nThis change allows us to get rid of the `USE_THE_REPOSITORY_VARIABLE`\npreprocessor define.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex 72ff1ab5a7d..c150c01db4a 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"commit-graph.h\"\n@@ -476,12 +474,13 @@ void odb_add_submodule_alternate_by_path(struct object_database *odb,\n \tstring_list_insert(&odb->submodule_alternate_paths, path);\n }\n \n-static void fill_alternate_refs_command(struct child_process *cmd,\n+static void fill_alternate_refs_command(struct repository *repo,\n+\t\t\t\t\tstruct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n \tconst char *value;\n \n-\tif (!git_config_get_value(\"core.alternateRefsCommand\", &value)) {\n+\tif (!repo_config_get_value(repo, \"core.alternateRefsCommand\", &value)) {\n \t\tcmd->use_shell = 1;\n \n \t\tstrvec_push(&cmd->args, value);\n@@ -493,7 +492,7 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \t\tstrvec_push(&cmd->args, \"for-each-ref\");\n \t\tstrvec_push(&cmd->args, \"--format=%(objectname)\");\n \n-\t\tif (!git_config_get_value(\"core.alternateRefsPrefixes\", &value)) {\n+\t\tif (!repo_config_get_value(repo, \"core.alternateRefsPrefixes\", &value)) {\n \t\t\tstrvec_push(&cmd->args, \"--\");\n \t\t\tstrvec_split(&cmd->args, value);\n \t\t}\n@@ -503,7 +502,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \tcmd->out = -1;\n }\n \n-static void read_alternate_refs(const char *path,\n+static void read_alternate_refs(struct repository *repo,\n+\t\t\t\tconst char *path,\n \t\t\t\todb_for_each_alternate_ref_fn *cb,\n \t\t\t\tvoid *payload)\n {\n@@ -511,7 +511,7 @@ static void read_alternate_refs(const char *path,\n \tstruct strbuf line = STRBUF_INIT;\n \tFILE *fh;\n \n-\tfill_alternate_refs_command(&cmd, path);\n+\tfill_alternate_refs_command(repo, &cmd, path);\n \n \tif (start_command(&cmd))\n \t\treturn;\n@@ -521,7 +521,7 @@ static void read_alternate_refs(const char *path,\n \t\tstruct object_id oid;\n \t\tconst char *p;\n \n-\t\tif (parse_oid_hex(line.buf, &oid, &p) || *p) {\n+\t\tif (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) {\n \t\t\twarning(_(\"invalid line while parsing alternate refs: %s\"),\n \t\t\t\tline.buf);\n \t\t\tbreak;\n@@ -559,7 +559,7 @@ static int refs_from_alternate_cb(struct odb_alternate *alternate,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n+\tread_alternate_refs(alternate->odb->repo, path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, the_repository->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n \t\tif (oi->type_name)\n \t\t\tstrbuf_addstr(oi->type_name, type_name(co->type));\n \t\tif (oi->contentp)\n@@ -765,10 +765,10 @@ static int oid_object_info_convert(struct repository *r,\n \tvoid *content;\n \tint ret;\n \n-\tif (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) {\n+\tif (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) {\n \t\tif (do_die)\n \t\t\tdie(_(\"missing mapping of %s to %s\"),\n-\t\t\t    oid_to_hex(input_oid), the_hash_algo->name);\n+\t\t\t    oid_to_hex(input_oid), r->hash_algo->name);\n \t\treturn -1;\n \t}\n \n@@ -804,8 +804,8 @@ static int oid_object_info_convert(struct repository *r,\n \t\tif (type == -1)\n \t\t\treturn -1;\n \t\tif (type != OBJ_BLOB) {\n-\t\t\tret = convert_object_file(the_repository, &outbuf,\n-\t\t\t\t\t\t  the_hash_algo, input_algo,\n+\t\t\tret = convert_object_file(r, &outbuf,\n+\t\t\t\t\t\t  r->hash_algo, input_algo,\n \t\t\t\t\t\t  content, size, type, !do_die);\n \t\t\tfree(content);\n \t\t\tif (ret == -1)\n@@ -953,9 +953,9 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + the_hash_algo->hexsz > isize ||\n+\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex((char *) buffer + ref_length, &actual_oid)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517677","messageId":"20250509-pks-object-store-wo-the-repository-v2-13-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 13/17] odb: rename `oid_object_info()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:13Z","receivedAt":"2025-05-09T14:12:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `oid_object_info()` to `odb_read_object_info()` as well as their\n`_extended()` variant to match other functions related to the object\ndatabase and our modern coding guidelines.\n\nIntroduce compatibility wrappers so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n archive.c                     |  2 +-\n blame.c                       |  4 +--\n builtin/blame.c               |  4 +--\n builtin/cat-file.c            | 26 ++++++++++---------\n builtin/describe.c            |  3 ++-\n builtin/fast-export.c         |  2 +-\n builtin/fast-import.c         | 17 ++++++------\n builtin/fsck.c                |  7 ++---\n builtin/gc.c                  |  2 +-\n builtin/grep.c                |  2 +-\n builtin/index-pack.c          | 13 +++++-----\n builtin/ls-files.c            |  2 +-\n builtin/ls-tree.c             |  4 +--\n builtin/mktree.c              |  8 +++---\n builtin/pack-objects.c        | 30 ++++++++++++----------\n builtin/prune.c               |  4 +--\n builtin/repack.c              |  2 +-\n builtin/replace.c             | 10 ++++----\n builtin/rev-list.c            |  6 +++--\n builtin/tag.c                 |  4 +--\n builtin/unpack-objects.c      |  2 +-\n commit-graph.c                |  2 +-\n commit.c                      |  3 ++-\n diff.c                        | 18 ++++++-------\n fetch-pack.c                  |  4 +--\n list-objects-filter.c         |  2 +-\n log-tree.c                    |  2 +-\n merge-ort.c                   |  4 +--\n object-file.c                 |  2 +-\n object-file.h                 |  2 +-\n object-name.c                 | 16 ++++++------\n object.c                      |  6 ++---\n odb.c                         | 60 ++++++++++++++++++++++---------------------\n odb.h                         | 46 +++++++++++++++++++++++++++------\n pack-bitmap-write.c           |  4 +--\n pack-bitmap.c                 |  8 +++---\n packfile.c                    |  5 ++--\n promisor-remote.c             |  4 +--\n protocol-caps.c               |  2 +-\n reachable.c                   |  2 +-\n read-cache.c                  |  6 ++---\n ref-filter.c                  |  4 +--\n remote.c                      |  5 ++--\n sequencer.c                   |  5 ++--\n streaming.c                   |  8 +++---\n submodule.c                   |  5 ++--\n t/helper/test-partial-clone.c |  2 +-\n tag.c                         |  2 +-\n 48 files changed, 213 insertions(+), 170 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 7fa2cc2596a..f2511d530d5 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,\n \n \t/* Stream it? */\n \tif (S_ISREG(mode) && !args->convert &&\n-\t    oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&\n+\t    odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&\n \t    size > repo_settings_get_big_file_threshold(the_repository))\n \t\treturn write_entry(args, oid, path.buf, path.len, mode, NULL, size);\n \ndiff --git a/blame.c b/blame.c\nindex 0ceea080a80..97db3355af4 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,\n \t\tunsigned short mode;\n \n \t\tif (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&\n-\t\t    oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)\n+\t\t    odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n \n@@ -1245,7 +1245,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,\n \t\treturn 0;\n \tif (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))\n \t\tgoto error_out;\n-\tif (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)\n+\tif (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\n \treturn 0;\n  error_out:\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 15eda60af90..91586e6852b 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -837,7 +837,7 @@ static int is_a_rev(const char *name)\n \n \tif (repo_get_oid(the_repository, name, &oid))\n \t\treturn 0;\n-\treturn OBJ_NONE < oid_object_info(the_repository, &oid, NULL);\n+\treturn OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);\n }\n \n static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n@@ -848,7 +848,7 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n \toidcpy(&oid, oid_ret);\n \twhile (1) {\n \t\tstruct object *obj;\n-\t\tint kind = oid_object_info(r, &oid, NULL);\n+\t\tint kind = odb_read_object_info(r->objects, &oid, NULL);\n \t\tif (kind == OBJ_COMMIT) {\n \t\t\toidcpy(oid_ret, &oid);\n \t\t\treturn 0;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 2fa5e3f43bd..da172155c85 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -137,7 +137,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tswitch (opt) {\n \tcase 't':\n \t\toi.type_name = &sb;\n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tif (sb.len) {\n \t\t\tprintf(\"%s\\n\", sb.buf);\n@@ -155,7 +155,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\toi.contentp = (void**)&buf;\n \t\t}\n \n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \n \t\tif (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {\n@@ -189,7 +189,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t/* else fallthrough */\n \n \tcase 'p':\n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Not a valid object name %s\", obj_name);\n \n@@ -226,7 +226,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \n \t\tif (exp_type_id == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n-\t\t\tif (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n \t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n \t\t\t\t\t\t\t\t     &oid,\n \t\t\t\t\t\t\t\t     &type,\n@@ -244,7 +245,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t} else\n \t\t\t\toidcpy(&blob_oid, &oid);\n \n-\t\t\tif (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &blob_oid, NULL) == OBJ_BLOB) {\n \t\t\t\tret = stream_blob(&blob_oid);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n@@ -303,7 +305,7 @@ struct expand_data {\n \n \t/*\n \t * After a mark_query run, this object_info is set up to be\n-\t * passed to oid_object_info_extended. It will point to the data\n+\t * passed to odb_read_object_info_extended. It will point to the data\n \t * elements above, so you can retrieve the response from there.\n \t */\n \tstruct object_info info;\n@@ -493,12 +495,12 @@ static void batch_object_write(const char *obj_name,\n \t\t\tdata->info.sizep = &data->size;\n \n \t\tif (pack)\n-\t\t\tret = packed_object_info(the_repository, pack, offset,\n-\t\t\t\t\t\t &data->info);\n+\t\t\tret = packed_object_info(the_repository, pack,\n+\t\t\t\t\t\t offset, &data->info);\n \t\telse\n-\t\t\tret = oid_object_info_extended(the_repository,\n-\t\t\t\t\t\t       &data->oid, &data->info,\n-\t\t\t\t\t\t       OBJECT_INFO_LOOKUP_REPLACE);\n+\t\t\tret = odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t    &data->oid, &data->info,\n+\t\t\t\t\t\t\t    OBJECT_INFO_LOOKUP_REPLACE);\n \t\tif (ret < 0) {\n \t\t\treport_object_status(opt, obj_name, &data->oid, \"missing\");\n \t\t\treturn;\n@@ -881,7 +883,7 @@ static int batch_objects(struct batch_options *opt)\n \n \t/*\n \t * Expand once with our special mark_query flag, which will prime the\n-\t * object_info to be handed to oid_object_info_extended for each\n+\t * object_info to be handed to odb_read_object_info_extended for each\n \t * object.\n \t */\n \tmemset(&data, 0, sizeof(data));\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 96cb68e5e5d..fbf305d7624 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\n-\telse if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)\n+\telse if (odb_read_object_info(the_repository->objects,\n+\t\t\t\t      &oid, NULL) == OBJ_BLOB)\n \t\tdescribe_blob(oid, &sb);\n \telse\n \t\tdie(_(\"%s is neither a commit nor blob\"), arg);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 0505f289a94..6c93cf0a8aa 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\n \n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 413304db9b5..2718376f2c9 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1756,8 +1756,8 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint\n \tstruct object_entry *e;\n \te = find_object(oid);\n \tif (!e) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\toid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\te = insert_object(oid);\n@@ -2416,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)\n \t\tenum object_type expected = S_ISDIR(mode) ?\n \t\t\t\t\t\tOBJ_TREE: OBJ_BLOB;\n \t\tenum object_type type = oe ? oe->type :\n-\t\t\t\t\toid_object_info(the_repository, &oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\t\t\t\todb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"%s not found: %s\",\n \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n@@ -2553,7 +2553,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttype_name(oe->type), command_buf.buf);\n \t} else if (!is_null_oid(&oid)) {\n-\t\tenum object_type type = oid_object_info(the_repository, &oid,\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects, &oid,\n \t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n@@ -2895,7 +2895,8 @@ static void parse_new_tag(const char *arg)\n \t} else if (!repo_get_oid(the_repository, from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n-\t\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t    &oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -3085,8 +3086,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tif (!oe) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex b961c2caa22..08a79fe044d 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,\n \tconst char *ret;\n \n \tif (type == OBJ_NONE)\n-\t\ttype = oid_object_info(the_repository, oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t    oid, NULL);\n \n \tret = type_name(type);\n \tif (!ret)\n@@ -232,8 +233,8 @@ static void mark_unreachable_referents(const struct object_id *oid)\n \t * (and we want to avoid parsing blobs).\n \t */\n \tif (obj->type == OBJ_NONE) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\t&obj->oid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &obj->oid, NULL);\n \t\tif (type > 0)\n \t\t\tobject_as_type(obj, type, 0);\n \t}\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 9e9d31c1f39..40bd2259c6a 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -1006,7 +1006,7 @@ static int dfs_on_ref(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tcommit = lookup_commit(the_repository, oid);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 277bc121e4e..311c940aa9e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobj_read_lock();\n-\t\tobject_type = oid_object_info(subrepo, oid, NULL);\n+\t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n \t\tdata = read_object_with_reference(subrepo,\n \t\t\t\t\t\t  oid, OBJ_TREE,\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 8e5acefde40..82cf80b89d1 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -260,7 +260,8 @@ static unsigned check_object(struct object *obj)\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t&obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n \t\t\t      oid_to_hex(&obj->oid));\n@@ -908,7 +909,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\tenum object_type has_type;\n \t\tunsigned long has_size;\n \t\tread_lock();\n-\t\thas_type = oid_object_info(the_repository, oid, &has_size);\n+\t\thas_type = odb_read_object_info(the_repository->objects, oid, &has_size);\n \t\tif (has_type < 0)\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n@@ -1495,9 +1496,9 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \t\tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \t\tfor (i = 0; i < nr_ref_deltas; i++) {\n \t\t\tstruct ref_delta_entry *d = sorted_by_pos[i];\n-\t\t\tif (!oid_object_info_extended(the_repository, &d->oid,\n-\t\t\t\t\t\t      NULL,\n-\t\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t   &d->oid, NULL,\n+\t\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\tcontinue;\n \t\t\toid_array_append(&to_fetch, &d->oid);\n \t\t}\n@@ -1823,7 +1824,7 @@ static void repack_local_links(void)\n \toidset_iter_init(&outgoing_links, &iter);\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct object_info info = OBJECT_INFO_INIT;\n-\t\tif (oid_object_info_extended(the_repository, oid, &info, 0))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))\n \t\t\t/* Missing; assume it is a promisor object */\n \t\t\tcontinue;\n \t\tif (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 821339b07d4..ff975e7be06 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -251,7 +251,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(repo, oid, &size) < 0)\n+\t\tif (odb_read_object_info(repo->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 62b6fd58c16..4d616dd5282 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -27,7 +27,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\n@@ -217,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,\n \n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)\n \t\t\txsnprintf(size_text, sizeof(size_text), \"BAD\");\n \t\telse\n \t\t\txsnprintf(size_text, sizeof(size_text),\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 016b0e5b224..81df7f6099f 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -124,10 +124,10 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)\n \n \t/* Check the type of object identified by oid without fetching objects */\n \toi.typep = &obj_type;\n-\tif (oid_object_info_extended(the_repository, &oid, &oi,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t     OBJECT_INFO_QUICK |\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t  OBJECT_INFO_QUICK |\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n \t\tobj_type = -1;\n \n \tif (obj_type < 0) {\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 99b63cb0980..da35d684081 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2154,10 +2154,10 @@ static void prefetch_to_pack(uint32_t object_index_start) {\n \tfor (i = object_index_start; i < to_pack.nr_objects; i++) {\n \t\tstruct object_entry *entry = to_pack.objects + i;\n \n-\t\tif (!oid_object_info_extended(the_repository,\n-\t\t\t\t\t      &entry->idx.oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &entry->idx.oid,\n+\t\t\t\t\t\t   NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &entry->idx.oid);\n \t}\n@@ -2298,19 +2298,19 @@ static void check_object(struct object_entry *entry, uint32_t object_index)\n \n \t\t/*\n \t\t * No choice but to fall back to the recursive delta walk\n-\t\t * with oid_object_info() to find about the object type\n+\t\t * with odb_read_object_info() to find about the object type\n \t\t * at this point...\n \t\t */\n \t\tgive_up:\n \t\tunuse_pack(&w_curs);\n \t}\n \n-\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n \t\tif (repo_has_promisor_remote(the_repository)) {\n \t\t\tprefetch_to_pack(object_index);\n-\t\t\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\t\t\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\t\t\ttype = -1;\n \t\t} else {\n \t\t\ttype = -1;\n@@ -2384,12 +2384,13 @@ static void drop_reused_delta(struct object_entry *entry)\n \tif (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {\n \t\t/*\n \t\t * We failed to get the info from this pack for some reason;\n-\t\t * fall back to oid_object_info, which may find another copy.\n+\t\t * fall back to odb_read_object_info, which may find another copy.\n \t\t * And if that fails, the error will be recorded in oe_type(entry)\n \t\t * and dealt with in prepare_pack().\n \t\t */\n \t\toe_set_type(entry,\n-\t\t\t    oid_object_info(the_repository, &entry->idx.oid, &size));\n+\t\t\t    odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &entry->idx.oid, &size));\n \t} else {\n \t\toe_set_type(entry, type);\n \t}\n@@ -2677,7 +2678,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n \n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tif (oid_object_info(the_repository, &e->idx.oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &e->idx.oid, &size) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"),\n \t\t\t    oid_to_hex(&e->idx.oid));\n \t\tpacking_data_unlock(&to_pack);\n@@ -4063,7 +4065,7 @@ static void add_objects_in_unpacked_packs(void)\n static int add_loose_object(const struct object_id *oid, const char *path,\n \t\t\t    void *data UNUSED)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\twarning(_(\"loose object at %s could not be examined\"), path);\n@@ -4449,7 +4451,7 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED,\n static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)\n {\n \tstruct object_info info = OBJECT_INFO_INIT;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &info, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))\n \t\tBUG(\"should_include_obj should only be called on existing objects\");\n \treturn info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;\n }\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 7bbfb14c2be..339017c7ccf 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -99,8 +99,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \tif (st.st_mtime > expire)\n \t\treturn 0;\n \tif (show_only || verbose) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tprintf(\"%s %s\\n\", oid_to_hex(oid),\n \t\t       (type > 0) ? type_name(type) : \"unknown\");\n \t}\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 8145474cf8d..a89c2b704fb 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -707,7 +707,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,\n \tif (oidset_insert(&data->seen, oid))\n \t\treturn 0; /* already seen */\n \n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tfprintf(data->f->fp, \"%s%s\\n\", data->preferred ? \"+\" : \"\",\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 11c7e2d4c0c..5ff2ab723cb 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -65,8 +65,8 @@ static int show_reference(const char *refname,\n \t\t\tif (repo_get_oid(data->repo, refname, &object))\n \t\t\t\treturn error(_(\"failed to resolve '%s' as a valid ref\"), refname);\n \n-\t\t\tobj_type = oid_object_info(data->repo, &object, NULL);\n-\t\t\trepl_type = oid_object_info(data->repo, oid, NULL);\n+\t\t\tobj_type = odb_read_object_info(data->repo->objects, &object, NULL);\n+\t\t\trepl_type = odb_read_object_info(data->repo->objects, oid, NULL);\n \n \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, type_name(obj_type),\n \t\t\t       oid_to_hex(oid), type_name(repl_type));\n@@ -185,8 +185,8 @@ static int replace_object_oid(const char *object_ref,\n \tstruct strbuf err = STRBUF_INIT;\n \tint res = 0;\n \n-\tobj_type = oid_object_info(the_repository, object, NULL);\n-\trepl_type = oid_object_info(the_repository, repl, NULL);\n+\tobj_type = odb_read_object_info(the_repository->objects, object, NULL);\n+\trepl_type = odb_read_object_info(the_repository->objects, repl, NULL);\n \tif (!force && obj_type != repl_type)\n \t\treturn error(_(\"Objects must be of the same type.\\n\"\n \t\t\t       \"'%s' points to a replaced object of type '%s'\\n\"\n@@ -334,7 +334,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)\n \tif (repo_get_oid(the_repository, object_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), object_ref);\n \n-\ttype = oid_object_info(the_repository, &old_oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &old_oid, NULL);\n \tif (type < 0)\n \t\treturn error(_(\"unable to get object type for %s\"),\n \t\t\t     oid_to_hex(&old_oid));\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex ee25d61c802..eed73f5fc0b 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -110,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)\n \toff_t size;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \toi.disk_sizep = &size;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\tdie(_(\"unable to get disk usage of %s\"), oid_to_hex(&obj->oid));\n \treturn size;\n }\n@@ -346,7 +347,8 @@ static void show_commit(struct commit *commit, void *data)\n static int finish_object(struct object *obj, const char *name, void *cb_data)\n {\n \tstruct rev_list_info *info = cb_data;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, NULL, 0) < 0) {\n \t\tfinish_object__ma(obj, name);\n \t\treturn 1;\n \t}\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex cf2ea4b4993..e0b27396c6b 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -304,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,\n \tstruct strbuf header = STRBUF_INIT;\n \tint should_edit;\n \n-\ttype = oid_object_info(the_repository, object, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, object, NULL);\n \tif (type <= OBJ_NONE)\n \t\tdie(_(\"bad object type.\"));\n \n@@ -401,7 +401,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 7bf395eec84..405e78bc592 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -232,7 +232,7 @@ static int check_object(struct object *obj, enum object_type type,\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n \t\tobj->flags |= FLAG_WRITTEN;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex cd34b71d270..84cfaf87639 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1862,7 +1862,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT)\n \t\toidset_insert(data->commits, oid);\n \n \tdisplay_progress(data->progress, oidset_size(data->commits));\ndiff --git a/commit.c b/commit.c\nindex aa65183d8b6..d4aa9c7a5f8 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -585,7 +585,8 @@ int repo_parse_commit_internal(struct repository *r,\n \t\treturn 0;\n \t}\n \n-\tif (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)\n+\tif (odb_read_object_info_extended(r->objects, &item->object.oid,\n+\t\t\t\t\t  &oi, flags) < 0)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/diff.c b/diff.c\nindex 193da8bee68..75cfedf18a5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4230,14 +4230,14 @@ int diff_populate_filespec(struct repository *r,\n \t\t\tinfo.contentp = &s->data;\n \n \t\tif (options && options->missing_object_cb) {\n-\t\t\tif (!oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t\t\t      OBJECT_INFO_SKIP_FETCH_OBJECT))\n+\t\t\tif (!odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t   OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t\t\t   OBJECT_INFO_SKIP_FETCH_OBJECT))\n \t\t\t\tgoto object_read;\n \t\t\toptions->missing_object_cb(options->missing_object_data);\n \t\t}\n-\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \n object_read:\n@@ -4252,8 +4252,8 @@ int diff_populate_filespec(struct repository *r,\n \t\t}\n \t\tif (!info.contentp) {\n \t\t\tinfo.contentp = &s->data;\n-\t\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \t\t}\n \t\ts->should_free = 1;\n@@ -7019,8 +7019,8 @@ void diff_add_if_missing(struct repository *r,\n {\n \tif (filespec && filespec->oid_valid &&\n \t    !S_ISGITLINK(filespec->mode) &&\n-\t    oid_object_info_extended(r, &filespec->oid, NULL,\n-\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t    odb_read_object_info_extended(r->objects, &filespec->oid, NULL,\n+\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\toid_array_append(to_fetch, &filespec->oid);\n }\n \ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 47fa7fa4c49..0f5de1c94d1 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -149,8 +149,8 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \t}\n \n \twhile (1) {\n-\t\tif (oid_object_info_extended(the_repository, oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n \t\t\treturn NULL;\n \t\tif (type == OBJ_TAG) {\n \t\t\tstruct tag *tag = (struct tag *)\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex cb9c16734b1..ec7aebaffd0 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -310,7 +310,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \t\tassert(obj->type == OBJ_BLOB);\n \t\tassert((obj->flags & SEEN) == 0);\n \n-\t\tt = oid_object_info(r, &obj->oid, &object_length);\n+\t\tt = odb_read_object_info(r->objects, &obj->oid, &object_length);\n \t\tif (t != OBJ_BLOB) { /* probably OBJ_NONE */\n \t\t\t/*\n \t\t\t * We DO NOT have the blob locally, so we cannot\ndiff --git a/log-tree.c b/log-tree.c\nindex 1d05dc1c701..233bf9f227c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -176,7 +176,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,\n \t\treturn 0;\n \t}\n \n-\tobjtype = oid_object_info(the_repository, oid, NULL);\n+\tobjtype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (objtype < 0)\n \t\treturn 0;\n \tobj = lookup_object_by_type(the_repository, oid, objtype);\ndiff --git a/merge-ort.c b/merge-ort.c\nindex f86c84635f0..5d4501085e9 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -4374,8 +4374,8 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \n \t\t\tif ((ci->filemask & side_mask) &&\n \t\t\t    S_ISREG(vi->mode) &&\n-\t\t\t    oid_object_info_extended(opt->repo, &vi->oid, NULL,\n-\t\t\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t\t\t    odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,\n+\t\t\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\toid_array_append(&to_fetch, &vi->oid);\n \t\t}\n \t}\ndiff --git a/object-file.c b/object-file.c\nindex 9e8649135ce..d5f41cb73a2 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1211,7 +1211,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)\n \toi.typep = &type;\n \toi.sizep = &len;\n \toi.contentp = &buf;\n-\tif (oid_object_info_extended(the_repository, oid, &oi, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0))\n \t\treturn error(_(\"cannot read object for %s\"), oid_to_hex(oid));\n \tif (compat) {\n \t\tif (repo_oid_to_algop(repo, oid, compat, &compat_oid))\ndiff --git a/object-file.h b/object-file.h\nindex e4810eee449..86920bd4bb8 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -8,7 +8,7 @@\n struct index_state;\n \n /*\n- * Set this to 0 to prevent oid_object_info_extended() from fetching missing\n+ * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing\n  * blobs. This has a difference only if extensions.partialClone is set.\n  *\n  * Its default value is 1.\ndiff --git a/object-name.c b/object-name.c\nindex 2b757eb7948..973548d8923 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -251,7 +251,7 @@ static int disambiguate_commit_only(struct repository *r,\n \t\t\t\t    const struct object_id *oid,\n \t\t\t\t    void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_COMMIT;\n }\n \n@@ -262,7 +262,7 @@ static int disambiguate_committish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -279,7 +279,7 @@ static int disambiguate_tree_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_TREE;\n }\n \n@@ -290,7 +290,7 @@ static int disambiguate_treeish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_TREE || kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -307,7 +307,7 @@ static int disambiguate_blob_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_BLOB;\n }\n \n@@ -399,7 +399,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t\treturn 0;\n \n \thash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);\n-\ttype = oid_object_info(ds->repo, oid, NULL);\n+\ttype = odb_read_object_info(ds->repo->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\t/*\n@@ -514,8 +514,8 @@ static int sort_ambiguous(const void *va, const void *vb, void *ctx)\n {\n \tstruct repository *sort_ambiguous_repo = ctx;\n \tconst struct object_id *a = va, *b = vb;\n-\tint a_type = oid_object_info(sort_ambiguous_repo, a, NULL);\n-\tint b_type = oid_object_info(sort_ambiguous_repo, b, NULL);\n+\tint a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL);\n+\tint b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL);\n \tint a_type_sort;\n \tint b_type_sort;\n \ndiff --git a/object.c b/object.c\nindex 3b15469139d..868d89eed42 100644\n--- a/object.c\n+++ b/object.c\n@@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,\n \tstruct object *o = lookup_unknown_object(r, name);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = oid_object_info(r, name, NULL);\n+\t\tint type = odb_read_object_info(r->objects, name, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\n@@ -315,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t}\n \n \tif ((!obj || obj->type == OBJ_BLOB) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_BLOB) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {\n \t\tif (!skip_hash && stream_object_signature(r, repl) < 0) {\n \t\t\terror(_(\"hash mismatch %s\"), oid_to_hex(oid));\n \t\t\treturn NULL;\n@@ -331,7 +331,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t */\n \tif (skip_hash && discard_tree &&\n \t    (!obj || obj->type == OBJ_TREE) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_TREE) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex c150c01db4a..3d5d4ff8454 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -647,7 +647,7 @@ static int register_all_submodule_alternates(struct object_database *odb)\n \treturn ret;\n }\n \n-static int do_oid_object_info_extended(struct repository *r,\n+static int do_oid_object_info_extended(struct object_database *odb,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n {\n@@ -660,7 +660,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \n \n \tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n-\t\treal = lookup_replace_object(r, oid);\n+\t\treal = lookup_replace_object(odb->repo, oid);\n \n \tif (is_null_oid(real))\n \t\treturn -1;\n@@ -668,7 +668,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \tif (!oi)\n \t\toi = &blank_oi;\n \n-\tco = find_cached_object(r->objects, real);\n+\tco = find_cached_object(odb, real);\n \tif (co) {\n \t\tif (oi->typep)\n \t\t\t*(oi->typep) = co->type;\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, odb->repo->hash_algo);\n \t\tif (oi->type_name)\n \t\t\tstrbuf_addstr(oi->type_name, type_name(co->type));\n \t\tif (oi->contentp)\n@@ -687,17 +687,17 @@ static int do_oid_object_info_extended(struct repository *r,\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(r, real, &e))\n+\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\tbreak;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!loose_object_info(r, real, oi, flags))\n+\t\tif (!loose_object_info(odb->repo, real, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\tif (!(flags & OBJECT_INFO_QUICK)) {\n-\t\t\treprepare_packed_git(r);\n-\t\t\tif (find_pack_entry(r, real, &e))\n+\t\t\treprepare_packed_git(odb->repo);\n+\t\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\t\tbreak;\n \t\t}\n \n@@ -707,15 +707,15 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * `odb_add_submodule_alternate_by_path()` on that submodule's\n \t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (register_all_submodule_alternates(r->objects))\n+\t\tif (register_all_submodule_alternates(odb))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n \t\t/* Check if it is a missing object */\n-\t\tif (fetch_if_missing && repo_has_promisor_remote(r) &&\n+\t\tif (fetch_if_missing && repo_has_promisor_remote(odb->repo) &&\n \t\t    !already_retried &&\n \t\t    !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n-\t\t\tpromisor_remote_get_direct(r, real, 1);\n+\t\t\tpromisor_remote_get_direct(odb->repo, real, 1);\n \t\t\talready_retried = 1;\n \t\t\tcontinue;\n \t\t}\n@@ -725,7 +725,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t\tif ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))\n \t\t\t\tdie(_(\"replacement %s not found for %s\"),\n \t\t\t\t    oid_to_hex(real), oid_to_hex(oid));\n-\t\t\tif ((p = has_packed_and_bad(r, real)))\n+\t\t\tif ((p = has_packed_and_bad(odb->repo, real)))\n \t\t\t\tdie(_(\"packed object %s (stored in %s) is corrupt\"),\n \t\t\t\t    oid_to_hex(real), p->pack_name);\n \t\t}\n@@ -738,10 +738,10 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(r, e.p, e.offset, oi);\n+\trtype = packed_object_info(odb->repo, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real);\n-\t\treturn do_oid_object_info_extended(r, real, oi, 0);\n+\t\treturn do_oid_object_info_extended(odb, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -789,7 +789,7 @@ static int oid_object_info_convert(struct repository *r,\n \t\toi = &new_oi;\n \t}\n \n-\tret = oid_object_info_extended(r, &oid, oi, flags);\n+\tret = odb_read_object_info_extended(r->objects, &oid, oi, flags);\n \tif (ret)\n \t\treturn -1;\n \tif (oi == input_oi)\n@@ -839,33 +839,35 @@ static int oid_object_info_convert(struct repository *r,\n \treturn ret;\n }\n \n-int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n-\t\t\t     struct object_info *oi, unsigned flags)\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags)\n {\n \tint ret;\n \n-\tif (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo))\n-\t\treturn oid_object_info_convert(r, oid, oi, flags);\n+\tif (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo))\n+\t\treturn oid_object_info_convert(odb->repo, oid, oi, flags);\n \n \tobj_read_lock();\n-\tret = do_oid_object_info_extended(r, oid, oi, flags);\n+\tret = do_oid_object_info_extended(odb, oid, oi, flags);\n \tobj_read_unlock();\n \treturn ret;\n }\n \n \n /* returns enum object_type or negative */\n-int oid_object_info(struct repository *r,\n-\t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (odb_read_object_info_extended(odb, oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n@@ -896,7 +898,7 @@ int pretend_object_file(struct repository *repo,\n \n /*\n  * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call oid_object_info_extended() and give\n+ * deal with them should arrange to call odb_read_object_info_extended() and give\n  * error messages themselves.\n  */\n void *repo_read_object_file(struct repository *r,\n@@ -911,7 +913,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (oid_object_info_extended(r, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -977,13 +979,13 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(odb, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex ef8a8a544b2..d75a5f9d44b 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -254,9 +254,6 @@ void *repo_read_object_file(struct repository *r,\n \t\t\t    enum object_type *type,\n \t\t\t    unsigned long *size);\n \n-/* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n-\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -328,9 +325,24 @@ struct object_info {\n /* Die if object corruption (not just an object being missing) was detected. */\n #define OBJECT_INFO_DIE_IF_CORRUPT 32\n \n-int oid_object_info_extended(struct repository *r,\n-\t\t\t     const struct object_id *,\n-\t\t\t     struct object_info *, unsigned flags);\n+/*\n+ * Read object info from the object database and populate the `object_info`\n+ * structure. Returns 0 on success, a negative error code otherwise.\n+ */\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags);\n+\n+/*\n+ * Read a subset of object info for the given object ID. Returns an `enum\n+ * object_type` on success, a negative error code otherwise. If successful and\n+ * `sizep` is non-NULL, then the size of the object will be written to the\n+ * pointer.\n+ */\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep);\n \n enum {\n \t/* Retry packed storage after checking packed and loose storage */\n@@ -352,7 +364,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: repo_read_object_file(),\n- * read_object_with_reference(), oid_object_info() and oid_object_info_extended().\n+ * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -360,7 +372,7 @@ void odb_assert_oid_type(struct object_database *odb,\n  * reading functions. However, beware that in these cases zlib inflation won't\n  * be performed in parallel, losing performance.\n  *\n- * TODO: oid_object_info_extended()'s call stack has a recursive behavior. If\n+ * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If\n  * any of its callees end up calling it, this recursive call won't benefit from\n  * parallel inflation.\n  */\n@@ -408,4 +420,22 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n+/* Compatibility wrappers, to be removed once Git 2.50 has been released. */\n+#include \"repository.h\"\n+\n+static inline int oid_object_info_extended(struct repository *r,\n+\t\t\t\t\t   const struct object_id *oid,\n+\t\t\t\t\t   struct object_info *oi,\n+\t\t\t\t\t   unsigned flags)\n+{\n+\treturn odb_read_object_info_extended(r->objects, oid, oi, flags);\n+}\n+\n+static inline int oid_object_info(struct repository *r,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  unsigned long *sizep)\n+{\n+\treturn odb_read_object_info(r->objects, oid, sizep);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex c847369eaaa..c5183b619c1 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -144,8 +144,8 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\treal_type = oid_object_info(writer->to_pack->repo,\n-\t\t\t\t\t\t    &entry->idx.oid, NULL);\n+\t\t\treal_type = odb_read_object_info(writer->to_pack->repo->objects,\n+\t\t\t\t\t\t\t &entry->idx.oid, NULL);\n \t\t\tbreak;\n \t\t}\n \ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex 467a3e91035..0bd6f1c282f 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -1868,8 +1868,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,\n \t\tsize_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git);\n \t\tstruct eindex *eindex = &bitmap_git->ext_index;\n \t\tstruct object *obj = eindex->objects[eindex_pos];\n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid,\n+\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"), oid_to_hex(&obj->oid));\n \t}\n \n@@ -3220,8 +3220,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)\n \t\t\t\t       i)))\n \t\t\tcontinue;\n \n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects,\n+\t\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get disk usage of '%s'\"),\n \t\t\t    oid_to_hex(&obj->oid));\n \ndiff --git a/packfile.c b/packfile.c\nindex ab9628eb3d4..2f022265a5b 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1310,7 +1310,7 @@ static int retry_bad_packed_offset(struct repository *r,\n \t\treturn OBJ_BAD;\n \tnth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));\n \tmark_bad_packed_object(p, &oid);\n-\ttype = oid_object_info(r, &oid, NULL);\n+\ttype = odb_read_object_info(r->objects, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1843,7 +1843,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\t\t\toi.typep = &type;\n \t\t\t\toi.sizep = &base_size;\n \t\t\t\toi.contentp = &base;\n-\t\t\t\tif (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)\n+\t\t\t\tif (odb_read_object_info_extended(r->objects, &base_oid,\n+\t\t\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\t\t\tbase = NULL;\n \n \t\t\t\texternal_base = base;\ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 2baa286bfd0..be6f82d12f8 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -245,8 +245,8 @@ static int remove_fetched_oids(struct repository *repo,\n \tstruct object_id *new_oids;\n \n \tfor (i = 0; i < oid_nr; i++)\n-\t\tif (oid_object_info_extended(repo, &old_oids[i], NULL,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n+\t\tif (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n \t\t\tremaining[i] = 1;\n \t\t\tremaining_nr++;\n \t\t}\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 3022f69a1bd..ecdd0dc58d5 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -64,7 +64,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,\n \t\tstrbuf_addstr(&send_buffer, oid_str);\n \n \t\tif (info->size) {\n-\t\t\tif (oid_object_info(r, &oid, &object_size) < 0) {\n+\t\t\tif (odb_read_object_info(r->objects, &oid, &object_size) < 0) {\n \t\t\t\tstrbuf_addstr(&send_buffer, \" \");\n \t\t\t} else {\n \t\t\t\tstrbuf_addf(&send_buffer, \" %lu\", object_size);\ndiff --git a/reachable.c b/reachable.c\nindex 9dc748f0b9a..e984b68a0c4 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -211,7 +211,7 @@ static void add_recent_object(const struct object_id *oid,\n \t * later processing, and the revision machinery expects\n \t * commits and tags to have been parsed.\n \t */\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object info for %s\", oid_to_hex(oid));\n \ndiff --git a/read-cache.c b/read-cache.c\nindex dce1056ec7c..be664f857b4 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3758,9 +3758,9 @@ void prefetch_cache_entries(const struct index_state *istate,\n \n \t\tif (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))\n \t\t\tcontinue;\n-\t\tif (!oid_object_info_extended(the_repository, &ce->oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &ce->oid, NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &ce->oid);\n \t}\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 4ce45440ad1..f9f2c512a8c 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2302,8 +2302,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj\n \t\toi->info.sizep = &oi->size;\n \t\toi->info.typep = &oi->type;\n \t}\n-\tif (oid_object_info_extended(the_repository, &oi->oid, &oi->info,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\tif (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\treturn strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n \t\t\t\t       oid_to_hex(&oi->oid), ref->refname);\n \tif (oi->info.disk_sizep && oi->disk_size < 0)\ndiff --git a/remote.c b/remote.c\nindex 17a842f5684..72c36239d31 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1182,7 +1182,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,\n \t\tBUG(\"'%s' is not a valid object, \"\n \t\t    \"match_explicit_lhs() should catch this!\",\n \t\t    matched_src_name);\n-\ttype = oid_object_info(the_repository, &oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \tif (type == OBJ_COMMIT) {\n \t\tadvise(_(\"The <src> part of the refspec is a commit object.\\n\"\n \t\t\t \"Did you mean to create a new branch by pushing to\\n\"\n@@ -1412,7 +1412,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &ref->new_oid, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\ndiff --git a/sequencer.c b/sequencer.c\nindex 35f4e68d59f..bb012a4bfd9 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5502,9 +5502,8 @@ int sequencer_pick_revisions(struct repository *r,\n \n \t\tif (!repo_get_oid(r, name, &oid)) {\n \t\t\tif (!lookup_commit_reference_gently(r, &oid, 1)) {\n-\t\t\t\tenum object_type type = oid_object_info(r,\n-\t\t\t\t\t\t\t\t\t&oid,\n-\t\t\t\t\t\t\t\t\tNULL);\n+\t\t\t\tenum object_type type = odb_read_object_info(r->objects,\n+\t\t\t\t\t\t\t\t\t     &oid, NULL);\n \t\t\t\tres = error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\t    name, type_name(type));\n \t\t\t\tgoto out;\ndiff --git a/streaming.c b/streaming.c\nindex 29cc877f22a..032f134dc10 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -44,7 +44,7 @@ struct git_istream {\n \n \tunion {\n \t\tstruct {\n-\t\t\tchar *buf; /* from oid_object_info_extended() */\n+\t\t\tchar *buf; /* from odb_read_object_info_extended() */\n \t\t\tunsigned long read_ptr;\n \t\t} incore;\n \n@@ -403,8 +403,8 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,\n \toi.typep = type;\n \toi.sizep = &st->size;\n \toi.contentp = (void **)&st->u.incore.buf;\n-\treturn oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t\tOBJECT_INFO_DIE_IF_CORRUPT);\n+\treturn odb_read_object_info_extended(r->objects, oid, &oi,\n+\t\t\t\t\t     OBJECT_INFO_DIE_IF_CORRUPT);\n }\n \n /*****************************************************************************\n@@ -422,7 +422,7 @@ static int istream_source(struct git_istream *st,\n \n \toi.typep = type;\n \toi.sizep = &size;\n-\tstatus = oid_object_info_extended(r, oid, &oi, 0);\n+\tstatus = odb_read_object_info_extended(r->objects, oid, &oi, 0);\n \tif (status < 0)\n \t\treturn status;\n \ndiff --git a/submodule.c b/submodule.c\nindex 788c9e55ed3..f8373a9ea7d 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -968,7 +968,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n \t\treturn 0;\n \t}\n \n-\ttype = oid_object_info(&subrepo, oid, NULL);\n+\ttype = odb_read_object_info(subrepo.objects, oid, NULL);\n \n \tswitch (type) {\n \tcase OBJ_COMMIT:\n@@ -1752,8 +1752,7 @@ static int fetch_start_failure(struct strbuf *err UNUSED,\n static int commit_missing_in_sub(const struct object_id *oid, void *data)\n {\n \tstruct repository *subrepo = data;\n-\n-\tenum object_type type = oid_object_info(subrepo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(subrepo->objects, oid, NULL);\n \n \treturn type != OBJ_COMMIT;\n }\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex dba227259a2..d8488007493 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -23,7 +23,7 @@ static void object_info(const char *gitdir, const char *oid_hex)\n \t\tdie(\"could not init repo\");\n \tif (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo))\n \t\tdie(\"could not parse oid\");\n-\tif (oid_object_info_extended(&r, &oid, &oi, 0))\n+\tif (odb_read_object_info_extended(r.objects, &oid, &oi, 0))\n \t\tdie(\"could not obtain object info\");\n \tprintf(\"%d\\n\", (int) size);\n \ndiff --git a/tag.c b/tag.c\nindex 5f6868bf7b1..144048fd5e0 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \tunsigned long size;\n \tint ret;\n \n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517678","messageId":"20250509-pks-object-store-wo-the-repository-v2-14-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 14/17] odb: rename `repo_read_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:14Z","receivedAt":"2025-05-09T14:12:29Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `repo_read_object_file()` to `odb_read_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  | 10 +++++-----\n archive.c                |  2 +-\n attr.c                   |  2 +-\n bisect.c                 |  6 +++---\n blame.c                  | 13 ++++++-------\n builtin/cat-file.c       | 26 +++++++++++---------------\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  6 +++---\n builtin/fast-import.c    |  8 ++++----\n builtin/grep.c           |  8 ++++----\n builtin/index-pack.c     |  8 ++++----\n builtin/log.c            |  2 +-\n builtin/merge-tree.c     | 12 ++++++------\n builtin/mktag.c          |  4 ++--\n builtin/notes.c          |  6 +++---\n builtin/pack-objects.c   | 30 +++++++++++++++---------------\n builtin/tag.c            |  4 ++--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c |  4 ++--\n bundle.c                 |  2 +-\n combine-diff.c           |  2 +-\n commit.c                 |  6 +++---\n config.c                 |  2 +-\n dir.c                    |  2 +-\n entry.c                  |  4 ++--\n fmt-merge-msg.c          |  4 ++--\n fsck.c                   |  2 +-\n grep.c                   |  4 ++--\n http-push.c              |  4 ++--\n mailmap.c                |  2 +-\n match-trees.c            |  4 ++--\n merge-blobs.c            |  8 ++++----\n merge-ort.c              |  2 +-\n notes-cache.c            |  2 +-\n notes-merge.c            |  2 +-\n notes.c                  | 13 +++++++------\n object.c                 |  2 +-\n odb.c                    | 19 +++++++------------\n odb.h                    | 29 +++++++++++++++++++++++------\n read-cache.c             |  6 +++---\n reflog.c                 |  4 ++--\n rerere.c                 |  5 ++---\n submodule-config.c       |  4 ++--\n tag.c                    |  6 +++---\n tree-walk.c              |  6 +++---\n tree.c                   |  4 ++--\n xdiff-interface.c        |  2 +-\n 47 files changed, 157 insertions(+), 150 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 879f04df31e..56cd0540350 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3210,8 +3210,8 @@ static int apply_binary(struct apply_state *state,\n \t\tunsigned long size;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t       &size);\n+\t\tresult = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t\t &type, &size);\n \t\tif (!result)\n \t\t\treturn error(_(\"the necessary postimage %s for \"\n \t\t\t\t       \"'%s' cannot be read\"),\n@@ -3273,8 +3273,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tunsigned long sz;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t       &sz);\n+\t\tresult = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t &type, &sz);\n \t\tif (!result)\n \t\t\treturn -1;\n \t\t/* XXX read_sha1_file NUL-terminates */\n@@ -3503,7 +3503,7 @@ static int resolve_to(struct image *image, const struct object_id *result_id)\n \n \timage_clear(image);\n \n-\tdata = repo_read_object_file(the_repository, result_id, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, result_id, &type, &size);\n \tif (!data || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(result_id));\n \tstrbuf_attach(&image->buf, data, size, size + 1);\ndiff --git a/archive.c b/archive.c\nindex f2511d530d5..f5a9d45c8d3 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -98,7 +98,7 @@ static void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t       (args->tree ? &args->tree->object.oid : NULL), oid);\n \n \tpath += args->baselen;\n-\tbuffer = repo_read_object_file(the_repository, oid, type, sizep);\n+\tbuffer = odb_read_object(the_repository->objects, oid, type, sizep);\n \tif (buffer && S_ISREG(mode)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tsize_t size = 0;\ndiff --git a/attr.c b/attr.c\nindex e5680db7f65..d1daeb0b4d9 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -779,7 +779,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,\n \tif (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))\n \t\treturn NULL;\n \n-\tbuf = repo_read_object_file(istate->repo, &oid, &type, &sz);\n+\tbuf = odb_read_object(istate->repo->objects, &oid, &type, &sz);\n \tif (!buf || type != OBJ_BLOB) {\n \t\tfree(buf);\n \t\treturn NULL;\ndiff --git a/bisect.c b/bisect.c\nindex a7939216d00..f24474542ec 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -155,9 +155,9 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tunsigned commit_flags = commit->object.flags;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &commit->object.oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &commit->object.oid, &type,\n+\t\t\t\t\t    &size);\n \t\tconst char *subject_start;\n \t\tint subject_len;\n \ndiff --git a/blame.c b/blame.c\nindex 97db3355af4..858d2d74df9 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1041,9 +1041,9 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\t\t\t    &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n-\t\t\tfile->ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t  &o->blob_oid, &type,\n-\t\t\t\t\t\t\t  &file_size);\n+\t\t\tfile->ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t    &o->blob_oid, &type,\n+\t\t\t\t\t\t    &file_size);\n \t\tfile->size = file_size;\n \n \t\tif (!file->ptr)\n@@ -2869,10 +2869,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\n \t\telse\n-\t\t\tsb->final_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &o->blob_oid,\n-\t\t\t\t\t\t\t      &type,\n-\t\t\t\t\t\t\t      &sb->final_buf_size);\n+\t\t\tsb->final_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&o->blob_oid, &type,\n+\t\t\t\t\t\t\t&sb->final_buf_size);\n \n \t\tif (!sb->final_buf)\n \t\t\tdie(_(\"cannot read blob %s for path %s\"),\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex da172155c85..d6b9afca06e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -74,7 +74,7 @@ static int filter_object(const char *path, unsigned mode,\n {\n \tenum object_type type;\n \n-\t*buf = repo_read_object_file(the_repository, oid, &type, size);\n+\t*buf = odb_read_object(the_repository->objects, oid, &type, size);\n \tif (!*buf)\n \t\treturn error(_(\"cannot read object %s '%s'\"),\n \t\t\t     oid_to_hex(oid), path);\n@@ -206,8 +206,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\tret = stream_blob(&oid);\n \t\t\tgoto cleanup;\n \t\t}\n-\t\tbuf = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t      &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"Cannot read object %s\", obj_name);\n \n@@ -228,10 +228,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\tstruct object_id blob_oid;\n \t\t\tif (odb_read_object_info(the_repository->objects,\n \t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n-\t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t     &oid,\n-\t\t\t\t\t\t\t\t     &type,\n-\t\t\t\t\t\t\t\t     &size);\n+\t\t\t\tchar *buffer = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t       &oid, &type, &size);\n \t\t\t\tconst char *target;\n \n \t\t\t\tif (!buffer)\n@@ -412,10 +410,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\t\tif (!textconv_object(the_repository,\n \t\t\t\t\t\t     data->rest, 0100644, oid,\n \t\t\t\t\t\t     1, &contents, &size))\n-\t\t\t\t\tcontents = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t\t oid,\n-\t\t\t\t\t\t\t\t\t &type,\n-\t\t\t\t\t\t\t\t\t &size);\n+\t\t\t\t\tcontents = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t\t   oid, &type, &size);\n \t\t\t\tif (!contents)\n \t\t\t\t\tdie(\"could not convert '%s' %s\",\n \t\t\t\t\t    oid_to_hex(oid), data->rest);\n@@ -432,8 +428,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\tunsigned long size;\n \t\tvoid *contents;\n \n-\t\tcontents = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t &size);\n+\t\tcontents = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &type, &size);\n \t\tif (!contents)\n \t\t\tdie(\"object %s disappeared\", oid_to_hex(oid));\n \n@@ -542,8 +538,8 @@ static void batch_object_write(const char *obj_name,\n \t\t\tsize_t s = data->size;\n \t\t\tchar *buf = NULL;\n \n-\t\t\tbuf = repo_read_object_file(the_repository, &data->oid, &data->type,\n-\t\t\t\t\t\t    &data->size);\n+\t\t\tbuf = odb_read_object(the_repository->objects, &data->oid,\n+\t\t\t\t\t      &data->type, &data->size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"), oid_to_hex(&data->oid));\n \t\t\tbuf = replace_idents_using_mailmap(buf, &s);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex fac613e3bc3..e4bc1f83169 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -320,7 +320,7 @@ static char *get_symlink(struct repository *repo,\n \t} else {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tdata = repo_read_object_file(repo, oid, &type, &size);\n+\t\tdata = odb_read_object(repo->objects, oid, &type, &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\n \t\t\t\toid_to_hex(oid), path);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 6c93cf0a8aa..33f304dd0ad 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -323,7 +323,7 @@ static void export_blob(const struct object_id *oid)\n \t\tobject = (struct object *)lookup_blob(the_repository, oid);\n \t\teaten = 0;\n \t} else {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"could not read blob %s\", oid_to_hex(oid));\n \t\tif (check_object_signature(the_repository, oid, buf, size,\n@@ -869,8 +869,8 @@ static void handle_tag(const char *name, struct tag *tag)\n \t\treturn;\n \t}\n \n-\tbuf = repo_read_object_file(the_repository, &tag->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(\"could not read tag %s\", oid_to_hex(&tag->object.oid));\n \tmessage = memmem(buf, size, \"\\n\\n\", 2);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 2718376f2c9..1973c504e25 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf || type != OBJ_TREE)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t}\n@@ -3002,7 +3002,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \tchar *buf;\n \n \tif (!oe || oe->pack_id == MAX_PACK_ID) {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t} else {\n \t\ttype = oe->type;\n \t\tbuf = gfi_unpack_entry(oe, &size);\n@@ -3110,8 +3110,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \t\tbuf = gfi_unpack_entry(oe, &size);\n \t} else {\n \t\tenum object_type unused;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &unused,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t      &unused, &size);\n \t}\n \tif (!buf)\n \t\tdie(\"Can't load object %s\", oid_to_hex(oid));\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 311c940aa9e..f84298af0f6 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -573,8 +573,8 @@ static int grep_cache(struct grep_opt *opt,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t     &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t       &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree %s\"), oid_to_hex(&ce->oid));\n \t\t\tinit_tree_desc(&tree, &ce->oid, data, size);\n@@ -666,8 +666,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry.oid, &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry.oid, &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree (%s)\"),\n \t\t\t\t    oid_to_hex(&entry.oid));\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 82cf80b89d1..d33392cab65 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -914,8 +914,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), oid_to_hex(oid));\n-\t\thas_data = repo_read_object_file(the_repository, oid,\n-\t\t\t\t\t\t &has_type, &has_size);\n+\t\thas_data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &has_type, &has_size);\n \t\tread_unlock();\n \t\tif (!data)\n \t\t\tdata = new_data = get_data_from_pack(obj_entry);\n@@ -1515,8 +1515,8 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \n \t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n-\t\tdata = repo_read_object_file(the_repository, &d->oid, &type,\n-\t\t\t\t\t     &size);\n+\t\tdata = odb_read_object(the_repository->objects, &d->oid,\n+\t\t\t\t       &type, &size);\n \t\tif (!data)\n \t\t\tcontinue;\n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex fe9cc5ebecb..f2040b18159 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -714,7 +714,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tunsigned long offset = 0;\n \n \tif (!buf)\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 709ae3966a6..21fb0b2df1d 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -75,9 +75,9 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \tconst char *path = entry->path;\n \n \tif (!entry->stage)\n-\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t     &entry->blob->object.oid, &type,\n-\t\t\t\t\t     size);\n+\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t       &entry->blob->object.oid, &type,\n+\t\t\t\t       size);\n \tbase = NULL;\n \tif (entry->stage == 1) {\n \t\tbase = entry->blob;\n@@ -100,9 +100,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)\n \tenum object_type type;\n \twhile (entry) {\n \t\tif (entry->stage == 2)\n-\t\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry->blob->object.oid,\n-\t\t\t\t\t\t     &type, size);\n+\t\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry->blob->object.oid,\n+\t\t\t\t\t       &type, size);\n \t\tentry = entry->link;\n \t}\n \treturn NULL;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 1809b38f937..1b391119de8 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -54,8 +54,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)\n \tvoid *buffer;\n \tconst struct object_id *repl;\n \n-\tbuffer = repo_read_object_file(the_repository, tagged_oid, &type,\n-\t\t\t\t       &size);\n+\tbuffer = odb_read_object(the_repository->objects, tagged_oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\tdie(_(\"could not read tagged object '%s'\"),\n \t\t    oid_to_hex(tagged_oid));\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 783d4932ca6..a9529b1696a 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -152,7 +152,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (buf) {\n \t\tif (size)\n \t\t\twrite_or_die(fd, buf, size);\n@@ -319,7 +319,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tstrbuf_init(&msg->buf, 0);\n \tif (repo_get_oid(the_repository, arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(value = repo_read_object_file(the_repository, &object, &type, &len)))\n+\tif (!(value = odb_read_object(the_repository->objects, &object, &type, &len)))\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n \tif (type != OBJ_BLOB) {\n \t\tstrbuf_release(&msg->buf);\n@@ -722,7 +722,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,\n \t\tunsigned long size;\n \t\tenum object_type type;\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tchar *prev_buf = repo_read_object_file(the_repository, note, &type, &size);\n+\t\tchar *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \t\tif (!prev_buf)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(note));\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex da35d684081..580a5c1996b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -337,13 +337,13 @@ static void *get_delta(struct object_entry *entry)\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &entry->idx.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &entry->idx.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(_(\"unable to read %s\"), oid_to_hex(&entry->idx.oid));\n-\tbase_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t &DELTA(entry)->idx.oid, &type,\n-\t\t\t\t\t &base_size);\n+\tbase_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t   &DELTA(entry)->idx.oid, &type,\n+\t\t\t\t   &base_size);\n \tif (!base_buf)\n \t\tdie(\"unable to read %s\",\n \t\t    oid_to_hex(&DELTA(entry)->idx.oid));\n@@ -506,9 +506,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \t\t\t\t       &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n-\t\t\tbuf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t    &entry->idx.oid, &type,\n-\t\t\t\t\t\t    &size);\n+\t\t\tbuf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t      &entry->idx.oid, &type,\n+\t\t\t\t\t      &size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&entry->idx.oid));\n@@ -1895,7 +1895,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \t/* Did not find one.  Either we got a bogus request or\n \t * we need to read and perhaps cache.\n \t */\n-\tdata = repo_read_object_file(the_repository, oid, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!data)\n \t\treturn NULL;\n \tif (type != OBJ_TREE) {\n@@ -2762,9 +2762,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t/* Load data if not already done */\n \tif (!trg->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\ttrg->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &trg_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\ttrg->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &trg_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!trg->data)\n \t\t\tdie(_(\"object %s cannot be read\"),\n@@ -2777,9 +2777,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t}\n \tif (!src->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tsrc->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &src_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\tsrc->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &src_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!src->data) {\n \t\t\tif (src_entry->preferred_base) {\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex e0b27396c6b..46cbf892e34 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -244,7 +244,7 @@ static void write_tag_body(int fd, const struct object_id *oid)\n \tstruct strbuf payload = STRBUF_INIT;\n \tstruct strbuf signature = STRBUF_INIT;\n \n-\torig = buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\torig = buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn;\n \tif (parse_signature(buf, size, &payload, &signature)) {\n@@ -407,7 +407,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {\n+\t\tif ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) {\n \t\t\tsubject_len = find_commit_subject(buf, &subject_start);\n \t\t\tstrbuf_insert(sb, sb->len, subject_start, subject_len);\n \t\t} else {\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex b92fd4710a9..4360872ae07 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -14,7 +14,7 @@ static char *create_temp_file(struct object_id *oid)\n \tunsigned long size;\n \tint fd;\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 405e78bc592..4bc6575a574 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -516,8 +516,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \tif (resolve_against_held(nr, &base_oid, delta_data, delta_size))\n \t\treturn;\n \n-\tbase = repo_read_object_file(the_repository, &base_oid, &type,\n-\t\t\t\t     &base_size);\n+\tbase = odb_read_object(the_repository->objects, &base_oid,\n+\t\t\t       &type, &base_size);\n \tif (!base) {\n \t\terror(\"failed to read delta-pack base object %s\",\n \t\t      oid_to_hex(&base_oid));\ndiff --git a/bundle.c b/bundle.c\nindex c67f85126da..66d0e8eaf0e 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -305,7 +305,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n \tif (revs->max_age == -1 && revs->min_age == -1)\n \t\tgoto out;\n \n-\tbuf = repo_read_object_file(the_repository, &tag->oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->oid, &type, &size);\n \tif (!buf)\n \t\tgoto out;\n \tline = memmem(buf, size, \"\\ntagger \", 8);\ndiff --git a/combine-diff.c b/combine-diff.c\nindex cf23a753407..4ea2dc93c4f 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -325,7 +325,7 @@ static char *grab_blob(struct repository *r,\n \t\t*size = fill_textconv(r, textconv, df, &blob);\n \t\tfree_filespec(df);\n \t} else {\n-\t\tblob = repo_read_object_file(r, oid, &type, size);\n+\t\tblob = odb_read_object(r->objects, oid, &type, size);\n \t\tif (!blob)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(oid));\n \t\tif (type != OBJ_BLOB)\ndiff --git a/commit.c b/commit.c\nindex d4aa9c7a5f8..28ee6b73ae6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -374,7 +374,7 @@ const void *repo_get_commit_buffer(struct repository *r,\n \tif (!ret) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n+\t\tret = odb_read_object(r->objects, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n \t\t\t    oid_to_hex(&commit->object.oid));\n@@ -1275,8 +1275,8 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h\n \tdesc = merge_remote_util(parent);\n \tif (!desc || !desc->obj)\n \t\treturn;\n-\tbuf = repo_read_object_file(the_repository, &desc->obj->oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &desc->obj->oid,\n+\t\t\t      &type, &size);\n \tif (!buf || type != OBJ_TAG)\n \t\tgoto free_return;\n \tif (!parse_signature(buf, size, &payload, &signature))\ndiff --git a/config.c b/config.c\nindex 883dd066827..142c37215a8 100644\n--- a/config.c\n+++ b/config.c\n@@ -1942,7 +1942,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n \tunsigned long size;\n \tint ret;\n \n-\tbuf = repo_read_object_file(repo, oid, &type, &size);\n+\tbuf = odb_read_object(repo->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(_(\"unable to load config blob object '%s'\"), name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/dir.c b/dir.c\nindex e11342e1366..251dedf1f5e 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -302,7 +302,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t*size_out = 0;\n \t*data_out = NULL;\n \n-\tdata = repo_read_object_file(the_repository, oid, &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn -1;\ndiff --git a/entry.c b/entry.c\nindex 75d55038d7c..cae02eb5039 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -93,8 +93,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tunsigned long ul;\n-\tvoid *blob_data = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t&type, &ul);\n+\tvoid *blob_data = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t  &type, &ul);\n \n \t*size = ul;\n \tif (blob_data) {\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 1a8c972adf3..40174efa3de 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -526,8 +526,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t    &type, &size);\n \t\tchar *origbuf = buf;\n \t\tunsigned long len = size;\n \t\tstruct signature_check sigc = { NULL };\ndiff --git a/fsck.c b/fsck.c\nindex e69baab3af7..23965e1880f 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1293,7 +1293,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,\n \t\tif (oidset_contains(blobs_done, oid))\n \t\t\tcontinue;\n \n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf) {\n \t\t\tif (is_promisor_object(the_repository, oid))\n \t\t\t\tcontinue;\ndiff --git a/grep.c b/grep.c\nindex dc77e6c4631..932647e4a65 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1931,8 +1931,8 @@ static int grep_source_load_oid(struct grep_source *gs)\n {\n \tenum object_type type;\n \n-\tgs->buf = repo_read_object_file(gs->repo, gs->identifier, &type,\n-\t\t\t\t\t&gs->size);\n+\tgs->buf = odb_read_object(gs->repo->objects, gs->identifier,\n+\t\t\t\t  &type, &gs->size);\n \tif (!gs->buf)\n \t\treturn error(_(\"'%s': unable to read %s\"),\n \t\t\t     gs->name,\ndiff --git a/http-push.c b/http-push.c\nindex d1b1bb23711..9481825abfb 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -369,8 +369,8 @@ static void start_put(struct transfer_request *request)\n \tssize_t size;\n \tgit_zstream stream;\n \n-\tunpacked = repo_read_object_file(the_repository, &request->obj->oid,\n-\t\t\t\t\t &type, &len);\n+\tunpacked = odb_read_object(the_repository->objects, &request->obj->oid,\n+\t\t\t\t   &type, &len);\n \thdrlen = format_object_header(hdr, sizeof(hdr), type, len);\n \n \t/* Set it up */\ndiff --git a/mailmap.c b/mailmap.c\nindex b18e74c2110..56c72102d9e 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -196,7 +196,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \tif (repo_get_oid(the_repository, name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = repo_read_object_file(the_repository, &oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/match-trees.c b/match-trees.c\nindex 4704f95c340..5a8a5c39b04 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -63,7 +63,7 @@ static void *fill_tree_desc_strict(struct repository *r,\n \tenum object_type type;\n \tunsigned long size;\n \n-\tbuffer = repo_read_object_file(r, hash, &type, &size);\n+\tbuffer = odb_read_object(r->objects, hash, &type, &size);\n \tif (!buffer)\n \t\tdie(\"unable to read tree (%s)\", oid_to_hex(hash));\n \tif (type != OBJ_TREE)\n@@ -199,7 +199,7 @@ static int splice_tree(struct repository *r,\n \tif (*subpath)\n \t\tsubpath++;\n \n-\tbuf = repo_read_object_file(r, oid1, &type, &sz);\n+\tbuf = odb_read_object(r->objects, oid1, &type, &sz);\n \tif (!buf)\n \t\tdie(\"cannot read tree %s\", oid_to_hex(oid1));\n \tinit_tree_desc(&desc, oid1, buf, sz);\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex ba8a3fdfd82..6fc27994171 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -12,8 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n \tunsigned long size;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &obj->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &obj->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\treturn -1;\n \tif (type != OBJ_BLOB) {\n@@ -79,8 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path,\n \t\t\treturn NULL;\n \t\tif (!our)\n \t\t\tour = their;\n-\t\treturn repo_read_object_file(the_repository, &our->object.oid,\n-\t\t\t\t\t     &type, size);\n+\t\treturn odb_read_object(the_repository->objects, &our->object.oid,\n+\t\t\t\t       &type, size);\n \t}\n \n \tif (fill_mmfile_blob(&f1, our) < 0)\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 5d4501085e9..53417d399c7 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -3624,7 +3624,7 @@ static int read_oid_strbuf(struct merge_options *opt,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf) {\n \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n \t\t\t path, NULL, NULL, NULL,\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 344f67762b8..dd56feed6e8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -87,7 +87,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\n \t\treturn NULL;\n-\tvalue = repo_read_object_file(the_repository, value_oid, &type, &size);\n+\tvalue = odb_read_object(the_repository->objects, value_oid, &type, &size);\n \n \t*outsize = size;\n \treturn value;\ndiff --git a/notes-merge.c b/notes-merge.c\nindex de6a52e2e7f..586939939f2 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -340,7 +340,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n {\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buf = repo_read_object_file(the_repository, note, &type, &size);\n+\tvoid *buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"cannot read note %s for object %s\",\ndiff --git a/notes.c b/notes.c\nindex fc000e501d2..73eb5f00cf5 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -816,15 +816,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \n \t/* read in both note blob objects */\n \tif (!is_null_oid(new_oid))\n-\t\tnew_msg = repo_read_object_file(the_repository, new_oid,\n-\t\t\t\t\t\t&new_type, &new_len);\n+\t\tnew_msg = odb_read_object(the_repository->objects, new_oid,\n+\t\t\t\t\t  &new_type, &new_len);\n \tif (!new_msg || !new_len || new_type != OBJ_BLOB) {\n \t\tfree(new_msg);\n \t\treturn 0;\n \t}\n \tif (!is_null_oid(cur_oid))\n-\t\tcur_msg = repo_read_object_file(the_repository, cur_oid,\n-\t\t\t\t\t\t&cur_type, &cur_len);\n+\t\tcur_msg = odb_read_object(the_repository->objects, cur_oid,\n+\t\t\t\t\t  &cur_type, &cur_len);\n \tif (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {\n \t\tfree(cur_msg);\n \t\tfree(new_msg);\n@@ -880,7 +880,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\treturn 0;\n \n \t/* read_sha1_file NUL-terminates */\n-\tdata = repo_read_object_file(the_repository, oid, &t, &len);\n+\tdata = odb_read_object(the_repository->objects, oid, &t, &len);\n \tif (t != OBJ_BLOB || !data || !len) {\n \t\tfree(data);\n \t\treturn t != OBJ_BLOB || !data;\n@@ -1290,7 +1290,8 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tif (!oid)\n \t\treturn;\n \n-\tif (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {\n+\tif (!(msg = odb_read_object(the_repository->objects, oid, &type, &msglen)) ||\n+\t    type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn;\n \t}\ndiff --git a/object.c b/object.c\nindex 868d89eed42..c1553ee4330 100644\n--- a/object.c\n+++ b/object.c\n@@ -335,7 +335,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \n-\tbuffer = repo_read_object_file(r, oid, &type, &size);\n+\tbuffer = odb_read_object(r->objects, oid, &type, &size);\n \tif (buffer) {\n \t\tif (!skip_hash &&\n \t\t    check_object_signature(r, repl, buffer, size, type) < 0) {\ndiff --git a/odb.c b/odb.c\nindex 3d5d4ff8454..5202f107af2 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -30,7 +30,7 @@ KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n- * want repo_read_object_file() to be able to return, but yet you do not want\n+ * want odb_read_object() to be able to return, but yet you do not want\n  * to write them into the object store (e.g. a browse-only\n  * application).\n  */\n@@ -896,15 +896,10 @@ int pretend_object_file(struct repository *repo,\n \treturn 0;\n }\n \n-/*\n- * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call odb_read_object_info_extended() and give\n- * error messages themselves.\n- */\n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size)\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tunsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE;\n@@ -913,7 +908,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(odb, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -935,7 +930,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = repo_read_object_file(r, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\ndiff --git a/odb.h b/odb.h\nindex d75a5f9d44b..e4a3763914a 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -130,7 +130,7 @@ struct object_database {\n \n \t/*\n \t * This is meant to hold a *small* number of objects that you would\n-\t * want repo_read_object_file() to be able to return, but yet you do not want\n+\t * want odb_read_object() to be able to return, but yet you do not want\n \t * to write them into the object store (e.g. a browse-only\n \t * application).\n \t */\n@@ -249,10 +249,19 @@ void odb_add_to_alternates_file(struct object_database *odb,\n void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t\t  const char *dir);\n \n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size);\n+/*\n+ * Read an object from the database. Returns the object data and assigns object\n+ * type and size to the `type` and `size` pointers, if these pointers are\n+ * non-NULL. Returns a `NULL` pointer in case the object does not exist.\n+ *\n+ * This function dies on corrupt objects; the callers who want to deal with\n+ * them should arrange to call odb_read_object_info_extended() and give error\n+ * messages themselves.\n+ */\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size);\n \n /*\n  * Add an object file to the in-memory object store, without writing it\n@@ -363,7 +372,7 @@ void odb_assert_oid_type(struct object_database *odb,\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n- * following functions in parallel: repo_read_object_file(),\n+ * following functions in parallel: odb_read_object(),\n  * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n@@ -438,4 +447,12 @@ static inline int oid_object_info(struct repository *r,\n \treturn odb_read_object_info(r->objects, oid, sizep);\n }\n \n+static inline void *repo_read_object_file(struct repository *r,\n+\t\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t\t  enum object_type *type,\n+\t\t\t\t\t  unsigned long *size)\n+{\n+\treturn odb_read_object(r->objects, oid, type, size);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/read-cache.c b/read-cache.c\nindex be664f857b4..46986798a38 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -254,7 +254,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n \tif (strbuf_readlink(&sb, ce->name, expected_size))\n \t\treturn -1;\n \n-\tbuffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &ce->oid, &type, &size);\n \tif (buffer) {\n \t\tif (size == sb.len)\n \t\t\tmatch = memcmp(buffer, sb.buf, size);\n@@ -3514,8 +3514,8 @@ void *read_blob_data_from_index(struct index_state *istate,\n \t}\n \tif (pos < 0)\n \t\treturn NULL;\n-\tdata = repo_read_object_file(the_repository, &istate->cache[pos]->oid,\n-\t\t\t\t     &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, &istate->cache[pos]->oid,\n+\t\t\t       &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn NULL;\ndiff --git a/reflog.c b/reflog.c\nindex 4f8a3b717cd..747b82eada8 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -140,8 +140,8 @@ static int tree_is_complete(const struct object_id *oid)\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t   &size);\n+\t\tvoid *data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t     &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\treturn 0;\ndiff --git a/rerere.c b/rerere.c\nindex 951e4bf8b41..8bb97c98229 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -1000,9 +1000,8 @@ static int handle_cache(struct index_state *istate,\n \t\t\tbreak;\n \t\ti = ce_stage(ce) - 1;\n \t\tif (!mmfile[i].ptr) {\n-\t\t\tmmfile[i].ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &ce->oid, &type,\n-\t\t\t\t\t\t\t      &size);\n+\t\t\tmmfile[i].ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&ce->oid, &type, &size);\n \t\t\tif (!mmfile[i].ptr)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&ce->oid));\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 0f775f93259..2730a47fad1 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -743,8 +743,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \tif (submodule)\n \t\tgoto out;\n \n-\tconfig = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t       &config_size);\n+\tconfig = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t &type, &config_size);\n \tif (!config || type != OBJ_BLOB)\n \t\tgoto out;\n \ndiff --git a/tag.c b/tag.c\nindex 144048fd5e0..1d52686ee10 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -60,7 +60,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\t\t\trepo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),\n \t\t\t\ttype_name(type));\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n@@ -222,8 +222,8 @@ int parse_tag(struct tag *item)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tdata = repo_read_object_file(the_repository, &item->object.oid, &type,\n-\t\t\t\t     &size);\n+\tdata = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t       &type, &size);\n \tif (!data)\n \t\treturn error(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 34b0fff4873..766af99f466 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -795,9 +795,9 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\t */\n \t\t\tretval = DANGLING_SYMLINK;\n \n-\t\t\tcontents = repo_read_object_file(r,\n-\t\t\t\t\t\t    &current_tree_oid, &type,\n-\t\t\t\t\t\t    &link_len);\n+\t\t\tcontents = odb_read_object(r->objects,\n+\t\t\t\t\t\t   &current_tree_oid, &type,\n+\t\t\t\t\t\t   &link_len);\n \n \t\t\tif (!contents)\n \t\t\t\tgoto done;\ndiff --git a/tree.c b/tree.c\nindex 341b7c2ff3f..1ef743d90f4 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -193,8 +193,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tbuffer = repo_read_object_file(the_repository, &item->object.oid,\n-\t\t\t\t       &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 01e6e378ea6..0e5d38c9600 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -187,7 +187,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n \t\treturn;\n \t}\n \n-\tptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);\n+\tptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!ptr->ptr || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \tptr->size = size;\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517679","messageId":"20250509-pks-object-store-wo-the-repository-v2-15-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 15/17] odb: rename `has_object()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:15Z","receivedAt":"2025-05-09T14:12:30Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `has_object()` to `odb_has_object()` to match other functions\nrelated to the object database and our modern coding guidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  |  2 +-\n builtin/backfill.c       |  4 ++--\n builtin/cat-file.c       |  4 ++--\n builtin/clone.c          |  2 +-\n builtin/fetch.c          | 17 +++++++++--------\n builtin/fsck.c           |  2 +-\n builtin/index-pack.c     |  4 ++--\n builtin/pack-objects.c   |  4 ++--\n builtin/receive-pack.c   |  4 ++--\n builtin/remote.c         |  4 ++--\n builtin/show-ref.c       |  4 ++--\n builtin/unpack-objects.c |  4 ++--\n bulk-checkin.c           |  4 ++--\n cache-tree.c             | 15 ++++++++-------\n commit-graph.c           |  2 +-\n commit.c                 |  2 +-\n fetch-pack.c             |  8 ++++----\n http-push.c              | 14 ++++++++------\n http-walker.c            |  8 ++++----\n list-objects.c           |  4 ++--\n notes.c                  |  4 ++--\n odb.c                    |  6 +++---\n odb.h                    | 12 ++++++++++--\n reflog.c                 |  2 +-\n refs.c                   |  3 ++-\n remote.c                 |  2 +-\n send-pack.c              |  2 +-\n shallow.c                | 12 ++++++------\n upload-pack.c            |  2 +-\n walker.c                 |  4 ++--\n 30 files changed, 87 insertions(+), 74 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 56cd0540350..7fb56517649 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3204,7 +3204,7 @@ static int apply_binary(struct apply_state *state,\n \t\treturn 0; /* deletion patch */\n \t}\n \n-\tif (has_object(the_repository, &oid, 0)) {\n+\tif (odb_has_object(the_repository->objects, &oid, 0)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n \t\tunsigned long size;\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex 0b49baa39fa..80056abe473 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -67,8 +67,8 @@ static int fill_missing_blobs(const char *path UNUSED,\n \t\treturn 0;\n \n \tfor (size_t i = 0; i < list->nr; i++) {\n-\t\tif (!has_object(ctx->repo, &list->oid[i],\n-\t\t\t\tOBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_has_object(ctx->repo->objects, &list->oid[i],\n+\t\t\t\t    OBJECT_INFO_FOR_PREFETCH))\n \t\t\toid_array_append(&ctx->current_batch, &list->oid[i]);\n \t}\n \ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex d6b9afca06e..571b5cc2ad5 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -169,8 +169,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\tgoto cleanup;\n \n \tcase 'e':\n-\t\tret = !has_object(the_repository, &oid,\n-\t\t\t\t  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n+\t\tret = !odb_has_object(the_repository->objects, &oid,\n+\t\t\t\t      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n \t\tgoto cleanup;\n \n \tcase 'w':\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 3aabdf6570b..6d08abed37c 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -506,7 +506,7 @@ static void write_followtags(const struct ref *refs, const char *msg)\n \t\t\tcontinue;\n \t\tif (ends_with(ref->name, \"^{}\"))\n \t\t\tcontinue;\n-\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\tcontinue;\n \t\trefs_update_ref(get_main_ref_store(the_repository), msg,\n \t\t\t\tref->name, &ref->old_oid, NULL, 0,\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 82e9603ccab..2000299bcc5 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -366,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t */\n \t\tif (ends_with(ref->name, \"^{}\")) {\n \t\t\tif (item &&\n-\t\t\t    !has_object(the_repository, &ref->old_oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &ref->old_oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &ref->old_oid) &&\n-\t\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\t\tclear_item(item);\n \t\t\titem = NULL;\n@@ -382,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t * fetch.\n \t\t */\n \t\tif (item &&\n-\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\tclear_item(item);\n \n@@ -403,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t * checked to see if it needs fetching.\n \t */\n \tif (item &&\n-\t    !has_object(the_repository, &item->oid, 0) &&\n+\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t    !oidset_contains(&fetch_oids, &item->oid))\n \t\tclear_item(item);\n \n@@ -910,8 +910,8 @@ static int update_local_ref(struct ref *ref,\n \tstruct commit *current = NULL, *updated;\n \tint fast_forward = 0;\n \n-\tif (!has_object(the_repository, &ref->new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, &ref->new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \n \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n@@ -1330,7 +1330,8 @@ static int check_exist_and_connected(struct ref *ref_map)\n \t * we need all direct targets to exist.\n \t */\n \tfor (r = rm; r; r = r->next) {\n-\t\tif (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (!odb_has_object(the_repository->objects, &r->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED))\n \t\t\treturn -1;\n \t}\n \n@@ -1485,7 +1486,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)\n \t\t\tstruct object_id oid;\n \t\t\tif (repo_get_oid(the_repository, s, &oid))\n \t\t\t\tdie(_(\"%s is not a valid object\"), s);\n-\t\t\tif (!has_object(the_repository, &oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &oid, 0))\n \t\t\t\tdie(_(\"the object %s does not exist\"), s);\n \t\t\toid_array_append(oids, &oid);\n \t\t\tcontinue;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 08a79fe044d..74bfa182597 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -161,7 +161,7 @@ static int mark_object(struct object *obj, enum object_type type,\n \t\treturn 0;\n \n \tif (!(obj->flags & HAS_OBJ)) {\n-\t\tif (parent && !has_object(the_repository, &obj->oid, 1)) {\n+\t\tif (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {\n \t\t\tprintf_ln(_(\"broken link from %7s %s\\n\"\n \t\t\t\t    \"              to %7s %s\"),\n \t\t\t\t  printable_type(&parent->oid, parent->type),\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d33392cab65..0aa2f099cbe 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -893,8 +893,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \n \tif (startup_info->have_repository) {\n \t\tread_lock();\n-\t\tcollision_test_needed = has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_FETCH_PROMISOR);\n+\t\tcollision_test_needed = odb_has_object(the_repository->objects, oid,\n+\t\t\t\t\t\t       HAS_OBJECT_FETCH_PROMISOR);\n \t\tread_unlock();\n \t}\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 580a5c1996b..06bdeb4223b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3968,7 +3968,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void\n \t * Quietly ignore ALL missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0))\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0))\n \t\treturn;\n \n \tshow_object(obj, name, data);\n@@ -3982,7 +3982,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,\n \t * Quietly ignore EXPECTED missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0) &&\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0) &&\n \t    is_promisor_object(to_pack.repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 8c157ea7d1b..27684dce3a4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1508,8 +1508,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \t}\n \n \tif (!is_null_oid(new_oid) &&\n-\t    !has_object(the_repository, new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(\"unpack should have generated %s, \"\n \t\t      \"but I can't find it!\", oid_to_hex(new_oid));\n \t\tret = \"bad pack\";\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex ac5b8d2a1a6..7cbda285ebe 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -454,8 +454,8 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \t\t\tinfo->status = PUSH_STATUS_UPTODATE;\n \t\telse if (is_null_oid(&ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_CREATE;\n-\t\telse if (has_object(the_repository, &ref->old_oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t\telse if (odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t\t\t ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_FASTFORWARD;\n \t\telse\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 90ec1de78f9..117709cb076 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -35,8 +35,8 @@ static void show_one(const struct show_one_options *opts,\n \tconst char *hex;\n \tstruct object_id peeled;\n \n-\tif (!has_object(the_repository, oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(\"git show-ref: bad ref %s (%s)\", refname,\n \t\t    oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 4bc6575a574..a69d59eb50c 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -449,8 +449,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\tdelta_data = get_data(delta_size);\n \t\tif (!delta_data)\n \t\t\treturn;\n-\t\tif (has_object(the_repository, &base_oid,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, &base_oid,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t; /* Ok we have this one */\n \t\telse if (resolve_against_held(nr, &base_oid,\n \t\t\t\t\t      delta_data, delta_size))\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 55406a539e7..16df86c0ba8 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -130,8 +130,8 @@ static void flush_batch_fsync(void)\n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n \t/* The object may already exist in the repository */\n-\tif (has_object(the_repository, oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 1;\n \n \t/* Might want to keep the list sorted */\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 9786b32b3a1..a4bc14ad15c 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -239,8 +239,8 @@ int cache_tree_fully_valid(struct cache_tree *it)\n \tif (!it)\n \t\treturn 0;\n \tif (it->entry_count < 0 ||\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0;\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tif (!cache_tree_fully_valid(it->down[i]->cache_tree))\n@@ -292,8 +292,8 @@ static int update_one(struct cache_tree *it,\n \t}\n \n \tif (0 <= it->entry_count &&\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn it->entry_count;\n \n \t/*\n@@ -399,8 +399,9 @@ static int update_one(struct cache_tree *it,\n \t\tce_missing_ok = mode == S_IFGITLINK || missing_ok ||\n \t\t\t!must_check_existence(ce);\n \t\tif (is_null_oid(oid) ||\n-\t\t    (!ce_missing_ok && !has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n+\t\t    (!ce_missing_ok &&\n+\t\t     !odb_has_object(the_repository->objects, oid,\n+\t\t\t\t     HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n \t\t\tstrbuf_release(&buffer);\n \t\t\tif (expected_missing)\n \t\t\t\treturn -1;\n@@ -448,7 +449,7 @@ static int update_one(struct cache_tree *it,\n \t\tstruct object_id oid;\n \t\thash_object_file(the_hash_algo, buffer.buf, buffer.len,\n \t\t\t\t OBJ_TREE, &oid);\n-\t\tif (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\toidcpy(&it->oid, &oid);\n \t\telse\n \t\t\tto_invalidate = 1;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 84cfaf87639..cb81a5ce228 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1040,7 +1040,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje\n \t\treturn NULL;\n \tif (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos))\n \t\treturn NULL;\n-\tif (commit_graph_paranoia && !has_object(repo, id, 0))\n+\tif (commit_graph_paranoia && !odb_has_object(repo->objects, id, 0))\n \t\treturn NULL;\n \n \tcommit = lookup_commit(repo, id);\ndiff --git a/commit.c b/commit.c\nindex 28ee6b73ae6..15115125c36 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -575,7 +575,7 @@ int repo_parse_commit_internal(struct repository *r,\n \t\tif (commit_graph_paranoia == -1)\n \t\t\tcommit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);\n \n-\t\tif (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {\n+\t\tif (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {\n \t\t\tunparse_commit(r, &item->object.oid);\n \t\t\treturn quiet_on_missing ? -1 :\n \t\t\t\terror(_(\"commit %s exists in commit-graph but not in the object database\"),\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 0f5de1c94d1..5e74235fc06 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -142,7 +142,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \tcommit = lookup_commit_in_graph(the_repository, oid);\n \tif (commit) {\n \t\tif (mark_tags_complete_and_check_obj_db) {\n-\t\t\tif (!has_object(the_repository, oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\t\t\tdie_in_commit_graph_only(oid);\n \t\t}\n \t\treturn commit;\n@@ -770,7 +770,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,\n \t\tif (!commit) {\n \t\t\tstruct object *o;\n \n-\t\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\t\tcontinue;\n \t\t\to = parse_object(the_repository, &ref->old_oid);\n \t\t\tif (!o || o->type != OBJ_COMMIT)\n@@ -1984,8 +1984,8 @@ static void update_shallow(struct fetch_pack_args *args,\n \t\tstruct oid_array extra = OID_ARRAY_INIT;\n \t\tstruct object_id *oid = si->shallow->oid;\n \t\tfor (i = 0; i < si->shallow->nr; i++)\n-\t\t\tif (has_object(the_repository, &oid[i],\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &oid[i],\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\toid_array_append(&extra, &oid[i]);\n \t\tif (extra.nr) {\n \t\t\tsetup_alternate_shallow(&shallow_lock,\ndiff --git a/http-push.c b/http-push.c\nindex 9481825abfb..beb41732fb6 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1447,8 +1447,8 @@ static void one_remote_ref(const char *refname)\n \t * may be required for updating server info later.\n \t */\n \tif (repo->can_update_info_refs &&\n-\t    !has_object(the_repository, &ref->old_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tobj = lookup_unknown_object(the_repository, &ref->old_oid);\n \t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n \t\t\toid_to_hex(&ref->old_oid), refname);\n@@ -1653,14 +1653,16 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t\treturn error(\"Remote HEAD symrefs too deep\");\n \t\tif (is_null_oid(&head_oid))\n \t\t\treturn error(\"Unable to resolve remote HEAD\");\n-\t\tif (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &head_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", oid_to_hex(&head_oid));\n \n \t\t/* Remote branch must resolve to a known object */\n \t\tif (is_null_oid(&remote_ref->old_oid))\n \t\t\treturn error(\"Unable to resolve remote branch %s\",\n \t\t\t\t     remote_ref->name);\n-\t\tif (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &remote_ref->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, oid_to_hex(&remote_ref->old_oid));\n \n \t\t/* Remote branch must be an ancestor of remote HEAD */\n@@ -1881,8 +1883,8 @@ int cmd_main(int argc, const char **argv)\n \t\tif (!force_all &&\n \t\t    !is_null_oid(&ref->old_oid) &&\n \t\t    !ref->force) {\n-\t\t\tif (!has_object(the_repository, &ref->old_oid,\n-\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t\t    !ref_newer(&ref->peer_ref->new_oid,\n \t\t\t\t       &ref->old_oid)) {\n \t\t\t\t/*\ndiff --git a/http-walker.c b/http-walker.c\nindex 4b1cdd25a80..4e7024ebc5f 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -138,8 +138,8 @@ static int fill_active_slot(void *data UNUSED)\n \tlist_for_each_safe(pos, tmp, head) {\n \t\tobj_req = list_entry(pos, struct object_request, node);\n \t\tif (obj_req->state == WAITING) {\n-\t\t\tif (has_object(the_repository, &obj_req->oid,\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\tobj_req->state = COMPLETE;\n \t\t\telse {\n \t\t\t\tstart_object_request(obj_req);\n@@ -497,8 +497,8 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \tif (!obj_req)\n \t\treturn error(\"Couldn't find request for %s in the queue\", hex);\n \n-\tif (has_object(the_repository, &obj_req->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tif (obj_req->req)\n \t\t\tabort_http_object_request(&obj_req->req);\n \t\tabort_object_request(obj_req);\ndiff --git a/list-objects.c b/list-objects.c\nindex c50b9578584..42c17d95739 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -74,8 +74,8 @@ static void process_blob(struct traversal_context *ctx,\n \t * of missing objects.\n \t */\n \tif (ctx->revs->exclude_promisor_objects &&\n-\t    !has_object(the_repository, &obj->oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t    !odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t    is_promisor_object(ctx->revs->repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/notes.c b/notes.c\nindex 73eb5f00cf5..97b995f3f2d 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -794,8 +794,8 @@ static int prune_notes_helper(const struct object_id *object_oid,\n \tstruct note_delete_list **l = (struct note_delete_list **) cb_data;\n \tstruct note_delete_list *n;\n \n-\tif (has_object(the_repository, object_oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, object_oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0; /* nothing to do for this note */\n \n \t/* failed to find object => prune this note */\ndiff --git a/odb.c b/odb.c\nindex 5202f107af2..787611c8f60 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -880,7 +880,7 @@ int pretend_object_file(struct repository *repo,\n \tchar *co_buf;\n \n \thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (has_object(repo, oid, 0) ||\n+\tif (odb_has_object(repo->objects, oid, 0) ||\n \t    find_cached_object(repo->objects, oid))\n \t\treturn 0;\n \n@@ -962,7 +962,7 @@ void *read_object_with_reference(struct repository *r,\n \t}\n }\n \n-int has_object(struct repository *r, const struct object_id *oid,\n+int odb_has_object(struct object_database *odb, const struct object_id *oid,\n \t       unsigned flags)\n {\n \tunsigned object_info_flags = 0;\n@@ -974,7 +974,7 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\ndiff --git a/odb.h b/odb.h\nindex e4a3763914a..3d38f1ebe60 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -364,8 +364,9 @@ enum {\n  * Returns 1 if the object exists. This function will not lazily fetch objects\n  * in a partial clone by default.\n  */\n-int has_object(struct repository *r, const struct object_id *oid,\n-\t       unsigned flags);\n+int odb_has_object(struct object_database *odb,\n+\t\t   const struct object_id *oid,\n+\t\t   unsigned flags);\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect);\n@@ -455,4 +456,11 @@ static inline void *repo_read_object_file(struct repository *r,\n \treturn odb_read_object(r->objects, oid, type, size);\n }\n \n+static inline int has_object(struct repository *r,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     unsigned flags)\n+{\n+\treturn odb_has_object(r->objects, oid, flags);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/reflog.c b/reflog.c\nindex 747b82eada8..39c205fd26e 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -152,7 +152,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tinit_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size);\n \tcomplete = 1;\n \twhile (tree_entry(&desc, &entry)) {\n-\t\tif (!has_object(the_repository, &entry.oid,\n+\t\tif (!odb_has_object(the_repository->objects, &entry.oid,\n \t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/refs.c b/refs.c\nindex 82a70b502f8..d6475d5e745 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -376,7 +376,8 @@ int ref_resolves_to_object(const char *refname,\n {\n \tif (flags & REF_ISBROKEN)\n \t\treturn 0;\n-\tif (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (!odb_has_object(repo->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(_(\"%s does not point to a valid object!\"), refname);\n \t\treturn 0;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 72c36239d31..5edf2a9f4b2 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1703,7 +1703,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\tif (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {\n \t\t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n-\t\t\telse if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\t\telse if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n \t\t\telse if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||\n \t\t\t\t !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))\ndiff --git a/send-pack.c b/send-pack.c\nindex abca2dd38a7..d029f748232 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -45,7 +45,7 @@ int option_parse_push_signed(const struct option *opt,\n static void feed_object(struct repository *r,\n \t\t\tconst struct object_id *oid, FILE *fh, int negative)\n {\n-\tif (negative && !has_object(r, oid, 0))\n+\tif (negative && !odb_has_object(r->objects, oid, 0))\n \t\treturn;\n \n \tif (negative)\ndiff --git a/shallow.c b/shallow.c\nindex d379756e39a..ef3adb635fd 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -310,8 +310,8 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n \tif (graft->nr_parent != -1)\n \t\treturn 0;\n \tif (data->flags & QUICK) {\n-\t\tif (!has_object(the_repository, &graft->oid,\n-\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &graft->oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn 0;\n \t} else if (data->flags & SEEN_ONLY) {\n \t\tstruct commit *c = lookup_commit(the_repository, &graft->oid);\n@@ -477,8 +477,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)\n \tALLOC_ARRAY(info->ours, sa->nr);\n \tALLOC_ARRAY(info->theirs, sa->nr);\n \tfor (size_t i = 0; i < sa->nr; i++) {\n-\t\tif (has_object(the_repository, sa->oid + i,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\tif (odb_has_object(the_repository->objects, sa->oid + i,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t\tstruct commit_graft *graft;\n \t\t\tgraft = lookup_commit_graft(the_repository,\n \t\t\t\t\t\t    &sa->oid[i]);\n@@ -515,8 +515,8 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)\n \tfor (i = dst = 0; i < info->nr_theirs; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->theirs[dst] = info->theirs[i];\n-\t\tif (has_object(the_repository, oid + info->theirs[i],\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, oid + info->theirs[i],\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\tdst++;\n \t}\n \tinfo->nr_theirs = dst;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex cec12cb478a..98cda156434 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -509,7 +509,7 @@ static int got_oid(struct upload_pack_data *data,\n {\n \tif (get_oid_hex(hex, oid))\n \t\tdie(\"git upload-pack: expected SHA1 object, got '%s'\", hex);\n-\tif (!has_object(the_repository, oid, 0))\n+\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\treturn -1;\n \treturn do_got_oid(data, oid);\n }\ndiff --git a/walker.c b/walker.c\nindex a8abe8a2e78..d131af04c7b 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -150,8 +150,8 @@ static int process(struct walker *walker, struct object *obj)\n \t\treturn 0;\n \tobj->flags |= SEEN;\n \n-\tif (has_object(the_repository, &obj->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t/* We already have it, so we should scan it now. */\n \t\tobj->flags |= TO_SCAN;\n \t}\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517680","messageId":"20250509-pks-object-store-wo-the-repository-v2-16-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 16/17] odb: rename `pretend_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:16Z","receivedAt":"2025-05-09T14:12:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `pretend_object_file()` to `odb_pretend_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nNo compatibility wrapper is introduces as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n blame.c |  3 ++-\n odb.c   | 18 +++++++++---------\n odb.h   |  6 +++---\n 3 files changed, 14 insertions(+), 13 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 858d2d74df9..dce5c8d855c 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -277,7 +277,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \tconvert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);\n \torigin->file.ptr = buf.buf;\n \torigin->file.size = buf.len;\n-\tpretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);\n+\todb_pretend_object(the_repository->objects, buf.buf, buf.len,\n+\t\t\t   OBJ_BLOB, &origin->blob_oid);\n \n \t/*\n \t * Read the current index, replace the path entry with\ndiff --git a/odb.c b/odb.c\nindex 787611c8f60..dfebeb4c8c0 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -872,21 +872,21 @@ int odb_read_object_info(struct object_database *odb,\n \treturn type;\n }\n \n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid)\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid)\n {\n \tstruct cached_object_entry *co;\n \tchar *co_buf;\n \n-\thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (odb_has_object(repo->objects, oid, 0) ||\n-\t    find_cached_object(repo->objects, oid))\n+\thash_object_file(odb->repo->hash_algo, buf, len, type, oid);\n+\tif (odb_has_object(odb, oid, 0) ||\n+\t    find_cached_object(odb, oid))\n \t\treturn 0;\n \n-\tALLOC_GROW(repo->objects->cached_objects,\n-\t\t   repo->objects->cached_object_nr + 1, repo->objects->cached_object_alloc);\n-\tco = &repo->objects->cached_objects[repo->objects->cached_object_nr++];\n+\tALLOC_GROW(odb->cached_objects,\n+\t\t   odb->cached_object_nr + 1, odb->cached_object_alloc);\n+\tco = &odb->cached_objects[odb->cached_object_nr++];\n \tco->value.size = len;\n \tco->value.type = type;\n \tco_buf = xmalloc(len);\ndiff --git a/odb.h b/odb.h\nindex 3d38f1ebe60..911448f4d42 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -271,9 +271,9 @@ void *odb_read_object(struct object_database *odb,\n  * object in persistent storage before writing any other new objects\n  * that reference it.\n  */\n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid);\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid);\n \n struct object_info {\n \t/* Request */\n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517681","messageId":"20250509-pks-object-store-wo-the-repository-v2-17-103f59bf8e28@pks.im","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"[PATCH v2 17/17] odb: rename `read_object_with_reference()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-09T14:12:17Z","receivedAt":"2025-05-09T14:12:33Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `read_object_with_reference()` to `odb_read_object_peeled()` to\nmatch other functions related to the object database and our modern\ncoding guidelines. Furthermore though, the old name didn't really\ndescribe very well what this function actually does, which is to walk\ndown any commit and tag objects until an object of the required type has\nbeen found. This is generally referred to as \"peeling\", so the new name\nshould be way more descriptive.\n\nNo compatibility wrapper is introduces as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/user-manual.adoc |  4 ++--\n builtin/cat-file.c             |  4 ++--\n builtin/fast-import.c          | 19 ++++++++-----------\n builtin/grep.c                 |  9 +++------\n builtin/pack-objects.c         |  4 ++--\n odb.c                          | 17 +++++++++--------\n odb.h                          | 15 +++++++--------\n tree-walk.c                    | 10 ++++------\n 8 files changed, 37 insertions(+), 45 deletions(-)\n\ndiff --git a/Documentation/user-manual.adoc b/Documentation/user-manual.adoc\nindex d2b478ad232..e86b2ad9f8a 100644\n--- a/Documentation/user-manual.adoc\n+++ b/Documentation/user-manual.adoc\n@@ -4301,11 +4301,11 @@ Now, for the meat:\n \n -----------------------------------------------------------------------------\n         case 0:\n-                buf = read_object_with_reference(sha1, argv[1], &size, NULL);\n+                buf = odb_read_object_peeled(r->objects, sha1, argv[1], &size, NULL);\n -----------------------------------------------------------------------------\n \n This is how you read a blob (actually, not only a blob, but any type of\n-object).  To know how the function `read_object_with_reference()` actually\n+object).  To know how the function `odb_read_object_peeled()` actually\n works, find the source code for it (something like `git grep\n read_object_with | grep \":[a-z]\"` in the Git repository), and read\n the source.\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 571b5cc2ad5..ed0fce9b490 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -255,8 +255,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t * fall-back to the usual case.\n \t\t\t */\n \t\t}\n-\t\tbuf = read_object_with_reference(the_repository, &oid,\n-\t\t\t\t\t\t exp_type_id, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &oid,\n+\t\t\t\t\t     exp_type_id, &size, NULL);\n \n \t\tif (use_mailmap) {\n \t\t\tsize_t s = size;\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 1973c504e25..b1389c59211 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -2535,10 +2535,9 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!repo_get_oid(the_repository, p, &commit_oid)) {\n \t\tunsigned long size;\n-\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t       &commit_oid,\n-\t\t\t\t\t\t       OBJ_COMMIT, &size,\n-\t\t\t\t\t\t       &commit_oid);\n+\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t   &commit_oid, OBJ_COMMIT, &size,\n+\t\t\t\t\t\t   &commit_oid);\n \t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\tdie(\"Not a valid commit: %s\", p);\n \t\tfree(buf);\n@@ -2604,9 +2603,8 @@ static void parse_from_existing(struct branch *b)\n \t\tunsigned long size;\n \t\tchar *buf;\n \n-\t\tbuf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t &b->oid, OBJ_COMMIT, &size,\n-\t\t\t\t\t\t &b->oid);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &b->oid,\n+\t\t\t\t\t     OBJ_COMMIT, &size, &b->oid);\n \t\tparse_from_commit(b, buf, size);\n \t\tfree(buf);\n \t}\n@@ -2699,10 +2697,9 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!repo_get_oid(the_repository, from, &n->oid)) {\n \t\t\tunsigned long size;\n-\t\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t\t       &n->oid,\n-\t\t\t\t\t\t\t       OBJ_COMMIT,\n-\t\t\t\t\t\t\t       &size, &n->oid);\n+\t\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t\t   &n->oid, OBJ_COMMIT,\n+\t\t\t\t\t\t\t   &size, &n->oid);\n \t\t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\t\tdie(\"Not a valid commit: %s\", from);\n \t\t\tfree(buf);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex f84298af0f6..7619479ddad 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -522,9 +522,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tobj_read_lock();\n \t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n-\t\tdata = read_object_with_reference(subrepo,\n-\t\t\t\t\t\t  oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(subrepo->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \n@@ -705,9 +703,8 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \n-\t\tdata = read_object_with_reference(opt->repo,\n-\t\t\t\t\t\t  &obj->oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(opt->repo->objects, &obj->oid,\n+\t\t\t\t\t      OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(&obj->oid));\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 06bdeb4223b..e88a13dbb9f 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2055,8 +2055,8 @@ static void add_preferred_base(struct object_id *oid)\n \tif (window <= num_preferred_base++)\n \t\treturn;\n \n-\tdata = read_object_with_reference(the_repository, oid,\n-\t\t\t\t\t  OBJ_TREE, &size, &tree_oid);\n+\tdata = odb_read_object_peeled(the_repository->objects, oid,\n+\t\t\t\t      OBJ_TREE, &size, &tree_oid);\n \tif (!data)\n \t\treturn;\n \ndiff --git a/odb.c b/odb.c\nindex dfebeb4c8c0..fd7fe398d2d 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -914,11 +914,11 @@ void *odb_read_object(struct object_database *odb,\n \treturn data;\n }\n \n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *actual_oid_return)\n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *actual_oid_return)\n {\n \tenum object_type type;\n \tvoid *buffer;\n@@ -930,7 +930,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(odb, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\n@@ -950,9 +950,10 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n+\t\tif (ref_length + odb->repo->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid,\n+\t\t\t\t      odb->repo->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\ndiff --git a/odb.h b/odb.h\nindex 911448f4d42..0f26ee3216c 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -263,6 +263,12 @@ void *odb_read_object(struct object_database *odb,\n \t\t      enum object_type *type,\n \t\t      unsigned long *size);\n \n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *oid_ret);\n+\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -374,7 +380,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: odb_read_object(),\n- * read_object_with_reference(), odb_read_object_info() and odb().\n+ * odb_read_object_peeled(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -423,13 +429,6 @@ enum for_each_object_flags {\n \tFOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),\n };\n \n-\n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *oid_ret);\n-\n /* Compatibility wrappers, to be removed once Git 2.50 has been released. */\n #include \"repository.h\"\n \ndiff --git a/tree-walk.c b/tree-walk.c\nindex 766af99f466..e449a1320e5 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -90,7 +90,7 @@ void *fill_tree_descriptor(struct repository *r,\n \tvoid *buf = NULL;\n \n \tif (oid) {\n-\t\tbuf = read_object_with_reference(r, oid, OBJ_TREE, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(r->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!buf)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \t}\n@@ -611,7 +611,7 @@ int get_tree_entry(struct repository *r,\n \tunsigned long size;\n \tstruct object_id root;\n \n-\ttree = read_object_with_reference(r, tree_oid, OBJ_TREE, &size, &root);\n+\ttree = odb_read_object_peeled(r->objects, tree_oid, OBJ_TREE, &size, &root);\n \tif (!tree)\n \t\treturn -1;\n \n@@ -681,10 +681,8 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n \t\t\tunsigned long size;\n-\t\t\ttree = read_object_with_reference(r,\n-\t\t\t\t\t\t\t  &current_tree_oid,\n-\t\t\t\t\t\t\t  OBJ_TREE, &size,\n-\t\t\t\t\t\t\t  &root);\n+\t\t\ttree = odb_read_object_peeled(r->objects, &current_tree_oid,\n+\t\t\t\t\t\t      OBJ_TREE, &size, &root);\n \t\t\tif (!tree)\n \t\t\t\tgoto done;\n \n\n-- \n2.49.0.1077.gc0e912fd4c.dirty\n\n"},{"id":"517715","messageId":"xmqq8qn5zci8.fsf@gitster.g","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im","subject":"Re: [PATCH v2 00/17] object-store: carve out the object database subsystem","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-09T21:43:11Z","receivedAt":"2025-05-09T21:43:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Changes in v2:\n>   - Fix for a copy-and-pasted commit message.\n>   - Rename `struct odb_backend` to `struct odb_alternate`. I'm happy to\n>     revert to the previous name if we ultimately think it's the better\n>     suited one.\n\nDiff between the previous iteration is quite noisy due to this; I do\nnot have strong opinion for or against either name myself.\n\n>   - A couple of fixes to move changes into the correct commit. `git\n>     rebase -x 'meson compile -C build'` is now clean.\n\nGood to see that we care about bisectability.\n\n>   - I _didn't_ back out the rename to \"odb.{c,h}\". Junio has already\n>     fixed the fallout, so it's probably more work for him to kick it out\n>     again than to just leave it in.\n\nYou do not have to make me an excuse, if popular demand is not to\nrename; I can cope with either one fine.\n\nWill replace, thanks.\n"},{"id":"517892","messageId":"35622599-c127-438b-9646-591bdfa7e1ae@gmail.com","threadId":"63403","inReplyTo":"aB3mKS2aSQMKB0xo@pks.im","subject":"Re: [PATCH 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-12T18:28:39Z","receivedAt":"2025-05-12T18:29:02Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/9/2025 7:25 AM, Patrick Steinhardt wrote:\n> On Tue, May 06, 2025 at 09:21:15PM -0400, Derrick Stolee wrote:\n>> On 5/6/25 7:09 AM, Patrick Steinhardt wrote:\n>>> There are a couple of iterator-style functions that execute a callback\n>>> for each instance of a given set, all of which currently depend on\n>>> `the_repository`. Refactor them to instead take an object database as\n>>> parameter so that we can get rid of this dependency.\n>> ...\n>>> +/*\n>>> + * Iterate through all backends of the database and execute the provided\n>>> + * callback function for each of them. Stop iterating once the callback\n>>> + * function returns a non-zero value, in which case the value is bubbled up\n>>> + * from the callback.\n>>> + */\n>>> +typedef int odb_for_each_backend_fn(struct odb_backend *, void *);\n>>> +int odb_for_each_backend(struct object_database *odb,\n>>> +\t\t\t odb_for_each_backend_fn cb, void *payload);\n>>> +\n>>> +/*\n>>> + * Iterate through all alternative object backends of the database and yield\n>>> + * their respective references.\n>>> + */\n>>> +typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n>>> +void odb_for_each_alternate_ref(struct object_database *odb,\n>>> +\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n>>> +\n>>\n>> Here's another occasion where we should be careful about how we rename\n>> an \"alternate odb\". What is an \"alternate ref\" if we have different 'odb\n>> backend's (or slices/shards/odbs etc.). Should we be updating the term\n>> \"alternate ref\" here?\n>>\n>> Changing 'alternate ref' would be quite difficult seeing how it is based\n>> on the 'core.alternateRefsCommand' and 'core.alternateRefsPrefix' config\n>> keys.\n>>\n>> Perhaps this is motivation to keep the word 'alternate' but as a way to\n>> differentiate the repo's odb from ones it is borrowing.\n> \n> Yeah, the next iteration will call things `odb_alternate` instead of\n> `odb_backend`, which I think makes a lot of the terminology fall out\n> naturally. The only thing that may be confusing at first is that we also\n> have a \"primary alternate\" now, but I think that's bearable.\n\nI like odb_alternate over odb_backend. Thanks.\n\n-Stolee\n"},{"id":"517893","messageId":"21bccc17-7e8a-47cc-a48f-de16bf075e54@gmail.com","threadId":"63403","inReplyTo":"xmqq8qn5zci8.fsf@gitster.g","subject":"Re: [PATCH v2 00/17] object-store: carve out the object database subsystem","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-05-12T18:33:28Z","receivedAt":"2025-05-12T18:33:30Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/9/2025 5:43 PM, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n>> Changes in v2:\n>>   - Fix for a copy-and-pasted commit message.\n>>   - Rename `struct odb_backend` to `struct odb_alternate`. I'm happy to\n>>     revert to the previous name if we ultimately think it's the better\n>>     suited one.\n> \n> Diff between the previous iteration is quite noisy due to this; I do\n> not have strong opinion for or against either name myself.\n\nI agree the range-diff is noisy, so I had to reread the patches.\n\nThankfully, the patch organization was already pretty good, so\nit was quick to validate that my earlier concerns were handled. \n>>   - A couple of fixes to move changes into the correct commit. `git\n>>     rebase -x 'meson compile -C build'` is now clean.\n> \n> Good to see that we care about bisectability.\n> \n>>   - I _didn't_ back out the rename to \"odb.{c,h}\". Junio has already\n>>     fixed the fallout, so it's probably more work for him to kick it out\n>>     again than to just leave it in.\n> \n> You do not have to make me an excuse, if popular demand is not to\n> rename; I can cope with either one fine.\nI'm happy that you considered my advice as necessary.\n\nSince the rename doesn't appear to have huge implications for\nongoing series, I won't voice any further objections to this\nrename.\n\nv2 LGTM.\n\nThanks,\n-Stolee\n\n"},{"id":"517976","messageId":"87cyccjopz.fsf@iotcl.com","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-1-103f59bf8e28@pks.im","subject":"Re: [PATCH v2 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-05-13T19:27:20Z","receivedAt":"2025-05-13T19:27:36Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> The `raw_object_store` structure is the central entry point for reading\n> and writing objects in a repository. The main purpose of this structure\n> is to manage object directories and provide an interface to access and\n> write objects in those object directories.\n>\n> Right now, many of the functions associated with the raw object store\n> implicitly rely on `the_repository` to get access to its `objects`\n> pointer, which is the `raw_object_store`. As we want to generally get\n> rid of using `the_repository` across our codebase we will have to\n> convert this implicit dependency on this global variable into an\n> explicit parameter.\n>\n> This conversion can be done by simply passing in an explicit pointer to\n> a repository and then using its `->objects` pointer. But there is a\n> second effort underway, which is to make the object subsystem more\n> selfcontained so that we can eventually have pluggale object backends.\n\nTiniest nit, but worth mentioning in case of a reroll:\n\ns/pluggale/pluggable/\n\n--\nToon\n"},{"id":"517977","messageId":"87bjrwjoov.fsf@iotcl.com","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-2-103f59bf8e28@pks.im","subject":"Re: [PATCH v2 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-05-13T19:28:00Z","receivedAt":"2025-05-13T19:28:11Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> The `object_directory` structure is used as an access point for a single\n> object directory like \".git/objects\". While the structure isn't yet\n> fully self-contained, the intent is for it to eventually contain all\n> information required to access objects in one specific location.\n>\n> While the name \"object directory\" is a good fit for now, this will\n> change over time as we continue with the agenda to make pluggable object\n> databases a thing. Eventually, objects may not be accessed via any kind\n> of directory at all anymore, but they could instead be backed by any\n> kind of durable storage mechanism. While it seems quite far-fetched for\n> now, it is thinkable that eventually this might even be some form of a\n> database, for example.\n>\n> As such, the current name of this structure will become worse over time\n> as we evolve into the direction of pluggable ODBs. Immediate next steps\n> will start to carve out proper self-contained object directories, which\n> requires us to pass in these object directories as parameters. Based on\n> our modern naming schema this means that those functions should then be\n> named after their subsystem, which means that we would start to bake the\n> current name into the codebase more and more.\n>\n> Let's preempt this by renaming the structure to `odb_alternate` now\n> already. This name is agnostic of how exactly objects are stored while\n> still specifically pinpointing that this is about an alternate object\n> database. In the future, it allows us to easily introduce e.g. a\n> `odb_files_alternate` and other specific implementations over time.\n>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  builtin/commit-graph.c      |  18 +++----\n>  builtin/count-objects.c     |   4 +-\n>  builtin/fetch.c             |   2 +-\n>  builtin/fsck.c              |  14 ++---\n>  builtin/gc.c                |  14 ++---\n>  builtin/grep.c              |   2 +-\n>  builtin/multi-pack-index.c  |   4 +-\n>  builtin/submodule--helper.c |   6 +--\n>  bundle.c                    |   2 +-\n>  commit-graph.c              |  94 +++++++++++++++++-----------------\n>  commit-graph.h              |  14 ++---\n>  diagnose.c                  |   8 +--\n>  http-walker.c               |   2 +-\n>  http.c                      |   4 +-\n>  loose.c                     |  42 +++++++--------\n>  midx.c                      |   6 +--\n>  object-file.c               |  80 ++++++++++++++---------------\n>  object-file.h               |   8 +--\n>  object-name.c               |   6 +--\n>  object-store.c              | 122 ++++++++++++++++++++++----------------------\n>  object-store.h              |  25 +++++----\n>  packfile.c                  |  16 +++---\n>  path.c                      |   2 +-\n>  refs.c                      |   2 +-\n>  repository.c                |  14 ++---\n>  submodule-config.c          |   2 +-\n>  t/helper/test-read-graph.c  |   6 +--\n>  tmp-objdir.c                |  24 ++++-----\n>  28 files changed, 273 insertions(+), 270 deletions(-)\n\n[snip]\n\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 53da2116ddf..cd7db11d825 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -1582,7 +1582,7 @@ static const char alternate_error_advice[] = N_(\n>  );\n>  \n>  static int add_possible_reference_from_superproject(\n> -\t\tstruct object_directory *odb, void *sas_cb)\n> +\t\tstruct odb_alternate *alt_odb, void *sas_cb)\n>  {\n>  \tstruct submodule_alternate_setup *sas = sas_cb;\n>  \tsize_t len;\n> @@ -1591,12 +1591,12 @@ static int add_possible_reference_from_superproject(\n>  \t * If the alternate object store is another repository, try the\n\nThis comment reads weirdly if an \"alternate\" is a location where objects\nare stored. Maybe say something like:\n\n    * It the alternate resides in another repository, try the\n\n>  \t * standard layout with .git/(modules/<name>)+/objects\n>  \t */\n> -\tif (strip_suffix(odb->path, \"/objects\", &len)) {\n> +\tif (strip_suffix(alt_odb->path, \"/objects\", &len)) {\n>  \t\tstruct repository alternate;\n>  \t\tchar *sm_alternate;\n>  \t\tstruct strbuf sb = STRBUF_INIT;\n>  \t\tstruct strbuf err = STRBUF_INIT;\n> -\t\tstrbuf_add(&sb, odb->path, len);\n> +\t\tstrbuf_add(&sb, alt_odb->path, len);\n>  \n>  \t\tif (repo_init(&alternate, sb.buf, NULL) < 0)\n>  \t\t\tdie(_(\"could not get a repository handle for gitdir '%s'\"),\n\n[snip]\n\n> diff --git a/object-file.h b/object-file.h\n> index a85b2e5b494..f1601200938 100644\n> --- a/object-file.h\n> +++ b/object-file.h\n> @@ -24,23 +24,23 @@ enum {\n>  int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n>  int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n>  \n> -struct object_directory;\n> +struct odb_alternate;\n>  \n>  /*\n>   * Populate and return the loose object cache array corresponding to the\n>   * given object ID.\n>   */\n> -struct oidtree *odb_loose_cache(struct object_directory *odb,\n> +struct oidtree *odb_loose_cache(struct odb_alternate *alternate,\n>  \t\t\t\tconst struct object_id *oid);\n>  \n>  /* Empty the loose object cache for the specified object directory. */\n\nAlso here s/directory/alternate/ ? Or database?\n\n> -void odb_clear_loose_cache(struct object_directory *odb);\n> +void odb_clear_loose_cache(struct odb_alternate *alternate);\n>  \n>  /*\n>   * Put in `buf` the name of the file in the local object database that\n>   * would be used to store a loose object with the specified oid.\n>   */\n\nNot sure if we should use \"alternate\" here?\n\n> -const char *odb_loose_path(struct object_directory *odb,\n> +const char *odb_loose_path(struct odb_alternate *alternate,\n>  \t\t\t   struct strbuf *buf,\n>  \t\t\t   const struct object_id *oid);\n>  \n> diff --git a/object-name.c b/object-name.c\n> index 9288b2dd245..b83ba882b9e 100644\n> --- a/object-name.c\n> +++ b/object-name.c\n> @@ -112,10 +112,10 @@ static enum cb_next match_prefix(const struct object_id *oid, void *arg)\n>  \n>  static void find_short_object_filename(struct disambiguate_state *ds)\n>  {\n> -\tstruct object_directory *odb;\n> +\tstruct odb_alternate *alternate;\n>  \n> -\tfor (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next)\n> -\t\toidtree_each(odb_loose_cache(odb, &ds->bin_pfx),\n> +\tfor (alternate = ds->repo->objects->alternates; alternate && !ds->ambiguous; alternate = alternate->next)\n> +\t\toidtree_each(odb_loose_cache(alternate, &ds->bin_pfx),\n>  \t\t\t\t&ds->bin_pfx, ds->len, match_prefix, ds);\n>  }\n\n[snip]\n\n> diff --git a/object-store.h b/object-store.h\n> index 34b8efbbb83..2dda6e85388 100644\n> --- a/object-store.h\n> +++ b/object-store.h\n> @@ -12,8 +12,11 @@ struct oidtree;\n>  struct strbuf;\n>  struct repository;\n>  \n> -struct object_directory {\n> -\tstruct object_directory *next;\n> +/*\n> + * An alternate part of an object database that stores the actual objects.\n\nI'm having a hard time trying to understand what you're saying here.\nWhat do you think about:\n\n    * The alternate is the part of the object database that stores the actual objects.\n\n> + */\n> +struct odb_alternate {\n> +\tstruct odb_alternate *next;\n>  \n>  \t/*\n>  \t * Used to store the results of readdir(3) calls when we are OK\n> @@ -52,8 +55,8 @@ struct object_directory {\n>  void prepare_alt_odb(struct repository *r);\n>  int has_alt_odb(struct repository *r);\n>  char *compute_alternate_path(const char *path, struct strbuf *err);\n> -struct object_directory *find_odb(struct repository *r, const char *obj_dir);\n> -typedef int alt_odb_fn(struct object_directory *, void *);\n> +struct odb_alternate *find_odb(struct repository *r, const char *obj_dir);\n> +typedef int alt_odb_fn(struct odb_alternate *, void *);\n>  int foreach_alt_odb(alt_odb_fn, void*);\n>  typedef void alternate_ref_fn(const struct object_id *oid, void *);\n>  void for_each_alternate_ref(alternate_ref_fn, void *);\n> @@ -75,12 +78,12 @@ void add_to_alternates_memory(const char *dir);\n>   * Replace the current writable object directory with the specified temporary\n>   * object directory; returns the former primary object directory.\n>   */\n> -struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy);\n> +struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy);\n>  \n>  /*\n>   * Restore a previous ODB replaced by set_temporary_main_odb.\n>   */\n> -void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);\n> +void restore_primary_odb(struct odb_alternate *restore_alternate, const char *old_path);\n>  \n>  struct packed_git;\n>  struct multi_pack_index;\n> @@ -88,7 +91,7 @@ struct cached_object_entry;\n>  \n>  /*\n>   * The object database encapsulates access to objects in a repository. It\n> - * manages one or more backends that store the actual objects which are\n> + * manages one or more alternates that store the actual objects which are\n>   * configured via alternates.\n>   */\n>  struct object_database {\n> @@ -97,16 +100,16 @@ struct object_database {\n>  \t * cannot be NULL after initialization). Subsequent directories are\n>  \t * alternates.\n>  \t */\n\nThe full original comment can use some love too:\n\n    *\n    * Set of all object directories; the main directory is first (and\n    * cannot be NULL after initialization). Subsequent directories are\n    * alternates.\n    */\n\nHow about:\n\n    *\n    * Set of all alternates, storing the actual objects.\n    * The primary alternate is first (and cannot be NULL after\n    * & initialization). More alternates are optional.\n    */\n\n\n> -\tstruct object_directory *odb;\n> -\tstruct object_directory **odb_tail;\n> -\tstruct kh_odb_path_map *odb_by_path;\n> +\tstruct odb_alternate *alternates;\n> +\tstruct odb_alternate **alternates_tail;\n> +\tstruct kh_odb_path_map *alternate_by_path;\n>  \n>  \tint loaded_alternates;\n>  \n>  \t/*\n>  \t * A list of alternate object directories loaded from the environment;\n>  \t * this should not generally need to be accessed directly, but will\n> -\t * populate the \"odb\" list when prepare_alt_odb() is run.\n> +\t * populate the \"alternates\" list when prepare_alt_odb() is run.\n>  \t */\n>  \tchar *alternate_db;\n>  \n\n[snip]\n\nHuge patch, I scrolled through the changes, but focused on some naming\nand comments.\n\n--\nToon\n"},{"id":"517978","messageId":"87a57gjoo1.fsf@iotcl.com","threadId":"63403","inReplyTo":"aB3mMtoxCcaOFn0W@pks.im","subject":"Re: [PATCH 00/17] object-store: carve out the object database subsystem","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-05-13T19:28:30Z","receivedAt":"2025-05-13T19:28:41Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> ... I have decided to rename this to `odb_alternate`. I don't think\n> \"shard\" works well, as shard is an extremely generic term that doesn't\n> really convey much meaning.\n>\n> On the other hand, I think that `odb_alternate` is quite a good fit. We\n> already use it all over the place to mean almost exactly what we are\n> after here. And it doesn't seem far-fetched to have an\n> `odb_packed_alternate`, `odb_loose_alternate` and `odb_redis_alternate`\n> for different backends.\n\nSo a database is a collection of alternates? And the alternates are\nstored as a linked list?\n\n> The only stretch is that the primary object directory is now the primary\n> alternate. I think that this is acceptable though'\n\nThis is a very important nuance, and with that knowledge it starts to\nclick with me. I didn't read this in the commit messages though, so I\nthink it's worth adding something about that in [PATCH 02/17].\n\n-- \nToon\n"},{"id":"517979","messageId":"878qn0jonh.fsf@iotcl.com","threadId":"63403","inReplyTo":"20250509-pks-object-store-wo-the-repository-v2-3-103f59bf8e28@pks.im","subject":"Re: [PATCH v2 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-05-13T19:28:50Z","receivedAt":"2025-05-13T19:29:00Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> In the preceding commits we have renamed the structures contained in\n> \"object-store.h\" to `struct object_database` and `struct odb_backend`.\n> As such, the code files \"object-store.{c,h}\" are confusingly named now.\n> Rename them to \"odb.{c,h}\" accordingly.\n\nDo we have plans to extract the object database subsystem into a\nsubdirectory? With us adding multiple backends in the future, I can\nimage us having a dozen files at some point. So since we're renaming,\nshall we prepare for that at once? Or will `odb.h` always be the root-level\nentry point for the object database, and only live backends live in\n`odb/` for example?\n\n--\nToon\n"},{"id":"517996","messageId":"aCQcp7NjRBFcV2Bn@pks.im","threadId":"63403","inReplyTo":"87a57gjoo1.fsf@iotcl.com","subject":"Re: [PATCH 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T04:31:35Z","receivedAt":"2025-05-14T04:31:44Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 13, 2025 at 09:28:30PM +0200, Toon Claes wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > ... I have decided to rename this to `odb_alternate`. I don't think\n> > \"shard\" works well, as shard is an extremely generic term that doesn't\n> > really convey much meaning.\n> >\n> > On the other hand, I think that `odb_alternate` is quite a good fit. We\n> > already use it all over the place to mean almost exactly what we are\n> > after here. And it doesn't seem far-fetched to have an\n> > `odb_packed_alternate`, `odb_loose_alternate` and `odb_redis_alternate`\n> > for different backends.\n> \n> So a database is a collection of alternates? And the alternates are\n> stored as a linked list?\n\nYes.\n\n> > The only stretch is that the primary object directory is now the primary\n> > alternate. I think that this is acceptable though'\n> \n> This is a very important nuance, and with that knowledge it starts to\n> click with me. I didn't read this in the commit messages though, so I\n> think it's worth adding something about that in [PATCH 02/17].\n\nGood point, done now.\n\nPatrick\n"},{"id":"517997","messageId":"aCQcrmAxMhN8WLL3@pks.im","threadId":"63403","inReplyTo":"878qn0jonh.fsf@iotcl.com","subject":"Re: [PATCH v2 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T04:31:42Z","receivedAt":"2025-05-14T04:31:46Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 13, 2025 at 09:28:50PM +0200, Toon Claes wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > In the preceding commits we have renamed the structures contained in\n> > \"object-store.h\" to `struct object_database` and `struct odb_backend`.\n> > As such, the code files \"object-store.{c,h}\" are confusingly named now.\n> > Rename them to \"odb.{c,h}\" accordingly.\n> \n> Do we have plans to extract the object database subsystem into a\n> subdirectory? With us adding multiple backends in the future, I can\n> image us having a dozen files at some point. So since we're renaming,\n> shall we prepare for that at once? Or will `odb.h` always be the root-level\n> entry point for the object database, and only live backends live in\n> `odb/` for example?\n\nYes, my plan was to create \"odb/alternate.h\" in one of the next steps\nand then also host alternative formats in that directory, similar to how\nwe do it with the \"refs/\" subsystem. But \"odb.{c,h}\" are files that I\nrather want to keep in the root directory, similar again to \"refs.h\".\nMost users shouldn't even need to be aware of anything in \"odb/\" and\nshould only need to use \"odb.h\", so everything in that subdirectory can\nbe considered as low-level implementation details.\n\nPatrick\n"},{"id":"517998","messageId":"aCQctNv5IkVJAfQL@pks.im","threadId":"63403","inReplyTo":"87bjrwjoov.fsf@iotcl.com","subject":"Re: [PATCH v2 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T04:31:48Z","receivedAt":"2025-05-14T04:31:51Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 13, 2025 at 09:28:00PM +0200, Toon Claes wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> > index 53da2116ddf..cd7db11d825 100644\n> > --- a/builtin/submodule--helper.c\n> > +++ b/builtin/submodule--helper.c\n> > @@ -1591,12 +1591,12 @@ static int add_possible_reference_from_superproject(\n> >  \t * If the alternate object store is another repository, try the\n> \n> This comment reads weirdly if an \"alternate\" is a location where objects\n> are stored. Maybe say something like:\n> \n>     * It the alternate resides in another repository, try the\n\nFair, but I'd prefer to not adapt too many of the surroundings yet.\nOtherwise I fear that it'll open a can of worms that we can otherwise\naddress over time.\n\n> > diff --git a/object-file.h b/object-file.h\n> > index a85b2e5b494..f1601200938 100644\n> > --- a/object-file.h\n> > +++ b/object-file.h\n> > @@ -24,23 +24,23 @@ enum {\n> >  int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n> >  int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n> >  \n> > -struct object_directory;\n> > +struct odb_alternate;\n> >  \n> >  /*\n> >   * Populate and return the loose object cache array corresponding to the\n> >   * given object ID.\n> >   */\n> > -struct oidtree *odb_loose_cache(struct object_directory *odb,\n> > +struct oidtree *odb_loose_cache(struct odb_alternate *alternate,\n> >  \t\t\t\tconst struct object_id *oid);\n> >  \n> >  /* Empty the loose object cache for the specified object directory. */\n> \n> Also here s/directory/alternate/ ? Or database?\n\nThis one remains valid even with the new terminology. The loose cache is\nspecific to loose object files, which does have an associated object\ndirectory. Refactoring loose objects to become a bit more self-contained\nwill be one of the next steps after these refactoring land.\n\n> > -void odb_clear_loose_cache(struct object_directory *odb);\n> > +void odb_clear_loose_cache(struct odb_alternate *alternate);\n> >  \n> >  /*\n> >   * Put in `buf` the name of the file in the local object database that\n> >   * would be used to store a loose object with the specified oid.\n> >   */\n> \n> Not sure if we should use \"alternate\" here?\n\nProbably rather \"loose object directory\", as it is again specific to\nloose objects.\n\n> > diff --git a/object-store.h b/object-store.h\n> > index 34b8efbbb83..2dda6e85388 100644\n> > --- a/object-store.h\n> > +++ b/object-store.h\n> > @@ -12,8 +12,11 @@ struct oidtree;\n> >  struct strbuf;\n> >  struct repository;\n> >  \n> > -struct object_directory {\n> > -\tstruct object_directory *next;\n> > +/*\n> > + * An alternate part of an object database that stores the actual objects.\n> \n> I'm having a hard time trying to understand what you're saying here.\n> What do you think about:\n> \n>     * The alternate is the part of the object database that stores the actual objects.\n\nThat reads better. I'll extend this even further to give a bit more\ncontext around primary alternates.\n\n> > @@ -97,16 +100,16 @@ struct object_database {\n> >  \t * cannot be NULL after initialization). Subsequent directories are\n> >  \t * alternates.\n> >  \t */\n> \n> The full original comment can use some love too:\n> \n>     *\n>     * Set of all object directories; the main directory is first (and\n>     * cannot be NULL after initialization). Subsequent directories are\n>     * alternates.\n>     */\n> \n> How about:\n> \n>     *\n>     * Set of all alternates, storing the actual objects.\n>     * The primary alternate is first (and cannot be NULL after\n>     * & initialization). More alternates are optional.\n>     */\n\nSame here, I'd rather not touch this comment for now. We'd only catch a\nsmall subset of outdated comments anyway, so I'd rather focus on the\nrequired changes given that this patch is already quite large.\n\nPatrick\n"},{"id":"518000","messageId":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH v3 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:23Z","receivedAt":"2025-05-14T05:12:30Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series refactors the object store subsystem to become more\nself-contained by getting rid of `the_repository`. Instead of passing in\nthe repository explicitly, we start to pass in the object store itself,\nwhich is in contrast to many other refactorings we did, but in line with\nwhat we did for the ref store, as well.\n\nThis series also starts to properly scope functions to the carved out\nobject database subsystem, which requires a bit of shuffling. This\nallows us to have a short-and-sweet `odb_` prefix for functions and\nprepares us for a future with pluggable object backends.\n\nThe series is structured as follows:\n\n  - Patches 1 to 3 rename `struct object_store` and `struct\n    object_directory` as well as the code files.\n\n  - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n\n  - Patches 13 to 17 adjust the name of remaining functions so that they\n    can be clearly attributed to the ODB. I'm happy to kick these\n    patches out of this series and resend them at a later point in case\n    they create too much turmoil.\n\nThis series is built on top of 6f84262c44a (The eleventh batch,\n2025-05-05) with ps/object-store-cleanup at 8a9e27be821 (object-store:\ndrop `repo_has_object_file()`, 2025-04-29) merged into it. There are a\ncouple of trivial conflicts when merged with \"seen\", I have appended the\nmerge conflict resolution as a patch at the end of this mail.\n\nChanges in v2:\n  - Fix for a copy-and-pasted commit message.\n  - Rename `struct odb_backend` to `struct odb_alternate`. I'm happy to\n    revert to the previous name if we ultimately think it's the better\n    suited one.\n  - A couple of fixes to move changes into the correct commit. `git\n    rebase -x 'meson compile -C build'` is now clean.\n  - I _didn't_ back out the rename to \"odb.{c,h}\". Junio has already\n    fixed the fallout, so it's probably more work for him to kick it out\n    again than to just leave it in.\n  - Link to v1: https://lore.kernel.org/r/20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im\n\nChanges in v3:\n  - Polishing for some comments and commit messages.\n  - Link to v2: https://lore.kernel.org/r/20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (17):\n      object-store: rename `raw_object_store` to `object_database`\n      object-store: rename `object_directory` to `odb_alternate`\n      object-store: rename files to \"odb.{c,h}\"\n      odb: introduce parent pointers\n      odb: get rid of `the_repository` in `find_odb()`\n      odb: get rid of `the_repository` in `assert_oid_type()`\n      odb: get rid of `the_repository` in `odb_mkstemp()`\n      odb: get rid of `the_repository` when handling alternates\n      odb: get rid of `the_repository`  in `for_each()` functions\n      odb: get rid of `the_repository` when handling the primary alternate\n      odb: get rid of `the_repository` when handling submodule alternates\n      odb: trivial refactorings to get rid of `the_repository`\n      odb: rename `oid_object_info()`\n      odb: rename `repo_read_object_file()`\n      odb: rename `has_object()`\n      odb: rename `pretend_object_file()`\n      odb: rename `read_object_with_reference()`\n\n Documentation/user-manual.adoc          |   4 +-\n Makefile                                |   2 +-\n apply.c                                 |  14 +-\n archive-tar.c                           |   2 +-\n archive-zip.c                           |   2 +-\n archive.c                               |   6 +-\n attr.c                                  |   4 +-\n bisect.c                                |   8 +-\n blame.c                                 |  22 +-\n builtin/backfill.c                      |   6 +-\n builtin/blame.c                         |   6 +-\n builtin/cat-file.c                      |  62 +++--\n builtin/checkout.c                      |   2 +-\n builtin/clone.c                         |  14 +-\n builtin/commit-graph.c                  |  20 +-\n builtin/commit-tree.c                   |   4 +-\n builtin/count-objects.c                 |   6 +-\n builtin/describe.c                      |   5 +-\n builtin/difftool.c                      |   4 +-\n builtin/fast-export.c                   |  10 +-\n builtin/fast-import.c                   |  49 ++--\n builtin/fetch.c                         |  21 +-\n builtin/fsck.c                          |  31 +--\n builtin/gc.c                            |  16 +-\n builtin/grep.c                          |  26 +-\n builtin/hash-object.c                   |   2 +-\n builtin/index-pack.c                    |  29 +--\n builtin/log.c                           |   4 +-\n builtin/ls-files.c                      |   4 +-\n builtin/ls-tree.c                       |   6 +-\n builtin/merge-file.c                    |   2 +-\n builtin/merge-tree.c                    |  14 +-\n builtin/mktag.c                         |   6 +-\n builtin/mktree.c                        |  10 +-\n builtin/multi-pack-index.c              |   6 +-\n builtin/notes.c                         |   8 +-\n builtin/pack-objects.c                  |  70 +++---\n builtin/pack-redundant.c                |   2 +-\n builtin/prune.c                         |   6 +-\n builtin/receive-pack.c                  |   9 +-\n builtin/remote.c                        |   6 +-\n builtin/repack.c                        |   7 +-\n builtin/replace.c                       |  12 +-\n builtin/rev-list.c                      |   8 +-\n builtin/show-ref.c                      |   6 +-\n builtin/submodule--helper.c             |  11 +-\n builtin/tag.c                           |  10 +-\n builtin/unpack-file.c                   |   4 +-\n builtin/unpack-objects.c                |  12 +-\n bulk-checkin.c                          |   6 +-\n bundle-uri.c                            |   5 +-\n bundle.c                                |   6 +-\n cache-tree.c                            |  17 +-\n combine-diff.c                          |   4 +-\n commit-graph.c                          | 106 ++++----\n commit-graph.h                          |  20 +-\n commit.c                                |  15 +-\n config.c                                |   4 +-\n connected.c                             |   2 +-\n contrib/coccinelle/the_repository.cocci |   2 +-\n diagnose.c                              |  12 +-\n diff.c                                  |  20 +-\n dir.c                                   |   2 +-\n entry.c                                 |   6 +-\n fetch-pack.c                            |  17 +-\n fmt-merge-msg.c                         |   6 +-\n fsck.c                                  |   4 +-\n grep.c                                  |   6 +-\n http-backend.c                          |   2 +-\n http-push.c                             |  20 +-\n http-walker.c                           |  12 +-\n http.c                                  |   6 +-\n list-objects-filter.c                   |   4 +-\n list-objects.c                          |   6 +-\n log-tree.c                              |   2 +-\n loose.c                                 |  46 ++--\n mailmap.c                               |   4 +-\n match-trees.c                           |   6 +-\n merge-blobs.c                           |  10 +-\n merge-ort.c                             |   8 +-\n meson.build                             |   2 +-\n midx-write.c                            |   2 +-\n midx.c                                  |   6 +-\n notes-cache.c                           |   4 +-\n notes-merge.c                           |   4 +-\n notes.c                                 |  19 +-\n object-file.c                           |  94 ++++----\n object-file.h                           |  12 +-\n object-name.c                           |  24 +-\n object.c                                |   8 +-\n object-store.c => odb.c                 | 413 +++++++++++++++++---------------\n object-store.h => odb.h                 | 272 +++++++++++++++------\n oss-fuzz/fuzz-pack-idx.c                |   2 +-\n pack-bitmap-write.c                     |   9 +-\n pack-bitmap.c                           |  10 +-\n pack-check.c                            |   2 +-\n pack-mtimes.c                           |   2 +-\n pack-objects.h                          |   2 +-\n pack-revindex.c                         |   2 +-\n pack-write.c                            |  10 +-\n packfile.c                              |  29 +--\n packfile.h                              |   8 +-\n path.c                                  |   4 +-\n promisor-remote.c                       |   6 +-\n protocol-caps.c                         |   4 +-\n reachable.c                             |   2 +-\n read-cache.c                            |  14 +-\n ref-filter.c                            |   6 +-\n reflog.c                                |   8 +-\n refs.c                                  |   7 +-\n remote.c                                |   9 +-\n replace-object.c                        |   2 +-\n replace-object.h                        |   2 +-\n repository.c                            |  21 +-\n repository.h                            |   4 +-\n rerere.c                                |   7 +-\n revision.c                              |   5 +-\n send-pack.c                             |   4 +-\n sequencer.c                             |   7 +-\n server-info.c                           |   2 +-\n shallow.c                               |  14 +-\n streaming.c                             |  10 +-\n submodule-config.c                      |   9 +-\n submodule.c                             |  32 +--\n submodule.h                             |   9 -\n t/helper/test-find-pack.c               |   2 +-\n t/helper/test-pack-mtimes.c             |   2 +-\n t/helper/test-partial-clone.c           |   4 +-\n t/helper/test-read-graph.c              |   8 +-\n t/helper/test-read-midx.c               |   2 +-\n t/helper/test-ref-store.c               |   4 +-\n tag.c                                   |  10 +-\n tmp-objdir.c                            |  30 +--\n tree-walk.c                             |  18 +-\n tree.c                                  |   6 +-\n unpack-trees.c                          |   2 +-\n upload-pack.c                           |   4 +-\n walker.c                                |   6 +-\n xdiff-interface.c                       |   4 +-\n 139 files changed, 1180 insertions(+), 1032 deletions(-)\n\nRange-diff versus v2:\n\n 1:  c113f51cc1a !  1:  40051831e0e object-store: rename `raw_object_store` to `object_database`\n    @@ Commit message\n         This conversion can be done by simply passing in an explicit pointer to\n         a repository and then using its `->objects` pointer. But there is a\n         second effort underway, which is to make the object subsystem more\n    -    selfcontained so that we can eventually have pluggale object backends.\n    +    selfcontained so that we can eventually have pluggable object backends.\n         As such, passing in a repository wouldn't make a ton of sense, and the\n         goal is to convert the object store interfaces such that we always pass\n         in a reference to the `raw_object_store` instead.\n 2:  05a6fb88bf3 !  2:  39f178ace57 object-store: rename `object_directory` to `odb_alternate`\n    @@ Commit message\n         Let's preempt this by renaming the structure to `odb_alternate` now\n         already. This name is agnostic of how exactly objects are stored while\n         still specifically pinpointing that this is about an alternate object\n    -    database. In the future, it allows us to easily introduce e.g. a\n    -    `odb_files_alternate` and other specific implementations over time.\n    +    database. Furthermore, it is already used in Git to represent this\n    +    context -- the only stretch is that the primary object directory is now\n    +    the primary alternate.\n    +\n    +    In the future, this change allows us to easily introduce for example a\n    +    `odb_files_alternate` and other format-specific implementations.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n     \n    @@ object-store.h: struct oidtree;\n     -struct object_directory {\n     -\tstruct object_directory *next;\n     +/*\n    -+ * An alternate part of an object database that stores the actual objects.\n    ++ * The alternate is the part of the object database that stores the actual\n    ++ * objects. It thus encapsulates the logic to read and write the specific\n    ++ * on-disk format. An object database can have multiple alternates, and\n    ++ * exactly one primary alternate that is used when writing new objects.\n     + */\n     +struct odb_alternate {\n     +\tstruct odb_alternate *next;\n 3:  bcc552e554c =  3:  7d79268aa73 object-store: rename files to \"odb.{c,h}\"\n 4:  908e399cde6 =  4:  25777175ade odb: introduce parent pointers\n 5:  939961a4eb3 =  5:  c8daaa9bd03 odb: get rid of `the_repository` in `find_odb()`\n 6:  74dc4d61e37 =  6:  23cf77f4e83 odb: get rid of `the_repository` in `assert_oid_type()`\n 7:  61f1302201f =  7:  58975fe2c7f odb: get rid of `the_repository` in `odb_mkstemp()`\n 8:  81926adbd98 !  8:  27959349ffe odb: get rid of `the_repository` when handling alternates\n    @@ odb.h: struct oidtree;\n     +char *compute_alternate_path(const char *path, struct strbuf *err);\n     +\n      /*\n    -  * An alternate part of an object database that stores the actual objects.\n    -  */\n    +  * The alternate is the part of the object database that stores the actual\n    +  * objects. It thus encapsulates the logic to read and write the specific\n     @@ odb.h: struct odb_alternate {\n      \tchar *path;\n      };\n 9:  60693ef4805 =  9:  3bb54296615 odb: get rid of `the_repository`  in `for_each()` functions\n10:  387e0311264 = 10:  b39a3d934a5 odb: get rid of `the_repository` when handling the primary alternate\n11:  64503d9eeb8 = 11:  489c6b4c33f odb: get rid of `the_repository` when handling submodule alternates\n12:  fd793aef552 = 12:  a3068a0ad76 odb: trivial refactorings to get rid of `the_repository`\n13:  efcd16f5d14 = 13:  eb614efd08b odb: rename `oid_object_info()`\n14:  1f020271cc5 = 14:  6c7c24739d1 odb: rename `repo_read_object_file()`\n15:  8a51662e84d = 15:  07c2b387ace odb: rename `has_object()`\n16:  3bd6d7e2ae4 = 16:  f1e8c7f10ab odb: rename `pretend_object_file()`\n17:  7d63407a1b4 = 17:  d612f806675 odb: rename `read_object_with_reference()`\n\n---\nbase-commit: 046efb6f2b050efd580e1c1750b77328a1790c0e\nchange-id: 20250505-pks-object-store-wo-the-repository-9c6cbdf8d4b1\n\n"},{"id":"518001","messageId":"20250514-pks-object-store-wo-the-repository-v3-1-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:24Z","receivedAt":"2025-05-14T05:12:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `raw_object_store` structure is the central entry point for reading\nand writing objects in a repository. The main purpose of this structure\nis to manage object directories and provide an interface to access and\nwrite objects in those object directories.\n\nRight now, many of the functions associated with the raw object store\nimplicitly rely on `the_repository` to get access to its `objects`\npointer, which is the `raw_object_store`. As we want to generally get\nrid of using `the_repository` across our codebase we will have to\nconvert this implicit dependency on this global variable into an\nexplicit parameter.\n\nThis conversion can be done by simply passing in an explicit pointer to\na repository and then using its `->objects` pointer. But there is a\nsecond effort underway, which is to make the object subsystem more\nselfcontained so that we can eventually have pluggable object backends.\nAs such, passing in a repository wouldn't make a ton of sense, and the\ngoal is to convert the object store interfaces such that we always pass\nin a reference to the `raw_object_store` instead.\n\nThis will expose the `raw_object_store` type to a lot more callers\nthough, which surfaces that this type is named somewhat awkwardly. The\n\"raw_\" prefix makes readers wonder whether there is a non-raw variant of\nthe object store, but there isn't. Furthermore, we nowadays want to name\nfunctions in a way that they can be clearly attributed to a specific\nsubsystem, but calling them e.g. `raw_object_store_has_object()` is just\ntoo unwieldy, even when dropping the \"raw_\" prefix.\n\nInstead, rename the structure to `object_database`. This term is already\nused a lot throughout our codebase, and it cannot easily be mistaken for\n\"object directories\", either. Furthermore, its acronym ODB is already\nwell-known and works well as part of a function's name, like for example\n`odb_has_object()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n commit-graph.c |  2 +-\n commit-graph.h |  4 ++--\n object-store.c | 12 ++++++------\n object-store.h | 11 ++++++++---\n packfile.c     |  2 +-\n packfile.h     |  4 ++--\n repository.c   |  4 ++--\n repository.h   |  4 ++--\n 8 files changed, 24 insertions(+), 19 deletions(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 6394752b0b0..1b66486b9c9 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -829,7 +829,7 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)\n \treturn NULL;\n }\n \n-void close_commit_graph(struct raw_object_store *o)\n+void close_commit_graph(struct object_database *o)\n {\n \tif (!o->commit_graph)\n \t\treturn;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 13f662827d4..20d38c100ce 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -26,7 +26,7 @@ void git_test_write_commit_graph_or_die(void);\n struct commit;\n struct bloom_filter_settings;\n struct repository;\n-struct raw_object_store;\n+struct object_database;\n struct string_list;\n \n char *get_commit_graph_filename(struct object_directory *odb);\n@@ -186,7 +186,7 @@ int write_commit_graph(struct object_directory *odb,\n \n int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags);\n \n-void close_commit_graph(struct raw_object_store *);\n+void close_commit_graph(struct object_database *);\n void free_commit_graph(struct commit_graph *);\n \n /*\ndiff --git a/object-store.c b/object-store.c\nindex 2f51d0e3b03..1effcb12273 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -44,7 +44,7 @@ struct cached_object_entry {\n \t} value;\n };\n \n-static const struct cached_object *find_cached_object(struct raw_object_store *object_store,\n+static const struct cached_object *find_cached_object(struct object_database *object_store,\n \t\t\t\t\t\t      const struct object_id *oid)\n {\n \tstatic const struct cached_object empty_tree = {\n@@ -86,7 +86,7 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n /*\n  * Return non-zero iff the path is usable as an alternate object database.\n  */\n-static int alt_odb_usable(struct raw_object_store *o,\n+static int alt_odb_usable(struct object_database *o,\n \t\t\t  struct strbuf *path,\n \t\t\t  const char *normalized_objdir, khiter_t *pos)\n {\n@@ -959,9 +959,9 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct raw_object_store *raw_object_store_new(void)\n+struct object_database *odb_new(void)\n {\n-\tstruct raw_object_store *o = xmalloc(sizeof(*o));\n+\tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n@@ -970,7 +970,7 @@ struct raw_object_store *raw_object_store_new(void)\n \treturn o;\n }\n \n-static void free_object_directories(struct raw_object_store *o)\n+static void free_object_directories(struct object_database *o)\n {\n \twhile (o->odb) {\n \t\tstruct object_directory *next;\n@@ -983,7 +983,7 @@ static void free_object_directories(struct raw_object_store *o)\n \to->odb_by_path = NULL;\n }\n \n-void raw_object_store_clear(struct raw_object_store *o)\n+void odb_clear(struct object_database *o)\n {\n \tFREE_AND_NULL(o->alternate_db);\n \ndiff --git a/object-store.h b/object-store.h\nindex c2fe5a19605..34b8efbbb83 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -86,7 +86,12 @@ struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n \n-struct raw_object_store {\n+/*\n+ * The object database encapsulates access to objects in a repository. It\n+ * manages one or more backends that store the actual objects which are\n+ * configured via alternates.\n+ */\n+struct object_database {\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -168,8 +173,8 @@ struct raw_object_store {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct raw_object_store *raw_object_store_new(void);\n-void raw_object_store_clear(struct raw_object_store *o);\n+struct object_database *odb_new(void);\n+void odb_clear(struct object_database *o);\n \n /*\n  * Create a temporary file rooted in the object database directory, or\ndiff --git a/packfile.c b/packfile.c\nindex d91016f1c7f..8f51665266d 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -359,7 +359,7 @@ void close_pack(struct packed_git *p)\n \toidset_clear(&p->bad_objects);\n }\n \n-void close_object_store(struct raw_object_store *o)\n+void close_object_store(struct object_database *o)\n {\n \tstruct packed_git *p;\n \ndiff --git a/packfile.h b/packfile.h\nindex 3a3c77cf05a..826eb7f475f 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -183,12 +183,12 @@ int close_pack_fd(struct packed_git *p);\n \n uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);\n \n-struct raw_object_store;\n+struct object_database;\n \n unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);\n void close_pack_windows(struct packed_git *);\n void close_pack(struct packed_git *);\n-void close_object_store(struct raw_object_store *o);\n+void close_object_store(struct object_database *o);\n void unuse_pack(struct pack_window **);\n void clear_delta_base_cache(void);\n struct packed_git *add_packed_git(struct repository *r, const char *path,\ndiff --git a/repository.c b/repository.c\nindex 9b3d6665fc6..07757e6e0c9 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = raw_object_store_new();\n+\trepo->objects = odb_new();\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -374,7 +374,7 @@ void repo_clear(struct repository *repo)\n \tFREE_AND_NULL(repo->worktree);\n \tFREE_AND_NULL(repo->submodule_prefix);\n \n-\traw_object_store_clear(repo->objects);\n+\todb_clear(repo->objects);\n \tFREE_AND_NULL(repo->objects);\n \n \tparsed_object_pool_clear(repo->parsed_objects);\ndiff --git a/repository.h b/repository.h\nindex c4c92b2ab9c..3a5ef9c781e 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -9,7 +9,7 @@ struct git_hash_algo;\n struct index_state;\n struct lock_file;\n struct pathspec;\n-struct raw_object_store;\n+struct object_database;\n struct submodule_cache;\n struct promisor_remote_config;\n struct remote_state;\n@@ -47,7 +47,7 @@ struct repository {\n \t/*\n \t * Holds any information related to accessing the raw object content.\n \t */\n-\tstruct raw_object_store *objects;\n+\tstruct object_database *objects;\n \n \t/*\n \t * All objects in this repository that have been parsed. This structure\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518003","messageId":"20250514-pks-object-store-wo-the-repository-v3-3-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:26Z","receivedAt":"2025-05-14T05:12:33Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In the preceding commits we have renamed the structures contained in\n\"object-store.h\" to `struct object_database` and `struct odb_backend`.\nAs such, the code files \"object-store.{c,h}\" are confusingly named now.\nRename them to \"odb.{c,h}\" accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile                                | 2 +-\n apply.c                                 | 2 +-\n archive-tar.c                           | 2 +-\n archive-zip.c                           | 2 +-\n archive.c                               | 2 +-\n attr.c                                  | 2 +-\n bisect.c                                | 2 +-\n blame.c                                 | 2 +-\n builtin/backfill.c                      | 2 +-\n builtin/blame.c                         | 2 +-\n builtin/cat-file.c                      | 2 +-\n builtin/checkout.c                      | 2 +-\n builtin/clone.c                         | 2 +-\n builtin/commit-graph.c                  | 2 +-\n builtin/commit-tree.c                   | 2 +-\n builtin/describe.c                      | 2 +-\n builtin/difftool.c                      | 2 +-\n builtin/fast-export.c                   | 2 +-\n builtin/fast-import.c                   | 2 +-\n builtin/fetch.c                         | 2 +-\n builtin/fsck.c                          | 2 +-\n builtin/grep.c                          | 2 +-\n builtin/hash-object.c                   | 2 +-\n builtin/index-pack.c                    | 2 +-\n builtin/log.c                           | 2 +-\n builtin/ls-files.c                      | 2 +-\n builtin/ls-tree.c                       | 2 +-\n builtin/merge-file.c                    | 2 +-\n builtin/merge-tree.c                    | 2 +-\n builtin/mktag.c                         | 2 +-\n builtin/mktree.c                        | 2 +-\n builtin/multi-pack-index.c              | 2 +-\n builtin/notes.c                         | 2 +-\n builtin/pack-objects.c                  | 2 +-\n builtin/pack-redundant.c                | 2 +-\n builtin/prune.c                         | 2 +-\n builtin/receive-pack.c                  | 2 +-\n builtin/remote.c                        | 2 +-\n builtin/repack.c                        | 2 +-\n builtin/replace.c                       | 2 +-\n builtin/rev-list.c                      | 2 +-\n builtin/show-ref.c                      | 2 +-\n builtin/submodule--helper.c             | 2 +-\n builtin/tag.c                           | 2 +-\n builtin/unpack-file.c                   | 2 +-\n builtin/unpack-objects.c                | 2 +-\n bulk-checkin.c                          | 2 +-\n bundle-uri.c                            | 2 +-\n bundle.c                                | 2 +-\n cache-tree.c                            | 2 +-\n combine-diff.c                          | 2 +-\n commit-graph.c                          | 2 +-\n commit-graph.h                          | 2 +-\n commit.c                                | 2 +-\n config.c                                | 2 +-\n connected.c                             | 2 +-\n contrib/coccinelle/the_repository.cocci | 2 +-\n diagnose.c                              | 2 +-\n diff.c                                  | 2 +-\n entry.c                                 | 2 +-\n fetch-pack.c                            | 2 +-\n fmt-merge-msg.c                         | 2 +-\n fsck.c                                  | 2 +-\n grep.c                                  | 2 +-\n http-backend.c                          | 2 +-\n http-push.c                             | 2 +-\n http-walker.c                           | 2 +-\n http.c                                  | 2 +-\n list-objects-filter.c                   | 2 +-\n list-objects.c                          | 2 +-\n loose.c                                 | 2 +-\n mailmap.c                               | 2 +-\n match-trees.c                           | 2 +-\n merge-blobs.c                           | 2 +-\n merge-ort.c                             | 2 +-\n meson.build                             | 2 +-\n notes-cache.c                           | 2 +-\n notes-merge.c                           | 2 +-\n notes.c                                 | 2 +-\n object-file.c                           | 2 +-\n object-file.h                           | 2 +-\n object-store.c => odb.c                 | 2 +-\n object-store.h => odb.h                 | 6 +++---\n oss-fuzz/fuzz-pack-idx.c                | 2 +-\n pack-bitmap-write.c                     | 2 +-\n pack-bitmap.c                           | 2 +-\n pack-check.c                            | 2 +-\n pack-mtimes.c                           | 2 +-\n pack-objects.h                          | 2 +-\n pack-revindex.c                         | 2 +-\n packfile.c                              | 2 +-\n packfile.h                              | 4 ++--\n path.c                                  | 2 +-\n promisor-remote.c                       | 2 +-\n protocol-caps.c                         | 2 +-\n read-cache.c                            | 2 +-\n ref-filter.c                            | 2 +-\n reflog.c                                | 2 +-\n refs.c                                  | 2 +-\n remote.c                                | 2 +-\n replace-object.c                        | 2 +-\n replace-object.h                        | 2 +-\n repository.c                            | 2 +-\n rerere.c                                | 2 +-\n revision.c                              | 2 +-\n send-pack.c                             | 2 +-\n sequencer.c                             | 2 +-\n server-info.c                           | 2 +-\n shallow.c                               | 2 +-\n streaming.c                             | 2 +-\n submodule-config.c                      | 2 +-\n submodule.c                             | 2 +-\n t/helper/test-find-pack.c               | 2 +-\n t/helper/test-pack-mtimes.c             | 2 +-\n t/helper/test-partial-clone.c           | 2 +-\n t/helper/test-read-graph.c              | 2 +-\n t/helper/test-read-midx.c               | 2 +-\n t/helper/test-ref-store.c               | 2 +-\n tag.c                                   | 2 +-\n tmp-objdir.c                            | 2 +-\n tree-walk.c                             | 2 +-\n tree.c                                  | 2 +-\n unpack-trees.c                          | 2 +-\n upload-pack.c                           | 2 +-\n walker.c                                | 2 +-\n xdiff-interface.c                       | 2 +-\n 126 files changed, 129 insertions(+), 129 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8a7f1c76543..d2d65f30907 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1083,8 +1083,8 @@ LIB_OBJS += notes.o\n LIB_OBJS += object-file-convert.o\n LIB_OBJS += object-file.o\n LIB_OBJS += object-name.o\n-LIB_OBJS += object-store.o\n LIB_OBJS += object.o\n+LIB_OBJS += odb.o\n LIB_OBJS += oid-array.o\n LIB_OBJS += oidmap.o\n LIB_OBJS += oidset.o\ndiff --git a/apply.c b/apply.c\nindex 381d2e3652f..879f04df31e 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -14,7 +14,7 @@\n #include \"abspath.h\"\n #include \"base85.h\"\n #include \"config.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"delta.h\"\n #include \"diff.h\"\n #include \"dir.h\"\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 282b48196f9..249164ea77d 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -11,7 +11,7 @@\n #include \"hex.h\"\n #include \"tar.h\"\n #include \"archive.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"streaming.h\"\n #include \"run-command.h\"\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 405da6f3d83..df8866d5bae 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -12,7 +12,7 @@\n #include \"hex.h\"\n #include \"streaming.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"userdiff.h\"\n #include \"write-or-die.h\"\ndiff --git a/archive.c b/archive.c\nindex 8309ea213e6..7fa2cc2596a 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -14,7 +14,7 @@\n #include \"pretty.h\"\n #include \"setup.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/attr.c b/attr.c\nindex 86b6109fc4e..e5680db7f65 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -22,7 +22,7 @@\n #include \"read-cache-ll.h\"\n #include \"refs.h\"\n #include \"revision.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/bisect.c b/bisect.c\nindex a327468c75b..a7939216d00 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -20,7 +20,7 @@\n #include \"commit-slab.h\"\n #include \"commit-reach.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"dir.h\"\n \ndiff --git a/blame.c b/blame.c\nindex 57daa45e899..0ceea080a80 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -3,7 +3,7 @@\n \n #include \"git-compat-util.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"cache-tree.h\"\n #include \"mergesort.h\"\n #include \"commit.h\"\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex fa82ad2f6ff..0b49baa39fa 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -13,7 +13,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"promisor-remote.h\"\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 944952e30eb..15eda60af90 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -28,7 +28,7 @@\n #include \"line-log.h\"\n #include \"progress.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"blame.h\"\n #include \"refs.h\"\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 3914a2a3f61..2fa5e3f43bd 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -24,7 +24,7 @@\n #include \"pack-bitmap.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"promisor-remote.h\"\n #include \"mailmap.h\"\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex d185982f3a6..e7dd66173dd 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -20,7 +20,7 @@\n #include \"merge-ort-wrappers.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"path.h\"\n #include \"preload-index.h\"\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 91b9cd0d164..1eafeefb48d 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -25,7 +25,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 628d3a1e92e..ae8ac52a975 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -6,7 +6,7 @@\n #include \"hex.h\"\n #include \"parse-options.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"progress.h\"\n #include \"replace-object.h\"\n #include \"strbuf.h\"\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex ad6b2c93209..546069f8682 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -9,7 +9,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n #include \"commit.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 2d50883b729..96cb68e5e5d 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -19,7 +19,7 @@\n #include \"setup.h\"\n #include \"strvec.h\"\n #include \"run-command.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects.h\"\n #include \"commit-slab.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex a3b64ce6942..fac613e3bc3 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -30,7 +30,7 @@\n #include \"strbuf.h\"\n #include \"lockfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"entry.h\"\n #include \"setup.h\"\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 37c01d6c6fe..0505f289a94 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"object.h\"\n #include \"tag.h\"\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex b2839c5f439..52c792488e1 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -24,7 +24,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"mem-pool.h\"\n #include \"commit-reach.h\"\n #include \"khash.h\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 4de6d3206d4..82e9603ccab 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"oid-array.h\"\n #include \"commit.h\"\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 9c54286540c..6a5181393a2 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3c51a39c10d..3858df2a82e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -26,7 +26,7 @@\n #include \"submodule-config.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pager.h\"\n #include \"path.h\"\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex cd53fa3bde8..9ce0b87c30b 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -11,7 +11,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 147e9b8b479..8ce446064e8 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -21,7 +21,7 @@\n #include \"packfile.h\"\n #include \"pack-revindex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"path.h\"\ndiff --git a/builtin/log.c b/builtin/log.c\nindex b450cd3bde8..fe9cc5ebecb 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -15,7 +15,7 @@\n #include \"hex.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"color.h\"\n #include \"commit.h\"\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex be74f0a03b2..821339b07d4 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -25,7 +25,7 @@\n #include \"setup.h\"\n #include \"sparse-index.h\"\n #include \"submodule.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n \n \ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 8aafc30ca48..62b6fd58c16 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -10,7 +10,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"path.h\"\n #include \"quote.h\"\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 2b16b10d2ca..9464f275629 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -7,7 +7,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"setup.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 4aafa73c615..709ae3966a6 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -10,7 +10,7 @@\n #include \"commit-reach.h\"\n #include \"merge-ort.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 7ac11c46d53..1809b38f937 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -6,7 +6,7 @@\n #include \"strbuf.h\"\n #include \"replace-object.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"fsck.h\"\n #include \"config.h\"\n \ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 4b478034675..016b0e5b224 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -12,7 +12,7 @@\n #include \"tree.h\"\n #include \"parse-options.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct treeent {\n \tunsigned mode;\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex a77ae465d48..01c4c8e62e3 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -7,7 +7,7 @@\n #include \"midx.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex a3f433ca4c0..783d4932ca6 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -16,7 +16,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n \n #include \"pretty.h\"\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8b33edc2ff5..99b63cb0980 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -32,7 +32,7 @@\n #include \"list.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"dir.h\"\n #include \"midx.h\"\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 5d1fc781761..3134cb8c689 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -13,7 +13,7 @@\n #include \"hex.h\"\n \n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n \n #define BLKSIZE 512\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex e930caa0c0a..7bbfb14c2be 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -17,7 +17,7 @@\n #include \"replace-object.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"shallow.h\"\n \n static const char * const prune_usage[] = {\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex c92e57ba188..cb5fd55a8e4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -33,7 +33,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"protocol.h\"\n #include \"commit-reach.h\"\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 0d6755bcb71..ac5b8d2a1a6 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -14,7 +14,7 @@\n #include \"rebase.h\"\n #include \"refs.h\"\n #include \"refspec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strvec.h\"\n #include \"commit-reach.h\"\n #include \"progress.h\"\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 59214dbdfdf..16782320058 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -17,7 +17,7 @@\n #include \"midx.h\"\n #include \"packfile.h\"\n #include \"prune-packed.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"shallow.h\"\n #include \"pack.h\"\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 48c7c6a2d56..11c7e2d4c0c 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"tag.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex c4cd4ed5c81..ee25d61c802 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -14,7 +14,7 @@\n #include \"object.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"parse-options.h\"\n #include \"log-tree.h\"\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 623a52a45f8..90ec1de78f9 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"refs/refs-internal.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"string-list.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex cd7db11d825..a6c936fb2bd 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -28,7 +28,7 @@\n #include \"diff.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"advice.h\"\n #include \"branch.h\"\n #include \"list-objects-filter-options.h\"\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 4742b27d16e..cf2ea4b4993 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -19,7 +19,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"tag.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex e33acfc4ee4..b92fd4710a9 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static char *create_temp_file(struct object_id *oid)\n {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex e905d5f4e19..7bf395eec84 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -9,7 +9,7 @@\n #include \"git-zlib.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"delta.h\"\n #include \"pack.h\"\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 678e2ecc2c2..55406a539e7 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -17,7 +17,7 @@\n #include \"tmp-objdir.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int odb_transaction_nesting;\n \ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 96d2ba726d9..993ac62c271 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -14,7 +14,7 @@\n #include \"fetch-pack.h\"\n #include \"remote.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct {\n \tenum bundle_list_heuristic heuristic;\ndiff --git a/bundle.c b/bundle.c\nindex 0c7cd15bb12..c67f85126da 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -7,7 +7,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/cache-tree.c b/cache-tree.c\nindex fa3858e2829..9786b32b3a1 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -10,7 +10,7 @@\n #include \"cache-tree.h\"\n #include \"bulk-checkin.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\ndiff --git a/combine-diff.c b/combine-diff.c\nindex dfae9f7995d..cf23a753407 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -2,7 +2,7 @@\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"convert.h\"\n #include \"diff.h\"\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 58d1eeedb1a..4848198d7bf 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -13,7 +13,7 @@\n #include \"refs.h\"\n #include \"hash-lookup.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"alloc.h\"\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 19d95ade6ea..0be594e2638 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -1,7 +1,7 @@\n #ifndef COMMIT_GRAPH_H\n #define COMMIT_GRAPH_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n #define GIT_TEST_COMMIT_GRAPH \"GIT_TEST_COMMIT_GRAPH\"\ndiff --git a/commit.c b/commit.c\nindex e915b2b9a12..1d30f8ce15a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -9,7 +9,7 @@\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/config.c b/config.c\nindex b18b5617fcd..883dd066827 100644\n--- a/config.c\n+++ b/config.c\n@@ -31,7 +31,7 @@\n #include \"hashmap.h\"\n #include \"string-list.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"path.h\"\n #include \"utf8.h\"\ndiff --git a/connected.c b/connected.c\nindex 4415388beba..18c13245d8e 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"run-command.h\"\n #include \"sigchain.h\"\n #include \"connected.h\"\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 765ad689678..ea7fe1c8db7 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -77,7 +77,7 @@\n |\n - diff_setup\n + repo_diff_setup\n-// object-store.h\n+// odb.h\n |\n - read_object_file\n + repo_read_object_file\ndiff --git a/diagnose.c b/diagnose.c\nindex 50129cf4be3..d407c98d094 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -7,7 +7,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"strvec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"repository.h\"\ndiff --git a/diff.c b/diff.c\nindex 63e9ecb30c6..193da8bee68 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -23,7 +23,7 @@\n #include \"color.h\"\n #include \"run-command.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"userdiff.h\"\n #include \"submodule.h\"\n #include \"hashmap.h\"\ndiff --git a/entry.c b/entry.c\nindex f36ec5ad242..75d55038d7c 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -1,7 +1,7 @@\n #define USE_THE_REPOSITORY_VARIABLE\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex fa4231fee74..cf157f5d7e5 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -24,7 +24,7 @@\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"connected.h\"\n #include \"fetch-negotiator.h\"\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 501b5acdd44..1a8c972adf3 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -6,7 +6,7 @@\n #include \"environment.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"diff.h\"\n #include \"diff-merges.h\"\n #include \"hex.h\"\ndiff --git a/fsck.c b/fsck.c\nindex 8dc8472ceb3..e69baab3af7 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"dir.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"object.h\"\ndiff --git a/grep.c b/grep.c\nindex f8d535182c3..dc77e6c4631 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"grep.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\ndiff --git a/http-backend.c b/http-backend.c\nindex 0c575aa88aa..ad8c4037493 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -18,7 +18,7 @@\n #include \"url.h\"\n #include \"strvec.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"protocol.h\"\n #include \"date.h\"\n #include \"write-or-die.h\"\ndiff --git a/http-push.c b/http-push.c\nindex f9e67cabd4b..d1b1bb23711 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -20,7 +20,7 @@\n #include \"url.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n \n #ifdef EXPAT_NEEDS_XMLPARSE_H\ndiff --git a/http-walker.c b/http-walker.c\nindex 9e7bc37f02e..4b1cdd25a80 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -10,7 +10,7 @@\n #include \"transport.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct alt_base {\n \tchar *base;\ndiff --git a/http.c b/http.c\nindex 8ce2ec73947..e639d9fafef 100644\n--- a/http.c\n+++ b/http.c\n@@ -19,7 +19,7 @@\n #include \"packfile.h\"\n #include \"string-list.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tempfile.h\"\n \n static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 7765761b3c6..cb9c16734b1 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -12,7 +12,7 @@\n #include \"oidmap.h\"\n #include \"oidset.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n /* Remember to update object flag allocation in object.h */\n /*\ndiff --git a/list-objects.c b/list-objects.c\nindex 597114281f6..c50b9578584 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -14,7 +14,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace.h\"\n #include \"environment.h\"\n \ndiff --git a/loose.c b/loose.c\nindex bce4e1c3ee7..9febd1f3e9a 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"hash.h\"\n #include \"path.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"wrapper.h\"\ndiff --git a/mailmap.c b/mailmap.c\nindex 9e2642a043b..b18e74c2110 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -6,7 +6,7 @@\n #include \"string-list.h\"\n #include \"mailmap.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n char *git_mailmap_file;\ndiff --git a/match-trees.c b/match-trees.c\nindex 72922d5d64e..4704f95c340 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -7,7 +7,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n static int score_missing(unsigned mode)\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 53f36dbc175..ba8a3fdfd82 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -4,7 +4,7 @@\n #include \"merge-ll.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 77310a4a52c..f86c84635f0 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -39,7 +39,7 @@\n #include \"mem-pool.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/meson.build b/meson.build\nindex 270ce933d0f..a3c917b1345 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -394,8 +394,8 @@ libgit_sources = [\n   'object-file-convert.c',\n   'object-file.c',\n   'object-name.c',\n-  'object-store.c',\n   'object.c',\n+  'odb.c',\n   'oid-array.c',\n   'oidmap.c',\n   'oidset.c',\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 150241b15e0..344f67762b8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"notes-cache.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"repository.h\"\n #include \"commit.h\"\ndiff --git a/notes-merge.c b/notes-merge.c\nindex dae8e6a281a..de6a52e2e7f 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -8,7 +8,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"diff.h\"\ndiff --git a/notes.c b/notes.c\nindex 0a128f1de98..fc000e501d2 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -8,7 +8,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"strbuf.h\"\n #include \"tree-walk.h\"\ndiff --git a/object-file.c b/object-file.c\nindex e48d968c0e0..dabc238447a 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -21,7 +21,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidtree.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/object-file.h b/object-file.h\nindex f1601200938..e4810eee449 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -3,7 +3,7 @@\n \n #include \"git-zlib.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct index_state;\n \ndiff --git a/object-store.c b/odb.c\nsimilarity index 99%\nrename from object-store.c\nrename to odb.c\nindex 673a9c6006b..81281db7e0a 100644\n--- a/object-store.c\n+++ b/odb.c\n@@ -13,7 +13,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/object-store.h b/odb.h\nsimilarity index 99%\nrename from object-store.h\nrename to odb.h\nindex 6dc39376141..070dd28e394 100644\n--- a/object-store.h\n+++ b/odb.h\n@@ -1,5 +1,5 @@\n-#ifndef OBJECT_STORE_H\n-#define OBJECT_STORE_H\n+#ifndef ODB_H\n+#define ODB_H\n \n #include \"hashmap.h\"\n #include \"object.h\"\n@@ -348,4 +348,4 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n-#endif /* OBJECT_STORE_H */\n+#endif /* ODB_H */\ndiff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c\nindex 609a343ee3e..d2a92f34d98 100644\n--- a/oss-fuzz/fuzz-pack-idx.c\n+++ b/oss-fuzz/fuzz-pack-idx.c\n@@ -1,5 +1,5 @@\n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n \n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 7f400ee0121..37648b57125 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -4,7 +4,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex b9f1d866046..467a3e91035 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"repository.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects-filter-options.h\"\n #include \"midx.h\"\n #include \"config.h\"\ndiff --git a/pack-check.c b/pack-check.c\nindex 874897d6cba..67cb2cf72f2 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -8,7 +8,7 @@\n #include \"progress.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct idx_entry {\n \toff_t                offset;\ndiff --git a/pack-mtimes.c b/pack-mtimes.c\nindex 20900ca88d3..8e1f2dec0ef 100644\n--- a/pack-mtimes.c\n+++ b/pack-mtimes.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-mtimes.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 475a2d67ce3..1ac8644201b 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -1,7 +1,7 @@\n #ifndef PACK_OBJECTS_H\n #define PACK_OBJECTS_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"thread-utils.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex ffcde48870d..0cc422a1e67 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-revindex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\ndiff --git a/packfile.c b/packfile.c\nindex e31e55f0c02..8133948b58f 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -19,7 +19,7 @@\n #include \"tree-walk.h\"\n #include \"tree.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"midx.h\"\n #include \"commit-graph.h\"\n #include \"pack-revindex.h\"\ndiff --git a/packfile.h b/packfile.h\nindex 826eb7f475f..53c3b7d3b43 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -3,10 +3,10 @@\n \n #include \"list.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n-/* in object-store.h */\n+/* in odb.h */\n struct object_info;\n \n struct packed_git {\ndiff --git a/path.c b/path.c\nindex 7be0e0214df..36ddfb24701 100644\n--- a/path.c\n+++ b/path.c\n@@ -15,7 +15,7 @@\n #include \"submodule-config.h\"\n #include \"path.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"lockfile.h\"\n #include \"exec-cmd.h\"\n \ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 9d058586dfa..2baa286bfd0 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"config.h\"\n #include \"trace2.h\"\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 9b8db37a210..3022f69a1bd 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -6,7 +6,7 @@\n #include \"hash.h\"\n #include \"hex.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"string-list.h\"\n #include \"strbuf.h\"\ndiff --git a/read-cache.c b/read-cache.c\nindex 73f83a7e7a1..dce1056ec7c 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -20,7 +20,7 @@\n #include \"refs.h\"\n #include \"dir.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 7a274633cfc..4ce45440ad1 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"wildmatch.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"repo-settings.h\"\n #include \"repository.h\"\ndiff --git a/reflog.c b/reflog.c\nindex 15d81ebea97..4f8a3b717cd 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -5,7 +5,7 @@\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"parse-options.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"reflog.h\"\n #include \"refs.h\"\n #include \"revision.h\"\ndiff --git a/refs.c b/refs.c\nindex 27325d2f3c6..82a70b502f8 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"hook.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"path.h\"\n #include \"submodule.h\"\ndiff --git a/remote.c b/remote.c\nindex 4099183cacd..17a842f5684 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/replace-object.c b/replace-object.c\nindex 7b8a09b5cb4..65b3c108629 100644\n--- a/replace-object.c\n+++ b/replace-object.c\n@@ -2,7 +2,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"oidmap.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"refs.h\"\n #include \"repository.h\"\ndiff --git a/replace-object.h b/replace-object.h\nindex ba478eb30c4..b1b059ed2fe 100644\n--- a/replace-object.h\n+++ b/replace-object.h\n@@ -3,7 +3,7 @@\n \n #include \"oidmap.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct replace_object {\n \tstruct oidmap_entry original;\ndiff --git a/repository.c b/repository.c\nindex dcc03fd9e0a..dbc7fa8685f 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"object.h\"\n #include \"lockfile.h\"\ndiff --git a/rerere.c b/rerere.c\nindex 3cd37c5f0ae..951e4bf8b41 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -18,7 +18,7 @@\n #include \"path.h\"\n #include \"pathspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strmap.h\"\n \n #define RESOLVED 0\ndiff --git a/revision.c b/revision.c\nindex 2c36a9c179e..cdefe7d6e48 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -8,7 +8,7 @@\n #include \"hex.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"tag.h\"\n #include \"blob.h\"\ndiff --git a/send-pack.c b/send-pack.c\nindex 86592ce526d..abca2dd38a7 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"run-command.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex b5c4043757e..35f4e68d59f 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -13,7 +13,7 @@\n #include \"dir.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"pager.h\"\n #include \"commit.h\"\ndiff --git a/server-info.c b/server-info.c\nindex d6cd20a39d7..9bb30d9ab71 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -11,7 +11,7 @@\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"server-info.h\"\n #include \"strbuf.h\"\n #include \"tempfile.h\"\ndiff --git a/shallow.c b/shallow.c\nindex faeeeb45f98..d379756e39a 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -5,7 +5,7 @@\n #include \"repository.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"pkt-line.h\"\ndiff --git a/streaming.c b/streaming.c\nindex 127d6b5d6ac..29cc877f22a 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -10,7 +10,7 @@\n #include \"streaming.h\"\n #include \"repository.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"packfile.h\"\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex 0ee0a2884ef..09034a587f1 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -13,7 +13,7 @@\n #include \"submodule.h\"\n #include \"strbuf.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/submodule.c b/submodule.c\nindex ead3fb5dadc..9b1018877df 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -27,7 +27,7 @@\n #include \"parse-options.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c\nindex 76c2f4eba85..611a13a3261 100644\n--- a/t/helper/test-find-pack.c\n+++ b/t/helper/test-find-pack.c\n@@ -2,7 +2,7 @@\n \n #include \"test-tool.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c\nindex fdf1b13437b..d51aaa3dc40 100644\n--- a/t/helper/test-pack-mtimes.c\n+++ b/t/helper/test-pack-mtimes.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"strbuf.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pack-mtimes.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex 34f1aee5581..dba227259a2 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -1,7 +1,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n /*\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex cd8ba0c54e7..bc37c00a3bd 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"commit-graph.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"bloom.h\"\n #include \"setup.h\"\n \ndiff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c\nindex ac81390899a..da2aa036b57 100644\n--- a/t/helper/test-read-midx.c\n+++ b/t/helper/test-read-midx.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"midx.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"packfile.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 4cfc7c90b59..2920ca59d72 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -5,7 +5,7 @@\n #include \"refs.h\"\n #include \"setup.h\"\n #include \"worktree.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"strbuf.h\"\ndiff --git a/tag.c b/tag.c\nindex 05be39067cf..5f6868bf7b1 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -5,7 +5,7 @@\n #include \"environment.h\"\n #include \"tag.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"blob.h\"\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex b8fe0fdd7d4..9e05fcbddd0 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -10,7 +10,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"quote.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n struct tmp_objdir {\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 90655d52378..34b0fff4873 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -6,7 +6,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace2.h\"\n #include \"tree.h\"\n #include \"pathspec.h\"\ndiff --git a/tree.c b/tree.c\nindex b85f56267fb..341b7c2ff3f 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"tree.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"alloc.h\"\n #include \"tree-walk.h\"\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 471837f0329..f38c761ab98 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -26,7 +26,7 @@\n #include \"symlinks.h\"\n #include \"trace2.h\"\n #include \"fsmonitor.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"entry.h\"\n #include \"parallel-checkout.h\"\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 956da5b061a..cec12cb478a 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -10,7 +10,7 @@\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/walker.c b/walker.c\nindex b470d43e54d..a8abe8a2e78 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"walker.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"strbuf.h\"\n #include \"tree.h\"\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 1edcd319e6e..01e6e378ea6 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"config.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"xdiff-interface.h\"\n #include \"xdiff/xtypes.h\"\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518004","messageId":"20250514-pks-object-store-wo-the-repository-v3-2-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:25Z","receivedAt":"2025-05-14T05:12:33Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `object_directory` structure is used as an access point for a single\nobject directory like \".git/objects\". While the structure isn't yet\nfully self-contained, the intent is for it to eventually contain all\ninformation required to access objects in one specific location.\n\nWhile the name \"object directory\" is a good fit for now, this will\nchange over time as we continue with the agenda to make pluggable object\ndatabases a thing. Eventually, objects may not be accessed via any kind\nof directory at all anymore, but they could instead be backed by any\nkind of durable storage mechanism. While it seems quite far-fetched for\nnow, it is thinkable that eventually this might even be some form of a\ndatabase, for example.\n\nAs such, the current name of this structure will become worse over time\nas we evolve into the direction of pluggable ODBs. Immediate next steps\nwill start to carve out proper self-contained object directories, which\nrequires us to pass in these object directories as parameters. Based on\nour modern naming schema this means that those functions should then be\nnamed after their subsystem, which means that we would start to bake the\ncurrent name into the codebase more and more.\n\nLet's preempt this by renaming the structure to `odb_alternate` now\nalready. This name is agnostic of how exactly objects are stored while\nstill specifically pinpointing that this is about an alternate object\ndatabase. Furthermore, it is already used in Git to represent this\ncontext -- the only stretch is that the primary object directory is now\nthe primary alternate.\n\nIn the future, this change allows us to easily introduce for example a\n`odb_files_alternate` and other format-specific implementations.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c      |  18 +++----\n builtin/count-objects.c     |   4 +-\n builtin/fetch.c             |   2 +-\n builtin/fsck.c              |  14 ++---\n builtin/gc.c                |  14 ++---\n builtin/grep.c              |   2 +-\n builtin/multi-pack-index.c  |   4 +-\n builtin/submodule--helper.c |   6 +--\n bundle.c                    |   2 +-\n commit-graph.c              |  94 +++++++++++++++++-----------------\n commit-graph.h              |  14 ++---\n diagnose.c                  |   8 +--\n http-walker.c               |   2 +-\n http.c                      |   4 +-\n loose.c                     |  42 +++++++--------\n midx.c                      |   6 +--\n object-file.c               |  80 ++++++++++++++---------------\n object-file.h               |   8 +--\n object-name.c               |   6 +--\n object-store.c              | 122 ++++++++++++++++++++++----------------------\n object-store.h              |  28 ++++++----\n packfile.c                  |  16 +++---\n path.c                      |   2 +-\n refs.c                      |   2 +-\n repository.c                |  14 ++---\n submodule-config.c          |   2 +-\n t/helper/test-read-graph.c  |   6 +--\n tmp-objdir.c                |  24 ++++-----\n 28 files changed, 276 insertions(+), 270 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex a783a86e797..628d3a1e92e 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \t\t\tstruct repository *repo UNUSED)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_alternate *alternate = NULL;\n \tchar *graph_name;\n \tchar *chain_name;\n \tenum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;\n@@ -101,9 +101,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n-\tgraph_name = get_commit_graph_filename(odb);\n-\tchain_name = get_commit_graph_chain_filename(odb);\n+\talternate = find_odb(the_repository, opts.obj_dir);\n+\tgraph_name = get_commit_graph_filename(alternate);\n+\tchain_name = get_commit_graph_chain_filename(alternate);\n \tif (open_commit_graph(graph_name, &fd, &st))\n \t\topened = OPENED_GRAPH;\n \telse if (errno != ENOENT)\n@@ -120,7 +120,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opened == OPENED_NONE)\n \t\treturn 0;\n \telse if (opened == OPENED_GRAPH)\n-\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);\n+\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, alternate);\n \telse\n \t\tgraph = load_commit_graph_chain_fd_st(the_repository, fd, &st,\n \t\t\t\t\t\t      &incomplete_chain);\n@@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \tstruct string_list pack_indexes = STRING_LIST_INIT_DUP;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct oidset commits = OIDSET_INIT;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_alternate *alternate = NULL;\n \tint result = 0;\n \tenum commit_graph_write_flags flags = 0;\n \tstruct progress *progress = NULL;\n@@ -289,10 +289,10 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n+\talternate = find_odb(the_repository, opts.obj_dir);\n \n \tif (opts.reachable) {\n-\t\tif (write_commit_graph_reachable(odb, flags, &write_opts))\n+\t\tif (write_commit_graph_reachable(alternate, flags, &write_opts))\n \t\t\tresult = 1;\n \t\tgoto cleanup;\n \t}\n@@ -318,7 +318,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t\tstop_progress(&progress);\n \t}\n \n-\tif (write_commit_graph(odb,\n+\tif (write_commit_graph(alternate,\n \t\t\t       opts.stdin_packs ? &pack_indexes : NULL,\n \t\t\t       opts.stdin_commits ? &commits : NULL,\n \t\t\t       flags,\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex a88c0c9c09a..da830fcee57 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -80,10 +80,10 @@ static int count_cruft(const char *basename UNUSED, const char *path,\n \treturn 0;\n }\n \n-static int print_alternate(struct object_directory *odb, void *data UNUSED)\n+static int print_alternate(struct odb_alternate *alternate, void *data UNUSED)\n {\n \tprintf(\"alternate: \");\n-\tquote_c_style(odb->path, NULL, stdout, 0);\n+\tquote_c_style(alternate->path, NULL, stdout, 0);\n \tputchar('\\n');\n \treturn 0;\n }\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex cda6eaf1fd6..4de6d3206d4 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2652,7 +2652,7 @@ int cmd_fetch(int argc,\n \t\t\tcommit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n \t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\", the_repository);\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->alternates,\n \t\t\t\t\t     commit_graph_flags,\n \t\t\t\t\t     NULL);\n \t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\", the_repository);\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6cac28356ce..9c54286540c 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -965,7 +965,7 @@ int cmd_fsck(int argc,\n \t     struct repository *repo UNUSED)\n {\n \tint i;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \t/* fsck knows how to handle missing promisor objects */\n \tfetch_if_missing = 0;\n@@ -1007,8 +1007,8 @@ int cmd_fsck(int argc,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next)\n-\t\t\tfsck_object_dir(odb->path);\n+\t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next)\n+\t\t\tfsck_object_dir(alternate->path);\n \n \t\tif (check_full) {\n \t\t\tstruct packed_git *p;\n@@ -1118,11 +1118,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&commit_graph_verify.args, \"commit-graph\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", alternate->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&commit_graph_verify.args, \"--progress\");\n \t\t\telse\n@@ -1136,11 +1136,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&midx_verify.args, \"multi-pack-index\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", alternate->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&midx_verify.args, \"--progress\");\n \t\t\telse\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 78a2751aa8a..9e9d31c1f39 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -944,7 +944,7 @@ struct repository *repo UNUSED)\n \t}\n \n \tif (the_repository->settings.gc_write_commit_graph == 1)\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->alternates,\n \t\t\t\t\t     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,\n \t\t\t\t\t     NULL);\n \n@@ -1197,7 +1197,7 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)\n \tif (loose_object_auto_limit < 0)\n \t\treturn 1;\n \n-\treturn for_each_loose_file_in_objdir(the_repository->objects->odb->path,\n+\treturn for_each_loose_file_in_objdir(the_repository->objects->alternates->path,\n \t\t\t\t\t     loose_object_count,\n \t\t\t\t\t     NULL, NULL, &count);\n }\n@@ -1232,7 +1232,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t * Do not start pack-objects process\n \t * if there are no loose objects.\n \t */\n-\tif (!for_each_loose_file_in_objdir(r->objects->odb->path,\n+\tif (!for_each_loose_file_in_objdir(r->objects->alternates->path,\n \t\t\t\t\t   bail_on_loose,\n \t\t\t\t\t   NULL, NULL, NULL))\n \t\treturn 0;\n@@ -1244,7 +1244,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t\tstrvec_push(&pack_proc.args, \"--quiet\");\n \telse\n \t\tstrvec_push(&pack_proc.args, \"--no-quiet\");\n-\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->odb->path);\n+\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->alternates->path);\n \n \tpack_proc.in = -1;\n \n@@ -1272,7 +1272,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \telse if (data.batch_size > 0)\n \t\tdata.batch_size--; /* Decrease for equality on limit. */\n \n-\tfor_each_loose_file_in_objdir(r->objects->odb->path,\n+\tfor_each_loose_file_in_objdir(r->objects->alternates->path,\n \t\t\t\t      write_loose_object_to_stdin,\n \t\t\t\t      NULL,\n \t\t\t\t      NULL,\n@@ -1525,7 +1525,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,\n \tint result = 0;\n \tstruct lock_file lk;\n \tstruct repository *r = the_repository;\n-\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->alternates->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\t/*\n@@ -2997,7 +2997,7 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,\n \tunsigned int i;\n \tint result = 0;\n \tstruct lock_file lk;\n-\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->alternates->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\tif (errno == EEXIST)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ce574a605b..3c51a39c10d 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->odb->path);\n+\tadd_submodule_odb_by_path(subrepo->objects->alternates->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex 69a97507324..a77ae465d48 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -294,8 +294,8 @@ int cmd_multi_pack_index(int argc,\n \n \tif (the_repository &&\n \t    the_repository->objects &&\n-\t    the_repository->objects->odb)\n-\t\topts.object_dir = xstrdup(the_repository->objects->odb->path);\n+\t    the_repository->objects->alternates)\n+\t\topts.object_dir = xstrdup(the_repository->objects->alternates->path);\n \n \targc = parse_options(argc, argv, prefix, options,\n \t\t\t     builtin_multi_pack_index_usage, 0);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 53da2116ddf..cd7db11d825 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1582,7 +1582,7 @@ static const char alternate_error_advice[] = N_(\n );\n \n static int add_possible_reference_from_superproject(\n-\t\tstruct object_directory *odb, void *sas_cb)\n+\t\tstruct odb_alternate *alt_odb, void *sas_cb)\n {\n \tstruct submodule_alternate_setup *sas = sas_cb;\n \tsize_t len;\n@@ -1591,12 +1591,12 @@ static int add_possible_reference_from_superproject(\n \t * If the alternate object store is another repository, try the\n \t * standard layout with .git/(modules/<name>)+/objects\n \t */\n-\tif (strip_suffix(odb->path, \"/objects\", &len)) {\n+\tif (strip_suffix(alt_odb->path, \"/objects\", &len)) {\n \t\tstruct repository alternate;\n \t\tchar *sm_alternate;\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstruct strbuf err = STRBUF_INIT;\n-\t\tstrbuf_add(&sb, odb->path, len);\n+\t\tstrbuf_add(&sb, alt_odb->path, len);\n \n \t\tif (repo_init(&alternate, sb.buf, NULL) < 0)\n \t\t\tdie(_(\"could not get a repository handle for gitdir '%s'\"),\ndiff --git a/bundle.c b/bundle.c\nindex b0a3fee2efa..0c7cd15bb12 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -233,7 +233,7 @@ int verify_bundle(struct repository *r,\n \t\t.quiet = 1,\n \t};\n \n-\tif (!r || !r->objects || !r->objects->odb)\n+\tif (!r || !r->objects || !r->objects->alternates)\n \t\treturn error(_(\"need a repository to verify a bundle\"));\n \n \tfor (i = 0; i < p->nr; i++) {\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 1b66486b9c9..58d1eeedb1a 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -37,7 +37,7 @@ void git_test_write_commit_graph_or_die(void)\n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph_reachable(the_repository->objects->odb,\n+\tif (write_commit_graph_reachable(the_repository->objects->alternates,\n \t\t\t\t\t flags, NULL))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n@@ -191,21 +191,21 @@ static int commit_gen_cmp(const void *va, const void *vb)\n \treturn 0;\n }\n \n-char *get_commit_graph_filename(struct object_directory *obj_dir)\n+char *get_commit_graph_filename(struct odb_alternate *alternate)\n {\n-\treturn xstrfmt(\"%s/info/commit-graph\", obj_dir->path);\n+\treturn xstrfmt(\"%s/info/commit-graph\", alternate->path);\n }\n \n-static char *get_split_graph_filename(struct object_directory *odb,\n+static char *get_split_graph_filename(struct odb_alternate *alternate,\n \t\t\t\t      const char *oid_hex)\n {\n-\treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", odb->path,\n+\treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", alternate->path,\n \t\t       oid_hex);\n }\n \n-char *get_commit_graph_chain_filename(struct object_directory *odb)\n+char *get_commit_graph_chain_filename(struct odb_alternate *alternate)\n {\n-\treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", odb->path);\n+\treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", alternate->path);\n }\n \n static struct commit_graph *alloc_commit_graph(void)\n@@ -250,7 +250,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_alternate *alternate)\n {\n \tvoid *graph_map;\n \tsize_t graph_size;\n@@ -269,7 +269,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \tret = parse_commit_graph(&r->settings, graph_map, graph_size);\n \n \tif (ret)\n-\t\tret->odb = odb;\n+\t\tret->alternate = alternate;\n \telse\n \t\tmunmap(graph_map, graph_size);\n \n@@ -487,7 +487,7 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s,\n \n static struct commit_graph *load_commit_graph_one(struct repository *r,\n \t\t\t\t\t\t  const char *graph_file,\n-\t\t\t\t\t\t  struct object_directory *odb)\n+\t\t\t\t\t\t  struct odb_alternate *alternate)\n {\n \n \tstruct stat st;\n@@ -498,7 +498,7 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n \tif (!open_ok)\n \t\treturn NULL;\n \n-\tg = load_commit_graph_one_fd_st(r, fd, &st, odb);\n+\tg = load_commit_graph_one_fd_st(r, fd, &st, alternate);\n \n \tif (g)\n \t\tg->filename = xstrdup(graph_file);\n@@ -507,10 +507,10 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_v1(struct repository *r,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_alternate *alternate)\n {\n-\tchar *graph_name = get_commit_graph_filename(odb);\n-\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\tchar *graph_name = get_commit_graph_filename(alternate);\n+\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, alternate);\n \tfree(graph_name);\n \n \treturn g;\n@@ -652,7 +652,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tprepare_alt_odb(r);\n \n \tfor (i = 0; i < count; i++) {\n-\t\tstruct object_directory *odb;\n+\t\tstruct odb_alternate *alternate;\n \n \t\tif (strbuf_getline_lf(&line, fp) == EOF)\n \t\t\tbreak;\n@@ -665,9 +665,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t}\n \n \t\tvalid = 0;\n-\t\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t\tchar *graph_name = get_split_graph_filename(odb, line.buf);\n-\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\t\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\t\tchar *graph_name = get_split_graph_filename(alternate, line.buf);\n+\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, alternate);\n \n \t\t\tfree(graph_name);\n \n@@ -701,9 +701,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_chain(struct repository *r,\n-\t\t\t\t\t\t    struct object_directory *odb)\n+\t\t\t\t\t\t    struct odb_alternate *alternate)\n {\n-\tchar *chain_file = get_commit_graph_chain_filename(odb);\n+\tchar *chain_file = get_commit_graph_chain_filename(alternate);\n \tstruct stat st;\n \tint fd;\n \tstruct commit_graph *g = NULL;\n@@ -719,24 +719,24 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,\n }\n \n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb)\n+\t\t\t\t\t   struct odb_alternate *alternate)\n {\n-\tstruct commit_graph *g = load_commit_graph_v1(r, odb);\n+\tstruct commit_graph *g = load_commit_graph_v1(r, alternate);\n \n \tif (!g)\n-\t\tg = load_commit_graph_chain(r, odb);\n+\t\tg = load_commit_graph_chain(r, alternate);\n \n \treturn g;\n }\n \n static void prepare_commit_graph_one(struct repository *r,\n-\t\t\t\t     struct object_directory *odb)\n+\t\t\t\t     struct odb_alternate *alternate)\n {\n \n \tif (r->objects->commit_graph)\n \t\treturn;\n \n-\tr->objects->commit_graph = read_commit_graph_one(r, odb);\n+\tr->objects->commit_graph = read_commit_graph_one(r, alternate);\n }\n \n /*\n@@ -747,7 +747,7 @@ static void prepare_commit_graph_one(struct repository *r,\n  */\n static int prepare_commit_graph(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \t/*\n \t * Early return if there is no git dir or if the commit graph is\n@@ -779,10 +779,10 @@ static int prepare_commit_graph(struct repository *r)\n \t\treturn 0;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb;\n-\t     !r->objects->commit_graph && odb;\n-\t     odb = odb->next)\n-\t\tprepare_commit_graph_one(r, odb);\n+\tfor (alternate = r->objects->alternates;\n+\t     !r->objects->commit_graph && alternate;\n+\t     alternate = alternate->next)\n+\t\tprepare_commit_graph_one(r, alternate);\n \treturn !!r->objects->commit_graph;\n }\n \n@@ -1137,7 +1137,7 @@ struct packed_commit_list {\n \n struct write_commit_graph_context {\n \tstruct repository *r;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tchar *graph_name;\n \tstruct oid_array oids;\n \tstruct packed_commit_list commits;\n@@ -1870,7 +1870,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \treturn 0;\n }\n \n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_alternate *alternate,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts)\n {\n@@ -1890,7 +1890,7 @@ int write_commit_graph_reachable(struct object_directory *odb,\n \n \tstop_progress(&data.progress);\n \n-\tresult = write_commit_graph(odb, NULL, &commits,\n+\tresult = write_commit_graph(alternate, NULL, &commits,\n \t\t\t\t    flags, opts);\n \n \toidset_clear(&commits);\n@@ -1906,7 +1906,7 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,\n \tint dirlen;\n \tint ret = 0;\n \n-\tstrbuf_addf(&packname, \"%s/pack/\", ctx->odb->path);\n+\tstrbuf_addf(&packname, \"%s/pack/\", ctx->alternate->path);\n \tdirlen = packname.len;\n \tif (ctx->report_progress) {\n \t\tstrbuf_addf(&progress_title,\n@@ -2058,10 +2058,10 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \n \t\tstrbuf_addf(&tmp_file,\n \t\t\t    \"%s/info/commit-graphs/tmp_graph_XXXXXX\",\n-\t\t\t    ctx->odb->path);\n+\t\t\t    ctx->alternate->path);\n \t\tctx->graph_name = strbuf_detach(&tmp_file, NULL);\n \t} else {\n-\t\tctx->graph_name = get_commit_graph_filename(ctx->odb);\n+\t\tctx->graph_name = get_commit_graph_filename(ctx->alternate);\n \t}\n \n \tif (safe_create_leading_directories(the_repository, ctx->graph_name)) {\n@@ -2071,7 +2071,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t}\n \n \tif (ctx->split) {\n-\t\tchar *lock_name = get_commit_graph_chain_filename(ctx->odb);\n+\t\tchar *lock_name = get_commit_graph_chain_filename(ctx->alternate);\n \n \t\thold_lock_file_for_update_mode(&lk, lock_name,\n \t\t\t\t\t       LOCK_DIE_ON_ERROR, 0444);\n@@ -2159,7 +2159,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \n \tif (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {\n \t\tchar *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));\n-\t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb, new_base_hash);\n+\t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->alternate, new_base_hash);\n \n \t\tfree(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]);\n \t\tfree(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]);\n@@ -2199,14 +2199,14 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\t\t\t}\n \t\t\t}\n \t\t} else {\n-\t\t\tchar *graph_name = get_commit_graph_filename(ctx->odb);\n+\t\t\tchar *graph_name = get_commit_graph_filename(ctx->alternate);\n \t\t\tunlink(graph_name);\n \t\t\tfree(graph_name);\n \t\t}\n \n \t\tfree(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);\n \t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));\n-\t\tfinal_graph_name = get_split_graph_filename(ctx->odb,\n+\t\tfinal_graph_name = get_split_graph_filename(ctx->alternate,\n \t\t\t\t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);\n \t\tfree(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);\n \t\tctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;\n@@ -2257,7 +2257,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)\n \t    flags != COMMIT_GRAPH_SPLIT_REPLACE) {\n \t\twhile (g && (g->num_commits <= st_mult(size_mult, num_commits) ||\n \t\t\t    (max_commits && num_commits > max_commits))) {\n-\t\t\tif (g->odb != ctx->odb)\n+\t\t\tif (g->alternate != ctx->alternate)\n \t\t\t\tbreak;\n \n \t\t\tif (unsigned_add_overflows(num_commits, g->num_commits))\n@@ -2279,10 +2279,10 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)\n \t\t    \"should be 1 with --split=replace\");\n \n \tif (ctx->num_commit_graphs_after == 2) {\n-\t\tchar *old_graph_name = get_commit_graph_filename(g->odb);\n+\t\tchar *old_graph_name = get_commit_graph_filename(g->alternate);\n \n \t\tif (!strcmp(g->filename, old_graph_name) &&\n-\t\t    g->odb != ctx->odb) {\n+\t\t    g->alternate != ctx->alternate) {\n \t\t\tctx->num_commit_graphs_after = 1;\n \t\t\tctx->new_base_graph = NULL;\n \t\t}\n@@ -2454,13 +2454,13 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tif (ctx->opts && ctx->opts->expire_time)\n \t\texpire_time = ctx->opts->expire_time;\n \tif (!ctx->split) {\n-\t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->odb);\n+\t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->alternate);\n \t\tunlink(chain_file_name);\n \t\tfree(chain_file_name);\n \t\tctx->num_commit_graphs_after = 0;\n \t}\n \n-\tstrbuf_addstr(&path, ctx->odb->path);\n+\tstrbuf_addstr(&path, ctx->alternate->path);\n \tstrbuf_addstr(&path, \"/info/commit-graphs\");\n \tdir = opendir(path.buf);\n \n@@ -2502,7 +2502,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tstrbuf_release(&path);\n }\n \n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_alternate *alternate,\n \t\t       const struct string_list *const pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\n@@ -2533,7 +2533,7 @@ int write_commit_graph(struct object_directory *odb,\n \n \tCALLOC_ARRAY(ctx, 1);\n \tctx->r = r;\n-\tctx->odb = odb;\n+\tctx->alternate = alternate;\n \tctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;\n \tctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;\n \tctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 20d38c100ce..19d95ade6ea 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -29,8 +29,8 @@ struct repository;\n struct object_database;\n struct string_list;\n \n-char *get_commit_graph_filename(struct object_directory *odb);\n-char *get_commit_graph_chain_filename(struct object_directory *odb);\n+char *get_commit_graph_filename(struct odb_alternate *alternate);\n+char *get_commit_graph_chain_filename(struct odb_alternate *alternate);\n int open_commit_graph(const char *graph_file, int *fd, struct stat *st);\n int open_commit_graph_chain(const char *chain_file, int *fd, struct stat *st);\n \n@@ -89,7 +89,7 @@ struct commit_graph {\n \tuint32_t num_commits;\n \tstruct object_id oid;\n \tchar *filename;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tuint32_t num_commits_in_base;\n \tunsigned int read_generation_data;\n@@ -115,12 +115,12 @@ struct commit_graph {\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb);\n+\t\t\t\t\t\t struct odb_alternate *alternate);\n struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t\t\t\t\t   int fd, struct stat *st,\n \t\t\t\t\t\t   int *incomplete_chain);\n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb);\n+\t\t\t\t\t   struct odb_alternate *alternate);\n \n struct repo_settings;\n \n@@ -173,10 +173,10 @@ struct commit_graph_opts {\n  * is not compatible with the commit-graph feature, then the\n  * methods will return 0 without writing a commit-graph.\n  */\n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_alternate *alternate,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts);\n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_alternate *alternate,\n \t\t       const struct string_list *pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\ndiff --git a/diagnose.c b/diagnose.c\nindex b1be74be983..50129cf4be3 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -59,13 +59,13 @@ static void dir_file_stats_objects(const char *full_path,\n \t\t\t    (uintmax_t)st.st_size);\n }\n \n-static int dir_file_stats(struct object_directory *object_dir, void *data)\n+static int dir_file_stats(struct odb_alternate *alternate, void *data)\n {\n \tstruct strbuf *buf = data;\n \n-\tstrbuf_addf(buf, \"Contents of %s:\\n\", object_dir->path);\n+\tstrbuf_addf(buf, \"Contents of %s:\\n\", alternate->path);\n \n-\tfor_each_file_in_pack_dir(object_dir->path, dir_file_stats_objects,\n+\tfor_each_file_in_pack_dir(alternate->path, dir_file_stats_objects,\n \t\t\t\t  data);\n \n \treturn 0;\n@@ -228,7 +228,7 @@ int create_diagnostics_archive(struct repository *r,\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n-\tdir_file_stats(r->objects->odb, &buf);\n+\tdir_file_stats(r->objects->alternates, &buf);\n \tforeach_alt_odb(dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \ndiff --git a/http-walker.c b/http-walker.c\nindex 463f7b119ad..9e7bc37f02e 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -543,7 +543,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \t\tret = error(\"File %s has bad hash\", hex);\n \t} else if (req->rename < 0) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\todb_loose_path(the_repository->objects->odb, &buf, &req->oid);\n+\t\todb_loose_path(the_repository->objects->alternates, &buf, &req->oid);\n \t\tret = error(\"unable to write sha1 filename %s\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\ndiff --git a/http.c b/http.c\nindex 3c029cf8947..8ce2ec73947 100644\n--- a/http.c\n+++ b/http.c\n@@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \toidcpy(&freq->oid, oid);\n \tfreq->localfile = -1;\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->alternates, &filename, oid);\n \tstrbuf_addf(&freq->tmpfile, \"%s.temp\", filename.buf);\n \n \tstrbuf_addf(&prevfile, \"%s.prev\", filename.buf);\n@@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)\n \t\tunlink_or_warn(freq->tmpfile.buf);\n \t\treturn -1;\n \t}\n-\todb_loose_path(the_repository->objects->odb, &filename, &freq->oid);\n+\todb_loose_path(the_repository->objects->alternates, &filename, &freq->oid);\n \tfreq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);\n \tstrbuf_release(&filename);\n \ndiff --git a/loose.c b/loose.c\nindex bb602aaa366..bce4e1c3ee7 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -44,36 +44,36 @@ static int insert_oid_pair(kh_oid_map_t *map, const struct object_id *key, const\n \treturn 1;\n }\n \n-static int insert_loose_map(struct object_directory *odb,\n+static int insert_loose_map(struct odb_alternate *alternate,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\n {\n-\tstruct loose_object_map *map = odb->loose_map;\n+\tstruct loose_object_map *map = alternate->loose_map;\n \tint inserted = 0;\n \n \tinserted |= insert_oid_pair(map->to_compat, oid, compat_oid);\n \tinserted |= insert_oid_pair(map->to_storage, compat_oid, oid);\n \tif (inserted)\n-\t\toidtree_insert(odb->loose_objects_cache, compat_oid);\n+\t\toidtree_insert(alternate->loose_objects_cache, compat_oid);\n \n \treturn inserted;\n }\n \n-static int load_one_loose_object_map(struct repository *repo, struct object_directory *dir)\n+static int load_one_loose_object_map(struct repository *repo, struct odb_alternate *alternate)\n {\n \tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n \tFILE *fp;\n \n-\tif (!dir->loose_map)\n-\t\tloose_object_map_init(&dir->loose_map);\n-\tif (!dir->loose_objects_cache) {\n-\t\tALLOC_ARRAY(dir->loose_objects_cache, 1);\n-\t\toidtree_init(dir->loose_objects_cache);\n+\tif (!alternate->loose_map)\n+\t\tloose_object_map_init(&alternate->loose_map);\n+\tif (!alternate->loose_objects_cache) {\n+\t\tALLOC_ARRAY(alternate->loose_objects_cache, 1);\n+\t\toidtree_init(alternate->loose_objects_cache);\n \t}\n \n-\tinsert_loose_map(dir, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);\n-\tinsert_loose_map(dir, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);\n-\tinsert_loose_map(dir, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);\n+\tinsert_loose_map(alternate, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);\n+\tinsert_loose_map(alternate, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);\n+\tinsert_loose_map(alternate, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);\n \n \trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n \tfp = fopen(path.buf, \"rb\");\n@@ -93,7 +93,7 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \t\t    parse_oid_hex_algop(p, &compat_oid, &p, repo->compat_hash_algo) ||\n \t\t    p != buf.buf + buf.len)\n \t\t\tgoto err;\n-\t\tinsert_loose_map(dir, &oid, &compat_oid);\n+\t\tinsert_loose_map(alternate, &oid, &compat_oid);\n \t}\n \n \tstrbuf_release(&buf);\n@@ -107,15 +107,15 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \n int repo_read_loose_object_map(struct repository *repo)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_alternate *alternate;\n \n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n \tprepare_alt_odb(repo);\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tif (load_one_loose_object_map(repo, dir) < 0) {\n+\tfor (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tif (load_one_loose_object_map(repo, alternate) < 0) {\n \t\t\treturn -1;\n \t\t}\n \t}\n@@ -124,7 +124,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \n int repo_write_loose_object_map(struct repository *repo)\n {\n-\tkh_oid_map_t *map = repo->objects->odb->loose_map->to_compat;\n+\tkh_oid_map_t *map = repo->objects->alternates->loose_map->to_compat;\n \tstruct lock_file lock;\n \tint fd;\n \tkhiter_t iter;\n@@ -212,7 +212,7 @@ int repo_add_loose_object_map(struct repository *repo, const struct object_id *o\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tinserted = insert_loose_map(repo->objects->odb, oid, compat_oid);\n+\tinserted = insert_loose_map(repo->objects->alternates, oid, compat_oid);\n \tif (inserted)\n \t\treturn write_one_object(repo, oid, compat_oid);\n \treturn 0;\n@@ -223,12 +223,12 @@ int repo_loose_object_map_oid(struct repository *repo,\n \t\t\t      const struct git_hash_algo *to,\n \t\t\t      struct object_id *dest)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_alternate *alternate;\n \tkh_oid_map_t *map;\n \tkhiter_t pos;\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tstruct loose_object_map *loose_map = dir->loose_map;\n+\tfor (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tstruct loose_object_map *loose_map = alternate->loose_map;\n \t\tif (!loose_map)\n \t\t\tcontinue;\n \t\tmap = (to == repo->compat_hash_algo) ?\ndiff --git a/midx.c b/midx.c\nindex 3d0015f7828..c1adff4404e 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -824,7 +824,7 @@ void clear_midx_file(struct repository *r)\n {\n \tstruct strbuf midx = STRBUF_INIT;\n \n-\tget_midx_filename(r->hash_algo, &midx, r->objects->odb->path);\n+\tget_midx_filename(r->hash_algo, &midx, r->objects->alternates->path);\n \n \tif (r->objects && r->objects->multi_pack_index) {\n \t\tclose_midx(r->objects->multi_pack_index);\n@@ -834,8 +834,8 @@ void clear_midx_file(struct repository *r)\n \tif (remove_path(midx.buf))\n \t\tdie(_(\"failed to clear multi-pack-index at %s\"), midx.buf);\n \n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_BITMAP, NULL);\n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_REV, NULL);\n+\tclear_midx_files_ext(r->objects->alternates->path, MIDX_EXT_BITMAP, NULL);\n+\tclear_midx_files_ext(r->objects->alternates->path, MIDX_EXT_REV, NULL);\n \n \tstrbuf_release(&midx);\n }\ndiff --git a/object-file.c b/object-file.c\nindex dc56a4766df..e48d968c0e0 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -55,12 +55,12 @@ static void fill_loose_path(struct strbuf *buf, const struct object_id *oid)\n \t}\n }\n \n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_alternate *alternate,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid)\n {\n \tstrbuf_reset(buf);\n-\tstrbuf_addstr(buf, odb->path);\n+\tstrbuf_addstr(buf, alternate->path);\n \tstrbuf_addch(buf, '/');\n \tfill_loose_path(buf, oid);\n \treturn buf->buf;\n@@ -88,27 +88,27 @@ int check_and_freshen_file(const char *fn, int freshen)\n \treturn 1;\n }\n \n-static int check_and_freshen_odb(struct object_directory *odb,\n+static int check_and_freshen_odb(struct odb_alternate *alternate,\n \t\t\t\t const struct object_id *oid,\n \t\t\t\t int freshen)\n {\n \tstatic struct strbuf path = STRBUF_INIT;\n-\todb_loose_path(odb, &path, oid);\n+\todb_loose_path(alternate, &path, oid);\n \treturn check_and_freshen_file(path.buf, freshen);\n }\n \n static int check_and_freshen_local(const struct object_id *oid, int freshen)\n {\n-\treturn check_and_freshen_odb(the_repository->objects->odb, oid, freshen);\n+\treturn check_and_freshen_odb(the_repository->objects->alternates, oid, freshen);\n }\n \n static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb->next; odb; odb = odb->next) {\n-\t\tif (check_and_freshen_odb(odb, oid, freshen))\n+\tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n+\t\tif (check_and_freshen_odb(alternate, oid, freshen))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -208,12 +208,12 @@ int stream_object_signature(struct repository *r, const struct object_id *oid)\n static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \t\t\t     struct stat *st, const char **path)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\t*path = odb_loose_path(alternate, &buf, oid);\n \t\tif (!lstat(*path, st))\n \t\t\treturn 0;\n \t}\n@@ -229,13 +229,13 @@ static int open_loose_object(struct repository *r,\n \t\t\t     const struct object_id *oid, const char **path)\n {\n \tint fd;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\t*path = odb_loose_path(alternate, &buf, oid);\n \t\tfd = git_open(*path);\n \t\tif (fd >= 0)\n \t\t\treturn fd;\n@@ -250,11 +250,11 @@ static int open_loose_object(struct repository *r,\n static int quick_has_loose(struct repository *r,\n \t\t\t   const struct object_id *oid)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tif (oidtree_contains(odb_loose_cache(odb, oid), oid))\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tif (oidtree_contains(odb_loose_cache(alternate, oid), oid))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -750,7 +750,7 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,\n /* Finalize a file on disk, and close it. */\n static void close_loose_object(int fd, const char *filename)\n {\n-\tif (the_repository->objects->odb->will_destroy)\n+\tif (the_repository->objects->alternates->will_destroy)\n \t\tgoto out;\n \n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n@@ -932,7 +932,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,\n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n \t\tprepare_loose_object_bulk_checkin();\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->alternates, &filename, oid);\n \n \tfd = start_loose_object_common(&tmp_file, filename.buf, flags,\n \t\t\t\t       &stream, compressed, sizeof(compressed),\n@@ -1079,7 +1079,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,\n \t\tgoto cleanup;\n \t}\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->alternates, &filename, oid);\n \n \t/* We finally know the object path, and create the missing dir. */\n \tdirlen = directory_size(filename.buf);\n@@ -1540,11 +1540,11 @@ int for_each_loose_file_in_objdir(const char *path,\n int for_each_loose_object(each_loose_object_fn cb, void *data,\n \t\t\t  enum for_each_object_flags flags)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n-\t\tint r = for_each_loose_file_in_objdir(odb->path, cb, NULL,\n+\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tint r = for_each_loose_file_in_objdir(alternate->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\n \t\tif (r)\n \t\t\treturn r;\n@@ -1564,43 +1564,43 @@ static int append_loose_object(const struct object_id *oid,\n \treturn 0;\n }\n \n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n-\t\t\t\t  const struct object_id *oid)\n+struct oidtree *odb_loose_cache(struct odb_alternate *alternate,\n+\t\t\t\tconst struct object_id *oid)\n {\n \tint subdir_nr = oid->hash[0];\n \tstruct strbuf buf = STRBUF_INIT;\n-\tsize_t word_bits = bitsizeof(odb->loose_objects_subdir_seen[0]);\n+\tsize_t word_bits = bitsizeof(alternate->loose_objects_subdir_seen[0]);\n \tsize_t word_index = subdir_nr / word_bits;\n \tsize_t mask = (size_t)1u << (subdir_nr % word_bits);\n \tuint32_t *bitmap;\n \n \tif (subdir_nr < 0 ||\n-\t    subdir_nr >= bitsizeof(odb->loose_objects_subdir_seen))\n+\t    subdir_nr >= bitsizeof(alternate->loose_objects_subdir_seen))\n \t\tBUG(\"subdir_nr out of range\");\n \n-\tbitmap = &odb->loose_objects_subdir_seen[word_index];\n+\tbitmap = &alternate->loose_objects_subdir_seen[word_index];\n \tif (*bitmap & mask)\n-\t\treturn odb->loose_objects_cache;\n-\tif (!odb->loose_objects_cache) {\n-\t\tALLOC_ARRAY(odb->loose_objects_cache, 1);\n-\t\toidtree_init(odb->loose_objects_cache);\n+\t\treturn alternate->loose_objects_cache;\n+\tif (!alternate->loose_objects_cache) {\n+\t\tALLOC_ARRAY(alternate->loose_objects_cache, 1);\n+\t\toidtree_init(alternate->loose_objects_cache);\n \t}\n-\tstrbuf_addstr(&buf, odb->path);\n+\tstrbuf_addstr(&buf, alternate->path);\n \tfor_each_file_in_obj_subdir(subdir_nr, &buf,\n \t\t\t\t    append_loose_object,\n \t\t\t\t    NULL, NULL,\n-\t\t\t\t    odb->loose_objects_cache);\n+\t\t\t\t    alternate->loose_objects_cache);\n \t*bitmap |= mask;\n \tstrbuf_release(&buf);\n-\treturn odb->loose_objects_cache;\n+\treturn alternate->loose_objects_cache;\n }\n \n-void odb_clear_loose_cache(struct object_directory *odb)\n+void odb_clear_loose_cache(struct odb_alternate *alternate)\n {\n-\toidtree_clear(odb->loose_objects_cache);\n-\tFREE_AND_NULL(odb->loose_objects_cache);\n-\tmemset(&odb->loose_objects_subdir_seen, 0,\n-\t       sizeof(odb->loose_objects_subdir_seen));\n+\toidtree_clear(alternate->loose_objects_cache);\n+\tFREE_AND_NULL(alternate->loose_objects_cache);\n+\tmemset(&alternate->loose_objects_subdir_seen, 0,\n+\t       sizeof(alternate->loose_objects_subdir_seen));\n }\n \n static int check_stream_oid(git_zstream *stream,\ndiff --git a/object-file.h b/object-file.h\nindex a85b2e5b494..f1601200938 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -24,23 +24,23 @@ enum {\n int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n \n-struct object_directory;\n+struct odb_alternate;\n \n /*\n  * Populate and return the loose object cache array corresponding to the\n  * given object ID.\n  */\n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n+struct oidtree *odb_loose_cache(struct odb_alternate *alternate,\n \t\t\t\tconst struct object_id *oid);\n \n /* Empty the loose object cache for the specified object directory. */\n-void odb_clear_loose_cache(struct object_directory *odb);\n+void odb_clear_loose_cache(struct odb_alternate *alternate);\n \n /*\n  * Put in `buf` the name of the file in the local object database that\n  * would be used to store a loose object with the specified oid.\n  */\n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_alternate *alternate,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid);\n \ndiff --git a/object-name.c b/object-name.c\nindex 9288b2dd245..b83ba882b9e 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -112,10 +112,10 @@ static enum cb_next match_prefix(const struct object_id *oid, void *arg)\n \n static void find_short_object_filename(struct disambiguate_state *ds)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n-\tfor (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next)\n-\t\toidtree_each(odb_loose_cache(odb, &ds->bin_pfx),\n+\tfor (alternate = ds->repo->objects->alternates; alternate && !ds->ambiguous; alternate = alternate->next)\n+\t\toidtree_each(odb_loose_cache(alternate, &ds->bin_pfx),\n \t\t\t\t&ds->bin_pfx, ds->len, match_prefix, ds);\n }\n \ndiff --git a/object-store.c b/object-store.c\nindex 1effcb12273..673a9c6006b 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -27,7 +27,7 @@\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n-\tstruct object_directory *, 1, fspathhash, fspatheq)\n+\tstruct odb_alternate *, 1, fspathhash, fspatheq)\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n@@ -104,18 +104,18 @@ static int alt_odb_usable(struct object_database *o,\n \t * Prevent the common mistake of listing the same\n \t * thing twice, or object directory itself.\n \t */\n-\tif (!o->odb_by_path) {\n+\tif (!o->alternate_by_path) {\n \t\tkhiter_t p;\n \n-\t\to->odb_by_path = kh_init_odb_path_map();\n-\t\tassert(!o->odb->next);\n-\t\tp = kh_put_odb_path_map(o->odb_by_path, o->odb->path, &r);\n+\t\to->alternate_by_path = kh_init_odb_path_map();\n+\t\tassert(!o->alternates->next);\n+\t\tp = kh_put_odb_path_map(o->alternate_by_path, o->alternates->path, &r);\n \t\tassert(r == 1); /* never used */\n-\t\tkh_value(o->odb_by_path, p) = o->odb;\n+\t\tkh_value(o->alternate_by_path, p) = o->alternates;\n \t}\n \tif (fspatheq(path->buf, normalized_objdir))\n \t\treturn 0;\n-\t*pos = kh_put_odb_path_map(o->odb_by_path, path->buf, &r);\n+\t*pos = kh_put_odb_path_map(o->alternate_by_path, path->buf, &r);\n \t/* r: 0 = exists, 1 = never used, 2 = deleted */\n \treturn r == 0 ? 0 : 1;\n }\n@@ -124,7 +124,7 @@ static int alt_odb_usable(struct object_database *o,\n  * Prepare alternate object database registry.\n  *\n  * The variable alt_odb_list points at the list of struct\n- * object_directory.  The elements on this list come from\n+ * odb_alternate.  The elements on this list come from\n  * non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT\n  * environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates,\n  * whose contents is similar to that environment variable but can be\n@@ -141,7 +141,7 @@ static void read_info_alternates(struct repository *r,\n static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tconst char *relative_base, int depth, const char *normalized_objdir)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_alternate *alternate;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n \tstruct strbuf tmp = STRBUF_INIT;\n \tkhiter_t pos;\n@@ -170,19 +170,19 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n-\tCALLOC_ARRAY(ent, 1);\n-\t/* pathbuf.buf is already in r->objects->odb_by_path */\n-\tent->path = strbuf_detach(&pathbuf, NULL);\n+\tCALLOC_ARRAY(alternate, 1);\n+\t/* pathbuf.buf is already in r->objects->alternate_by_path */\n+\talternate->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->odb_tail = ent;\n-\tr->objects->odb_tail = &(ent->next);\n-\tent->next = NULL;\n-\tassert(r->objects->odb_by_path);\n-\tkh_value(r->objects->odb_by_path, pos) = ent;\n+\t*r->objects->alternates_tail = alternate;\n+\tr->objects->alternates_tail = &(alternate->next);\n+\talternate->next = NULL;\n+\tassert(r->objects->alternate_by_path);\n+\tkh_value(r->objects->alternate_by_path, pos) = alternate;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, ent->path, depth + 1);\n+\tread_info_alternates(r, alternate->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -234,7 +234,7 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->odb->path, 1);\n+\tstrbuf_realpath(&objdirbuf, r->objects->alternates->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n@@ -321,9 +321,9 @@ void add_to_alternates_memory(const char *reference)\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy)\n {\n-\tstruct object_directory *new_odb;\n+\tstruct odb_alternate *alternate;\n \n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n@@ -335,41 +335,41 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n-\tnew_odb = xcalloc(1, sizeof(*new_odb));\n-\tnew_odb->path = xstrdup(dir);\n+\talternate = xcalloc(1, sizeof(*alternate));\n+\talternate->path = xstrdup(dir);\n \n \t/*\n \t * Disable ref updates while a temporary odb is active, since\n \t * the objects in the database may roll back.\n \t */\n-\tnew_odb->disable_ref_updates = 1;\n-\tnew_odb->will_destroy = will_destroy;\n-\tnew_odb->next = the_repository->objects->odb;\n-\tthe_repository->objects->odb = new_odb;\n-\treturn new_odb->next;\n+\talternate->disable_ref_updates = 1;\n+\talternate->will_destroy = will_destroy;\n+\talternate->next = the_repository->objects->alternates;\n+\tthe_repository->objects->alternates = alternate;\n+\treturn alternate->next;\n }\n \n-static void free_object_directory(struct object_directory *odb)\n+static void free_object_directory(struct odb_alternate *alternate)\n {\n-\tfree(odb->path);\n-\todb_clear_loose_cache(odb);\n-\tloose_object_map_clear(&odb->loose_map);\n-\tfree(odb);\n+\tfree(alternate->path);\n+\todb_clear_loose_cache(alternate);\n+\tloose_object_map_clear(&alternate->loose_map);\n+\tfree(alternate);\n }\n \n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path)\n+void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path)\n {\n-\tstruct object_directory *cur_odb = the_repository->objects->odb;\n+\tstruct odb_alternate *cur_alt = the_repository->objects->alternates;\n \n-\tif (strcmp(old_path, cur_odb->path))\n+\tif (strcmp(old_path, cur_alt->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n-\t\t    old_path, cur_odb->path);\n+\t\t    old_path, cur_alt->path);\n \n-\tif (cur_odb->next != restore_odb)\n+\tif (cur_alt->next != restore_alt)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->odb = restore_odb;\n-\tfree_object_directory(cur_odb);\n+\tthe_repository->objects->alternates = restore_alt;\n+\tfree_object_directory(cur_alt);\n }\n \n /*\n@@ -442,15 +442,15 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_alternate *find_odb(struct repository *r, const char *obj_dir)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tstrbuf_realpath(&odb_path_real, odb->path, 1);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tstrbuf_realpath(&odb_path_real, alternate->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\n \t}\n@@ -458,9 +458,9 @@ struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n \tfree(obj_dir_real);\n \tstrbuf_release(&odb_path_real);\n \n-\tif (!odb)\n+\tif (!alternate)\n \t\tdie(_(\"could not find object directory matching %s\"), obj_dir);\n-\treturn odb;\n+\treturn alternate;\n }\n \n static void fill_alternate_refs_command(struct child_process *cmd,\n@@ -527,14 +527,14 @@ struct alternate_refs_data {\n \tvoid *data;\n };\n \n-static int refs_from_alternate_cb(struct object_directory *e,\n+static int refs_from_alternate_cb(struct odb_alternate *alternate,\n \t\t\t\t  void *data)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n \tstruct alternate_refs_data *cb = data;\n \n-\tif (!strbuf_realpath(&path, e->path, 0))\n+\tif (!strbuf_realpath(&path, alternate->path, 0))\n \t\tgoto out;\n \tif (!strbuf_strip_suffix(&path, \"/objects\"))\n \t\tgoto out;\n@@ -563,12 +563,12 @@ void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n \n int foreach_alt_odb(alt_odb_fn fn, void *cb)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_alternate *alternate;\n \tint r = 0;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (ent = the_repository->objects->odb->next; ent; ent = ent->next) {\n-\t\tr = fn(ent, cb);\n+\tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n+\t\tr = fn(alternate, cb);\n \t\tif (r)\n \t\t\tbreak;\n \t}\n@@ -582,14 +582,14 @@ void prepare_alt_odb(struct repository *r)\n \n \tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->odb->path, 0);\n+\tread_info_alternates(r, r->objects->alternates->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n int has_alt_odb(struct repository *r)\n {\n \tprepare_alt_odb(r);\n-\treturn !!r->objects->odb->next;\n+\treturn !!r->objects->alternates->next;\n }\n \n int obj_read_use_lock = 0;\n@@ -972,15 +972,15 @@ struct object_database *odb_new(void)\n \n static void free_object_directories(struct object_database *o)\n {\n-\twhile (o->odb) {\n-\t\tstruct object_directory *next;\n+\twhile (o->alternates) {\n+\t\tstruct odb_alternate *next;\n \n-\t\tnext = o->odb->next;\n-\t\tfree_object_directory(o->odb);\n-\t\to->odb = next;\n+\t\tnext = o->alternates->next;\n+\t\tfree_object_directory(o->alternates);\n+\t\to->alternates = next;\n \t}\n-\tkh_destroy_odb_path_map(o->odb_by_path);\n-\to->odb_by_path = NULL;\n+\tkh_destroy_odb_path_map(o->alternate_by_path);\n+\to->alternate_by_path = NULL;\n }\n \n void odb_clear(struct object_database *o)\n@@ -996,7 +996,7 @@ void odb_clear(struct object_database *o)\n \to->commit_graph_attempted = 0;\n \n \tfree_object_directories(o);\n-\to->odb_tail = NULL;\n+\to->alternates_tail = NULL;\n \to->loaded_alternates = 0;\n \n \tfor (size_t i = 0; i < o->cached_object_nr; i++)\ndiff --git a/object-store.h b/object-store.h\nindex 34b8efbbb83..6dc39376141 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -12,8 +12,14 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n-struct object_directory {\n-\tstruct object_directory *next;\n+/*\n+ * The alternate is the part of the object database that stores the actual\n+ * objects. It thus encapsulates the logic to read and write the specific\n+ * on-disk format. An object database can have multiple alternates, and\n+ * exactly one primary alternate that is used when writing new objects.\n+ */\n+struct odb_alternate {\n+\tstruct odb_alternate *next;\n \n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n@@ -52,8 +58,8 @@ struct object_directory {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct object_directory *find_odb(struct repository *r, const char *obj_dir);\n-typedef int alt_odb_fn(struct object_directory *, void *);\n+struct odb_alternate *find_odb(struct repository *r, const char *obj_dir);\n+typedef int alt_odb_fn(struct odb_alternate *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n@@ -75,12 +81,12 @@ void add_to_alternates_memory(const char *dir);\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n  */\n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy);\n+struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy);\n \n /*\n  * Restore a previous ODB replaced by set_temporary_main_odb.\n  */\n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);\n+void restore_primary_odb(struct odb_alternate *restore_alternate, const char *old_path);\n \n struct packed_git;\n struct multi_pack_index;\n@@ -88,7 +94,7 @@ struct cached_object_entry;\n \n /*\n  * The object database encapsulates access to objects in a repository. It\n- * manages one or more backends that store the actual objects which are\n+ * manages one or more alternates that store the actual objects which are\n  * configured via alternates.\n  */\n struct object_database {\n@@ -97,16 +103,16 @@ struct object_database {\n \t * cannot be NULL after initialization). Subsequent directories are\n \t * alternates.\n \t */\n-\tstruct object_directory *odb;\n-\tstruct object_directory **odb_tail;\n-\tstruct kh_odb_path_map *odb_by_path;\n+\tstruct odb_alternate *alternates;\n+\tstruct odb_alternate **alternates_tail;\n+\tstruct kh_odb_path_map *alternate_by_path;\n \n \tint loaded_alternates;\n \n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"odb\" list when prepare_alt_odb() is run.\n+\t * populate the \"alternates\" list when prepare_alt_odb() is run.\n \t */\n \tchar *alternate_db;\n \ndiff --git a/packfile.c b/packfile.c\nindex 8f51665266d..e31e55f0c02 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1018,16 +1018,16 @@ static void prepare_packed_git_mru(struct repository *r)\n \n static void prepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tint local = (odb == r->objects->odb);\n-\t\tprepare_multi_pack_index_one(r, odb->path, local);\n-\t\tprepare_packed_git_one(r, odb->path, local);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\t\tint local = (alternate == r->objects->alternates);\n+\t\tprepare_multi_pack_index_one(r, alternate->path, local);\n+\t\tprepare_packed_git_one(r, alternate->path, local);\n \t}\n \trearrange_packed_git(r);\n \n@@ -1037,7 +1037,7 @@ static void prepare_packed_git(struct repository *r)\n \n void reprepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \n \tobj_read_lock();\n \n@@ -1050,8 +1050,8 @@ void reprepare_packed_git(struct repository *r)\n \tr->objects->loaded_alternates = 0;\n \tprepare_alt_odb(r);\n \n-\tfor (odb = r->objects->odb; odb; odb = odb->next)\n-\t\todb_clear_loose_cache(odb);\n+\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next)\n+\t\todb_clear_loose_cache(alternate);\n \n \tr->objects->approximate_object_count_valid = 0;\n \tr->objects->packed_git_initialized = 0;\ndiff --git a/path.c b/path.c\nindex 3b598b2847f..7be0e0214df 100644\n--- a/path.c\n+++ b/path.c\n@@ -397,7 +397,7 @@ static void adjust_git_path(struct repository *repo,\n \t\tstrbuf_splice(buf, 0, buf->len,\n \t\t\t      repo->index_file, strlen(repo->index_file));\n \telse if (dir_prefix(base, \"objects\"))\n-\t\treplace_dir(buf, git_dir_len + 7, repo->objects->odb->path);\n+\t\treplace_dir(buf, git_dir_len + 7, repo->objects->alternates->path);\n \telse if (repo_settings_get_hooks_path(repo) && dir_prefix(base, \"hooks\"))\n \t\treplace_dir(buf, git_dir_len + 5, repo_settings_get_hooks_path(repo));\n \telse if (repo->different_commondir)\ndiff --git a/refs.c b/refs.c\nindex dce5c49ca2b..27325d2f3c6 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -2477,7 +2477,7 @@ int ref_transaction_prepare(struct ref_transaction *transaction,\n \t\tbreak;\n \t}\n \n-\tif (refs->repo->objects->odb->disable_ref_updates) {\n+\tif (refs->repo->objects->alternates->disable_ref_updates) {\n \t\tstrbuf_addstr(err,\n \t\t\t      _(\"ref updates forbidden inside quarantine environment\"));\n \t\treturn -1;\ndiff --git a/repository.c b/repository.c\nindex 07757e6e0c9..dcc03fd9e0a 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -107,9 +107,9 @@ const char *repo_get_common_dir(struct repository *repo)\n \n const char *repo_get_object_directory(struct repository *repo)\n {\n-\tif (!repo->objects->odb)\n+\tif (!repo->objects->alternates)\n \t\tBUG(\"repository hasn't been set up\");\n-\treturn repo->objects->odb->path;\n+\treturn repo->objects->alternates->path;\n }\n \n const char *repo_get_index_file(struct repository *repo)\n@@ -165,14 +165,14 @@ void repo_set_gitdir(struct repository *repo,\n \n \trepo_set_commondir(repo, o->commondir);\n \n-\tif (!repo->objects->odb) {\n-\t\tCALLOC_ARRAY(repo->objects->odb, 1);\n-\t\trepo->objects->odb_tail = &repo->objects->odb->next;\n+\tif (!repo->objects->alternates) {\n+\t\tCALLOC_ARRAY(repo->objects->alternates, 1);\n+\t\trepo->objects->alternates_tail = &repo->objects->alternates->next;\n \t}\n-\texpand_base_dir(&repo->objects->odb->path, o->object_dir,\n+\texpand_base_dir(&repo->objects->alternates->path, o->object_dir,\n \t\t\trepo->commondir, \"objects\");\n \n-\trepo->objects->odb->disable_ref_updates = o->disable_ref_updates;\n+\trepo->objects->alternates->disable_ref_updates = o->disable_ref_updates;\n \n \tfree(repo->objects->alternate_db);\n \trepo->objects->alternate_db = xstrdup_or_null(o->alternate_db);\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 8630e27947d..0ee0a2884ef 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,7 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->odb->path);\n+\t\t\t\tadd_submodule_odb_by_path(repo->objects->alternates->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 8b413b644be..cd8ba0c54e7 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -73,15 +73,15 @@ static void dump_graph_bloom_filters(struct commit_graph *graph)\n int cmd__read_graph(int argc, const char **argv)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb;\n+\tstruct odb_alternate *alternate;\n \tint ret = 0;\n \n \tsetup_git_directory();\n-\todb = the_repository->objects->odb;\n+\talternate = the_repository->objects->alternates;\n \n \tprepare_repo_settings(the_repository);\n \n-\tgraph = read_commit_graph_one(the_repository, odb);\n+\tgraph = read_commit_graph_one(the_repository, alternate);\n \tif (!graph) {\n \t\tret = 1;\n \t\tgoto done;\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex c38fbeb5e8a..b8fe0fdd7d4 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -17,7 +17,7 @@ struct tmp_objdir {\n \tstruct repository *repo;\n \tstruct strbuf path;\n \tstruct strvec env;\n-\tstruct object_directory *prev_odb;\n+\tstruct odb_alternate *prev_alt;\n \tint will_destroy;\n };\n \n@@ -46,8 +46,8 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \tif (t == the_tmp_objdir)\n \t\tthe_tmp_objdir = NULL;\n \n-\tif (t->prev_odb)\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n+\tif (t->prev_alt)\n+\t\trestore_primary_odb(t->prev_alt, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -276,11 +276,11 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (!t)\n \t\treturn 0;\n \n-\tif (t->prev_odb) {\n-\t\tif (t->repo->objects->odb->will_destroy)\n+\tif (t->prev_alt) {\n+\t\tif (t->repo->objects->alternates->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n-\t\tt->prev_odb = NULL;\n+\t\trestore_primary_odb(t->prev_alt, t->path.buf);\n+\t\tt->prev_alt = NULL;\n \t}\n \n \tstrbuf_addbuf(&src, &t->path);\n@@ -309,19 +309,19 @@ void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n-\tif (t->prev_odb)\n+\tif (t->prev_alt)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_odb = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_alt = set_temporary_primary_odb(t->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n {\n-\tif (!the_tmp_objdir || !the_tmp_objdir->prev_odb)\n+\tif (!the_tmp_objdir || !the_tmp_objdir->prev_alt)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf);\n-\tthe_tmp_objdir->prev_odb = NULL;\n+\trestore_primary_odb(the_tmp_objdir->prev_alt, the_tmp_objdir->path.buf);\n+\tthe_tmp_objdir->prev_alt = NULL;\n \treturn the_tmp_objdir;\n }\n \n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518002","messageId":"20250514-pks-object-store-wo-the-repository-v3-4-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 04/17] odb: introduce parent pointers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:27Z","receivedAt":"2025-05-14T05:12:34Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In subsequent commits we'll get rid of our use of `the_repository` in\n\"odb.c\" in favor of explicitly passing in a `struct object_database` or\na `struct odb_alternate`. In some cases though we'll need access to the\nrepository, for example to read a config value from it, but we don't\nhave a way to access the repository owning a specific object database.\n\nIntroduce parent pointers for `struct object_database` to its owning\nrepository as well as for `struct odb_alternate` to its owning object\ndatabase, which will allow us to adapt those use cases.\n\nNote that this change requires us to pass through the object database to\n`link_alt_odb_entry()` so that we can set up the parent pointers for any\nalternate there. The callchain is adapted to pass through the object\ndatabase accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 45 ++++++++++++++++++++++++++-------------------\n odb.h        |  8 +++++++-\n repository.c |  3 ++-\n 3 files changed, 35 insertions(+), 21 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex 81281db7e0a..2b36735087e 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -135,11 +135,15 @@ static int alt_odb_usable(struct object_database *o,\n  * of the object ID, an extra slash for the first level indirection, and\n  * the terminating NUL.\n  */\n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth);\n-static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n-\tconst char *relative_base, int depth, const char *normalized_objdir)\n+\n+static int link_alt_odb_entry(struct object_database *odb,\n+\t\t\t      const struct strbuf *entry,\n+\t\t\t      const char *relative_base,\n+\t\t\t      int depth,\n+\t\t\t      const char *normalized_objdir)\n {\n \tstruct odb_alternate *alternate;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n@@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \twhile (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')\n \t\tstrbuf_setlen(&pathbuf, pathbuf.len - 1);\n \n-\tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n+\tif (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n \tCALLOC_ARRAY(alternate, 1);\n+\talternate->odb = odb;\n \t/* pathbuf.buf is already in r->objects->alternate_by_path */\n \talternate->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->alternates_tail = alternate;\n-\tr->objects->alternates_tail = &(alternate->next);\n+\t*odb->alternates_tail = alternate;\n+\todb->alternates_tail = &(alternate->next);\n \talternate->next = NULL;\n-\tassert(r->objects->alternate_by_path);\n-\tkh_value(r->objects->alternate_by_path, pos) = alternate;\n+\tassert(odb->alternate_by_path);\n+\tkh_value(odb->alternate_by_path, pos) = alternate;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, alternate->path, depth + 1);\n+\tread_info_alternates(odb, alternate->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -219,7 +224,7 @@ static const char *parse_alt_odb_entry(const char *string,\n \treturn end;\n }\n \n-static void link_alt_odb_entries(struct repository *r, const char *alt,\n+static void link_alt_odb_entries(struct object_database *odb, const char *alt,\n \t\t\t\t int sep, const char *relative_base, int depth)\n {\n \tstruct strbuf objdirbuf = STRBUF_INIT;\n@@ -234,20 +239,20 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->alternates->path, 1);\n+\tstrbuf_realpath(&objdirbuf, odb->alternates->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n \t\tif (!entry.len)\n \t\t\tcontinue;\n-\t\tlink_alt_odb_entry(r, &entry,\n+\t\tlink_alt_odb_entry(odb, &entry,\n \t\t\t\t   relative_base, depth, objdirbuf.buf);\n \t}\n \tstrbuf_release(&entry);\n \tstrbuf_release(&objdirbuf);\n }\n \n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth)\n {\n@@ -261,7 +266,7 @@ static void read_info_alternates(struct repository *r,\n \t\treturn;\n \t}\n \n-\tlink_alt_odb_entries(r, buf.buf, '\\n', relative_base, depth);\n+\tlink_alt_odb_entries(odb, buf.buf, '\\n', relative_base, depth);\n \tstrbuf_release(&buf);\n \tfree(path);\n }\n@@ -303,7 +308,7 @@ void add_to_alternates_file(const char *reference)\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n \t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository, reference,\n+\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n@@ -317,7 +322,7 @@ void add_to_alternates_memory(const char *reference)\n \t */\n \tprepare_alt_odb(the_repository);\n \n-\tlink_alt_odb_entries(the_repository, reference,\n+\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -336,6 +341,7 @@ struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n \t * alternate\n \t */\n \talternate = xcalloc(1, sizeof(*alternate));\n+\talternate->odb = the_repository->objects;\n \talternate->path = xstrdup(dir);\n \n \t/*\n@@ -580,9 +586,9 @@ void prepare_alt_odb(struct repository *r)\n \tif (r->objects->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->alternates->path, 0);\n+\tread_info_alternates(r->objects, r->objects->alternates->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n@@ -959,11 +965,12 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct object_database *odb_new(void)\n+struct object_database *odb_new(struct repository *repo)\n {\n \tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n+\to->repo = repo;\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\ndiff --git a/odb.h b/odb.h\nindex 070dd28e394..1d1ab8e8bf2 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -21,6 +21,9 @@ struct repository;\n struct odb_alternate {\n \tstruct odb_alternate *next;\n \n+\t/* Object database that owns this alternate. */\n+\tstruct object_database *odb;\n+\n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n \t * sacrificing accuracy due to races for speed. That includes\n@@ -98,6 +101,9 @@ struct cached_object_entry;\n  * configured via alternates.\n  */\n struct object_database {\n+\t/* Repository that owns this database. */\n+\tstruct repository *repo;\n+\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -179,7 +185,7 @@ struct object_database {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct object_database *odb_new(void);\n+struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n /*\ndiff --git a/repository.c b/repository.c\nindex dbc7fa8685f..36c508f7cb2 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = odb_new();\n+\trepo->objects = odb_new(repo);\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -167,6 +167,7 @@ void repo_set_gitdir(struct repository *repo,\n \n \tif (!repo->objects->alternates) {\n \t\tCALLOC_ARRAY(repo->objects->alternates, 1);\n+\t\trepo->objects->alternates->odb = repo->objects;\n \t\trepo->objects->alternates_tail = &repo->objects->alternates->next;\n \t}\n \texpand_base_dir(&repo->objects->alternates->path, o->object_dir,\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518005","messageId":"20250514-pks-object-store-wo-the-repository-v3-5-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:28Z","receivedAt":"2025-05-14T05:12:34Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `find_odb()` by passing\nin the object database in which we want to search for the alternate and\nadjusting all callers.\n\nRename the function to `odb_find_alternate()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c | 4 ++--\n midx-write.c           | 2 +-\n odb.c                  | 6 +++---\n odb.h                  | 7 ++++++-\n 4 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex ae8ac52a975..90c767797e2 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -101,7 +101,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\talternate = find_odb(the_repository, opts.obj_dir);\n+\talternate = odb_find_alternate(the_repository->objects, opts.obj_dir);\n \tgraph_name = get_commit_graph_filename(alternate);\n \tchain_name = get_commit_graph_chain_filename(alternate);\n \tif (open_commit_graph(graph_name, &fd, &st))\n@@ -289,7 +289,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\talternate = find_odb(the_repository, opts.obj_dir);\n+\talternate = odb_find_alternate(the_repository->objects, opts.obj_dir);\n \n \tif (opts.reachable) {\n \t\tif (write_commit_graph_reachable(alternate, flags, &write_opts))\ndiff --git a/midx-write.c b/midx-write.c\nindex dd3b3070e55..dd65800e8b3 100644\n--- a/midx-write.c\n+++ b/midx-write.c\n@@ -922,7 +922,7 @@ static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,\n \tstruct strbuf cur_path_real = STRBUF_INIT;\n \n \t/* Ensure the given object_dir is local, or a known alternate. */\n-\tfind_odb(r, obj_dir_real);\n+\todb_find_alternate(r->objects, obj_dir_real);\n \n \tfor (cur = get_multi_pack_index(r); cur; cur = cur->next) {\n \t\tstrbuf_realpath(&cur_path_real, cur->object_dir, 1);\ndiff --git a/odb.c b/odb.c\nindex 2b36735087e..621a16b35ea 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -448,14 +448,14 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct odb_alternate *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir)\n {\n \tstruct odb_alternate *alternate;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n-\tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n+\tprepare_alt_odb(odb->repo);\n+\tfor (alternate = odb->alternates; alternate; alternate = alternate->next) {\n \t\tstrbuf_realpath(&odb_path_real, alternate->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\ndiff --git a/odb.h b/odb.h\nindex 1d1ab8e8bf2..5c5ce4653eb 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -61,7 +61,6 @@ struct odb_alternate {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct odb_alternate *find_odb(struct repository *r, const char *obj_dir);\n typedef int alt_odb_fn(struct odb_alternate *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n@@ -188,6 +187,12 @@ struct object_database {\n struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n+/*\n+ * Find backend by its object directory path. Dies in case the object directory\n+ * couldn't be found.\n+ */\n+struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n+\n /*\n  * Create a temporary file rooted in the object database directory, or\n  * die on failure. The filename is taken from \"pattern\", which should have the\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518007","messageId":"20250514-pks-object-store-wo-the-repository-v3-6-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 06/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:29Z","receivedAt":"2025-05-14T05:12:35Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `assert_oid_type()` by\npassing in the object database as a parameter and adjusting all callers.\n\nRename the function to `odb_assert_oid_type()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-tree.c | 2 +-\n commit.c              | 2 +-\n odb.c                 | 5 +++--\n odb.h                 | 3 ++-\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 546069f8682..31cfd9bd15d 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -48,7 +48,7 @@ static int parse_parent_arg_callback(const struct option *opt,\n \tif (repo_get_oid_commit(the_repository, arg, &oid))\n \t\tdie(_(\"not a valid object name %s\"), arg);\n \n-\tassert_oid_type(&oid, OBJ_COMMIT);\n+\todb_assert_oid_type(the_repository->objects, &oid, OBJ_COMMIT);\n \tnew_parent(lookup_commit(the_repository, &oid), parents);\n \treturn 0;\n }\ndiff --git a/commit.c b/commit.c\nindex 1d30f8ce15a..aa65183d8b6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1706,7 +1706,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,\n \t/* Not having i18n.commitencoding is the same as having utf-8 */\n \tencoding_is_utf8 = is_encoding_utf8(git_commit_encoding);\n \n-\tassert_oid_type(tree, OBJ_TREE);\n+\todb_assert_oid_type(the_repository->objects, tree, OBJ_TREE);\n \n \tif (memchr(msg, '\\0', msg_len))\n \t\treturn error(\"a NUL byte in commit log message not allowed.\");\ndiff --git a/odb.c b/odb.c\nindex 621a16b35ea..d09b8bf00cc 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -955,9 +955,10 @@ int has_object(struct repository *r, const struct object_id *oid,\n \treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n }\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect)\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex 5c5ce4653eb..e38a46a05c9 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -298,7 +298,8 @@ enum {\n int has_object(struct repository *r, const struct object_id *oid,\n \t       unsigned flags);\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect);\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect);\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518006","messageId":"20250514-pks-object-store-wo-the-repository-v3-7-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 07/17] odb: get rid of `the_repository` in `odb_mkstemp()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:30Z","receivedAt":"2025-05-14T05:12:36Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `odb_mkstemp()` by\npassing in the object database as a parameter and adjusting all callers.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/fast-import.c |  3 ++-\n builtin/index-pack.c  |  2 +-\n bundle-uri.c          |  3 ++-\n odb.c                 |  9 +++++----\n odb.h                 |  7 ++++---\n pack-bitmap-write.c   |  3 ++-\n pack-write.c          | 10 ++++++----\n 7 files changed, 22 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 52c792488e1..413304db9b5 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -763,7 +763,8 @@ static void start_packfile(void)\n \tstruct packed_git *p;\n \tint pack_fd;\n \n-\tpack_fd = odb_mkstemp(&tmp_file, \"pack/tmp_pack_XXXXXX\");\n+\tpack_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n+\t\t\t      \"pack/tmp_pack_XXXXXX\");\n \tFLEX_ALLOC_STR(p, pack_name, tmp_file.buf);\n \tstrbuf_release(&tmp_file);\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 8ce446064e8..8e5acefde40 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -362,7 +362,7 @@ static const char *open_pack_file(const char *pack_name)\n \t\tinput_fd = 0;\n \t\tif (!pack_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\toutput_fd = odb_mkstemp(&tmp_file,\n+\t\t\toutput_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n \t\t\t\t\t\t\"pack/tmp_pack_XXXXXX\");\n \t\t\tpack_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 993ac62c271..87a5ba50945 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -278,7 +278,8 @@ static char *find_temp_filename(void)\n \t * Find a temporary filename that is available. This is briefly\n \t * racy, but unlikely to collide.\n \t */\n-\tfd = odb_mkstemp(&name, \"bundles/tmp_uri_XXXXXX\");\n+\tfd = odb_mkstemp(the_repository->objects, &name,\n+\t\t\t \"bundles/tmp_uri_XXXXXX\");\n \tif (fd < 0) {\n \t\twarning(_(\"failed to create temporary file\"));\n \t\treturn NULL;\ndiff --git a/odb.c b/odb.c\nindex d09b8bf00cc..7ff614fb0c7 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -63,7 +63,8 @@ static const struct cached_object *find_cached_object(struct object_database *ob\n \treturn NULL;\n }\n \n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern)\n {\n \tint fd;\n \t/*\n@@ -71,15 +72,15 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n \t * restrictive except to remove write permission.\n \t */\n \tint mode = 0444;\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n \tfd = git_mkstemp_mode(temp_filename->buf, mode);\n \tif (0 <= fd)\n \t\treturn fd;\n \n \t/* slow path */\n \t/* some mkstemp implementations erase temp_filename on failure */\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n-\tsafe_create_leading_directories(the_repository, temp_filename->buf);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n+\tsafe_create_leading_directories(odb->repo, temp_filename->buf);\n \treturn xmkstemp_mode(temp_filename->buf, mode);\n }\n \ndiff --git a/odb.h b/odb.h\nindex e38a46a05c9..eb46eb60edd 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -194,12 +194,13 @@ void odb_clear(struct object_database *o);\n struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n \n /*\n- * Create a temporary file rooted in the object database directory, or\n- * die on failure. The filename is taken from \"pattern\", which should have the\n+ * Create a temporary file rooted in the primary alternate's directory, or die\n+ * on failure. The filename is taken from \"pattern\", which should have the\n  * usual \"XXXXXX\" trailer, and the resulting filename is written into the\n  * \"template\" buffer. Returns the open descriptor.\n  */\n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern);\n \n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 37648b57125..c847369eaaa 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1052,7 +1052,8 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n \n \tstruct bitmap_disk_header header;\n \n-\tint fd = odb_mkstemp(&tmp_file, \"pack/tmp_bitmap_XXXXXX\");\n+\tint fd = odb_mkstemp(writer->repo->objects, &tmp_file,\n+\t\t\t     \"pack/tmp_bitmap_XXXXXX\");\n \n \tif (writer->pseudo_merges_nr)\n \t\toptions |= BITMAP_OPT_PSEUDO_MERGES;\ndiff --git a/pack-write.c b/pack-write.c\nindex 6b06315f80a..eccdc798e36 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -84,7 +84,8 @@ const char *write_idx_file(struct repository *repo,\n \t} else {\n \t\tif (!index_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_idx_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_idx_XXXXXX\");\n \t\t\tindex_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(index_name);\n@@ -259,7 +260,8 @@ char *write_rev_file_order(struct repository *repo,\n \tif (flags & WRITE_REV) {\n \t\tif (!rev_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_rev_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_rev_XXXXXX\");\n \t\t\tpath = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(rev_name);\n@@ -342,7 +344,7 @@ static char *write_mtimes_file(struct repository *repo,\n \tif (!to_pack)\n \t\tBUG(\"cannot call write_mtimes_file with NULL packing_data\");\n \n-\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n \tmtimes_name = strbuf_detach(&tmp_file, NULL);\n \tf = hashfd(repo->hash_algo, fd, mtimes_name);\n \n@@ -531,7 +533,7 @@ struct hashfile *create_tmp_packfile(struct repository *repo,\n \tstruct strbuf tmpname = STRBUF_INIT;\n \tint fd;\n \n-\tfd = odb_mkstemp(&tmpname, \"pack/tmp_pack_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmpname, \"pack/tmp_pack_XXXXXX\");\n \t*pack_tmp_name = strbuf_detach(&tmpname, NULL);\n \treturn hashfd(repo->hash_algo, fd, *pack_tmp_name);\n }\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518008","messageId":"20250514-pks-object-store-wo-the-repository-v3-8-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:31Z","receivedAt":"2025-05-14T05:12:37Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions to manage alternates all depend on `the_repository`.\nRefactor them to accept an object database as parameter and adjusting\nall callers. The functions are renamed accordingly.\n\nNote that right now the situation is still somewhat weird because we end\nup using the path provided by the object store's repository anyway. This\nwill be adapted over time though so that we instead store the path to\nthe primary object directory in the object database itself.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/clone.c           | 10 +++++----\n builtin/fsck.c            |  6 +++---\n builtin/grep.c            |  2 +-\n builtin/repack.c          |  3 ++-\n commit-graph.c            |  4 ++--\n loose.c                   |  2 +-\n object-file.c             | 10 ++++-----\n object-name.c             |  2 +-\n odb.c                     | 44 ++++++++++++++++++---------------------\n odb.h                     | 53 ++++++++++++++++++++++++++++++++---------------\n packfile.c                |  4 ++--\n submodule.c               |  3 ++-\n t/helper/test-ref-store.c |  2 +-\n tmp-objdir.c              |  2 +-\n 14 files changed, 83 insertions(+), 64 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 1eafeefb48d..3aabdf6570b 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -171,7 +171,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)\n \t} else {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstrbuf_addf(&sb, \"%s/objects\", ref_git);\n-\t\tadd_to_alternates_file(sb.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \t}\n \n@@ -212,12 +212,14 @@ static void copy_alternates(struct strbuf *src, const char *src_repo)\n \t\tif (!line.len || line.buf[0] == '#')\n \t\t\tcontinue;\n \t\tif (is_absolute_path(line.buf)) {\n-\t\t\tadd_to_alternates_file(line.buf);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   line.buf);\n \t\t\tcontinue;\n \t\t}\n \t\tabs_path = mkpathdup(\"%s/objects/%s\", src_repo, line.buf);\n \t\tif (!normalize_path_copy(abs_path, abs_path))\n-\t\t\tadd_to_alternates_file(abs_path);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   abs_path);\n \t\telse\n \t\t\twarning(\"skipping invalid relative alternate: %s/%s\",\n \t\t\t\tsrc_repo, line.buf);\n@@ -352,7 +354,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)\n \t\tstruct strbuf alt = STRBUF_INIT;\n \t\tget_common_dir(&alt, src_repo);\n \t\tstrbuf_addstr(&alt, \"/objects\");\n-\t\tadd_to_alternates_file(alt.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, alt.buf);\n \t\tstrbuf_release(&alt);\n \t} else {\n \t\tstruct strbuf src = STRBUF_INIT;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6a5181393a2..b961c2caa22 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -1006,7 +1006,7 @@ int cmd_fsck(int argc,\n \t\tfor_each_packed_object(the_repository,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next)\n \t\t\tfsck_object_dir(alternate->path);\n \n@@ -1117,7 +1117,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_commit_graph) {\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n@@ -1135,7 +1135,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_multi_pack_index) {\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3858df2a82e..b19fee20425 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -462,7 +462,7 @@ static int grep_submodule(struct grep_opt *opt,\n \n \t/*\n \t * NEEDSWORK: repo_read_gitmodules() might call\n-\t * add_to_alternates_memory() via config_from_gitmodules(). This\n+\t * odb_add_to_alternates_memory() via config_from_gitmodules(). This\n \t * operation causes a race condition with concurrent object readings\n \t * performed by the worker threads. That's why we need obj_read_lock()\n \t * here. It should be removed once it's no longer necessary to add the\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 16782320058..8145474cf8d 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -1256,7 +1256,8 @@ int cmd_repack(int argc,\n \tif (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)\n \t\tdie(_(incremental_bitmap_conflict_error));\n \n-\tif (write_bitmaps && po_args.local && has_alt_odb(the_repository)) {\n+\tif (write_bitmaps && po_args.local &&\n+\t    odb_has_alternates(the_repository->objects)) {\n \t\t/*\n \t\t * When asked to do a local repack, but we have\n \t\t * packfiles that are inherited from an alternate, then\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 4848198d7bf..cd34b71d270 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -649,7 +649,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tcount = st->st_size / (the_hash_algo->hexsz + 1);\n \tCALLOC_ARRAY(oids, count);\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (i = 0; i < count; i++) {\n \t\tstruct odb_alternate *alternate;\n@@ -778,7 +778,7 @@ static int prepare_commit_graph(struct repository *r)\n \tif (!commit_graph_compatible(r))\n \t\treturn 0;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates;\n \t     !r->objects->commit_graph && alternate;\n \t     alternate = alternate->next)\ndiff --git a/loose.c b/loose.c\nindex 9febd1f3e9a..9fbf2336822 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -112,7 +112,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tprepare_alt_odb(repo);\n+\todb_prepare_alternates(repo->objects);\n \n \tfor (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n \t\tif (load_one_loose_object_map(repo, alternate) < 0) {\ndiff --git a/object-file.c b/object-file.c\nindex dabc238447a..9e8649135ce 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -106,7 +106,7 @@ static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n \tstruct odb_alternate *alternate;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n \t\tif (check_and_freshen_odb(alternate, oid, freshen))\n \t\t\treturn 1;\n@@ -211,7 +211,7 @@ static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \tstruct odb_alternate *alternate;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n \t\t*path = odb_loose_path(alternate, &buf, oid);\n \t\tif (!lstat(*path, st))\n@@ -233,7 +233,7 @@ static int open_loose_object(struct repository *r,\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n \t\t*path = odb_loose_path(alternate, &buf, oid);\n \t\tfd = git_open(*path);\n@@ -252,7 +252,7 @@ static int quick_has_loose(struct repository *r,\n {\n \tstruct odb_alternate *alternate;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n \t\tif (oidtree_contains(odb_loose_cache(alternate, oid), oid))\n \t\t\treturn 1;\n@@ -1542,7 +1542,7 @@ int for_each_loose_object(each_loose_object_fn cb, void *data,\n {\n \tstruct odb_alternate *alternate;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n \t\tint r = for_each_loose_file_in_objdir(alternate->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\ndiff --git a/object-name.c b/object-name.c\nindex b83ba882b9e..2b757eb7948 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -376,7 +376,7 @@ static int init_object_disambiguation(struct repository *r,\n \tds->hex_pfx[len] = '\\0';\n \tds->repo = r;\n \tds->bin_pfx.algo = algo ? hash_algo_by_ptr(algo) : GIT_HASH_UNKNOWN;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \treturn 0;\n }\n \ndiff --git a/odb.c b/odb.c\nindex 7ff614fb0c7..bd601471cd7 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -272,10 +272,11 @@ static void read_info_alternates(struct object_database *odb,\n \tfree(path);\n }\n \n-void add_to_alternates_file(const char *reference)\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *reference)\n {\n \tstruct lock_file lock = LOCK_INIT;\n-\tchar *alts = repo_git_path(the_repository, \"objects/info/alternates\");\n+\tchar *alts = repo_git_path(odb->repo, \"objects/info/alternates\");\n \tFILE *in, *out;\n \tint found = 0;\n \n@@ -308,22 +309,23 @@ void add_to_alternates_file(const char *reference)\n \t\tfprintf_or_die(out, \"%s\\n\", reference);\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n-\t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n+\t\tif (odb->loaded_alternates)\n+\t\t\tlink_alt_odb_entries(odb, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n }\n \n-void add_to_alternates_memory(const char *reference)\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *reference)\n {\n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(odb);\n \n-\tlink_alt_odb_entries(the_repository->objects, reference,\n+\tlink_alt_odb_entries(odb, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -335,7 +337,7 @@ struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n@@ -379,12 +381,6 @@ void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path\n \tfree_object_directory(cur_alt);\n }\n \n-/*\n- * Compute the exact path an alternate is at and returns it. In case of\n- * error NULL is returned and the human readable error is added to `err`\n- * `path` may be relative and should point to $GIT_DIR.\n- * `err` must not be null.\n- */\n char *compute_alternate_path(const char *path, struct strbuf *err)\n {\n \tchar *ref_git = NULL;\n@@ -455,7 +451,7 @@ struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(odb->repo);\n+\todb_prepare_alternates(odb);\n \tfor (alternate = odb->alternates; alternate; alternate = alternate->next) {\n \t\tstrbuf_realpath(&odb_path_real, alternate->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n@@ -573,7 +569,7 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \tstruct odb_alternate *alternate;\n \tint r = 0;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n \t\tr = fn(alternate, cb);\n \t\tif (r)\n@@ -582,21 +578,21 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \treturn r;\n }\n \n-void prepare_alt_odb(struct repository *r)\n+void odb_prepare_alternates(struct object_database *odb)\n {\n-\tif (r->objects->loaded_alternates)\n+\tif (odb->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(odb, odb->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r->objects, r->objects->alternates->path, 0);\n-\tr->objects->loaded_alternates = 1;\n+\tread_info_alternates(odb, odb->alternates->path, 0);\n+\todb->loaded_alternates = 1;\n }\n \n-int has_alt_odb(struct repository *r)\n+int odb_has_alternates(struct object_database *odb)\n {\n-\tprepare_alt_odb(r);\n-\treturn !!r->objects->alternates->next;\n+\todb_prepare_alternates(odb);\n+\treturn !!odb->alternates->next;\n }\n \n int obj_read_use_lock = 0;\ndiff --git a/odb.h b/odb.h\nindex eb46eb60edd..7ff3e54c061 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -12,6 +12,14 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n+/*\n+ * Compute the exact path an alternate is at and returns it. In case of\n+ * error NULL is returned and the human readable error is added to `err`\n+ * `path` may be relative and should point to $GIT_DIR.\n+ * `err` must not be null.\n+ */\n+char *compute_alternate_path(const char *path, struct strbuf *err);\n+\n /*\n  * The alternate is the part of the object database that stores the actual\n  * objects. It thus encapsulates the logic to read and write the specific\n@@ -58,27 +66,11 @@ struct odb_alternate {\n \tchar *path;\n };\n \n-void prepare_alt_odb(struct repository *r);\n-int has_alt_odb(struct repository *r);\n-char *compute_alternate_path(const char *path, struct strbuf *err);\n typedef int alt_odb_fn(struct odb_alternate *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n \n-/*\n- * Add the directory to the on-disk alternates file; the new entry will also\n- * take effect in the current process.\n- */\n-void add_to_alternates_file(const char *dir);\n-\n-/*\n- * Add the directory to the in-memory list of alternates (along with any\n- * recursive alternates it points to), but do not modify the on-disk alternates\n- * file.\n- */\n-void add_to_alternates_memory(const char *dir);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -117,7 +109,7 @@ struct object_database {\n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"alternates\" list when prepare_alt_odb() is run.\n+\t * populate the \"alternates\" list when odb_prepare_alternates() is run.\n \t */\n \tchar *alternate_db;\n \n@@ -202,6 +194,33 @@ struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n int odb_mkstemp(struct object_database *odb,\n \t\tstruct strbuf *temp_filename, const char *pattern);\n \n+/*\n+ * Prepare alternate object backends for the given database by reading\n+ * \"objects/info/alternates\" and opening the respective alternates.\n+ */\n+void odb_prepare_alternates(struct object_database *odb);\n+\n+/*\n+ * Check whether the object database has any alternates. The primary object\n+ * backend does not count as alternate.\n+ */\n+int odb_has_alternates(struct object_database *odb);\n+\n+/*\n+ * Add the directory to the on-disk alternates file; the new entry will also\n+ * take effect in the current process.\n+ */\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *dir);\n+\n+/*\n+ * Add the directory to the in-memory list of alternates (along with any\n+ * recursive alternates it points to), but do not modify the on-disk alternates\n+ * file.\n+ */\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *dir);\n+\n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\n \t\t\t    enum object_type *type,\ndiff --git a/packfile.c b/packfile.c\nindex 8133948b58f..ab9628eb3d4 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1023,7 +1023,7 @@ static void prepare_packed_git(struct repository *r)\n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n \t\tint local = (alternate == r->objects->alternates);\n \t\tprepare_multi_pack_index_one(r, alternate->path, local);\n@@ -1048,7 +1048,7 @@ void reprepare_packed_git(struct repository *r)\n \t * the lifetime of the process.\n \t */\n \tr->objects->loaded_alternates = 0;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (alternate = r->objects->alternates; alternate; alternate = alternate->next)\n \t\todb_clear_loose_cache(alternate);\ndiff --git a/submodule.c b/submodule.c\nindex 9b1018877df..386be234230 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -189,7 +189,8 @@ int register_all_submodule_odb_as_alternates(void)\n \tint ret = added_submodule_odb_paths.nr;\n \n \tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\tadd_to_alternates_memory(added_submodule_odb_paths.items[i].string);\n+\t\todb_add_to_alternates_memory(the_repository->objects,\n+\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n \tif (ret) {\n \t\tstring_list_clear(&added_submodule_odb_paths, 0);\n \t\ttrace2_data_intmax(\"submodule\", the_repository,\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 2920ca59d72..8d9a271845c 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -79,7 +79,7 @@ static const char **get_store(const char **argv, struct ref_store **refs)\n \t\tif (!repo_submodule_path_append(the_repository,\n \t\t\t\t\t\t&sb, gitdir, \"objects/\"))\n \t\t\tdie(\"computing submodule path failed\");\n-\t\tadd_to_alternates_memory(sb.buf);\n+\t\todb_add_to_alternates_memory(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \n \t\t*refs = repo_get_submodule_ref_store(the_repository, gitdir);\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex 9e05fcbddd0..cbb50438d16 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -304,7 +304,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)\n \n void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n {\n-\tadd_to_alternates_memory(t->path.buf);\n+\todb_add_to_alternates_memory(t->repo->objects, t->path.buf);\n }\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518009","messageId":"20250514-pks-object-store-wo-the-repository-v3-9-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:32Z","receivedAt":"2025-05-14T05:12:38Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"There are a couple of iterator-style functions that execute a callback\nfor each instance of a given set, all of which currently depend on\n`the_repository`. Refactor them to instead take an object database as\nparameter so that we can get rid of this dependency.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/count-objects.c     |  2 +-\n builtin/receive-pack.c      |  3 ++-\n builtin/submodule--helper.c |  3 ++-\n diagnose.c                  |  2 +-\n fetch-pack.c                |  3 ++-\n odb.c                       | 36 +++++++++++++++++++-----------------\n odb.h                       | 23 ++++++++++++++++++-----\n revision.c                  |  3 ++-\n 8 files changed, 47 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex da830fcee57..2752a9b02f4 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -159,7 +159,7 @@ int cmd_count_objects(int argc,\n \t\tprintf(\"prune-packable: %lu\\n\", packed_loose);\n \t\tprintf(\"garbage: %lu\\n\", garbage);\n \t\tprintf(\"size-garbage: %s\\n\", garbage_buf.buf);\n-\t\tforeach_alt_odb(print_alternate, NULL);\n+\t\todb_for_each_alternate(the_repository->objects, print_alternate, NULL);\n \t\tstrbuf_release(&loose_buf);\n \t\tstrbuf_release(&pack_buf);\n \t\tstrbuf_release(&garbage_buf);\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex cb5fd55a8e4..8c157ea7d1b 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -358,7 +358,8 @@ static void write_head_info(void)\n \n \trefs_for_each_fullref_in(get_main_ref_store(the_repository), \"\",\n \t\t\t\t exclude_patterns, show_ref_cb, &seen);\n-\tfor_each_alternate_ref(show_one_alternate_ref, &seen);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   show_one_alternate_ref, &seen);\n \n \toidset_clear(&seen);\n \tstrvec_clear(&excludes_vector);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex a6c936fb2bd..88bbd97820a 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1668,7 +1668,8 @@ static void prepare_possible_alternates(const char *sm_name,\n \t\tdie(_(\"Value '%s' for submodule.alternateErrorStrategy is not recognized\"), error_strategy);\n \n \tif (!strcmp(sm_alternate, \"superproject\"))\n-\t\tforeach_alt_odb(add_possible_reference_from_superproject, &sas);\n+\t\todb_for_each_alternate(the_repository->objects,\n+\t\t\t\t       add_possible_reference_from_superproject, &sas);\n \telse if (!strcmp(sm_alternate, \"no\"))\n \t\t; /* do nothing */\n \telse\ndiff --git a/diagnose.c b/diagnose.c\nindex d407c98d094..0405368f178 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -229,7 +229,7 @@ int create_diagnostics_archive(struct repository *r,\n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n \tdir_file_stats(r->objects->alternates, &buf);\n-\tforeach_alt_odb(dir_file_stats, &buf);\n+\todb_for_each_alternate(r->objects, dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \n \tstrbuf_reset(&buf);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex cf157f5d7e5..47fa7fa4c49 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -115,7 +115,8 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,\n \tsize_t i;\n \n \tif (!initialized) {\n-\t\tfor_each_alternate_ref(cache_one_alternate, &cache);\n+\t\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t\t   cache_one_alternate, &cache);\n \t\tinitialized = 1;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex bd601471cd7..feca14d9683 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -494,8 +494,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n }\n \n static void read_alternate_refs(const char *path,\n-\t\t\t\talternate_ref_fn *cb,\n-\t\t\t\tvoid *data)\n+\t\t\t\todb_for_each_alternate_ref_fn *cb,\n+\t\t\t\tvoid *payload)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tstruct strbuf line = STRBUF_INIT;\n@@ -517,7 +517,7 @@ static void read_alternate_refs(const char *path,\n \t\t\tbreak;\n \t\t}\n \n-\t\tcb(&oid, data);\n+\t\tcb(&oid, payload);\n \t}\n \n \tfclose(fh);\n@@ -526,16 +526,16 @@ static void read_alternate_refs(const char *path,\n }\n \n struct alternate_refs_data {\n-\talternate_ref_fn *fn;\n-\tvoid *data;\n+\todb_for_each_alternate_ref_fn *fn;\n+\tvoid *payload;\n };\n \n static int refs_from_alternate_cb(struct odb_alternate *alternate,\n-\t\t\t\t  void *data)\n+\t\t\t\t  void *payload)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n-\tstruct alternate_refs_data *cb = data;\n+\tstruct alternate_refs_data *cb = payload;\n \n \tif (!strbuf_realpath(&path, alternate->path, 0))\n \t\tgoto out;\n@@ -549,29 +549,31 @@ static int refs_from_alternate_cb(struct odb_alternate *alternate,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->data);\n+\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n \treturn 0;\n }\n \n-void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload)\n {\n-\tstruct alternate_refs_data cb;\n-\tcb.fn = fn;\n-\tcb.data = data;\n-\tforeach_alt_odb(refs_from_alternate_cb, &cb);\n+\tstruct alternate_refs_data data;\n+\tdata.fn = cb;\n+\tdata.payload = payload;\n+\todb_for_each_alternate(odb, refs_from_alternate_cb, &data);\n }\n \n-int foreach_alt_odb(alt_odb_fn fn, void *cb)\n+int odb_for_each_alternate(struct object_database *odb,\n+\t\t\t odb_for_each_alternate_fn cb, void *payload)\n {\n \tstruct odb_alternate *alternate;\n \tint r = 0;\n \n-\todb_prepare_alternates(the_repository->objects);\n-\tfor (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n-\t\tr = fn(alternate, cb);\n+\todb_prepare_alternates(odb);\n+\tfor (alternate = odb->alternates->next; alternate; alternate = alternate->next) {\n+\t\tr = cb(alternate, payload);\n \t\tif (r)\n \t\t\tbreak;\n \t}\ndiff --git a/odb.h b/odb.h\nindex 7ff3e54c061..dcc3b0bc1f0 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -66,11 +66,6 @@ struct odb_alternate {\n \tchar *path;\n };\n \n-typedef int alt_odb_fn(struct odb_alternate *, void *);\n-int foreach_alt_odb(alt_odb_fn, void*);\n-typedef void alternate_ref_fn(const struct object_id *oid, void *);\n-void for_each_alternate_ref(alternate_ref_fn, void *);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -185,6 +180,24 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Iterate through all alternates of the database and execute the provided\n+ * callback function for each of them. Stop iterating once the callback\n+ * function returns a non-zero value, in which case the value is bubbled up\n+ * from the callback.\n+ */\n+typedef int odb_for_each_alternate_fn(struct odb_alternate *, void *);\n+int odb_for_each_alternate(struct object_database *odb,\n+\t\t\t   odb_for_each_alternate_fn cb, void *payload);\n+\n+/*\n+ * Iterate through all alternates of the database and yield their respective\n+ * references.\n+ */\n+typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n+\n /*\n  * Create a temporary file rooted in the primary alternate's directory, or die\n  * on failure. The filename is taken from \"pattern\", which should have the\ndiff --git a/revision.c b/revision.c\nindex cdefe7d6e48..b0364f556ee 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1907,7 +1907,8 @@ static void add_alternate_refs_to_pending(struct rev_info *revs,\n \tstruct add_alternate_refs_data data;\n \tdata.revs = revs;\n \tdata.flags = flags;\n-\tfor_each_alternate_ref(add_one_alternate_ref, &data);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   add_one_alternate_ref, &data);\n }\n \n static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518010","messageId":"20250514-pks-object-store-wo-the-repository-v3-10-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 10/17] odb: get rid of `the_repository` when handling the primary alternate","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:33Z","receivedAt":"2025-05-14T05:12:40Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions `set_temporary_primary_odb()` and `restore_primary_odb()`\nare responsible for managing a temporary primary alternate for the\ndatabase. Both of these functions implicitly rely on `the_repository`.\n\nRefactor them to instead take an explicit object database parameter as\nargument and adjust callers. Rename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 19 +++++++++++--------\n odb.h        | 25 ++++++++++++++-----------\n tmp-objdir.c | 10 ++++++----\n 3 files changed, 31 insertions(+), 23 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex feca14d9683..100dd39cbe8 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -329,7 +329,8 @@ void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_alternate *odb_set_temporary_primary_alternate(struct object_database *odb,\n+\t\t\t\t\t\t\t  const char *dir, int will_destroy)\n {\n \tstruct odb_alternate *alternate;\n \n@@ -337,14 +338,14 @@ struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\todb_prepare_alternates(the_repository->objects);\n+\todb_prepare_alternates(odb);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n \talternate = xcalloc(1, sizeof(*alternate));\n-\talternate->odb = the_repository->objects;\n+\talternate->odb = odb;\n \talternate->path = xstrdup(dir);\n \n \t/*\n@@ -353,8 +354,8 @@ struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n \t */\n \talternate->disable_ref_updates = 1;\n \talternate->will_destroy = will_destroy;\n-\talternate->next = the_repository->objects->alternates;\n-\tthe_repository->objects->alternates = alternate;\n+\talternate->next = odb->alternates;\n+\todb->alternates = alternate;\n \treturn alternate->next;\n }\n \n@@ -366,9 +367,11 @@ static void free_object_directory(struct odb_alternate *alternate)\n \tfree(alternate);\n }\n \n-void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path)\n+void odb_restore_primary_alternate(struct object_database *odb,\n+\t\t\t\t   struct odb_alternate *restore_alt,\n+\t\t\t\t   const char *old_path)\n {\n-\tstruct odb_alternate *cur_alt = the_repository->objects->alternates;\n+\tstruct odb_alternate *cur_alt = odb->alternates;\n \n \tif (strcmp(old_path, cur_alt->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n@@ -377,7 +380,7 @@ void restore_primary_odb(struct odb_alternate *restore_alt, const char *old_path\n \tif (cur_alt->next != restore_alt)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->alternates = restore_alt;\n+\todb->alternates = restore_alt;\n \tfree_object_directory(cur_alt);\n }\n \ndiff --git a/odb.h b/odb.h\nindex dcc3b0bc1f0..0db4de38529 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -66,17 +66,6 @@ struct odb_alternate {\n \tchar *path;\n };\n \n-/*\n- * Replace the current writable object directory with the specified temporary\n- * object directory; returns the former primary object directory.\n- */\n-struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destroy);\n-\n-/*\n- * Restore a previous ODB replaced by set_temporary_main_odb.\n- */\n-void restore_primary_odb(struct odb_alternate *restore_alternate, const char *old_path);\n-\n struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n@@ -180,6 +169,20 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Replace the current writable object directory with the specified temporary\n+ * object directory; returns the former primary alternate.\n+ */\n+struct odb_alternate *odb_set_temporary_primary_alternate(struct object_database *odb,\n+\t\t\t\t\t\t\t  const char *dir, int will_destroy);\n+\n+/*\n+ * Restore a previous bakcend replaced by `odb_set_temporary_primary_alternate()`.\n+ */\n+void odb_restore_primary_alternate(struct object_database *odb,\n+\t\t\t\t   struct odb_alternate *restore_alt,\n+\t\t\t\t   const char *old_path);\n+\n /*\n  * Iterate through all alternates of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex cbb50438d16..c2e58c4be5c 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -47,7 +47,7 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \t\tthe_tmp_objdir = NULL;\n \n \tif (t->prev_alt)\n-\t\trestore_primary_odb(t->prev_alt, t->path.buf);\n+\t\todb_restore_primary_alternate(t->repo->objects, t->prev_alt, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -279,7 +279,7 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (t->prev_alt) {\n \t\tif (t->repo->objects->alternates->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_alt, t->path.buf);\n+\t\todb_restore_primary_alternate(t->repo->objects, t->prev_alt, t->path.buf);\n \t\tt->prev_alt = NULL;\n \t}\n \n@@ -311,7 +311,8 @@ void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n \tif (t->prev_alt)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_alt = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_alt = odb_set_temporary_primary_alternate(t->repo->objects,\n+\t\t\t\t\t\t\t  t->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n@@ -320,7 +321,8 @@ struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n \tif (!the_tmp_objdir || !the_tmp_objdir->prev_alt)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_alt, the_tmp_objdir->path.buf);\n+\todb_restore_primary_alternate(the_tmp_objdir->repo->objects,\n+\t\t\t\t      the_tmp_objdir->prev_alt, the_tmp_objdir->path.buf);\n \tthe_tmp_objdir->prev_alt = NULL;\n \treturn the_tmp_objdir;\n }\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518011","messageId":"20250514-pks-object-store-wo-the-repository-v3-11-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 11/17] odb: get rid of `the_repository` when handling submodule alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:34Z","receivedAt":"2025-05-14T05:12:41Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"--recursive\" flag for git-grep(1) allows users to grep for a string\nacross submodule boundaries. To make this work we add each submodule's\nobject alternate to our own object database so that the objects can be\naccessed directly.\n\nThe infrastructure for this depends on a global string list of submodule\npaths. The caller is expected to call `add_submodule_odb_by_path()` for\neach alternate and the object database will then eventually register all\nsubmodule alternates via `do_oid_object_info_extended()` in case it\nisn't able to look up a specific object.\n\nThis reliance on global state is of course suboptimal with regards to\nour libification efforts.\n\nRefactor the logic so that the list of submodule alternates is instead\ntracked in the object database itself. This allows us to lose the\ncondition of `r == the_repository` before registering submodule\nalternates as we only ever add submodule alternates to `the_repository`\nanyway. As such, behaviour before and after this refactoring should\nalways be the same.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/grep.c     |  3 ++-\n odb.c              | 37 +++++++++++++++++++++++++++++++------\n odb.h              | 15 +++++++++++++++\n submodule-config.c |  3 ++-\n submodule.c        | 26 --------------------------\n submodule.h        |  9 ---------\n 6 files changed, 50 insertions(+), 43 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex b19fee20425..277bc121e4e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,8 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->alternates->path);\n+\todb_add_submodule_alternate_by_path(the_repository->objects,\n+\t\t\t\t\t    subrepo->objects->alternates->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/odb.c b/odb.c\nindex 100dd39cbe8..72ff1ab5a7d 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -24,6 +24,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"submodule.h\"\n+#include \"trace2.h\"\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n@@ -469,6 +470,12 @@ struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n \treturn alternate;\n }\n \n+void odb_add_submodule_alternate_by_path(struct object_database *odb,\n+\t\t\t\t\t const char *path)\n+{\n+\tstring_list_insert(&odb->submodule_alternate_paths, path);\n+}\n+\n static void fill_alternate_refs_command(struct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n@@ -623,6 +630,23 @@ void disable_obj_read_lock(void)\n \n int fetch_if_missing = 1;\n \n+static int register_all_submodule_alternates(struct object_database *odb)\n+{\n+\tint ret = odb->submodule_alternate_paths.nr;\n+\n+\tfor (size_t i = 0; i < odb->submodule_alternate_paths.nr; i++)\n+\t\todb_add_to_alternates_memory(odb,\n+\t\t\t\t\t     odb->submodule_alternate_paths.items[i].string);\n+\tif (ret) {\n+\t\tstring_list_clear(&odb->submodule_alternate_paths, 0);\n+\t\ttrace2_data_intmax(\"submodule\", odb->repo,\n+\t\t\t\t   \"register_all_submodule_alternates/registered\", ret);\n+\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n+\t\t\tBUG(\"register_all_submodule_alternates() called\");\n+\t}\n+\treturn ret;\n+}\n+\n static int do_oid_object_info_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n@@ -678,13 +702,12 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t}\n \n \t\t/*\n-\t\t * If r is the_repository, this might be an attempt at\n-\t\t * accessing a submodule object as if it were in the_repository\n-\t\t * (having called add_submodule_odb() on that submodule's ODB).\n-\t\t * If any such ODBs exist, register them and try again.\n+\t\t * This might be an attempt at accessing a submodule object as\n+\t\t * if it were in main object store (having called\n+\t\t * `odb_add_submodule_alternate_by_path()` on that submodule's\n+\t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (r == the_repository &&\n-\t\t    register_all_submodule_odb_as_alternates())\n+\t\tif (register_all_submodule_alternates(r->objects))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n@@ -977,6 +1000,7 @@ struct object_database *odb_new(struct repository *repo)\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n+\tstring_list_init_dup(&o->submodule_alternate_paths);\n \treturn o;\n }\n \n@@ -1027,4 +1051,5 @@ void odb_clear(struct object_database *o)\n \to->packed_git = NULL;\n \n \thashmap_clear(&o->pack_map);\n+\tstring_list_clear(&o->submodule_alternate_paths, 0);\n }\ndiff --git a/odb.h b/odb.h\nindex 0db4de38529..44326cb698d 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -5,6 +5,7 @@\n #include \"object.h\"\n #include \"list.h\"\n #include \"oidset.h\"\n+#include \"string-list.h\"\n #include \"thread-utils.h\"\n \n struct oidmap;\n@@ -158,6 +159,12 @@ struct object_database {\n \t * packs.\n \t */\n \tunsigned packed_git_initialized : 1;\n+\n+\t/*\n+\t * Submodule alternate paths that will be added as alternatives to\n+\t * allow lookup of submodule objects via the main object database.\n+\t */\n+\tstruct string_list submodule_alternate_paths;\n };\n \n struct object_database *odb_new(struct repository *repo);\n@@ -183,6 +190,14 @@ void odb_restore_primary_alternate(struct object_database *odb,\n \t\t\t\t   struct odb_alternate *restore_alt,\n \t\t\t\t   const char *old_path);\n \n+/*\n+ * Call odb_add_submodule_alternate_by_path() to add the submodule at the given\n+ * path to a list. The object stores of all submodules in that list will be\n+ * added as alternates in the object store when looking up objects.\n+ */\n+void odb_add_submodule_alternate_by_path(struct object_database *odb,\n+\t\t\t\t\t  const char *path);\n+\n /*\n  * Iterate through all alternates of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 09034a587f1..0f775f93259 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,8 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->alternates->path);\n+\t\t\t\todb_add_submodule_alternate_by_path(the_repository->objects,\n+\t\t\t\t\t\t\t\t    repo->objects->alternates->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/submodule.c b/submodule.c\nindex 386be234230..788c9e55ed3 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -31,7 +31,6 @@\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\n-#include \"trace2.h\"\n \n static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;\n static int initialized_fetch_ref_tips;\n@@ -176,31 +175,6 @@ void stage_updated_gitmodules(struct index_state *istate)\n \t\tdie(_(\"staging updated .gitmodules failed\"));\n }\n \n-static struct string_list added_submodule_odb_paths = STRING_LIST_INIT_DUP;\n-\n-void add_submodule_odb_by_path(const char *path)\n-{\n-\tstring_list_insert(&added_submodule_odb_paths, path);\n-}\n-\n-int register_all_submodule_odb_as_alternates(void)\n-{\n-\tint i;\n-\tint ret = added_submodule_odb_paths.nr;\n-\n-\tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\todb_add_to_alternates_memory(the_repository->objects,\n-\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n-\tif (ret) {\n-\t\tstring_list_clear(&added_submodule_odb_paths, 0);\n-\t\ttrace2_data_intmax(\"submodule\", the_repository,\n-\t\t\t\t   \"register_all_submodule_odb_as_alternates/registered\", ret);\n-\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n-\t\t\tBUG(\"register_all_submodule_odb_as_alternates() called\");\n-\t}\n-\treturn ret;\n-}\n-\n void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\t\t\t\t     const char *path)\n {\ndiff --git a/submodule.h b/submodule.h\nindex db980c1d083..b10e16e6c06 100644\n--- a/submodule.h\n+++ b/submodule.h\n@@ -104,15 +104,6 @@ int submodule_uses_gitfile(const char *path);\n #define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)\n int bad_to_remove_submodule(const char *path, unsigned flags);\n \n-/*\n- * Call add_submodule_odb_by_path() to add the submodule at the given\n- * path to a list. When register_all_submodule_odb_as_alternates() is\n- * called, the object stores of all submodules in that list will be\n- * added as alternates in the_repository.\n- */\n-void add_submodule_odb_by_path(const char *path);\n-int register_all_submodule_odb_as_alternates(void);\n-\n /*\n  * Checks if there are submodule changes in a..b. If a is the null OID,\n  * checks b and all its ancestors instead.\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518012","messageId":"20250514-pks-object-store-wo-the-repository-v3-12-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:35Z","receivedAt":"2025-05-14T05:12:42Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"All of the external functions provided by the object database subsystem\ndon't depend on `the_repository` anymore, but some internal functions\nstill do. Refactor those cases by plumbing through the repository that\nowns the object database.\n\nThis change allows us to get rid of the `USE_THE_REPOSITORY_VARIABLE`\npreprocessor define.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex 72ff1ab5a7d..c150c01db4a 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"commit-graph.h\"\n@@ -476,12 +474,13 @@ void odb_add_submodule_alternate_by_path(struct object_database *odb,\n \tstring_list_insert(&odb->submodule_alternate_paths, path);\n }\n \n-static void fill_alternate_refs_command(struct child_process *cmd,\n+static void fill_alternate_refs_command(struct repository *repo,\n+\t\t\t\t\tstruct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n \tconst char *value;\n \n-\tif (!git_config_get_value(\"core.alternateRefsCommand\", &value)) {\n+\tif (!repo_config_get_value(repo, \"core.alternateRefsCommand\", &value)) {\n \t\tcmd->use_shell = 1;\n \n \t\tstrvec_push(&cmd->args, value);\n@@ -493,7 +492,7 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \t\tstrvec_push(&cmd->args, \"for-each-ref\");\n \t\tstrvec_push(&cmd->args, \"--format=%(objectname)\");\n \n-\t\tif (!git_config_get_value(\"core.alternateRefsPrefixes\", &value)) {\n+\t\tif (!repo_config_get_value(repo, \"core.alternateRefsPrefixes\", &value)) {\n \t\t\tstrvec_push(&cmd->args, \"--\");\n \t\t\tstrvec_split(&cmd->args, value);\n \t\t}\n@@ -503,7 +502,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \tcmd->out = -1;\n }\n \n-static void read_alternate_refs(const char *path,\n+static void read_alternate_refs(struct repository *repo,\n+\t\t\t\tconst char *path,\n \t\t\t\todb_for_each_alternate_ref_fn *cb,\n \t\t\t\tvoid *payload)\n {\n@@ -511,7 +511,7 @@ static void read_alternate_refs(const char *path,\n \tstruct strbuf line = STRBUF_INIT;\n \tFILE *fh;\n \n-\tfill_alternate_refs_command(&cmd, path);\n+\tfill_alternate_refs_command(repo, &cmd, path);\n \n \tif (start_command(&cmd))\n \t\treturn;\n@@ -521,7 +521,7 @@ static void read_alternate_refs(const char *path,\n \t\tstruct object_id oid;\n \t\tconst char *p;\n \n-\t\tif (parse_oid_hex(line.buf, &oid, &p) || *p) {\n+\t\tif (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) {\n \t\t\twarning(_(\"invalid line while parsing alternate refs: %s\"),\n \t\t\t\tline.buf);\n \t\t\tbreak;\n@@ -559,7 +559,7 @@ static int refs_from_alternate_cb(struct odb_alternate *alternate,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n+\tread_alternate_refs(alternate->odb->repo, path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, the_repository->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n \t\tif (oi->type_name)\n \t\t\tstrbuf_addstr(oi->type_name, type_name(co->type));\n \t\tif (oi->contentp)\n@@ -765,10 +765,10 @@ static int oid_object_info_convert(struct repository *r,\n \tvoid *content;\n \tint ret;\n \n-\tif (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) {\n+\tif (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) {\n \t\tif (do_die)\n \t\t\tdie(_(\"missing mapping of %s to %s\"),\n-\t\t\t    oid_to_hex(input_oid), the_hash_algo->name);\n+\t\t\t    oid_to_hex(input_oid), r->hash_algo->name);\n \t\treturn -1;\n \t}\n \n@@ -804,8 +804,8 @@ static int oid_object_info_convert(struct repository *r,\n \t\tif (type == -1)\n \t\t\treturn -1;\n \t\tif (type != OBJ_BLOB) {\n-\t\t\tret = convert_object_file(the_repository, &outbuf,\n-\t\t\t\t\t\t  the_hash_algo, input_algo,\n+\t\t\tret = convert_object_file(r, &outbuf,\n+\t\t\t\t\t\t  r->hash_algo, input_algo,\n \t\t\t\t\t\t  content, size, type, !do_die);\n \t\t\tfree(content);\n \t\t\tif (ret == -1)\n@@ -953,9 +953,9 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + the_hash_algo->hexsz > isize ||\n+\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex((char *) buffer + ref_length, &actual_oid)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518013","messageId":"20250514-pks-object-store-wo-the-repository-v3-13-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 13/17] odb: rename `oid_object_info()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:36Z","receivedAt":"2025-05-14T05:12:43Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `oid_object_info()` to `odb_read_object_info()` as well as their\n`_extended()` variant to match other functions related to the object\ndatabase and our modern coding guidelines.\n\nIntroduce compatibility wrappers so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n archive.c                     |  2 +-\n blame.c                       |  4 +--\n builtin/blame.c               |  4 +--\n builtin/cat-file.c            | 26 ++++++++++---------\n builtin/describe.c            |  3 ++-\n builtin/fast-export.c         |  2 +-\n builtin/fast-import.c         | 17 ++++++------\n builtin/fsck.c                |  7 ++---\n builtin/gc.c                  |  2 +-\n builtin/grep.c                |  2 +-\n builtin/index-pack.c          | 13 +++++-----\n builtin/ls-files.c            |  2 +-\n builtin/ls-tree.c             |  4 +--\n builtin/mktree.c              |  8 +++---\n builtin/pack-objects.c        | 30 ++++++++++++----------\n builtin/prune.c               |  4 +--\n builtin/repack.c              |  2 +-\n builtin/replace.c             | 10 ++++----\n builtin/rev-list.c            |  6 +++--\n builtin/tag.c                 |  4 +--\n builtin/unpack-objects.c      |  2 +-\n commit-graph.c                |  2 +-\n commit.c                      |  3 ++-\n diff.c                        | 18 ++++++-------\n fetch-pack.c                  |  4 +--\n list-objects-filter.c         |  2 +-\n log-tree.c                    |  2 +-\n merge-ort.c                   |  4 +--\n object-file.c                 |  2 +-\n object-file.h                 |  2 +-\n object-name.c                 | 16 ++++++------\n object.c                      |  6 ++---\n odb.c                         | 60 ++++++++++++++++++++++---------------------\n odb.h                         | 46 +++++++++++++++++++++++++++------\n pack-bitmap-write.c           |  4 +--\n pack-bitmap.c                 |  8 +++---\n packfile.c                    |  5 ++--\n promisor-remote.c             |  4 +--\n protocol-caps.c               |  2 +-\n reachable.c                   |  2 +-\n read-cache.c                  |  6 ++---\n ref-filter.c                  |  4 +--\n remote.c                      |  5 ++--\n sequencer.c                   |  5 ++--\n streaming.c                   |  8 +++---\n submodule.c                   |  5 ++--\n t/helper/test-partial-clone.c |  2 +-\n tag.c                         |  2 +-\n 48 files changed, 213 insertions(+), 170 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 7fa2cc2596a..f2511d530d5 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,\n \n \t/* Stream it? */\n \tif (S_ISREG(mode) && !args->convert &&\n-\t    oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&\n+\t    odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&\n \t    size > repo_settings_get_big_file_threshold(the_repository))\n \t\treturn write_entry(args, oid, path.buf, path.len, mode, NULL, size);\n \ndiff --git a/blame.c b/blame.c\nindex 0ceea080a80..97db3355af4 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,\n \t\tunsigned short mode;\n \n \t\tif (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&\n-\t\t    oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)\n+\t\t    odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n \n@@ -1245,7 +1245,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,\n \t\treturn 0;\n \tif (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))\n \t\tgoto error_out;\n-\tif (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)\n+\tif (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\n \treturn 0;\n  error_out:\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 15eda60af90..91586e6852b 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -837,7 +837,7 @@ static int is_a_rev(const char *name)\n \n \tif (repo_get_oid(the_repository, name, &oid))\n \t\treturn 0;\n-\treturn OBJ_NONE < oid_object_info(the_repository, &oid, NULL);\n+\treturn OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);\n }\n \n static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n@@ -848,7 +848,7 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n \toidcpy(&oid, oid_ret);\n \twhile (1) {\n \t\tstruct object *obj;\n-\t\tint kind = oid_object_info(r, &oid, NULL);\n+\t\tint kind = odb_read_object_info(r->objects, &oid, NULL);\n \t\tif (kind == OBJ_COMMIT) {\n \t\t\toidcpy(oid_ret, &oid);\n \t\t\treturn 0;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 2fa5e3f43bd..da172155c85 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -137,7 +137,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tswitch (opt) {\n \tcase 't':\n \t\toi.type_name = &sb;\n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tif (sb.len) {\n \t\t\tprintf(\"%s\\n\", sb.buf);\n@@ -155,7 +155,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\toi.contentp = (void**)&buf;\n \t\t}\n \n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \n \t\tif (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {\n@@ -189,7 +189,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t/* else fallthrough */\n \n \tcase 'p':\n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Not a valid object name %s\", obj_name);\n \n@@ -226,7 +226,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \n \t\tif (exp_type_id == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n-\t\t\tif (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n \t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n \t\t\t\t\t\t\t\t     &oid,\n \t\t\t\t\t\t\t\t     &type,\n@@ -244,7 +245,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t} else\n \t\t\t\toidcpy(&blob_oid, &oid);\n \n-\t\t\tif (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &blob_oid, NULL) == OBJ_BLOB) {\n \t\t\t\tret = stream_blob(&blob_oid);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n@@ -303,7 +305,7 @@ struct expand_data {\n \n \t/*\n \t * After a mark_query run, this object_info is set up to be\n-\t * passed to oid_object_info_extended. It will point to the data\n+\t * passed to odb_read_object_info_extended. It will point to the data\n \t * elements above, so you can retrieve the response from there.\n \t */\n \tstruct object_info info;\n@@ -493,12 +495,12 @@ static void batch_object_write(const char *obj_name,\n \t\t\tdata->info.sizep = &data->size;\n \n \t\tif (pack)\n-\t\t\tret = packed_object_info(the_repository, pack, offset,\n-\t\t\t\t\t\t &data->info);\n+\t\t\tret = packed_object_info(the_repository, pack,\n+\t\t\t\t\t\t offset, &data->info);\n \t\telse\n-\t\t\tret = oid_object_info_extended(the_repository,\n-\t\t\t\t\t\t       &data->oid, &data->info,\n-\t\t\t\t\t\t       OBJECT_INFO_LOOKUP_REPLACE);\n+\t\t\tret = odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t    &data->oid, &data->info,\n+\t\t\t\t\t\t\t    OBJECT_INFO_LOOKUP_REPLACE);\n \t\tif (ret < 0) {\n \t\t\treport_object_status(opt, obj_name, &data->oid, \"missing\");\n \t\t\treturn;\n@@ -881,7 +883,7 @@ static int batch_objects(struct batch_options *opt)\n \n \t/*\n \t * Expand once with our special mark_query flag, which will prime the\n-\t * object_info to be handed to oid_object_info_extended for each\n+\t * object_info to be handed to odb_read_object_info_extended for each\n \t * object.\n \t */\n \tmemset(&data, 0, sizeof(data));\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 96cb68e5e5d..fbf305d7624 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\n-\telse if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)\n+\telse if (odb_read_object_info(the_repository->objects,\n+\t\t\t\t      &oid, NULL) == OBJ_BLOB)\n \t\tdescribe_blob(oid, &sb);\n \telse\n \t\tdie(_(\"%s is neither a commit nor blob\"), arg);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 0505f289a94..6c93cf0a8aa 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\n \n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 413304db9b5..2718376f2c9 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1756,8 +1756,8 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint\n \tstruct object_entry *e;\n \te = find_object(oid);\n \tif (!e) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\toid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\te = insert_object(oid);\n@@ -2416,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)\n \t\tenum object_type expected = S_ISDIR(mode) ?\n \t\t\t\t\t\tOBJ_TREE: OBJ_BLOB;\n \t\tenum object_type type = oe ? oe->type :\n-\t\t\t\t\toid_object_info(the_repository, &oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\t\t\t\todb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"%s not found: %s\",\n \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n@@ -2553,7 +2553,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttype_name(oe->type), command_buf.buf);\n \t} else if (!is_null_oid(&oid)) {\n-\t\tenum object_type type = oid_object_info(the_repository, &oid,\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects, &oid,\n \t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n@@ -2895,7 +2895,8 @@ static void parse_new_tag(const char *arg)\n \t} else if (!repo_get_oid(the_repository, from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n-\t\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t    &oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -3085,8 +3086,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tif (!oe) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex b961c2caa22..08a79fe044d 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,\n \tconst char *ret;\n \n \tif (type == OBJ_NONE)\n-\t\ttype = oid_object_info(the_repository, oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t    oid, NULL);\n \n \tret = type_name(type);\n \tif (!ret)\n@@ -232,8 +233,8 @@ static void mark_unreachable_referents(const struct object_id *oid)\n \t * (and we want to avoid parsing blobs).\n \t */\n \tif (obj->type == OBJ_NONE) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\t&obj->oid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &obj->oid, NULL);\n \t\tif (type > 0)\n \t\t\tobject_as_type(obj, type, 0);\n \t}\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 9e9d31c1f39..40bd2259c6a 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -1006,7 +1006,7 @@ static int dfs_on_ref(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tcommit = lookup_commit(the_repository, oid);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 277bc121e4e..311c940aa9e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobj_read_lock();\n-\t\tobject_type = oid_object_info(subrepo, oid, NULL);\n+\t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n \t\tdata = read_object_with_reference(subrepo,\n \t\t\t\t\t\t  oid, OBJ_TREE,\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 8e5acefde40..82cf80b89d1 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -260,7 +260,8 @@ static unsigned check_object(struct object *obj)\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t&obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n \t\t\t      oid_to_hex(&obj->oid));\n@@ -908,7 +909,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\tenum object_type has_type;\n \t\tunsigned long has_size;\n \t\tread_lock();\n-\t\thas_type = oid_object_info(the_repository, oid, &has_size);\n+\t\thas_type = odb_read_object_info(the_repository->objects, oid, &has_size);\n \t\tif (has_type < 0)\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n@@ -1495,9 +1496,9 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \t\tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \t\tfor (i = 0; i < nr_ref_deltas; i++) {\n \t\t\tstruct ref_delta_entry *d = sorted_by_pos[i];\n-\t\t\tif (!oid_object_info_extended(the_repository, &d->oid,\n-\t\t\t\t\t\t      NULL,\n-\t\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t   &d->oid, NULL,\n+\t\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\tcontinue;\n \t\t\toid_array_append(&to_fetch, &d->oid);\n \t\t}\n@@ -1823,7 +1824,7 @@ static void repack_local_links(void)\n \toidset_iter_init(&outgoing_links, &iter);\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct object_info info = OBJECT_INFO_INIT;\n-\t\tif (oid_object_info_extended(the_repository, oid, &info, 0))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))\n \t\t\t/* Missing; assume it is a promisor object */\n \t\t\tcontinue;\n \t\tif (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 821339b07d4..ff975e7be06 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -251,7 +251,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(repo, oid, &size) < 0)\n+\t\tif (odb_read_object_info(repo->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 62b6fd58c16..4d616dd5282 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -27,7 +27,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\n@@ -217,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,\n \n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)\n \t\t\txsnprintf(size_text, sizeof(size_text), \"BAD\");\n \t\telse\n \t\t\txsnprintf(size_text, sizeof(size_text),\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 016b0e5b224..81df7f6099f 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -124,10 +124,10 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)\n \n \t/* Check the type of object identified by oid without fetching objects */\n \toi.typep = &obj_type;\n-\tif (oid_object_info_extended(the_repository, &oid, &oi,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t     OBJECT_INFO_QUICK |\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t  OBJECT_INFO_QUICK |\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n \t\tobj_type = -1;\n \n \tif (obj_type < 0) {\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 99b63cb0980..da35d684081 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2154,10 +2154,10 @@ static void prefetch_to_pack(uint32_t object_index_start) {\n \tfor (i = object_index_start; i < to_pack.nr_objects; i++) {\n \t\tstruct object_entry *entry = to_pack.objects + i;\n \n-\t\tif (!oid_object_info_extended(the_repository,\n-\t\t\t\t\t      &entry->idx.oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &entry->idx.oid,\n+\t\t\t\t\t\t   NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &entry->idx.oid);\n \t}\n@@ -2298,19 +2298,19 @@ static void check_object(struct object_entry *entry, uint32_t object_index)\n \n \t\t/*\n \t\t * No choice but to fall back to the recursive delta walk\n-\t\t * with oid_object_info() to find about the object type\n+\t\t * with odb_read_object_info() to find about the object type\n \t\t * at this point...\n \t\t */\n \t\tgive_up:\n \t\tunuse_pack(&w_curs);\n \t}\n \n-\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n \t\tif (repo_has_promisor_remote(the_repository)) {\n \t\t\tprefetch_to_pack(object_index);\n-\t\t\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\t\t\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\t\t\ttype = -1;\n \t\t} else {\n \t\t\ttype = -1;\n@@ -2384,12 +2384,13 @@ static void drop_reused_delta(struct object_entry *entry)\n \tif (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {\n \t\t/*\n \t\t * We failed to get the info from this pack for some reason;\n-\t\t * fall back to oid_object_info, which may find another copy.\n+\t\t * fall back to odb_read_object_info, which may find another copy.\n \t\t * And if that fails, the error will be recorded in oe_type(entry)\n \t\t * and dealt with in prepare_pack().\n \t\t */\n \t\toe_set_type(entry,\n-\t\t\t    oid_object_info(the_repository, &entry->idx.oid, &size));\n+\t\t\t    odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &entry->idx.oid, &size));\n \t} else {\n \t\toe_set_type(entry, type);\n \t}\n@@ -2677,7 +2678,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n \n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tif (oid_object_info(the_repository, &e->idx.oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &e->idx.oid, &size) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"),\n \t\t\t    oid_to_hex(&e->idx.oid));\n \t\tpacking_data_unlock(&to_pack);\n@@ -4063,7 +4065,7 @@ static void add_objects_in_unpacked_packs(void)\n static int add_loose_object(const struct object_id *oid, const char *path,\n \t\t\t    void *data UNUSED)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\twarning(_(\"loose object at %s could not be examined\"), path);\n@@ -4449,7 +4451,7 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED,\n static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)\n {\n \tstruct object_info info = OBJECT_INFO_INIT;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &info, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))\n \t\tBUG(\"should_include_obj should only be called on existing objects\");\n \treturn info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;\n }\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 7bbfb14c2be..339017c7ccf 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -99,8 +99,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \tif (st.st_mtime > expire)\n \t\treturn 0;\n \tif (show_only || verbose) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tprintf(\"%s %s\\n\", oid_to_hex(oid),\n \t\t       (type > 0) ? type_name(type) : \"unknown\");\n \t}\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 8145474cf8d..a89c2b704fb 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -707,7 +707,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,\n \tif (oidset_insert(&data->seen, oid))\n \t\treturn 0; /* already seen */\n \n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tfprintf(data->f->fp, \"%s%s\\n\", data->preferred ? \"+\" : \"\",\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 11c7e2d4c0c..5ff2ab723cb 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -65,8 +65,8 @@ static int show_reference(const char *refname,\n \t\t\tif (repo_get_oid(data->repo, refname, &object))\n \t\t\t\treturn error(_(\"failed to resolve '%s' as a valid ref\"), refname);\n \n-\t\t\tobj_type = oid_object_info(data->repo, &object, NULL);\n-\t\t\trepl_type = oid_object_info(data->repo, oid, NULL);\n+\t\t\tobj_type = odb_read_object_info(data->repo->objects, &object, NULL);\n+\t\t\trepl_type = odb_read_object_info(data->repo->objects, oid, NULL);\n \n \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, type_name(obj_type),\n \t\t\t       oid_to_hex(oid), type_name(repl_type));\n@@ -185,8 +185,8 @@ static int replace_object_oid(const char *object_ref,\n \tstruct strbuf err = STRBUF_INIT;\n \tint res = 0;\n \n-\tobj_type = oid_object_info(the_repository, object, NULL);\n-\trepl_type = oid_object_info(the_repository, repl, NULL);\n+\tobj_type = odb_read_object_info(the_repository->objects, object, NULL);\n+\trepl_type = odb_read_object_info(the_repository->objects, repl, NULL);\n \tif (!force && obj_type != repl_type)\n \t\treturn error(_(\"Objects must be of the same type.\\n\"\n \t\t\t       \"'%s' points to a replaced object of type '%s'\\n\"\n@@ -334,7 +334,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)\n \tif (repo_get_oid(the_repository, object_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), object_ref);\n \n-\ttype = oid_object_info(the_repository, &old_oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &old_oid, NULL);\n \tif (type < 0)\n \t\treturn error(_(\"unable to get object type for %s\"),\n \t\t\t     oid_to_hex(&old_oid));\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex ee25d61c802..eed73f5fc0b 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -110,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)\n \toff_t size;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \toi.disk_sizep = &size;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\tdie(_(\"unable to get disk usage of %s\"), oid_to_hex(&obj->oid));\n \treturn size;\n }\n@@ -346,7 +347,8 @@ static void show_commit(struct commit *commit, void *data)\n static int finish_object(struct object *obj, const char *name, void *cb_data)\n {\n \tstruct rev_list_info *info = cb_data;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, NULL, 0) < 0) {\n \t\tfinish_object__ma(obj, name);\n \t\treturn 1;\n \t}\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex cf2ea4b4993..e0b27396c6b 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -304,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,\n \tstruct strbuf header = STRBUF_INIT;\n \tint should_edit;\n \n-\ttype = oid_object_info(the_repository, object, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, object, NULL);\n \tif (type <= OBJ_NONE)\n \t\tdie(_(\"bad object type.\"));\n \n@@ -401,7 +401,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 7bf395eec84..405e78bc592 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -232,7 +232,7 @@ static int check_object(struct object *obj, enum object_type type,\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n \t\tobj->flags |= FLAG_WRITTEN;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex cd34b71d270..84cfaf87639 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1862,7 +1862,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT)\n \t\toidset_insert(data->commits, oid);\n \n \tdisplay_progress(data->progress, oidset_size(data->commits));\ndiff --git a/commit.c b/commit.c\nindex aa65183d8b6..d4aa9c7a5f8 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -585,7 +585,8 @@ int repo_parse_commit_internal(struct repository *r,\n \t\treturn 0;\n \t}\n \n-\tif (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)\n+\tif (odb_read_object_info_extended(r->objects, &item->object.oid,\n+\t\t\t\t\t  &oi, flags) < 0)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/diff.c b/diff.c\nindex 193da8bee68..75cfedf18a5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4230,14 +4230,14 @@ int diff_populate_filespec(struct repository *r,\n \t\t\tinfo.contentp = &s->data;\n \n \t\tif (options && options->missing_object_cb) {\n-\t\t\tif (!oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t\t\t      OBJECT_INFO_SKIP_FETCH_OBJECT))\n+\t\t\tif (!odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t   OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t\t\t   OBJECT_INFO_SKIP_FETCH_OBJECT))\n \t\t\t\tgoto object_read;\n \t\t\toptions->missing_object_cb(options->missing_object_data);\n \t\t}\n-\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \n object_read:\n@@ -4252,8 +4252,8 @@ int diff_populate_filespec(struct repository *r,\n \t\t}\n \t\tif (!info.contentp) {\n \t\t\tinfo.contentp = &s->data;\n-\t\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \t\t}\n \t\ts->should_free = 1;\n@@ -7019,8 +7019,8 @@ void diff_add_if_missing(struct repository *r,\n {\n \tif (filespec && filespec->oid_valid &&\n \t    !S_ISGITLINK(filespec->mode) &&\n-\t    oid_object_info_extended(r, &filespec->oid, NULL,\n-\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t    odb_read_object_info_extended(r->objects, &filespec->oid, NULL,\n+\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\toid_array_append(to_fetch, &filespec->oid);\n }\n \ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 47fa7fa4c49..0f5de1c94d1 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -149,8 +149,8 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \t}\n \n \twhile (1) {\n-\t\tif (oid_object_info_extended(the_repository, oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n \t\t\treturn NULL;\n \t\tif (type == OBJ_TAG) {\n \t\t\tstruct tag *tag = (struct tag *)\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex cb9c16734b1..ec7aebaffd0 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -310,7 +310,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \t\tassert(obj->type == OBJ_BLOB);\n \t\tassert((obj->flags & SEEN) == 0);\n \n-\t\tt = oid_object_info(r, &obj->oid, &object_length);\n+\t\tt = odb_read_object_info(r->objects, &obj->oid, &object_length);\n \t\tif (t != OBJ_BLOB) { /* probably OBJ_NONE */\n \t\t\t/*\n \t\t\t * We DO NOT have the blob locally, so we cannot\ndiff --git a/log-tree.c b/log-tree.c\nindex 1d05dc1c701..233bf9f227c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -176,7 +176,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,\n \t\treturn 0;\n \t}\n \n-\tobjtype = oid_object_info(the_repository, oid, NULL);\n+\tobjtype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (objtype < 0)\n \t\treturn 0;\n \tobj = lookup_object_by_type(the_repository, oid, objtype);\ndiff --git a/merge-ort.c b/merge-ort.c\nindex f86c84635f0..5d4501085e9 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -4374,8 +4374,8 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \n \t\t\tif ((ci->filemask & side_mask) &&\n \t\t\t    S_ISREG(vi->mode) &&\n-\t\t\t    oid_object_info_extended(opt->repo, &vi->oid, NULL,\n-\t\t\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t\t\t    odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,\n+\t\t\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\toid_array_append(&to_fetch, &vi->oid);\n \t\t}\n \t}\ndiff --git a/object-file.c b/object-file.c\nindex 9e8649135ce..d5f41cb73a2 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1211,7 +1211,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)\n \toi.typep = &type;\n \toi.sizep = &len;\n \toi.contentp = &buf;\n-\tif (oid_object_info_extended(the_repository, oid, &oi, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0))\n \t\treturn error(_(\"cannot read object for %s\"), oid_to_hex(oid));\n \tif (compat) {\n \t\tif (repo_oid_to_algop(repo, oid, compat, &compat_oid))\ndiff --git a/object-file.h b/object-file.h\nindex e4810eee449..86920bd4bb8 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -8,7 +8,7 @@\n struct index_state;\n \n /*\n- * Set this to 0 to prevent oid_object_info_extended() from fetching missing\n+ * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing\n  * blobs. This has a difference only if extensions.partialClone is set.\n  *\n  * Its default value is 1.\ndiff --git a/object-name.c b/object-name.c\nindex 2b757eb7948..973548d8923 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -251,7 +251,7 @@ static int disambiguate_commit_only(struct repository *r,\n \t\t\t\t    const struct object_id *oid,\n \t\t\t\t    void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_COMMIT;\n }\n \n@@ -262,7 +262,7 @@ static int disambiguate_committish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -279,7 +279,7 @@ static int disambiguate_tree_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_TREE;\n }\n \n@@ -290,7 +290,7 @@ static int disambiguate_treeish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_TREE || kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -307,7 +307,7 @@ static int disambiguate_blob_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_BLOB;\n }\n \n@@ -399,7 +399,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t\treturn 0;\n \n \thash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);\n-\ttype = oid_object_info(ds->repo, oid, NULL);\n+\ttype = odb_read_object_info(ds->repo->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\t/*\n@@ -514,8 +514,8 @@ static int sort_ambiguous(const void *va, const void *vb, void *ctx)\n {\n \tstruct repository *sort_ambiguous_repo = ctx;\n \tconst struct object_id *a = va, *b = vb;\n-\tint a_type = oid_object_info(sort_ambiguous_repo, a, NULL);\n-\tint b_type = oid_object_info(sort_ambiguous_repo, b, NULL);\n+\tint a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL);\n+\tint b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL);\n \tint a_type_sort;\n \tint b_type_sort;\n \ndiff --git a/object.c b/object.c\nindex 3b15469139d..868d89eed42 100644\n--- a/object.c\n+++ b/object.c\n@@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,\n \tstruct object *o = lookup_unknown_object(r, name);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = oid_object_info(r, name, NULL);\n+\t\tint type = odb_read_object_info(r->objects, name, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\n@@ -315,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t}\n \n \tif ((!obj || obj->type == OBJ_BLOB) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_BLOB) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {\n \t\tif (!skip_hash && stream_object_signature(r, repl) < 0) {\n \t\t\terror(_(\"hash mismatch %s\"), oid_to_hex(oid));\n \t\t\treturn NULL;\n@@ -331,7 +331,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t */\n \tif (skip_hash && discard_tree &&\n \t    (!obj || obj->type == OBJ_TREE) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_TREE) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex c150c01db4a..3d5d4ff8454 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -647,7 +647,7 @@ static int register_all_submodule_alternates(struct object_database *odb)\n \treturn ret;\n }\n \n-static int do_oid_object_info_extended(struct repository *r,\n+static int do_oid_object_info_extended(struct object_database *odb,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n {\n@@ -660,7 +660,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \n \n \tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n-\t\treal = lookup_replace_object(r, oid);\n+\t\treal = lookup_replace_object(odb->repo, oid);\n \n \tif (is_null_oid(real))\n \t\treturn -1;\n@@ -668,7 +668,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \tif (!oi)\n \t\toi = &blank_oi;\n \n-\tco = find_cached_object(r->objects, real);\n+\tco = find_cached_object(odb, real);\n \tif (co) {\n \t\tif (oi->typep)\n \t\t\t*(oi->typep) = co->type;\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, odb->repo->hash_algo);\n \t\tif (oi->type_name)\n \t\t\tstrbuf_addstr(oi->type_name, type_name(co->type));\n \t\tif (oi->contentp)\n@@ -687,17 +687,17 @@ static int do_oid_object_info_extended(struct repository *r,\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(r, real, &e))\n+\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\tbreak;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!loose_object_info(r, real, oi, flags))\n+\t\tif (!loose_object_info(odb->repo, real, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\tif (!(flags & OBJECT_INFO_QUICK)) {\n-\t\t\treprepare_packed_git(r);\n-\t\t\tif (find_pack_entry(r, real, &e))\n+\t\t\treprepare_packed_git(odb->repo);\n+\t\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\t\tbreak;\n \t\t}\n \n@@ -707,15 +707,15 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * `odb_add_submodule_alternate_by_path()` on that submodule's\n \t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (register_all_submodule_alternates(r->objects))\n+\t\tif (register_all_submodule_alternates(odb))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n \t\t/* Check if it is a missing object */\n-\t\tif (fetch_if_missing && repo_has_promisor_remote(r) &&\n+\t\tif (fetch_if_missing && repo_has_promisor_remote(odb->repo) &&\n \t\t    !already_retried &&\n \t\t    !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n-\t\t\tpromisor_remote_get_direct(r, real, 1);\n+\t\t\tpromisor_remote_get_direct(odb->repo, real, 1);\n \t\t\talready_retried = 1;\n \t\t\tcontinue;\n \t\t}\n@@ -725,7 +725,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t\tif ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))\n \t\t\t\tdie(_(\"replacement %s not found for %s\"),\n \t\t\t\t    oid_to_hex(real), oid_to_hex(oid));\n-\t\t\tif ((p = has_packed_and_bad(r, real)))\n+\t\t\tif ((p = has_packed_and_bad(odb->repo, real)))\n \t\t\t\tdie(_(\"packed object %s (stored in %s) is corrupt\"),\n \t\t\t\t    oid_to_hex(real), p->pack_name);\n \t\t}\n@@ -738,10 +738,10 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(r, e.p, e.offset, oi);\n+\trtype = packed_object_info(odb->repo, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real);\n-\t\treturn do_oid_object_info_extended(r, real, oi, 0);\n+\t\treturn do_oid_object_info_extended(odb, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -789,7 +789,7 @@ static int oid_object_info_convert(struct repository *r,\n \t\toi = &new_oi;\n \t}\n \n-\tret = oid_object_info_extended(r, &oid, oi, flags);\n+\tret = odb_read_object_info_extended(r->objects, &oid, oi, flags);\n \tif (ret)\n \t\treturn -1;\n \tif (oi == input_oi)\n@@ -839,33 +839,35 @@ static int oid_object_info_convert(struct repository *r,\n \treturn ret;\n }\n \n-int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n-\t\t\t     struct object_info *oi, unsigned flags)\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags)\n {\n \tint ret;\n \n-\tif (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo))\n-\t\treturn oid_object_info_convert(r, oid, oi, flags);\n+\tif (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo))\n+\t\treturn oid_object_info_convert(odb->repo, oid, oi, flags);\n \n \tobj_read_lock();\n-\tret = do_oid_object_info_extended(r, oid, oi, flags);\n+\tret = do_oid_object_info_extended(odb, oid, oi, flags);\n \tobj_read_unlock();\n \treturn ret;\n }\n \n \n /* returns enum object_type or negative */\n-int oid_object_info(struct repository *r,\n-\t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (odb_read_object_info_extended(odb, oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n@@ -896,7 +898,7 @@ int pretend_object_file(struct repository *repo,\n \n /*\n  * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call oid_object_info_extended() and give\n+ * deal with them should arrange to call odb_read_object_info_extended() and give\n  * error messages themselves.\n  */\n void *repo_read_object_file(struct repository *r,\n@@ -911,7 +913,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (oid_object_info_extended(r, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -977,13 +979,13 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(odb, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex 44326cb698d..e521a608237 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -257,9 +257,6 @@ void *repo_read_object_file(struct repository *r,\n \t\t\t    enum object_type *type,\n \t\t\t    unsigned long *size);\n \n-/* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n-\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -331,9 +328,24 @@ struct object_info {\n /* Die if object corruption (not just an object being missing) was detected. */\n #define OBJECT_INFO_DIE_IF_CORRUPT 32\n \n-int oid_object_info_extended(struct repository *r,\n-\t\t\t     const struct object_id *,\n-\t\t\t     struct object_info *, unsigned flags);\n+/*\n+ * Read object info from the object database and populate the `object_info`\n+ * structure. Returns 0 on success, a negative error code otherwise.\n+ */\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags);\n+\n+/*\n+ * Read a subset of object info for the given object ID. Returns an `enum\n+ * object_type` on success, a negative error code otherwise. If successful and\n+ * `sizep` is non-NULL, then the size of the object will be written to the\n+ * pointer.\n+ */\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep);\n \n enum {\n \t/* Retry packed storage after checking packed and loose storage */\n@@ -355,7 +367,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: repo_read_object_file(),\n- * read_object_with_reference(), oid_object_info() and oid_object_info_extended().\n+ * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -363,7 +375,7 @@ void odb_assert_oid_type(struct object_database *odb,\n  * reading functions. However, beware that in these cases zlib inflation won't\n  * be performed in parallel, losing performance.\n  *\n- * TODO: oid_object_info_extended()'s call stack has a recursive behavior. If\n+ * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If\n  * any of its callees end up calling it, this recursive call won't benefit from\n  * parallel inflation.\n  */\n@@ -411,4 +423,22 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n+/* Compatibility wrappers, to be removed once Git 2.50 has been released. */\n+#include \"repository.h\"\n+\n+static inline int oid_object_info_extended(struct repository *r,\n+\t\t\t\t\t   const struct object_id *oid,\n+\t\t\t\t\t   struct object_info *oi,\n+\t\t\t\t\t   unsigned flags)\n+{\n+\treturn odb_read_object_info_extended(r->objects, oid, oi, flags);\n+}\n+\n+static inline int oid_object_info(struct repository *r,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  unsigned long *sizep)\n+{\n+\treturn odb_read_object_info(r->objects, oid, sizep);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex c847369eaaa..c5183b619c1 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -144,8 +144,8 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\treal_type = oid_object_info(writer->to_pack->repo,\n-\t\t\t\t\t\t    &entry->idx.oid, NULL);\n+\t\t\treal_type = odb_read_object_info(writer->to_pack->repo->objects,\n+\t\t\t\t\t\t\t &entry->idx.oid, NULL);\n \t\t\tbreak;\n \t\t}\n \ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex 467a3e91035..0bd6f1c282f 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -1868,8 +1868,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,\n \t\tsize_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git);\n \t\tstruct eindex *eindex = &bitmap_git->ext_index;\n \t\tstruct object *obj = eindex->objects[eindex_pos];\n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid,\n+\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"), oid_to_hex(&obj->oid));\n \t}\n \n@@ -3220,8 +3220,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)\n \t\t\t\t       i)))\n \t\t\tcontinue;\n \n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects,\n+\t\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get disk usage of '%s'\"),\n \t\t\t    oid_to_hex(&obj->oid));\n \ndiff --git a/packfile.c b/packfile.c\nindex ab9628eb3d4..2f022265a5b 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1310,7 +1310,7 @@ static int retry_bad_packed_offset(struct repository *r,\n \t\treturn OBJ_BAD;\n \tnth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));\n \tmark_bad_packed_object(p, &oid);\n-\ttype = oid_object_info(r, &oid, NULL);\n+\ttype = odb_read_object_info(r->objects, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1843,7 +1843,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\t\t\toi.typep = &type;\n \t\t\t\toi.sizep = &base_size;\n \t\t\t\toi.contentp = &base;\n-\t\t\t\tif (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)\n+\t\t\t\tif (odb_read_object_info_extended(r->objects, &base_oid,\n+\t\t\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\t\t\tbase = NULL;\n \n \t\t\t\texternal_base = base;\ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 2baa286bfd0..be6f82d12f8 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -245,8 +245,8 @@ static int remove_fetched_oids(struct repository *repo,\n \tstruct object_id *new_oids;\n \n \tfor (i = 0; i < oid_nr; i++)\n-\t\tif (oid_object_info_extended(repo, &old_oids[i], NULL,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n+\t\tif (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n \t\t\tremaining[i] = 1;\n \t\t\tremaining_nr++;\n \t\t}\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 3022f69a1bd..ecdd0dc58d5 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -64,7 +64,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,\n \t\tstrbuf_addstr(&send_buffer, oid_str);\n \n \t\tif (info->size) {\n-\t\t\tif (oid_object_info(r, &oid, &object_size) < 0) {\n+\t\t\tif (odb_read_object_info(r->objects, &oid, &object_size) < 0) {\n \t\t\t\tstrbuf_addstr(&send_buffer, \" \");\n \t\t\t} else {\n \t\t\t\tstrbuf_addf(&send_buffer, \" %lu\", object_size);\ndiff --git a/reachable.c b/reachable.c\nindex 9dc748f0b9a..e984b68a0c4 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -211,7 +211,7 @@ static void add_recent_object(const struct object_id *oid,\n \t * later processing, and the revision machinery expects\n \t * commits and tags to have been parsed.\n \t */\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object info for %s\", oid_to_hex(oid));\n \ndiff --git a/read-cache.c b/read-cache.c\nindex dce1056ec7c..be664f857b4 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3758,9 +3758,9 @@ void prefetch_cache_entries(const struct index_state *istate,\n \n \t\tif (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))\n \t\t\tcontinue;\n-\t\tif (!oid_object_info_extended(the_repository, &ce->oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &ce->oid, NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &ce->oid);\n \t}\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 4ce45440ad1..f9f2c512a8c 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2302,8 +2302,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj\n \t\toi->info.sizep = &oi->size;\n \t\toi->info.typep = &oi->type;\n \t}\n-\tif (oid_object_info_extended(the_repository, &oi->oid, &oi->info,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\tif (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\treturn strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n \t\t\t\t       oid_to_hex(&oi->oid), ref->refname);\n \tif (oi->info.disk_sizep && oi->disk_size < 0)\ndiff --git a/remote.c b/remote.c\nindex 17a842f5684..72c36239d31 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1182,7 +1182,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,\n \t\tBUG(\"'%s' is not a valid object, \"\n \t\t    \"match_explicit_lhs() should catch this!\",\n \t\t    matched_src_name);\n-\ttype = oid_object_info(the_repository, &oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \tif (type == OBJ_COMMIT) {\n \t\tadvise(_(\"The <src> part of the refspec is a commit object.\\n\"\n \t\t\t \"Did you mean to create a new branch by pushing to\\n\"\n@@ -1412,7 +1412,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &ref->new_oid, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\ndiff --git a/sequencer.c b/sequencer.c\nindex 35f4e68d59f..bb012a4bfd9 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5502,9 +5502,8 @@ int sequencer_pick_revisions(struct repository *r,\n \n \t\tif (!repo_get_oid(r, name, &oid)) {\n \t\t\tif (!lookup_commit_reference_gently(r, &oid, 1)) {\n-\t\t\t\tenum object_type type = oid_object_info(r,\n-\t\t\t\t\t\t\t\t\t&oid,\n-\t\t\t\t\t\t\t\t\tNULL);\n+\t\t\t\tenum object_type type = odb_read_object_info(r->objects,\n+\t\t\t\t\t\t\t\t\t     &oid, NULL);\n \t\t\t\tres = error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\t    name, type_name(type));\n \t\t\t\tgoto out;\ndiff --git a/streaming.c b/streaming.c\nindex 29cc877f22a..032f134dc10 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -44,7 +44,7 @@ struct git_istream {\n \n \tunion {\n \t\tstruct {\n-\t\t\tchar *buf; /* from oid_object_info_extended() */\n+\t\t\tchar *buf; /* from odb_read_object_info_extended() */\n \t\t\tunsigned long read_ptr;\n \t\t} incore;\n \n@@ -403,8 +403,8 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,\n \toi.typep = type;\n \toi.sizep = &st->size;\n \toi.contentp = (void **)&st->u.incore.buf;\n-\treturn oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t\tOBJECT_INFO_DIE_IF_CORRUPT);\n+\treturn odb_read_object_info_extended(r->objects, oid, &oi,\n+\t\t\t\t\t     OBJECT_INFO_DIE_IF_CORRUPT);\n }\n \n /*****************************************************************************\n@@ -422,7 +422,7 @@ static int istream_source(struct git_istream *st,\n \n \toi.typep = type;\n \toi.sizep = &size;\n-\tstatus = oid_object_info_extended(r, oid, &oi, 0);\n+\tstatus = odb_read_object_info_extended(r->objects, oid, &oi, 0);\n \tif (status < 0)\n \t\treturn status;\n \ndiff --git a/submodule.c b/submodule.c\nindex 788c9e55ed3..f8373a9ea7d 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -968,7 +968,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n \t\treturn 0;\n \t}\n \n-\ttype = oid_object_info(&subrepo, oid, NULL);\n+\ttype = odb_read_object_info(subrepo.objects, oid, NULL);\n \n \tswitch (type) {\n \tcase OBJ_COMMIT:\n@@ -1752,8 +1752,7 @@ static int fetch_start_failure(struct strbuf *err UNUSED,\n static int commit_missing_in_sub(const struct object_id *oid, void *data)\n {\n \tstruct repository *subrepo = data;\n-\n-\tenum object_type type = oid_object_info(subrepo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(subrepo->objects, oid, NULL);\n \n \treturn type != OBJ_COMMIT;\n }\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex dba227259a2..d8488007493 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -23,7 +23,7 @@ static void object_info(const char *gitdir, const char *oid_hex)\n \t\tdie(\"could not init repo\");\n \tif (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo))\n \t\tdie(\"could not parse oid\");\n-\tif (oid_object_info_extended(&r, &oid, &oi, 0))\n+\tif (odb_read_object_info_extended(r.objects, &oid, &oi, 0))\n \t\tdie(\"could not obtain object info\");\n \tprintf(\"%d\\n\", (int) size);\n \ndiff --git a/tag.c b/tag.c\nindex 5f6868bf7b1..144048fd5e0 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \tunsigned long size;\n \tint ret;\n \n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518014","messageId":"20250514-pks-object-store-wo-the-repository-v3-14-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 14/17] odb: rename `repo_read_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:37Z","receivedAt":"2025-05-14T05:12:44Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `repo_read_object_file()` to `odb_read_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  | 10 +++++-----\n archive.c                |  2 +-\n attr.c                   |  2 +-\n bisect.c                 |  6 +++---\n blame.c                  | 13 ++++++-------\n builtin/cat-file.c       | 26 +++++++++++---------------\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  6 +++---\n builtin/fast-import.c    |  8 ++++----\n builtin/grep.c           |  8 ++++----\n builtin/index-pack.c     |  8 ++++----\n builtin/log.c            |  2 +-\n builtin/merge-tree.c     | 12 ++++++------\n builtin/mktag.c          |  4 ++--\n builtin/notes.c          |  6 +++---\n builtin/pack-objects.c   | 30 +++++++++++++++---------------\n builtin/tag.c            |  4 ++--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c |  4 ++--\n bundle.c                 |  2 +-\n combine-diff.c           |  2 +-\n commit.c                 |  6 +++---\n config.c                 |  2 +-\n dir.c                    |  2 +-\n entry.c                  |  4 ++--\n fmt-merge-msg.c          |  4 ++--\n fsck.c                   |  2 +-\n grep.c                   |  4 ++--\n http-push.c              |  4 ++--\n mailmap.c                |  2 +-\n match-trees.c            |  4 ++--\n merge-blobs.c            |  8 ++++----\n merge-ort.c              |  2 +-\n notes-cache.c            |  2 +-\n notes-merge.c            |  2 +-\n notes.c                  | 13 +++++++------\n object.c                 |  2 +-\n odb.c                    | 19 +++++++------------\n odb.h                    | 29 +++++++++++++++++++++++------\n read-cache.c             |  6 +++---\n reflog.c                 |  4 ++--\n rerere.c                 |  5 ++---\n submodule-config.c       |  4 ++--\n tag.c                    |  6 +++---\n tree-walk.c              |  6 +++---\n tree.c                   |  4 ++--\n xdiff-interface.c        |  2 +-\n 47 files changed, 157 insertions(+), 150 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 879f04df31e..56cd0540350 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3210,8 +3210,8 @@ static int apply_binary(struct apply_state *state,\n \t\tunsigned long size;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t       &size);\n+\t\tresult = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t\t &type, &size);\n \t\tif (!result)\n \t\t\treturn error(_(\"the necessary postimage %s for \"\n \t\t\t\t       \"'%s' cannot be read\"),\n@@ -3273,8 +3273,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tunsigned long sz;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t       &sz);\n+\t\tresult = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t &type, &sz);\n \t\tif (!result)\n \t\t\treturn -1;\n \t\t/* XXX read_sha1_file NUL-terminates */\n@@ -3503,7 +3503,7 @@ static int resolve_to(struct image *image, const struct object_id *result_id)\n \n \timage_clear(image);\n \n-\tdata = repo_read_object_file(the_repository, result_id, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, result_id, &type, &size);\n \tif (!data || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(result_id));\n \tstrbuf_attach(&image->buf, data, size, size + 1);\ndiff --git a/archive.c b/archive.c\nindex f2511d530d5..f5a9d45c8d3 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -98,7 +98,7 @@ static void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t       (args->tree ? &args->tree->object.oid : NULL), oid);\n \n \tpath += args->baselen;\n-\tbuffer = repo_read_object_file(the_repository, oid, type, sizep);\n+\tbuffer = odb_read_object(the_repository->objects, oid, type, sizep);\n \tif (buffer && S_ISREG(mode)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tsize_t size = 0;\ndiff --git a/attr.c b/attr.c\nindex e5680db7f65..d1daeb0b4d9 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -779,7 +779,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,\n \tif (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))\n \t\treturn NULL;\n \n-\tbuf = repo_read_object_file(istate->repo, &oid, &type, &sz);\n+\tbuf = odb_read_object(istate->repo->objects, &oid, &type, &sz);\n \tif (!buf || type != OBJ_BLOB) {\n \t\tfree(buf);\n \t\treturn NULL;\ndiff --git a/bisect.c b/bisect.c\nindex a7939216d00..f24474542ec 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -155,9 +155,9 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tunsigned commit_flags = commit->object.flags;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &commit->object.oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &commit->object.oid, &type,\n+\t\t\t\t\t    &size);\n \t\tconst char *subject_start;\n \t\tint subject_len;\n \ndiff --git a/blame.c b/blame.c\nindex 97db3355af4..858d2d74df9 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1041,9 +1041,9 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\t\t\t    &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n-\t\t\tfile->ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t  &o->blob_oid, &type,\n-\t\t\t\t\t\t\t  &file_size);\n+\t\t\tfile->ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t    &o->blob_oid, &type,\n+\t\t\t\t\t\t    &file_size);\n \t\tfile->size = file_size;\n \n \t\tif (!file->ptr)\n@@ -2869,10 +2869,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\n \t\telse\n-\t\t\tsb->final_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &o->blob_oid,\n-\t\t\t\t\t\t\t      &type,\n-\t\t\t\t\t\t\t      &sb->final_buf_size);\n+\t\t\tsb->final_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&o->blob_oid, &type,\n+\t\t\t\t\t\t\t&sb->final_buf_size);\n \n \t\tif (!sb->final_buf)\n \t\t\tdie(_(\"cannot read blob %s for path %s\"),\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex da172155c85..d6b9afca06e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -74,7 +74,7 @@ static int filter_object(const char *path, unsigned mode,\n {\n \tenum object_type type;\n \n-\t*buf = repo_read_object_file(the_repository, oid, &type, size);\n+\t*buf = odb_read_object(the_repository->objects, oid, &type, size);\n \tif (!*buf)\n \t\treturn error(_(\"cannot read object %s '%s'\"),\n \t\t\t     oid_to_hex(oid), path);\n@@ -206,8 +206,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\tret = stream_blob(&oid);\n \t\t\tgoto cleanup;\n \t\t}\n-\t\tbuf = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t      &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"Cannot read object %s\", obj_name);\n \n@@ -228,10 +228,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\tstruct object_id blob_oid;\n \t\t\tif (odb_read_object_info(the_repository->objects,\n \t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n-\t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t     &oid,\n-\t\t\t\t\t\t\t\t     &type,\n-\t\t\t\t\t\t\t\t     &size);\n+\t\t\t\tchar *buffer = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t       &oid, &type, &size);\n \t\t\t\tconst char *target;\n \n \t\t\t\tif (!buffer)\n@@ -412,10 +410,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\t\tif (!textconv_object(the_repository,\n \t\t\t\t\t\t     data->rest, 0100644, oid,\n \t\t\t\t\t\t     1, &contents, &size))\n-\t\t\t\t\tcontents = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t\t oid,\n-\t\t\t\t\t\t\t\t\t &type,\n-\t\t\t\t\t\t\t\t\t &size);\n+\t\t\t\t\tcontents = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t\t   oid, &type, &size);\n \t\t\t\tif (!contents)\n \t\t\t\t\tdie(\"could not convert '%s' %s\",\n \t\t\t\t\t    oid_to_hex(oid), data->rest);\n@@ -432,8 +428,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\tunsigned long size;\n \t\tvoid *contents;\n \n-\t\tcontents = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t &size);\n+\t\tcontents = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &type, &size);\n \t\tif (!contents)\n \t\t\tdie(\"object %s disappeared\", oid_to_hex(oid));\n \n@@ -542,8 +538,8 @@ static void batch_object_write(const char *obj_name,\n \t\t\tsize_t s = data->size;\n \t\t\tchar *buf = NULL;\n \n-\t\t\tbuf = repo_read_object_file(the_repository, &data->oid, &data->type,\n-\t\t\t\t\t\t    &data->size);\n+\t\t\tbuf = odb_read_object(the_repository->objects, &data->oid,\n+\t\t\t\t\t      &data->type, &data->size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"), oid_to_hex(&data->oid));\n \t\t\tbuf = replace_idents_using_mailmap(buf, &s);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex fac613e3bc3..e4bc1f83169 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -320,7 +320,7 @@ static char *get_symlink(struct repository *repo,\n \t} else {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tdata = repo_read_object_file(repo, oid, &type, &size);\n+\t\tdata = odb_read_object(repo->objects, oid, &type, &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\n \t\t\t\toid_to_hex(oid), path);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 6c93cf0a8aa..33f304dd0ad 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -323,7 +323,7 @@ static void export_blob(const struct object_id *oid)\n \t\tobject = (struct object *)lookup_blob(the_repository, oid);\n \t\teaten = 0;\n \t} else {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"could not read blob %s\", oid_to_hex(oid));\n \t\tif (check_object_signature(the_repository, oid, buf, size,\n@@ -869,8 +869,8 @@ static void handle_tag(const char *name, struct tag *tag)\n \t\treturn;\n \t}\n \n-\tbuf = repo_read_object_file(the_repository, &tag->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(\"could not read tag %s\", oid_to_hex(&tag->object.oid));\n \tmessage = memmem(buf, size, \"\\n\\n\", 2);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 2718376f2c9..1973c504e25 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf || type != OBJ_TREE)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t}\n@@ -3002,7 +3002,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \tchar *buf;\n \n \tif (!oe || oe->pack_id == MAX_PACK_ID) {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t} else {\n \t\ttype = oe->type;\n \t\tbuf = gfi_unpack_entry(oe, &size);\n@@ -3110,8 +3110,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \t\tbuf = gfi_unpack_entry(oe, &size);\n \t} else {\n \t\tenum object_type unused;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &unused,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t      &unused, &size);\n \t}\n \tif (!buf)\n \t\tdie(\"Can't load object %s\", oid_to_hex(oid));\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 311c940aa9e..f84298af0f6 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -573,8 +573,8 @@ static int grep_cache(struct grep_opt *opt,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t     &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t       &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree %s\"), oid_to_hex(&ce->oid));\n \t\t\tinit_tree_desc(&tree, &ce->oid, data, size);\n@@ -666,8 +666,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry.oid, &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry.oid, &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree (%s)\"),\n \t\t\t\t    oid_to_hex(&entry.oid));\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 82cf80b89d1..d33392cab65 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -914,8 +914,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), oid_to_hex(oid));\n-\t\thas_data = repo_read_object_file(the_repository, oid,\n-\t\t\t\t\t\t &has_type, &has_size);\n+\t\thas_data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &has_type, &has_size);\n \t\tread_unlock();\n \t\tif (!data)\n \t\t\tdata = new_data = get_data_from_pack(obj_entry);\n@@ -1515,8 +1515,8 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \n \t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n-\t\tdata = repo_read_object_file(the_repository, &d->oid, &type,\n-\t\t\t\t\t     &size);\n+\t\tdata = odb_read_object(the_repository->objects, &d->oid,\n+\t\t\t\t       &type, &size);\n \t\tif (!data)\n \t\t\tcontinue;\n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex fe9cc5ebecb..f2040b18159 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -714,7 +714,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tunsigned long offset = 0;\n \n \tif (!buf)\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 709ae3966a6..21fb0b2df1d 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -75,9 +75,9 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \tconst char *path = entry->path;\n \n \tif (!entry->stage)\n-\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t     &entry->blob->object.oid, &type,\n-\t\t\t\t\t     size);\n+\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t       &entry->blob->object.oid, &type,\n+\t\t\t\t       size);\n \tbase = NULL;\n \tif (entry->stage == 1) {\n \t\tbase = entry->blob;\n@@ -100,9 +100,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)\n \tenum object_type type;\n \twhile (entry) {\n \t\tif (entry->stage == 2)\n-\t\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry->blob->object.oid,\n-\t\t\t\t\t\t     &type, size);\n+\t\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry->blob->object.oid,\n+\t\t\t\t\t       &type, size);\n \t\tentry = entry->link;\n \t}\n \treturn NULL;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 1809b38f937..1b391119de8 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -54,8 +54,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)\n \tvoid *buffer;\n \tconst struct object_id *repl;\n \n-\tbuffer = repo_read_object_file(the_repository, tagged_oid, &type,\n-\t\t\t\t       &size);\n+\tbuffer = odb_read_object(the_repository->objects, tagged_oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\tdie(_(\"could not read tagged object '%s'\"),\n \t\t    oid_to_hex(tagged_oid));\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 783d4932ca6..a9529b1696a 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -152,7 +152,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (buf) {\n \t\tif (size)\n \t\t\twrite_or_die(fd, buf, size);\n@@ -319,7 +319,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tstrbuf_init(&msg->buf, 0);\n \tif (repo_get_oid(the_repository, arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(value = repo_read_object_file(the_repository, &object, &type, &len)))\n+\tif (!(value = odb_read_object(the_repository->objects, &object, &type, &len)))\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n \tif (type != OBJ_BLOB) {\n \t\tstrbuf_release(&msg->buf);\n@@ -722,7 +722,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,\n \t\tunsigned long size;\n \t\tenum object_type type;\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tchar *prev_buf = repo_read_object_file(the_repository, note, &type, &size);\n+\t\tchar *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \t\tif (!prev_buf)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(note));\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex da35d684081..580a5c1996b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -337,13 +337,13 @@ static void *get_delta(struct object_entry *entry)\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &entry->idx.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &entry->idx.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(_(\"unable to read %s\"), oid_to_hex(&entry->idx.oid));\n-\tbase_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t &DELTA(entry)->idx.oid, &type,\n-\t\t\t\t\t &base_size);\n+\tbase_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t   &DELTA(entry)->idx.oid, &type,\n+\t\t\t\t   &base_size);\n \tif (!base_buf)\n \t\tdie(\"unable to read %s\",\n \t\t    oid_to_hex(&DELTA(entry)->idx.oid));\n@@ -506,9 +506,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \t\t\t\t       &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n-\t\t\tbuf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t    &entry->idx.oid, &type,\n-\t\t\t\t\t\t    &size);\n+\t\t\tbuf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t      &entry->idx.oid, &type,\n+\t\t\t\t\t      &size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&entry->idx.oid));\n@@ -1895,7 +1895,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \t/* Did not find one.  Either we got a bogus request or\n \t * we need to read and perhaps cache.\n \t */\n-\tdata = repo_read_object_file(the_repository, oid, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!data)\n \t\treturn NULL;\n \tif (type != OBJ_TREE) {\n@@ -2762,9 +2762,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t/* Load data if not already done */\n \tif (!trg->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\ttrg->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &trg_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\ttrg->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &trg_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!trg->data)\n \t\t\tdie(_(\"object %s cannot be read\"),\n@@ -2777,9 +2777,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t}\n \tif (!src->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tsrc->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &src_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\tsrc->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &src_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!src->data) {\n \t\t\tif (src_entry->preferred_base) {\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex e0b27396c6b..46cbf892e34 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -244,7 +244,7 @@ static void write_tag_body(int fd, const struct object_id *oid)\n \tstruct strbuf payload = STRBUF_INIT;\n \tstruct strbuf signature = STRBUF_INIT;\n \n-\torig = buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\torig = buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn;\n \tif (parse_signature(buf, size, &payload, &signature)) {\n@@ -407,7 +407,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {\n+\t\tif ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) {\n \t\t\tsubject_len = find_commit_subject(buf, &subject_start);\n \t\t\tstrbuf_insert(sb, sb->len, subject_start, subject_len);\n \t\t} else {\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex b92fd4710a9..4360872ae07 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -14,7 +14,7 @@ static char *create_temp_file(struct object_id *oid)\n \tunsigned long size;\n \tint fd;\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 405e78bc592..4bc6575a574 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -516,8 +516,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \tif (resolve_against_held(nr, &base_oid, delta_data, delta_size))\n \t\treturn;\n \n-\tbase = repo_read_object_file(the_repository, &base_oid, &type,\n-\t\t\t\t     &base_size);\n+\tbase = odb_read_object(the_repository->objects, &base_oid,\n+\t\t\t       &type, &base_size);\n \tif (!base) {\n \t\terror(\"failed to read delta-pack base object %s\",\n \t\t      oid_to_hex(&base_oid));\ndiff --git a/bundle.c b/bundle.c\nindex c67f85126da..66d0e8eaf0e 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -305,7 +305,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n \tif (revs->max_age == -1 && revs->min_age == -1)\n \t\tgoto out;\n \n-\tbuf = repo_read_object_file(the_repository, &tag->oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->oid, &type, &size);\n \tif (!buf)\n \t\tgoto out;\n \tline = memmem(buf, size, \"\\ntagger \", 8);\ndiff --git a/combine-diff.c b/combine-diff.c\nindex cf23a753407..4ea2dc93c4f 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -325,7 +325,7 @@ static char *grab_blob(struct repository *r,\n \t\t*size = fill_textconv(r, textconv, df, &blob);\n \t\tfree_filespec(df);\n \t} else {\n-\t\tblob = repo_read_object_file(r, oid, &type, size);\n+\t\tblob = odb_read_object(r->objects, oid, &type, size);\n \t\tif (!blob)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(oid));\n \t\tif (type != OBJ_BLOB)\ndiff --git a/commit.c b/commit.c\nindex d4aa9c7a5f8..28ee6b73ae6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -374,7 +374,7 @@ const void *repo_get_commit_buffer(struct repository *r,\n \tif (!ret) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n+\t\tret = odb_read_object(r->objects, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n \t\t\t    oid_to_hex(&commit->object.oid));\n@@ -1275,8 +1275,8 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h\n \tdesc = merge_remote_util(parent);\n \tif (!desc || !desc->obj)\n \t\treturn;\n-\tbuf = repo_read_object_file(the_repository, &desc->obj->oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &desc->obj->oid,\n+\t\t\t      &type, &size);\n \tif (!buf || type != OBJ_TAG)\n \t\tgoto free_return;\n \tif (!parse_signature(buf, size, &payload, &signature))\ndiff --git a/config.c b/config.c\nindex 883dd066827..142c37215a8 100644\n--- a/config.c\n+++ b/config.c\n@@ -1942,7 +1942,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n \tunsigned long size;\n \tint ret;\n \n-\tbuf = repo_read_object_file(repo, oid, &type, &size);\n+\tbuf = odb_read_object(repo->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(_(\"unable to load config blob object '%s'\"), name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/dir.c b/dir.c\nindex e11342e1366..251dedf1f5e 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -302,7 +302,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t*size_out = 0;\n \t*data_out = NULL;\n \n-\tdata = repo_read_object_file(the_repository, oid, &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn -1;\ndiff --git a/entry.c b/entry.c\nindex 75d55038d7c..cae02eb5039 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -93,8 +93,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tunsigned long ul;\n-\tvoid *blob_data = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t&type, &ul);\n+\tvoid *blob_data = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t  &type, &ul);\n \n \t*size = ul;\n \tif (blob_data) {\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 1a8c972adf3..40174efa3de 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -526,8 +526,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t    &type, &size);\n \t\tchar *origbuf = buf;\n \t\tunsigned long len = size;\n \t\tstruct signature_check sigc = { NULL };\ndiff --git a/fsck.c b/fsck.c\nindex e69baab3af7..23965e1880f 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1293,7 +1293,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,\n \t\tif (oidset_contains(blobs_done, oid))\n \t\t\tcontinue;\n \n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf) {\n \t\t\tif (is_promisor_object(the_repository, oid))\n \t\t\t\tcontinue;\ndiff --git a/grep.c b/grep.c\nindex dc77e6c4631..932647e4a65 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1931,8 +1931,8 @@ static int grep_source_load_oid(struct grep_source *gs)\n {\n \tenum object_type type;\n \n-\tgs->buf = repo_read_object_file(gs->repo, gs->identifier, &type,\n-\t\t\t\t\t&gs->size);\n+\tgs->buf = odb_read_object(gs->repo->objects, gs->identifier,\n+\t\t\t\t  &type, &gs->size);\n \tif (!gs->buf)\n \t\treturn error(_(\"'%s': unable to read %s\"),\n \t\t\t     gs->name,\ndiff --git a/http-push.c b/http-push.c\nindex d1b1bb23711..9481825abfb 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -369,8 +369,8 @@ static void start_put(struct transfer_request *request)\n \tssize_t size;\n \tgit_zstream stream;\n \n-\tunpacked = repo_read_object_file(the_repository, &request->obj->oid,\n-\t\t\t\t\t &type, &len);\n+\tunpacked = odb_read_object(the_repository->objects, &request->obj->oid,\n+\t\t\t\t   &type, &len);\n \thdrlen = format_object_header(hdr, sizeof(hdr), type, len);\n \n \t/* Set it up */\ndiff --git a/mailmap.c b/mailmap.c\nindex b18e74c2110..56c72102d9e 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -196,7 +196,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \tif (repo_get_oid(the_repository, name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = repo_read_object_file(the_repository, &oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/match-trees.c b/match-trees.c\nindex 4704f95c340..5a8a5c39b04 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -63,7 +63,7 @@ static void *fill_tree_desc_strict(struct repository *r,\n \tenum object_type type;\n \tunsigned long size;\n \n-\tbuffer = repo_read_object_file(r, hash, &type, &size);\n+\tbuffer = odb_read_object(r->objects, hash, &type, &size);\n \tif (!buffer)\n \t\tdie(\"unable to read tree (%s)\", oid_to_hex(hash));\n \tif (type != OBJ_TREE)\n@@ -199,7 +199,7 @@ static int splice_tree(struct repository *r,\n \tif (*subpath)\n \t\tsubpath++;\n \n-\tbuf = repo_read_object_file(r, oid1, &type, &sz);\n+\tbuf = odb_read_object(r->objects, oid1, &type, &sz);\n \tif (!buf)\n \t\tdie(\"cannot read tree %s\", oid_to_hex(oid1));\n \tinit_tree_desc(&desc, oid1, buf, sz);\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex ba8a3fdfd82..6fc27994171 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -12,8 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n \tunsigned long size;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &obj->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &obj->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\treturn -1;\n \tif (type != OBJ_BLOB) {\n@@ -79,8 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path,\n \t\t\treturn NULL;\n \t\tif (!our)\n \t\t\tour = their;\n-\t\treturn repo_read_object_file(the_repository, &our->object.oid,\n-\t\t\t\t\t     &type, size);\n+\t\treturn odb_read_object(the_repository->objects, &our->object.oid,\n+\t\t\t\t       &type, size);\n \t}\n \n \tif (fill_mmfile_blob(&f1, our) < 0)\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 5d4501085e9..53417d399c7 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -3624,7 +3624,7 @@ static int read_oid_strbuf(struct merge_options *opt,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf) {\n \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n \t\t\t path, NULL, NULL, NULL,\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 344f67762b8..dd56feed6e8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -87,7 +87,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\n \t\treturn NULL;\n-\tvalue = repo_read_object_file(the_repository, value_oid, &type, &size);\n+\tvalue = odb_read_object(the_repository->objects, value_oid, &type, &size);\n \n \t*outsize = size;\n \treturn value;\ndiff --git a/notes-merge.c b/notes-merge.c\nindex de6a52e2e7f..586939939f2 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -340,7 +340,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n {\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buf = repo_read_object_file(the_repository, note, &type, &size);\n+\tvoid *buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"cannot read note %s for object %s\",\ndiff --git a/notes.c b/notes.c\nindex fc000e501d2..73eb5f00cf5 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -816,15 +816,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \n \t/* read in both note blob objects */\n \tif (!is_null_oid(new_oid))\n-\t\tnew_msg = repo_read_object_file(the_repository, new_oid,\n-\t\t\t\t\t\t&new_type, &new_len);\n+\t\tnew_msg = odb_read_object(the_repository->objects, new_oid,\n+\t\t\t\t\t  &new_type, &new_len);\n \tif (!new_msg || !new_len || new_type != OBJ_BLOB) {\n \t\tfree(new_msg);\n \t\treturn 0;\n \t}\n \tif (!is_null_oid(cur_oid))\n-\t\tcur_msg = repo_read_object_file(the_repository, cur_oid,\n-\t\t\t\t\t\t&cur_type, &cur_len);\n+\t\tcur_msg = odb_read_object(the_repository->objects, cur_oid,\n+\t\t\t\t\t  &cur_type, &cur_len);\n \tif (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {\n \t\tfree(cur_msg);\n \t\tfree(new_msg);\n@@ -880,7 +880,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\treturn 0;\n \n \t/* read_sha1_file NUL-terminates */\n-\tdata = repo_read_object_file(the_repository, oid, &t, &len);\n+\tdata = odb_read_object(the_repository->objects, oid, &t, &len);\n \tif (t != OBJ_BLOB || !data || !len) {\n \t\tfree(data);\n \t\treturn t != OBJ_BLOB || !data;\n@@ -1290,7 +1290,8 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tif (!oid)\n \t\treturn;\n \n-\tif (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {\n+\tif (!(msg = odb_read_object(the_repository->objects, oid, &type, &msglen)) ||\n+\t    type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn;\n \t}\ndiff --git a/object.c b/object.c\nindex 868d89eed42..c1553ee4330 100644\n--- a/object.c\n+++ b/object.c\n@@ -335,7 +335,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \n-\tbuffer = repo_read_object_file(r, oid, &type, &size);\n+\tbuffer = odb_read_object(r->objects, oid, &type, &size);\n \tif (buffer) {\n \t\tif (!skip_hash &&\n \t\t    check_object_signature(r, repl, buffer, size, type) < 0) {\ndiff --git a/odb.c b/odb.c\nindex 3d5d4ff8454..5202f107af2 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -30,7 +30,7 @@ KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n- * want repo_read_object_file() to be able to return, but yet you do not want\n+ * want odb_read_object() to be able to return, but yet you do not want\n  * to write them into the object store (e.g. a browse-only\n  * application).\n  */\n@@ -896,15 +896,10 @@ int pretend_object_file(struct repository *repo,\n \treturn 0;\n }\n \n-/*\n- * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call odb_read_object_info_extended() and give\n- * error messages themselves.\n- */\n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size)\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tunsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE;\n@@ -913,7 +908,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(odb, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -935,7 +930,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = repo_read_object_file(r, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\ndiff --git a/odb.h b/odb.h\nindex e521a608237..fb56cc9e1fe 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -133,7 +133,7 @@ struct object_database {\n \n \t/*\n \t * This is meant to hold a *small* number of objects that you would\n-\t * want repo_read_object_file() to be able to return, but yet you do not want\n+\t * want odb_read_object() to be able to return, but yet you do not want\n \t * to write them into the object store (e.g. a browse-only\n \t * application).\n \t */\n@@ -252,10 +252,19 @@ void odb_add_to_alternates_file(struct object_database *odb,\n void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t\t  const char *dir);\n \n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size);\n+/*\n+ * Read an object from the database. Returns the object data and assigns object\n+ * type and size to the `type` and `size` pointers, if these pointers are\n+ * non-NULL. Returns a `NULL` pointer in case the object does not exist.\n+ *\n+ * This function dies on corrupt objects; the callers who want to deal with\n+ * them should arrange to call odb_read_object_info_extended() and give error\n+ * messages themselves.\n+ */\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size);\n \n /*\n  * Add an object file to the in-memory object store, without writing it\n@@ -366,7 +375,7 @@ void odb_assert_oid_type(struct object_database *odb,\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n- * following functions in parallel: repo_read_object_file(),\n+ * following functions in parallel: odb_read_object(),\n  * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n@@ -441,4 +450,12 @@ static inline int oid_object_info(struct repository *r,\n \treturn odb_read_object_info(r->objects, oid, sizep);\n }\n \n+static inline void *repo_read_object_file(struct repository *r,\n+\t\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t\t  enum object_type *type,\n+\t\t\t\t\t  unsigned long *size)\n+{\n+\treturn odb_read_object(r->objects, oid, type, size);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/read-cache.c b/read-cache.c\nindex be664f857b4..46986798a38 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -254,7 +254,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n \tif (strbuf_readlink(&sb, ce->name, expected_size))\n \t\treturn -1;\n \n-\tbuffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &ce->oid, &type, &size);\n \tif (buffer) {\n \t\tif (size == sb.len)\n \t\t\tmatch = memcmp(buffer, sb.buf, size);\n@@ -3514,8 +3514,8 @@ void *read_blob_data_from_index(struct index_state *istate,\n \t}\n \tif (pos < 0)\n \t\treturn NULL;\n-\tdata = repo_read_object_file(the_repository, &istate->cache[pos]->oid,\n-\t\t\t\t     &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, &istate->cache[pos]->oid,\n+\t\t\t       &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn NULL;\ndiff --git a/reflog.c b/reflog.c\nindex 4f8a3b717cd..747b82eada8 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -140,8 +140,8 @@ static int tree_is_complete(const struct object_id *oid)\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t   &size);\n+\t\tvoid *data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t     &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\treturn 0;\ndiff --git a/rerere.c b/rerere.c\nindex 951e4bf8b41..8bb97c98229 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -1000,9 +1000,8 @@ static int handle_cache(struct index_state *istate,\n \t\t\tbreak;\n \t\ti = ce_stage(ce) - 1;\n \t\tif (!mmfile[i].ptr) {\n-\t\t\tmmfile[i].ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &ce->oid, &type,\n-\t\t\t\t\t\t\t      &size);\n+\t\t\tmmfile[i].ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&ce->oid, &type, &size);\n \t\t\tif (!mmfile[i].ptr)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&ce->oid));\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 0f775f93259..2730a47fad1 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -743,8 +743,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \tif (submodule)\n \t\tgoto out;\n \n-\tconfig = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t       &config_size);\n+\tconfig = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t &type, &config_size);\n \tif (!config || type != OBJ_BLOB)\n \t\tgoto out;\n \ndiff --git a/tag.c b/tag.c\nindex 144048fd5e0..1d52686ee10 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -60,7 +60,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\t\t\trepo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),\n \t\t\t\ttype_name(type));\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n@@ -222,8 +222,8 @@ int parse_tag(struct tag *item)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tdata = repo_read_object_file(the_repository, &item->object.oid, &type,\n-\t\t\t\t     &size);\n+\tdata = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t       &type, &size);\n \tif (!data)\n \t\treturn error(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 34b0fff4873..766af99f466 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -795,9 +795,9 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\t */\n \t\t\tretval = DANGLING_SYMLINK;\n \n-\t\t\tcontents = repo_read_object_file(r,\n-\t\t\t\t\t\t    &current_tree_oid, &type,\n-\t\t\t\t\t\t    &link_len);\n+\t\t\tcontents = odb_read_object(r->objects,\n+\t\t\t\t\t\t   &current_tree_oid, &type,\n+\t\t\t\t\t\t   &link_len);\n \n \t\t\tif (!contents)\n \t\t\t\tgoto done;\ndiff --git a/tree.c b/tree.c\nindex 341b7c2ff3f..1ef743d90f4 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -193,8 +193,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tbuffer = repo_read_object_file(the_repository, &item->object.oid,\n-\t\t\t\t       &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 01e6e378ea6..0e5d38c9600 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -187,7 +187,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n \t\treturn;\n \t}\n \n-\tptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);\n+\tptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!ptr->ptr || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \tptr->size = size;\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518015","messageId":"20250514-pks-object-store-wo-the-repository-v3-15-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 15/17] odb: rename `has_object()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:38Z","receivedAt":"2025-05-14T05:12:46Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `has_object()` to `odb_has_object()` to match other functions\nrelated to the object database and our modern coding guidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  |  2 +-\n builtin/backfill.c       |  4 ++--\n builtin/cat-file.c       |  4 ++--\n builtin/clone.c          |  2 +-\n builtin/fetch.c          | 17 +++++++++--------\n builtin/fsck.c           |  2 +-\n builtin/index-pack.c     |  4 ++--\n builtin/pack-objects.c   |  4 ++--\n builtin/receive-pack.c   |  4 ++--\n builtin/remote.c         |  4 ++--\n builtin/show-ref.c       |  4 ++--\n builtin/unpack-objects.c |  4 ++--\n bulk-checkin.c           |  4 ++--\n cache-tree.c             | 15 ++++++++-------\n commit-graph.c           |  2 +-\n commit.c                 |  2 +-\n fetch-pack.c             |  8 ++++----\n http-push.c              | 14 ++++++++------\n http-walker.c            |  8 ++++----\n list-objects.c           |  4 ++--\n notes.c                  |  4 ++--\n odb.c                    |  6 +++---\n odb.h                    | 12 ++++++++++--\n reflog.c                 |  2 +-\n refs.c                   |  3 ++-\n remote.c                 |  2 +-\n send-pack.c              |  2 +-\n shallow.c                | 12 ++++++------\n upload-pack.c            |  2 +-\n walker.c                 |  4 ++--\n 30 files changed, 87 insertions(+), 74 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 56cd0540350..7fb56517649 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3204,7 +3204,7 @@ static int apply_binary(struct apply_state *state,\n \t\treturn 0; /* deletion patch */\n \t}\n \n-\tif (has_object(the_repository, &oid, 0)) {\n+\tif (odb_has_object(the_repository->objects, &oid, 0)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n \t\tunsigned long size;\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex 0b49baa39fa..80056abe473 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -67,8 +67,8 @@ static int fill_missing_blobs(const char *path UNUSED,\n \t\treturn 0;\n \n \tfor (size_t i = 0; i < list->nr; i++) {\n-\t\tif (!has_object(ctx->repo, &list->oid[i],\n-\t\t\t\tOBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_has_object(ctx->repo->objects, &list->oid[i],\n+\t\t\t\t    OBJECT_INFO_FOR_PREFETCH))\n \t\t\toid_array_append(&ctx->current_batch, &list->oid[i]);\n \t}\n \ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex d6b9afca06e..571b5cc2ad5 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -169,8 +169,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\tgoto cleanup;\n \n \tcase 'e':\n-\t\tret = !has_object(the_repository, &oid,\n-\t\t\t\t  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n+\t\tret = !odb_has_object(the_repository->objects, &oid,\n+\t\t\t\t      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n \t\tgoto cleanup;\n \n \tcase 'w':\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 3aabdf6570b..6d08abed37c 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -506,7 +506,7 @@ static void write_followtags(const struct ref *refs, const char *msg)\n \t\t\tcontinue;\n \t\tif (ends_with(ref->name, \"^{}\"))\n \t\t\tcontinue;\n-\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\tcontinue;\n \t\trefs_update_ref(get_main_ref_store(the_repository), msg,\n \t\t\t\tref->name, &ref->old_oid, NULL, 0,\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 82e9603ccab..2000299bcc5 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -366,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t */\n \t\tif (ends_with(ref->name, \"^{}\")) {\n \t\t\tif (item &&\n-\t\t\t    !has_object(the_repository, &ref->old_oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &ref->old_oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &ref->old_oid) &&\n-\t\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\t\tclear_item(item);\n \t\t\titem = NULL;\n@@ -382,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t * fetch.\n \t\t */\n \t\tif (item &&\n-\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\tclear_item(item);\n \n@@ -403,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t * checked to see if it needs fetching.\n \t */\n \tif (item &&\n-\t    !has_object(the_repository, &item->oid, 0) &&\n+\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t    !oidset_contains(&fetch_oids, &item->oid))\n \t\tclear_item(item);\n \n@@ -910,8 +910,8 @@ static int update_local_ref(struct ref *ref,\n \tstruct commit *current = NULL, *updated;\n \tint fast_forward = 0;\n \n-\tif (!has_object(the_repository, &ref->new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, &ref->new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \n \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n@@ -1330,7 +1330,8 @@ static int check_exist_and_connected(struct ref *ref_map)\n \t * we need all direct targets to exist.\n \t */\n \tfor (r = rm; r; r = r->next) {\n-\t\tif (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (!odb_has_object(the_repository->objects, &r->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED))\n \t\t\treturn -1;\n \t}\n \n@@ -1485,7 +1486,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)\n \t\t\tstruct object_id oid;\n \t\t\tif (repo_get_oid(the_repository, s, &oid))\n \t\t\t\tdie(_(\"%s is not a valid object\"), s);\n-\t\t\tif (!has_object(the_repository, &oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &oid, 0))\n \t\t\t\tdie(_(\"the object %s does not exist\"), s);\n \t\t\toid_array_append(oids, &oid);\n \t\t\tcontinue;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 08a79fe044d..74bfa182597 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -161,7 +161,7 @@ static int mark_object(struct object *obj, enum object_type type,\n \t\treturn 0;\n \n \tif (!(obj->flags & HAS_OBJ)) {\n-\t\tif (parent && !has_object(the_repository, &obj->oid, 1)) {\n+\t\tif (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {\n \t\t\tprintf_ln(_(\"broken link from %7s %s\\n\"\n \t\t\t\t    \"              to %7s %s\"),\n \t\t\t\t  printable_type(&parent->oid, parent->type),\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d33392cab65..0aa2f099cbe 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -893,8 +893,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \n \tif (startup_info->have_repository) {\n \t\tread_lock();\n-\t\tcollision_test_needed = has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_FETCH_PROMISOR);\n+\t\tcollision_test_needed = odb_has_object(the_repository->objects, oid,\n+\t\t\t\t\t\t       HAS_OBJECT_FETCH_PROMISOR);\n \t\tread_unlock();\n \t}\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 580a5c1996b..06bdeb4223b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3968,7 +3968,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void\n \t * Quietly ignore ALL missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0))\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0))\n \t\treturn;\n \n \tshow_object(obj, name, data);\n@@ -3982,7 +3982,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,\n \t * Quietly ignore EXPECTED missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0) &&\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0) &&\n \t    is_promisor_object(to_pack.repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 8c157ea7d1b..27684dce3a4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1508,8 +1508,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \t}\n \n \tif (!is_null_oid(new_oid) &&\n-\t    !has_object(the_repository, new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(\"unpack should have generated %s, \"\n \t\t      \"but I can't find it!\", oid_to_hex(new_oid));\n \t\tret = \"bad pack\";\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex ac5b8d2a1a6..7cbda285ebe 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -454,8 +454,8 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \t\t\tinfo->status = PUSH_STATUS_UPTODATE;\n \t\telse if (is_null_oid(&ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_CREATE;\n-\t\telse if (has_object(the_repository, &ref->old_oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t\telse if (odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t\t\t ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_FASTFORWARD;\n \t\telse\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 90ec1de78f9..117709cb076 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -35,8 +35,8 @@ static void show_one(const struct show_one_options *opts,\n \tconst char *hex;\n \tstruct object_id peeled;\n \n-\tif (!has_object(the_repository, oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(\"git show-ref: bad ref %s (%s)\", refname,\n \t\t    oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 4bc6575a574..a69d59eb50c 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -449,8 +449,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\tdelta_data = get_data(delta_size);\n \t\tif (!delta_data)\n \t\t\treturn;\n-\t\tif (has_object(the_repository, &base_oid,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, &base_oid,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t; /* Ok we have this one */\n \t\telse if (resolve_against_held(nr, &base_oid,\n \t\t\t\t\t      delta_data, delta_size))\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 55406a539e7..16df86c0ba8 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -130,8 +130,8 @@ static void flush_batch_fsync(void)\n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n \t/* The object may already exist in the repository */\n-\tif (has_object(the_repository, oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 1;\n \n \t/* Might want to keep the list sorted */\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 9786b32b3a1..a4bc14ad15c 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -239,8 +239,8 @@ int cache_tree_fully_valid(struct cache_tree *it)\n \tif (!it)\n \t\treturn 0;\n \tif (it->entry_count < 0 ||\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0;\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tif (!cache_tree_fully_valid(it->down[i]->cache_tree))\n@@ -292,8 +292,8 @@ static int update_one(struct cache_tree *it,\n \t}\n \n \tif (0 <= it->entry_count &&\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn it->entry_count;\n \n \t/*\n@@ -399,8 +399,9 @@ static int update_one(struct cache_tree *it,\n \t\tce_missing_ok = mode == S_IFGITLINK || missing_ok ||\n \t\t\t!must_check_existence(ce);\n \t\tif (is_null_oid(oid) ||\n-\t\t    (!ce_missing_ok && !has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n+\t\t    (!ce_missing_ok &&\n+\t\t     !odb_has_object(the_repository->objects, oid,\n+\t\t\t\t     HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n \t\t\tstrbuf_release(&buffer);\n \t\t\tif (expected_missing)\n \t\t\t\treturn -1;\n@@ -448,7 +449,7 @@ static int update_one(struct cache_tree *it,\n \t\tstruct object_id oid;\n \t\thash_object_file(the_hash_algo, buffer.buf, buffer.len,\n \t\t\t\t OBJ_TREE, &oid);\n-\t\tif (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\toidcpy(&it->oid, &oid);\n \t\telse\n \t\t\tto_invalidate = 1;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 84cfaf87639..cb81a5ce228 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1040,7 +1040,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje\n \t\treturn NULL;\n \tif (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos))\n \t\treturn NULL;\n-\tif (commit_graph_paranoia && !has_object(repo, id, 0))\n+\tif (commit_graph_paranoia && !odb_has_object(repo->objects, id, 0))\n \t\treturn NULL;\n \n \tcommit = lookup_commit(repo, id);\ndiff --git a/commit.c b/commit.c\nindex 28ee6b73ae6..15115125c36 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -575,7 +575,7 @@ int repo_parse_commit_internal(struct repository *r,\n \t\tif (commit_graph_paranoia == -1)\n \t\t\tcommit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);\n \n-\t\tif (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {\n+\t\tif (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {\n \t\t\tunparse_commit(r, &item->object.oid);\n \t\t\treturn quiet_on_missing ? -1 :\n \t\t\t\terror(_(\"commit %s exists in commit-graph but not in the object database\"),\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 0f5de1c94d1..5e74235fc06 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -142,7 +142,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \tcommit = lookup_commit_in_graph(the_repository, oid);\n \tif (commit) {\n \t\tif (mark_tags_complete_and_check_obj_db) {\n-\t\t\tif (!has_object(the_repository, oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\t\t\tdie_in_commit_graph_only(oid);\n \t\t}\n \t\treturn commit;\n@@ -770,7 +770,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,\n \t\tif (!commit) {\n \t\t\tstruct object *o;\n \n-\t\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\t\tcontinue;\n \t\t\to = parse_object(the_repository, &ref->old_oid);\n \t\t\tif (!o || o->type != OBJ_COMMIT)\n@@ -1984,8 +1984,8 @@ static void update_shallow(struct fetch_pack_args *args,\n \t\tstruct oid_array extra = OID_ARRAY_INIT;\n \t\tstruct object_id *oid = si->shallow->oid;\n \t\tfor (i = 0; i < si->shallow->nr; i++)\n-\t\t\tif (has_object(the_repository, &oid[i],\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &oid[i],\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\toid_array_append(&extra, &oid[i]);\n \t\tif (extra.nr) {\n \t\t\tsetup_alternate_shallow(&shallow_lock,\ndiff --git a/http-push.c b/http-push.c\nindex 9481825abfb..beb41732fb6 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1447,8 +1447,8 @@ static void one_remote_ref(const char *refname)\n \t * may be required for updating server info later.\n \t */\n \tif (repo->can_update_info_refs &&\n-\t    !has_object(the_repository, &ref->old_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tobj = lookup_unknown_object(the_repository, &ref->old_oid);\n \t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n \t\t\toid_to_hex(&ref->old_oid), refname);\n@@ -1653,14 +1653,16 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t\treturn error(\"Remote HEAD symrefs too deep\");\n \t\tif (is_null_oid(&head_oid))\n \t\t\treturn error(\"Unable to resolve remote HEAD\");\n-\t\tif (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &head_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", oid_to_hex(&head_oid));\n \n \t\t/* Remote branch must resolve to a known object */\n \t\tif (is_null_oid(&remote_ref->old_oid))\n \t\t\treturn error(\"Unable to resolve remote branch %s\",\n \t\t\t\t     remote_ref->name);\n-\t\tif (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &remote_ref->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, oid_to_hex(&remote_ref->old_oid));\n \n \t\t/* Remote branch must be an ancestor of remote HEAD */\n@@ -1881,8 +1883,8 @@ int cmd_main(int argc, const char **argv)\n \t\tif (!force_all &&\n \t\t    !is_null_oid(&ref->old_oid) &&\n \t\t    !ref->force) {\n-\t\t\tif (!has_object(the_repository, &ref->old_oid,\n-\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t\t    !ref_newer(&ref->peer_ref->new_oid,\n \t\t\t\t       &ref->old_oid)) {\n \t\t\t\t/*\ndiff --git a/http-walker.c b/http-walker.c\nindex 4b1cdd25a80..4e7024ebc5f 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -138,8 +138,8 @@ static int fill_active_slot(void *data UNUSED)\n \tlist_for_each_safe(pos, tmp, head) {\n \t\tobj_req = list_entry(pos, struct object_request, node);\n \t\tif (obj_req->state == WAITING) {\n-\t\t\tif (has_object(the_repository, &obj_req->oid,\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\tobj_req->state = COMPLETE;\n \t\t\telse {\n \t\t\t\tstart_object_request(obj_req);\n@@ -497,8 +497,8 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \tif (!obj_req)\n \t\treturn error(\"Couldn't find request for %s in the queue\", hex);\n \n-\tif (has_object(the_repository, &obj_req->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tif (obj_req->req)\n \t\t\tabort_http_object_request(&obj_req->req);\n \t\tabort_object_request(obj_req);\ndiff --git a/list-objects.c b/list-objects.c\nindex c50b9578584..42c17d95739 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -74,8 +74,8 @@ static void process_blob(struct traversal_context *ctx,\n \t * of missing objects.\n \t */\n \tif (ctx->revs->exclude_promisor_objects &&\n-\t    !has_object(the_repository, &obj->oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t    !odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t    is_promisor_object(ctx->revs->repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/notes.c b/notes.c\nindex 73eb5f00cf5..97b995f3f2d 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -794,8 +794,8 @@ static int prune_notes_helper(const struct object_id *object_oid,\n \tstruct note_delete_list **l = (struct note_delete_list **) cb_data;\n \tstruct note_delete_list *n;\n \n-\tif (has_object(the_repository, object_oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, object_oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0; /* nothing to do for this note */\n \n \t/* failed to find object => prune this note */\ndiff --git a/odb.c b/odb.c\nindex 5202f107af2..787611c8f60 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -880,7 +880,7 @@ int pretend_object_file(struct repository *repo,\n \tchar *co_buf;\n \n \thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (has_object(repo, oid, 0) ||\n+\tif (odb_has_object(repo->objects, oid, 0) ||\n \t    find_cached_object(repo->objects, oid))\n \t\treturn 0;\n \n@@ -962,7 +962,7 @@ void *read_object_with_reference(struct repository *r,\n \t}\n }\n \n-int has_object(struct repository *r, const struct object_id *oid,\n+int odb_has_object(struct object_database *odb, const struct object_id *oid,\n \t       unsigned flags)\n {\n \tunsigned object_info_flags = 0;\n@@ -974,7 +974,7 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\ndiff --git a/odb.h b/odb.h\nindex fb56cc9e1fe..3a96de56bd6 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -367,8 +367,9 @@ enum {\n  * Returns 1 if the object exists. This function will not lazily fetch objects\n  * in a partial clone by default.\n  */\n-int has_object(struct repository *r, const struct object_id *oid,\n-\t       unsigned flags);\n+int odb_has_object(struct object_database *odb,\n+\t\t   const struct object_id *oid,\n+\t\t   unsigned flags);\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect);\n@@ -458,4 +459,11 @@ static inline void *repo_read_object_file(struct repository *r,\n \treturn odb_read_object(r->objects, oid, type, size);\n }\n \n+static inline int has_object(struct repository *r,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     unsigned flags)\n+{\n+\treturn odb_has_object(r->objects, oid, flags);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/reflog.c b/reflog.c\nindex 747b82eada8..39c205fd26e 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -152,7 +152,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tinit_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size);\n \tcomplete = 1;\n \twhile (tree_entry(&desc, &entry)) {\n-\t\tif (!has_object(the_repository, &entry.oid,\n+\t\tif (!odb_has_object(the_repository->objects, &entry.oid,\n \t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/refs.c b/refs.c\nindex 82a70b502f8..d6475d5e745 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -376,7 +376,8 @@ int ref_resolves_to_object(const char *refname,\n {\n \tif (flags & REF_ISBROKEN)\n \t\treturn 0;\n-\tif (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (!odb_has_object(repo->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(_(\"%s does not point to a valid object!\"), refname);\n \t\treturn 0;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 72c36239d31..5edf2a9f4b2 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1703,7 +1703,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\tif (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {\n \t\t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n-\t\t\telse if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\t\telse if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n \t\t\telse if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||\n \t\t\t\t !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))\ndiff --git a/send-pack.c b/send-pack.c\nindex abca2dd38a7..d029f748232 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -45,7 +45,7 @@ int option_parse_push_signed(const struct option *opt,\n static void feed_object(struct repository *r,\n \t\t\tconst struct object_id *oid, FILE *fh, int negative)\n {\n-\tif (negative && !has_object(r, oid, 0))\n+\tif (negative && !odb_has_object(r->objects, oid, 0))\n \t\treturn;\n \n \tif (negative)\ndiff --git a/shallow.c b/shallow.c\nindex d379756e39a..ef3adb635fd 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -310,8 +310,8 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n \tif (graft->nr_parent != -1)\n \t\treturn 0;\n \tif (data->flags & QUICK) {\n-\t\tif (!has_object(the_repository, &graft->oid,\n-\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &graft->oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn 0;\n \t} else if (data->flags & SEEN_ONLY) {\n \t\tstruct commit *c = lookup_commit(the_repository, &graft->oid);\n@@ -477,8 +477,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)\n \tALLOC_ARRAY(info->ours, sa->nr);\n \tALLOC_ARRAY(info->theirs, sa->nr);\n \tfor (size_t i = 0; i < sa->nr; i++) {\n-\t\tif (has_object(the_repository, sa->oid + i,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\tif (odb_has_object(the_repository->objects, sa->oid + i,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t\tstruct commit_graft *graft;\n \t\t\tgraft = lookup_commit_graft(the_repository,\n \t\t\t\t\t\t    &sa->oid[i]);\n@@ -515,8 +515,8 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)\n \tfor (i = dst = 0; i < info->nr_theirs; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->theirs[dst] = info->theirs[i];\n-\t\tif (has_object(the_repository, oid + info->theirs[i],\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, oid + info->theirs[i],\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\tdst++;\n \t}\n \tinfo->nr_theirs = dst;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex cec12cb478a..98cda156434 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -509,7 +509,7 @@ static int got_oid(struct upload_pack_data *data,\n {\n \tif (get_oid_hex(hex, oid))\n \t\tdie(\"git upload-pack: expected SHA1 object, got '%s'\", hex);\n-\tif (!has_object(the_repository, oid, 0))\n+\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\treturn -1;\n \treturn do_got_oid(data, oid);\n }\ndiff --git a/walker.c b/walker.c\nindex a8abe8a2e78..d131af04c7b 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -150,8 +150,8 @@ static int process(struct walker *walker, struct object *obj)\n \t\treturn 0;\n \tobj->flags |= SEEN;\n \n-\tif (has_object(the_repository, &obj->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t/* We already have it, so we should scan it now. */\n \t\tobj->flags |= TO_SCAN;\n \t}\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518016","messageId":"20250514-pks-object-store-wo-the-repository-v3-16-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 16/17] odb: rename `pretend_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:39Z","receivedAt":"2025-05-14T05:12:47Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `pretend_object_file()` to `odb_pretend_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nNo compatibility wrapper is introduces as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n blame.c |  3 ++-\n odb.c   | 18 +++++++++---------\n odb.h   |  6 +++---\n 3 files changed, 14 insertions(+), 13 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 858d2d74df9..dce5c8d855c 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -277,7 +277,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \tconvert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);\n \torigin->file.ptr = buf.buf;\n \torigin->file.size = buf.len;\n-\tpretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);\n+\todb_pretend_object(the_repository->objects, buf.buf, buf.len,\n+\t\t\t   OBJ_BLOB, &origin->blob_oid);\n \n \t/*\n \t * Read the current index, replace the path entry with\ndiff --git a/odb.c b/odb.c\nindex 787611c8f60..dfebeb4c8c0 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -872,21 +872,21 @@ int odb_read_object_info(struct object_database *odb,\n \treturn type;\n }\n \n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid)\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid)\n {\n \tstruct cached_object_entry *co;\n \tchar *co_buf;\n \n-\thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (odb_has_object(repo->objects, oid, 0) ||\n-\t    find_cached_object(repo->objects, oid))\n+\thash_object_file(odb->repo->hash_algo, buf, len, type, oid);\n+\tif (odb_has_object(odb, oid, 0) ||\n+\t    find_cached_object(odb, oid))\n \t\treturn 0;\n \n-\tALLOC_GROW(repo->objects->cached_objects,\n-\t\t   repo->objects->cached_object_nr + 1, repo->objects->cached_object_alloc);\n-\tco = &repo->objects->cached_objects[repo->objects->cached_object_nr++];\n+\tALLOC_GROW(odb->cached_objects,\n+\t\t   odb->cached_object_nr + 1, odb->cached_object_alloc);\n+\tco = &odb->cached_objects[odb->cached_object_nr++];\n \tco->value.size = len;\n \tco->value.type = type;\n \tco_buf = xmalloc(len);\ndiff --git a/odb.h b/odb.h\nindex 3a96de56bd6..18de1f3f57c 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -274,9 +274,9 @@ void *odb_read_object(struct object_database *odb,\n  * object in persistent storage before writing any other new objects\n  * that reference it.\n  */\n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid);\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid);\n \n struct object_info {\n \t/* Request */\n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518017","messageId":"20250514-pks-object-store-wo-the-repository-v3-17-47df1d4ead22@pks.im","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"[PATCH v3 17/17] odb: rename `read_object_with_reference()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-14T05:12:40Z","receivedAt":"2025-05-14T05:12:48Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `read_object_with_reference()` to `odb_read_object_peeled()` to\nmatch other functions related to the object database and our modern\ncoding guidelines. Furthermore though, the old name didn't really\ndescribe very well what this function actually does, which is to walk\ndown any commit and tag objects until an object of the required type has\nbeen found. This is generally referred to as \"peeling\", so the new name\nshould be way more descriptive.\n\nNo compatibility wrapper is introduces as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/user-manual.adoc |  4 ++--\n builtin/cat-file.c             |  4 ++--\n builtin/fast-import.c          | 19 ++++++++-----------\n builtin/grep.c                 |  9 +++------\n builtin/pack-objects.c         |  4 ++--\n odb.c                          | 17 +++++++++--------\n odb.h                          | 15 +++++++--------\n tree-walk.c                    | 10 ++++------\n 8 files changed, 37 insertions(+), 45 deletions(-)\n\ndiff --git a/Documentation/user-manual.adoc b/Documentation/user-manual.adoc\nindex d2b478ad232..e86b2ad9f8a 100644\n--- a/Documentation/user-manual.adoc\n+++ b/Documentation/user-manual.adoc\n@@ -4301,11 +4301,11 @@ Now, for the meat:\n \n -----------------------------------------------------------------------------\n         case 0:\n-                buf = read_object_with_reference(sha1, argv[1], &size, NULL);\n+                buf = odb_read_object_peeled(r->objects, sha1, argv[1], &size, NULL);\n -----------------------------------------------------------------------------\n \n This is how you read a blob (actually, not only a blob, but any type of\n-object).  To know how the function `read_object_with_reference()` actually\n+object).  To know how the function `odb_read_object_peeled()` actually\n works, find the source code for it (something like `git grep\n read_object_with | grep \":[a-z]\"` in the Git repository), and read\n the source.\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 571b5cc2ad5..ed0fce9b490 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -255,8 +255,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t * fall-back to the usual case.\n \t\t\t */\n \t\t}\n-\t\tbuf = read_object_with_reference(the_repository, &oid,\n-\t\t\t\t\t\t exp_type_id, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &oid,\n+\t\t\t\t\t     exp_type_id, &size, NULL);\n \n \t\tif (use_mailmap) {\n \t\t\tsize_t s = size;\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 1973c504e25..b1389c59211 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -2535,10 +2535,9 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!repo_get_oid(the_repository, p, &commit_oid)) {\n \t\tunsigned long size;\n-\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t       &commit_oid,\n-\t\t\t\t\t\t       OBJ_COMMIT, &size,\n-\t\t\t\t\t\t       &commit_oid);\n+\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t   &commit_oid, OBJ_COMMIT, &size,\n+\t\t\t\t\t\t   &commit_oid);\n \t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\tdie(\"Not a valid commit: %s\", p);\n \t\tfree(buf);\n@@ -2604,9 +2603,8 @@ static void parse_from_existing(struct branch *b)\n \t\tunsigned long size;\n \t\tchar *buf;\n \n-\t\tbuf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t &b->oid, OBJ_COMMIT, &size,\n-\t\t\t\t\t\t &b->oid);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &b->oid,\n+\t\t\t\t\t     OBJ_COMMIT, &size, &b->oid);\n \t\tparse_from_commit(b, buf, size);\n \t\tfree(buf);\n \t}\n@@ -2699,10 +2697,9 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!repo_get_oid(the_repository, from, &n->oid)) {\n \t\t\tunsigned long size;\n-\t\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t\t       &n->oid,\n-\t\t\t\t\t\t\t       OBJ_COMMIT,\n-\t\t\t\t\t\t\t       &size, &n->oid);\n+\t\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t\t   &n->oid, OBJ_COMMIT,\n+\t\t\t\t\t\t\t   &size, &n->oid);\n \t\t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\t\tdie(\"Not a valid commit: %s\", from);\n \t\t\tfree(buf);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex f84298af0f6..7619479ddad 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -522,9 +522,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tobj_read_lock();\n \t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n-\t\tdata = read_object_with_reference(subrepo,\n-\t\t\t\t\t\t  oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(subrepo->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \n@@ -705,9 +703,8 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \n-\t\tdata = read_object_with_reference(opt->repo,\n-\t\t\t\t\t\t  &obj->oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(opt->repo->objects, &obj->oid,\n+\t\t\t\t\t      OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(&obj->oid));\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 06bdeb4223b..e88a13dbb9f 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2055,8 +2055,8 @@ static void add_preferred_base(struct object_id *oid)\n \tif (window <= num_preferred_base++)\n \t\treturn;\n \n-\tdata = read_object_with_reference(the_repository, oid,\n-\t\t\t\t\t  OBJ_TREE, &size, &tree_oid);\n+\tdata = odb_read_object_peeled(the_repository->objects, oid,\n+\t\t\t\t      OBJ_TREE, &size, &tree_oid);\n \tif (!data)\n \t\treturn;\n \ndiff --git a/odb.c b/odb.c\nindex dfebeb4c8c0..fd7fe398d2d 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -914,11 +914,11 @@ void *odb_read_object(struct object_database *odb,\n \treturn data;\n }\n \n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *actual_oid_return)\n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *actual_oid_return)\n {\n \tenum object_type type;\n \tvoid *buffer;\n@@ -930,7 +930,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(odb, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\n@@ -950,9 +950,10 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n+\t\tif (ref_length + odb->repo->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid,\n+\t\t\t\t      odb->repo->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\ndiff --git a/odb.h b/odb.h\nindex 18de1f3f57c..a9945d302fb 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -266,6 +266,12 @@ void *odb_read_object(struct object_database *odb,\n \t\t      enum object_type *type,\n \t\t      unsigned long *size);\n \n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *oid_ret);\n+\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -377,7 +383,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: odb_read_object(),\n- * read_object_with_reference(), odb_read_object_info() and odb().\n+ * odb_read_object_peeled(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -426,13 +432,6 @@ enum for_each_object_flags {\n \tFOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),\n };\n \n-\n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *oid_ret);\n-\n /* Compatibility wrappers, to be removed once Git 2.50 has been released. */\n #include \"repository.h\"\n \ndiff --git a/tree-walk.c b/tree-walk.c\nindex 766af99f466..e449a1320e5 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -90,7 +90,7 @@ void *fill_tree_descriptor(struct repository *r,\n \tvoid *buf = NULL;\n \n \tif (oid) {\n-\t\tbuf = read_object_with_reference(r, oid, OBJ_TREE, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(r->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!buf)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \t}\n@@ -611,7 +611,7 @@ int get_tree_entry(struct repository *r,\n \tunsigned long size;\n \tstruct object_id root;\n \n-\ttree = read_object_with_reference(r, tree_oid, OBJ_TREE, &size, &root);\n+\ttree = odb_read_object_peeled(r->objects, tree_oid, OBJ_TREE, &size, &root);\n \tif (!tree)\n \t\treturn -1;\n \n@@ -681,10 +681,8 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n \t\t\tunsigned long size;\n-\t\t\ttree = read_object_with_reference(r,\n-\t\t\t\t\t\t\t  &current_tree_oid,\n-\t\t\t\t\t\t\t  OBJ_TREE, &size,\n-\t\t\t\t\t\t\t  &root);\n+\t\t\ttree = odb_read_object_peeled(r->objects, &current_tree_oid,\n+\t\t\t\t\t\t      OBJ_TREE, &size, &root);\n \t\t\tif (!tree)\n \t\t\t\tgoto done;\n \n\n-- \n2.49.0.1141.g47af616452.dirty\n\n"},{"id":"518031","messageId":"xmqqikm3cprg.fsf@gitster.g","threadId":"63403","inReplyTo":"878qn0jonh.fsf@iotcl.com","subject":"Re: [PATCH v2 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-14T12:58:59Z","receivedAt":"2025-05-14T12:59:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Toon Claes <toon@iotcl.com> writes:\n\n> Do we have plans to extract the object database subsystem into a\n> subdirectory? With us adding multiple backends in the future, I can\n> image us having a dozen files at some point. So since we're renaming,\n> shall we prepare for that at once? Or will `odb.h` always be the root-level\n> entry point for the object database, and only live backends live in\n> `odb/` for example?\n\nJust like refs.h and refs/ directory holding code to support files\nand reftable backends?  I think that is what I've been assuming.\n"},{"id":"518044","messageId":"871psrjlio.fsf@iotcl.com","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im","subject":"Re: [PATCH v3 00/17] object-store: carve out the object database subsystem","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-05-14T14:48:47Z","receivedAt":"2025-05-14T14:48:59Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Hi,\n>\n> this patch series refactors the object store subsystem to become more\n> self-contained by getting rid of `the_repository`. Instead of passing in\n> the repository explicitly, we start to pass in the object store itself,\n> which is in contrast to many other refactorings we did, but in line with\n> what we did for the ref store, as well.\n>\n> This series also starts to properly scope functions to the carved out\n> object database subsystem, which requires a bit of shuffling. This\n> allows us to have a short-and-sweet `odb_` prefix for functions and\n> prepares us for a future with pluggable object backends.\n>\n> The series is structured as follows:\n>\n>   - Patches 1 to 3 rename `struct object_store` and `struct\n>     object_directory` as well as the code files.\n>\n>   - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n>\n>   - Patches 13 to 17 adjust the name of remaining functions so that they\n>     can be clearly attributed to the ODB. I'm happy to kick these\n>     patches out of this series and resend them at a later point in case\n>     they create too much turmoil.\n>\n> This series is built on top of 6f84262c44a (The eleventh batch,\n> 2025-05-05) with ps/object-store-cleanup at 8a9e27be821 (object-store:\n> drop `repo_has_object_file()`, 2025-04-29) merged into it. There are a\n> couple of trivial conflicts when merged with \"seen\", I have appended the\n> merge conflict resolution as a patch at the end of this mail.\n>\n> Changes in v2:\n>   - Fix for a copy-and-pasted commit message.\n>   - Rename `struct odb_backend` to `struct odb_alternate`. I'm happy to\n>     revert to the previous name if we ultimately think it's the better\n>     suited one.\n>   - A couple of fixes to move changes into the correct commit. `git\n>     rebase -x 'meson compile -C build'` is now clean.\n>   - I _didn't_ back out the rename to \"odb.{c,h}\". Junio has already\n>     fixed the fallout, so it's probably more work for him to kick it out\n>     again than to just leave it in.\n>   - Link to v1: https://lore.kernel.org/r/20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im\n>\n> Changes in v3:\n>   - Polishing for some comments and commit messages.\n>   - Link to v2: https://lore.kernel.org/r/20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im\n>\n> Thanks!\n>\n> Patrick\n\nThe range-diff looks good, and I've got no further comments.\n\nOnly one small question though, what's the point of the compatibility\nlayer in the last 5(-ish) commits? I mean if we add temp wrappers for\nother topics in flight, then when/how do we convert that new code to\nstop using the wrappers? Won't we remain having issues because there's\nalways something in flight?\n\nCheers,\n-- Toon\n"},{"id":"518087","messageId":"aCWkYdRN1B__oYZ5@pks.im","threadId":"63403","inReplyTo":"871psrjlio.fsf@iotcl.com","subject":"Re: [PATCH v3 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-15T08:22:57Z","receivedAt":"2025-05-15T08:23:01Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, May 14, 2025 at 04:48:47PM +0200, Toon Claes wrote:\n> Only one small question though, what's the point of the compatibility\n> layer in the last 5(-ish) commits? I mean if we add temp wrappers for\n> other topics in flight, then when/how do we convert that new code to\n> stop using the wrappers? Won't we remain having issues because there's\n> always something in flight?\n\nAs mentioned in the comment for those wrappers the expectation is that\nthose will be removed once Git 2.50 is out. This is a common approach we\nhave used in the past, as well: for global changes to functions with a\nlot of users we introduce wrappers that remain for the current release\ncycle.\n\nPatrick\n"},{"id":"518724","messageId":"mghywdyktv654vqywde2exazfr2zproisnojmb62vjsrhdessx@nxmj3m3pfuxn","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-1-47df1d4ead22@pks.im","subject":"Re: [PATCH v3 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-05-22T21:59:02Z","receivedAt":"2025-05-22T22:03:44Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/05/14 07:12AM, Patrick Steinhardt wrote:\n> The `raw_object_store` structure is the central entry point for reading\n> and writing objects in a repository. The main purpose of this structure\n> is to manage object directories and provide an interface to access and\n> write objects in those object directories.\n> \n> Right now, many of the functions associated with the raw object store\n> implicitly rely on `the_repository` to get access to its `objects`\n> pointer, which is the `raw_object_store`. As we want to generally get\n> rid of using `the_repository` across our codebase we will have to\n> convert this implicit dependency on this global variable into an\n> explicit parameter.\n> \n> This conversion can be done by simply passing in an explicit pointer to\n> a repository and then using its `->objects` pointer. But there is a\n> second effort underway, which is to make the object subsystem more\n> selfcontained so that we can eventually have pluggable object backends.\n> As such, passing in a repository wouldn't make a ton of sense, and the\n> goal is to convert the object store interfaces such that we always pass\n> in a reference to the `raw_object_store` instead.\n> \n> This will expose the `raw_object_store` type to a lot more callers\n> though, which surfaces that this type is named somewhat awkwardly. The\n> \"raw_\" prefix makes readers wonder whether there is a non-raw variant of\n> the object store, but there isn't. Furthermore, we nowadays want to name\n> functions in a way that they can be clearly attributed to a specific\n> subsystem, but calling them e.g. `raw_object_store_has_object()` is just\n> too unwieldy, even when dropping the \"raw_\" prefix.\n> \n> Instead, rename the structure to `object_database`. This term is already\n> used a lot throughout our codebase, and it cannot easily be mistaken for\n> \"object directories\", either. Furthermore, its acronym ODB is already\n> well-known and works well as part of a function's name, like for example\n> `odb_has_object()`.\n\nRenaming to `struct object_database` is a good change here. One oddity\nis that it still contains the `struct object_directory` field named\n\"odb\", but that gets cleared up in the next patch. So no issue there.\n\nThe patch itself just a bunch renames to adapt users of `struct\nobject_database` and some function renames to use the new prefix. This\npatch looks good to me.\n\n-Justin\n"},{"id":"518727","messageId":"tjsbotrnrffykmi3letktpb3bly4nqw4wxzyrszgbln7pznem4@3kwiq4zvaebw","threadId":"63403","inReplyTo":"20250514-pks-object-store-wo-the-repository-v3-2-47df1d4ead22@pks.im","subject":"Re: [PATCH v3 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-05-22T22:13:55Z","receivedAt":"2025-05-22T22:18:36Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/05/14 07:12AM, Patrick Steinhardt wrote:\n> The `object_directory` structure is used as an access point for a single\n> object directory like \".git/objects\". While the structure isn't yet\n> fully self-contained, the intent is for it to eventually contain all\n> information required to access objects in one specific location.\n> \n> While the name \"object directory\" is a good fit for now, this will\n> change over time as we continue with the agenda to make pluggable object\n> databases a thing. Eventually, objects may not be accessed via any kind\n> of directory at all anymore, but they could instead be backed by any\n> kind of durable storage mechanism. While it seems quite far-fetched for\n> now, it is thinkable that eventually this might even be some form of a\n> database, for example.\n> \n> As such, the current name of this structure will become worse over time\n> as we evolve into the direction of pluggable ODBs. Immediate next steps\n> will start to carve out proper self-contained object directories, which\n> requires us to pass in these object directories as parameters. Based on\n> our modern naming schema this means that those functions should then be\n> named after their subsystem, which means that we would start to bake the\n> current name into the codebase more and more.\n> \n> Let's preempt this by renaming the structure to `odb_alternate` now\n> already. This name is agnostic of how exactly objects are stored while\n> still specifically pinpointing that this is about an alternate object\n> database. Furthermore, it is already used in Git to represent this\n> context -- the only stretch is that the primary object directory is now\n> the primary alternate.\n\nI know the naming here has been discussed in other threads, but\n`odb_alternate` doesn't feel quite right to me. When I think of an\nobject database alternate, I think of the additional object sources that\nmay be configured for a repository.\n\nFrom my understanding, the `odb_alternate` here applies to any object\nsource, even the main one. Using \"alternate\" makes me think there is\nanother object database somewhere which may be confusing in scenarios\nwhere there would only be one.\n\nUltimately I don't want to bikeshed too much on names, but wanted to\nvoice my thoughts. As an alternative to \"alternate\", maybe we could do\n`object_source`? :)\n\n> In the future, this change allows us to easily introduce for example a\n> `odb_files_alternate` and other format-specific implementations.\n\nI look forward to seeing this. The patch itself looks good.\n\n-Justin\n"},{"id":"518900","messageId":"aDP_-VX_Rz-MqiAS@pks.im","threadId":"63403","inReplyTo":"tjsbotrnrffykmi3letktpb3bly4nqw4wxzyrszgbln7pznem4@3kwiq4zvaebw","subject":"Re: [PATCH v3 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-26T05:45:29Z","receivedAt":"2025-05-26T05:45:33Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, May 22, 2025 at 05:13:55PM -0500, Justin Tobler wrote:\n> On 25/05/14 07:12AM, Patrick Steinhardt wrote:\n> > The `object_directory` structure is used as an access point for a single\n> > object directory like \".git/objects\". While the structure isn't yet\n> > fully self-contained, the intent is for it to eventually contain all\n> > information required to access objects in one specific location.\n> > \n> > While the name \"object directory\" is a good fit for now, this will\n> > change over time as we continue with the agenda to make pluggable object\n> > databases a thing. Eventually, objects may not be accessed via any kind\n> > of directory at all anymore, but they could instead be backed by any\n> > kind of durable storage mechanism. While it seems quite far-fetched for\n> > now, it is thinkable that eventually this might even be some form of a\n> > database, for example.\n> > \n> > As such, the current name of this structure will become worse over time\n> > as we evolve into the direction of pluggable ODBs. Immediate next steps\n> > will start to carve out proper self-contained object directories, which\n> > requires us to pass in these object directories as parameters. Based on\n> > our modern naming schema this means that those functions should then be\n> > named after their subsystem, which means that we would start to bake the\n> > current name into the codebase more and more.\n> > \n> > Let's preempt this by renaming the structure to `odb_alternate` now\n> > already. This name is agnostic of how exactly objects are stored while\n> > still specifically pinpointing that this is about an alternate object\n> > database. Furthermore, it is already used in Git to represent this\n> > context -- the only stretch is that the primary object directory is now\n> > the primary alternate.\n> \n> I know the naming here has been discussed in other threads, but\n> `odb_alternate` doesn't feel quite right to me. When I think of an\n> object database alternate, I think of the additional object sources that\n> may be configured for a repository.\n> \n> From my understanding, the `odb_alternate` here applies to any object\n> source, even the main one. Using \"alternate\" makes me think there is\n> another object database somewhere which may be confusing in scenarios\n> where there would only be one.\n\nYeah, I do get that. On the other hand I don't think it's too much of a\nstretch: the local object directory of one repository is another repo's\nalternate. Furthermore, we already do have the distinction between\n\"local\" and \"non-local\" objects, which translates quite well into this\nnew naming schema.\n\n> Ultimately I don't want to bikeshed too much on names, but wanted to\n> voice my thoughts. As an alternative to \"alternate\", maybe we could do\n> `object_source`? :)\n\nIf we were picking something more \"generic\" I'd favor `odb_backend` over\n`object_source`, to be honest. But we have agreed in the previous\nversion of this patch series that this isn't the way to go.\n\nSo I'm not quite convinced that `object_source` is better, and if we\nwere to go this way I'd also rather call it `odb_source`. If others\nagree that `odb_source` is better than `odb_alternate` I'm happy to\nadapt. But until then I'd rather leave things as-is.\n\nThanks!\n\nPatrick\n"},{"id":"519007","messageId":"euflgbipchqi7jvmz4yzwzx6ao5guen6xmupkdaubjbc5ksgkp@aheynye35bby","threadId":"63403","inReplyTo":"aDP_-VX_Rz-MqiAS@pks.im","subject":"Re: [PATCH v3 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-05-27T16:45:14Z","receivedAt":"2025-05-27T16:50:01Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/05/26 07:45AM, Patrick Steinhardt wrote:\n> On Thu, May 22, 2025 at 05:13:55PM -0500, Justin Tobler wrote:\n> > On 25/05/14 07:12AM, Patrick Steinhardt wrote:\n> > > The `object_directory` structure is used as an access point for a single\n> > > object directory like \".git/objects\". While the structure isn't yet\n> > > fully self-contained, the intent is for it to eventually contain all\n> > > information required to access objects in one specific location.\n> > > \n> > > While the name \"object directory\" is a good fit for now, this will\n> > > change over time as we continue with the agenda to make pluggable object\n> > > databases a thing. Eventually, objects may not be accessed via any kind\n> > > of directory at all anymore, but they could instead be backed by any\n> > > kind of durable storage mechanism. While it seems quite far-fetched for\n> > > now, it is thinkable that eventually this might even be some form of a\n> > > database, for example.\n> > > \n> > > As such, the current name of this structure will become worse over time\n> > > as we evolve into the direction of pluggable ODBs. Immediate next steps\n> > > will start to carve out proper self-contained object directories, which\n> > > requires us to pass in these object directories as parameters. Based on\n> > > our modern naming schema this means that those functions should then be\n> > > named after their subsystem, which means that we would start to bake the\n> > > current name into the codebase more and more.\n> > > \n> > > Let's preempt this by renaming the structure to `odb_alternate` now\n> > > already. This name is agnostic of how exactly objects are stored while\n> > > still specifically pinpointing that this is about an alternate object\n> > > database. Furthermore, it is already used in Git to represent this\n> > > context -- the only stretch is that the primary object directory is now\n> > > the primary alternate.\n> > \n> > I know the naming here has been discussed in other threads, but\n> > `odb_alternate` doesn't feel quite right to me. When I think of an\n> > object database alternate, I think of the additional object sources that\n> > may be configured for a repository.\n> > \n> > From my understanding, the `odb_alternate` here applies to any object\n> > source, even the main one. Using \"alternate\" makes me think there is\n> > another object database somewhere which may be confusing in scenarios\n> > where there would only be one.\n> \n> Yeah, I do get that. On the other hand I don't think it's too much of a\n> stretch: the local object directory of one repository is another repo's\n> alternate. \n\nOk, I was only thinking about this from the perspective of the\nrepository we would be operating in. But I can sort of see how any odb\ncan be an alternate from the perspective of a different repository.\n\n> Furthermore, we already do have the distinction between\n> \"local\" and \"non-local\" objects, which translates quite well into this\n> new naming schema.\n\nJust to clarify, are you referring to how we differentiate between local\nand alternate odbs? I'm not quite sure I fully understand.\n\n> \n> > Ultimately I don't want to bikeshed too much on names, but wanted to\n> > voice my thoughts. As an alternative to \"alternate\", maybe we could do\n> > `object_source`? :)\n> \n> If we were picking something more \"generic\" I'd favor `odb_backend` over\n> `object_source`, to be honest. But we have agreed in the previous\n> version of this patch series that this isn't the way to go.\n> \n> So I'm not quite convinced that `object_source` is better, and if we\n> were to go this way I'd also rather call it `odb_source`. If others\n> agree that `odb_source` is better than `odb_alternate` I'm happy to\n> adapt. But until then I'd rather leave things as-is.\n\nThat's fair. Between `odb_backend` and `odb_alternate`, I would probably\nstill prefer the former, but ultimately I'll acclimate to whatever is\nchoosen. :)\n\n-Justin\n"},{"id":"519080","messageId":"87cybs3mch.fsf@iotcl.com","threadId":"63403","inReplyTo":"euflgbipchqi7jvmz4yzwzx6ao5guen6xmupkdaubjbc5ksgkp@aheynye35bby","subject":"Re: [PATCH v3 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-05-28T13:18:22Z","receivedAt":"2025-05-28T13:18:40Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Justin Tobler <jltobler@gmail.com> writes:\n\n> That's fair. Between `odb_backend` and `odb_alternate`, I would probably\n> still prefer the former, but ultimately I'll acclimate to whatever is\n> choosen. :)\n>\n> -Justin\n\nI feel you. But speaking as a non-native English-speaking person, I can\nsettle for \"alternate\" because I can still wire my brain to give it the\nmeaning we're using here.\n\nBut if you like another name, I want to steer away from \"backend\" as\nwell. As mentioned elsewhere, a \"backend\" sounds like an implementation\nof an object database, not the instance of an odb. But I'm open to other\nsuggestions. I've been browsing thesaurus for a bit, unfortunately I\ndidn't find anything better.\n\n\n-- \nCheers,\nToon\n"},{"id":"519211","messageId":"aDl8tnjQsqXEy8l-@pks.im","threadId":"63403","inReplyTo":"euflgbipchqi7jvmz4yzwzx6ao5guen6xmupkdaubjbc5ksgkp@aheynye35bby","subject":"Re: [PATCH v3 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-30T09:39:02Z","receivedAt":"2025-05-30T09:39:10Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, May 27, 2025 at 11:45:14AM -0500, Justin Tobler wrote:\n> On 25/05/26 07:45AM, Patrick Steinhardt wrote:\n> > Furthermore, we already do have the distinction between\n> > \"local\" and \"non-local\" objects, which translates quite well into this\n> > new naming schema.\n> \n> Just to clarify, are you referring to how we differentiate between local\n> and alternate odbs? I'm not quite sure I fully understand.\n\nYeah. Non-local objects come from an alternate object directory, whereas\nlocal objects come from the primary object directory.\n\nPatrick\n"},{"id":"519212","messageId":"aDl8vjzdCJKoKXY0@pks.im","threadId":"63403","inReplyTo":"87cybs3mch.fsf@iotcl.com","subject":"Re: [PATCH v3 02/17] object-store: rename `object_directory` to `odb_alternate`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-30T09:39:10Z","receivedAt":"2025-05-30T09:39:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, May 28, 2025 at 03:18:22PM +0200, Toon Claes wrote:\n> Justin Tobler <jltobler@gmail.com> writes:\n> \n> > That's fair. Between `odb_backend` and `odb_alternate`, I would probably\n> > still prefer the former, but ultimately I'll acclimate to whatever is\n> > choosen. :)\n> >\n> > -Justin\n> \n> I feel you. But speaking as a non-native English-speaking person, I can\n> settle for \"alternate\" because I can still wire my brain to give it the\n> meaning we're using here.\n> \n> But if you like another name, I want to steer away from \"backend\" as\n> well. As mentioned elsewhere, a \"backend\" sounds like an implementation\n> of an object database, not the instance of an odb. But I'm open to other\n> suggestions. I've been browsing thesaurus for a bit, unfortunately I\n> didn't find anything better.\n\nThis ultimately _will_ host the backend implementations -- every\nalternate is backed by one specific backend. The problem why we still\nwanted to steer away from \"backend\" is that `odb_backend` rather sounds\nas if the complete object database has one backend that can be switched.\nThat's why we settled on \"alternate\" instead, to clarify that there is\nnot a 1:1 relationship between the object database and the respective\nbackends.\n\n`odb_source` does not have the same problem as `odb_backend`, so I\ndefinitely think it's a way better name. But the reason why I think that\n\"alternate\" is the better name is that I think it will get quite\nconfusing if we have both the terms \"alternate\" and \"source\". It would\nmake some of the interfaces quite awkward because it wouldn't always be\nclear what exactly we are handling at any point in time.\n\nPatrick\n"},{"id":"519712","messageId":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH v5 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:50Z","receivedAt":"2025-06-05T06:47:01Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series refactors the object store subsystem to become more\nself-contained by getting rid of `the_repository`. Instead of passing in\nthe repository explicitly, we start to pass in the object store itself,\nwhich is in contrast to many other refactorings we did, but in line with\nwhat we did for the ref store, as well.\n\nThis series also starts to properly scope functions to the carved out\nobject database subsystem, which requires a bit of shuffling. This\nallows us to have a short-and-sweet `odb_` prefix for functions and\nprepares us for a future with pluggable object backends.\n\nThe series is structured as follows:\n\n  - Patches 1 to 3 rename `struct object_store` and `struct\n    object_directory` as well as the code files.\n\n  - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n\n  - Patches 13 to 17 adjust the name of remaining functions so that they\n    can be clearly attributed to the ODB. I'm happy to kick these\n    patches out of this series and resend them at a later point in case\n    they create too much turmoil.\n\nThis series is built on top of 6f84262c44a (The eleventh batch,\n2025-05-05) with ps/object-store-cleanup at 8a9e27be821 (object-store:\ndrop `repo_has_object_file()`, 2025-04-29) merged into it. There are a\ncouple of trivial conflicts when merged with \"seen\", I have appended the\nmerge conflict resolution as a patch at the end of this mail.\n\nChanges in v2:\n  - Fix for a copy-and-pasted commit message.\n  - Rename `struct odb_backend` to `struct odb_alternate`. I'm happy to\n    revert to the previous name if we ultimately think it's the better\n    suited one.\n  - A couple of fixes to move changes into the correct commit. `git\n    rebase -x 'meson compile -C build'` is now clean.\n  - I _didn't_ back out the rename to \"odb.{c,h}\". Junio has already\n    fixed the fallout, so it's probably more work for him to kick it out\n    again than to just leave it in.\n  - Link to v1: https://lore.kernel.org/r/20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im\n\nChanges in v3:\n  - Polishing for some comments and commit messages.\n  - Link to v2: https://lore.kernel.org/r/20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im\n\nChanges in v4:\n  - Rebased the patch series on top of 7014b55638d (A bit more topics\n    for -rc1, 2025-05-30). This fixes a couple of merge conflicts, most\n    importantly with jk/no-funny-object-types.\n  - Rename `struct odb_alternate` to `odb_source`.\n  - Link to v3: https://lore.kernel.org/r/20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im\n\nChanges in v5:\n  - Some polishing to fix leftover terminology from previous rounds.\n  - Link to v4: https://lore.kernel.org/r/20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (17):\n      object-store: rename `raw_object_store` to `object_database`\n      object-store: rename `object_directory` to `odb_source`\n      object-store: rename files to \"odb.{c,h}\"\n      odb: introduce parent pointers\n      odb: get rid of `the_repository` in `find_odb()`\n      odb: get rid of `the_repository` in `assert_oid_type()`\n      odb: get rid of `the_repository` in `odb_mkstemp()`\n      odb: get rid of `the_repository` when handling alternates\n      odb: get rid of `the_repository`  in `for_each()` functions\n      odb: get rid of `the_repository` when handling the primary source\n      odb: get rid of `the_repository` when handling submodule sources\n      odb: trivial refactorings to get rid of `the_repository`\n      odb: rename `oid_object_info()`\n      odb: rename `repo_read_object_file()`\n      odb: rename `has_object()`\n      odb: rename `pretend_object_file()`\n      odb: rename `read_object_with_reference()`\n\n Documentation/user-manual.adoc          |   4 +-\n Makefile                                |   2 +-\n apply.c                                 |  14 +-\n archive-tar.c                           |   2 +-\n archive-zip.c                           |   2 +-\n archive.c                               |   6 +-\n attr.c                                  |   4 +-\n bisect.c                                |   8 +-\n blame.c                                 |  22 +-\n builtin/backfill.c                      |   6 +-\n builtin/blame.c                         |   6 +-\n builtin/cat-file.c                      |  62 ++---\n builtin/checkout.c                      |   2 +-\n builtin/clone.c                         |  14 +-\n builtin/commit-graph.c                  |  20 +-\n builtin/commit-tree.c                   |   4 +-\n builtin/count-objects.c                 |   6 +-\n builtin/describe.c                      |   5 +-\n builtin/difftool.c                      |   4 +-\n builtin/fast-export.c                   |  10 +-\n builtin/fast-import.c                   |  49 ++--\n builtin/fetch.c                         |  21 +-\n builtin/fsck.c                          |  31 ++-\n builtin/gc.c                            |  16 +-\n builtin/grep.c                          |  26 +-\n builtin/hash-object.c                   |   2 +-\n builtin/index-pack.c                    |  29 +-\n builtin/log.c                           |   4 +-\n builtin/ls-files.c                      |   4 +-\n builtin/ls-tree.c                       |   6 +-\n builtin/merge-file.c                    |   2 +-\n builtin/merge-tree.c                    |  14 +-\n builtin/mktag.c                         |   6 +-\n builtin/mktree.c                        |  10 +-\n builtin/multi-pack-index.c              |   6 +-\n builtin/notes.c                         |   8 +-\n builtin/pack-objects.c                  |  70 ++---\n builtin/pack-redundant.c                |   2 +-\n builtin/prune.c                         |   6 +-\n builtin/receive-pack.c                  |   9 +-\n builtin/remote.c                        |   6 +-\n builtin/repack.c                        |   7 +-\n builtin/replace.c                       |  12 +-\n builtin/rev-list.c                      |   8 +-\n builtin/show-ref.c                      |   6 +-\n builtin/submodule--helper.c             |  11 +-\n builtin/tag.c                           |  10 +-\n builtin/unpack-file.c                   |   4 +-\n builtin/unpack-objects.c                |  12 +-\n bulk-checkin.c                          |   6 +-\n bundle-uri.c                            |   5 +-\n bundle.c                                |   6 +-\n cache-tree.c                            |  17 +-\n combine-diff.c                          |   4 +-\n commit-graph.c                          | 106 +++----\n commit-graph.h                          |  20 +-\n commit.c                                |  15 +-\n config.c                                |   4 +-\n connected.c                             |   2 +-\n contrib/coccinelle/the_repository.cocci |   2 +-\n diagnose.c                              |  12 +-\n diff.c                                  |  20 +-\n dir.c                                   |   2 +-\n entry.c                                 |   6 +-\n fetch-pack.c                            |  17 +-\n fmt-merge-msg.c                         |   6 +-\n fsck.c                                  |   4 +-\n grep.c                                  |   6 +-\n http-backend.c                          |   2 +-\n http-push.c                             |  20 +-\n http-walker.c                           |  12 +-\n http.c                                  |   6 +-\n list-objects-filter.c                   |   4 +-\n list-objects.c                          |   6 +-\n log-tree.c                              |   2 +-\n loose.c                                 |  46 ++--\n mailmap.c                               |   4 +-\n match-trees.c                           |   6 +-\n merge-blobs.c                           |  10 +-\n merge-ort.c                             |   8 +-\n meson.build                             |   2 +-\n midx-write.c                            |   2 +-\n midx.c                                  |   6 +-\n notes-cache.c                           |   4 +-\n notes-merge.c                           |   4 +-\n notes.c                                 |  19 +-\n object-file.c                           |  94 +++----\n object-file.h                           |  12 +-\n object-name.c                           |  24 +-\n object-store.h                          | 338 -----------------------\n object.c                                |   8 +-\n object-store.c => odb.c                 | 413 +++++++++++++++-------------\n odb.h                                   | 473 ++++++++++++++++++++++++++++++++\n oss-fuzz/fuzz-pack-idx.c                |   2 +-\n pack-bitmap-write.c                     |   9 +-\n pack-bitmap.c                           |  10 +-\n pack-check.c                            |   2 +-\n pack-mtimes.c                           |   2 +-\n pack-objects.h                          |   2 +-\n pack-revindex.c                         |   2 +-\n pack-write.c                            |  10 +-\n packfile.c                              |  29 +-\n packfile.h                              |   8 +-\n path.c                                  |   4 +-\n promisor-remote.c                       |   6 +-\n protocol-caps.c                         |   4 +-\n reachable.c                             |   2 +-\n read-cache.c                            |  14 +-\n ref-filter.c                            |   6 +-\n reflog.c                                |   8 +-\n refs.c                                  |   7 +-\n remote.c                                |   9 +-\n replace-object.c                        |   2 +-\n replace-object.h                        |   2 +-\n repository.c                            |  21 +-\n repository.h                            |   4 +-\n rerere.c                                |   7 +-\n revision.c                              |   5 +-\n send-pack.c                             |   4 +-\n sequencer.c                             |   7 +-\n server-info.c                           |   2 +-\n shallow.c                               |  14 +-\n streaming.c                             |  10 +-\n submodule-config.c                      |   9 +-\n submodule.c                             |  32 +--\n submodule.h                             |   9 -\n t/helper/test-find-pack.c               |   2 +-\n t/helper/test-pack-mtimes.c             |   2 +-\n t/helper/test-partial-clone.c           |   4 +-\n t/helper/test-read-graph.c              |   8 +-\n t/helper/test-read-midx.c               |   2 +-\n t/helper/test-ref-store.c               |   4 +-\n tag.c                                   |  10 +-\n tmp-objdir.c                            |  30 +-\n tree-walk.c                             |  18 +-\n tree.c                                  |   6 +-\n unpack-trees.c                          |   2 +-\n upload-pack.c                           |   4 +-\n walker.c                                |   6 +-\n xdiff-interface.c                       |   4 +-\n 140 files changed, 1453 insertions(+), 1298 deletions(-)\n\nRange-diff versus v4:\n\n 1:  cb0cee8ca28 =  1:  50bcf60f256 object-store: rename `raw_object_store` to `object_database`\n 2:  1886e2d9657 !  2:  5223817ea6e object-store: rename `object_directory` to `odb_source`\n    @@ object-store.h: struct cached_object_entry;\n      /*\n       * The object database encapsulates access to objects in a repository. It\n     - * manages one or more backends that store the actual objects which are\n    -+ * manages one or more alternates that store the actual objects which are\n    ++ * manages one or more sources that store the actual objects which are\n       * configured via alternates.\n       */\n      struct object_database {\n 3:  9f879846830 =  3:  b6aefd95bda object-store: rename files to \"odb.{c,h}\"\n 4:  13535610312 =  4:  4b67ce83a83 odb: introduce parent pointers\n 5:  c8eb92c2112 =  5:  6fe26d9012a odb: get rid of `the_repository` in `find_odb()`\n 6:  a9b75d55df3 =  6:  23b332596e4 odb: get rid of `the_repository` in `assert_oid_type()`\n 7:  890cabc3c06 =  7:  95b022aef55 odb: get rid of `the_repository` in `odb_mkstemp()`\n 8:  e38e8e2988f =  8:  45f89d7a5b2 odb: get rid of `the_repository` when handling alternates\n 9:  bc140fac83f =  9:  671e1d461db odb: get rid of `the_repository`  in `for_each()` functions\n10:  94679138925 ! 10:  fa2291c77a3 odb: get rid of `the_repository` when handling the primary source\n    @@ odb.h: void odb_clear(struct object_database *o);\n     +\t\t\t\t\t\t    const char *dir, int will_destroy);\n     +\n     +/*\n    -+ * Restore a previous backend replaced by `odb_set_temporary_primary_source()`.\n    ++ * Restore the primary source that was previously replaced by\n    ++ * `odb_set_temporary_primary_source()`.\n     + */\n     +void odb_restore_primary_source(struct object_database *odb,\n     +\t\t\t\tstruct odb_source *restore_source,\n11:  5bb13b32bb0 ! 11:  282b628fd7c odb: get rid of `the_repository` when handling submodule sources\n    @@ odb.c: void disable_obj_read_lock(void)\n      \n      int fetch_if_missing = 1;\n      \n    -+static int register_all_submodule_alternates(struct object_database *odb)\n    ++static int register_all_submodule_sources(struct object_database *odb)\n     +{\n     +\tint ret = odb->submodule_source_paths.nr;\n     +\n    @@ odb.c: void disable_obj_read_lock(void)\n     +\tif (ret) {\n     +\t\tstring_list_clear(&odb->submodule_source_paths, 0);\n     +\t\ttrace2_data_intmax(\"submodule\", odb->repo,\n    -+\t\t\t\t   \"register_all_submodule_alternates/registered\", ret);\n    ++\t\t\t\t   \"register_all_submodule_sources/registered\", ret);\n     +\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n    -+\t\t\tBUG(\"register_all_submodule_alternates() called\");\n    ++\t\t\tBUG(\"register_all_submodule_sources() called\");\n     +\t}\n     +\treturn ret;\n     +}\n    @@ odb.c: static int do_oid_object_info_extended(struct repository *r,\n      \t\t */\n     -\t\tif (r == the_repository &&\n     -\t\t    register_all_submodule_odb_as_alternates())\n    -+\t\tif (register_all_submodule_alternates(r->objects))\n    ++\t\tif (register_all_submodule_sources(r->objects))\n      \t\t\t/* We added some alternates; retry */\n      \t\t\tcontinue;\n      \n12:  1cb9d97c582 = 12:  9e7172fdb7f odb: trivial refactorings to get rid of `the_repository`\n13:  453435c4000 ! 13:  932bf88ac7a odb: rename `oid_object_info()`\n    @@ object.c: struct object *parse_object_with_flags(struct repository *r,\n      \n     \n      ## odb.c ##\n    -@@ odb.c: static int register_all_submodule_alternates(struct object_database *odb)\n    +@@ odb.c: static int register_all_submodule_sources(struct object_database *odb)\n      \treturn ret;\n      }\n      \n    @@ odb.c: static int do_oid_object_info_extended(struct repository *r,\n      \t\t * `odb_add_submodule_source_by_path()` on that submodule's\n      \t\t * ODB). If any such ODBs exist, register them and try again.\n      \t\t */\n    --\t\tif (register_all_submodule_alternates(r->objects))\n    -+\t\tif (register_all_submodule_alternates(odb))\n    +-\t\tif (register_all_submodule_sources(r->objects))\n    ++\t\tif (register_all_submodule_sources(odb))\n      \t\t\t/* We added some alternates; retry */\n      \t\t\tcontinue;\n      \n14:  238207c6646 = 14:  345ee62c5f9 odb: rename `repo_read_object_file()`\n15:  949dffee2b8 = 15:  6108150e126 odb: rename `has_object()`\n16:  aff9d3ae2fa = 16:  c7a5955f376 odb: rename `pretend_object_file()`\n17:  6dd67f110fd = 17:  033e5e2173e odb: rename `read_object_with_reference()`\n\n---\nbase-commit: 7014b55638da979331baf8dc31c4e1d697cf2d67\nchange-id: 20250505-pks-object-store-wo-the-repository-9c6cbdf8d4b1\n\n"},{"id":"519713","messageId":"20250605-pks-object-store-wo-the-repository-v5-1-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:51Z","receivedAt":"2025-06-05T06:47:02Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `raw_object_store` structure is the central entry point for reading\nand writing objects in a repository. The main purpose of this structure\nis to manage object directories and provide an interface to access and\nwrite objects in those object directories.\n\nRight now, many of the functions associated with the raw object store\nimplicitly rely on `the_repository` to get access to its `objects`\npointer, which is the `raw_object_store`. As we want to generally get\nrid of using `the_repository` across our codebase we will have to\nconvert this implicit dependency on this global variable into an\nexplicit parameter.\n\nThis conversion can be done by simply passing in an explicit pointer to\na repository and then using its `->objects` pointer. But there is a\nsecond effort underway, which is to make the object subsystem more\nselfcontained so that we can eventually have pluggable object backends.\nAs such, passing in a repository wouldn't make a ton of sense, and the\ngoal is to convert the object store interfaces such that we always pass\nin a reference to the `raw_object_store` instead.\n\nThis will expose the `raw_object_store` type to a lot more callers\nthough, which surfaces that this type is named somewhat awkwardly. The\n\"raw_\" prefix makes readers wonder whether there is a non-raw variant of\nthe object store, but there isn't. Furthermore, we nowadays want to name\nfunctions in a way that they can be clearly attributed to a specific\nsubsystem, but calling them e.g. `raw_object_store_has_object()` is just\ntoo unwieldy, even when dropping the \"raw_\" prefix.\n\nInstead, rename the structure to `object_database`. This term is already\nused a lot throughout our codebase, and it cannot easily be mistaken for\n\"object directories\", either. Furthermore, its acronym ODB is already\nwell-known and works well as part of a function's name, like for example\n`odb_has_object()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n commit-graph.c |  2 +-\n commit-graph.h |  4 ++--\n object-store.c | 12 ++++++------\n object-store.h | 11 ++++++++---\n packfile.c     |  2 +-\n packfile.h     |  4 ++--\n repository.c   |  4 ++--\n repository.h   |  4 ++--\n 8 files changed, 24 insertions(+), 19 deletions(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex ad3943b6906..905fcbdf0e8 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -829,7 +829,7 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)\n \treturn NULL;\n }\n \n-void close_commit_graph(struct raw_object_store *o)\n+void close_commit_graph(struct object_database *o)\n {\n \tif (!o->commit_graph)\n \t\treturn;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 13f662827d4..20d38c100ce 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -26,7 +26,7 @@ void git_test_write_commit_graph_or_die(void);\n struct commit;\n struct bloom_filter_settings;\n struct repository;\n-struct raw_object_store;\n+struct object_database;\n struct string_list;\n \n char *get_commit_graph_filename(struct object_directory *odb);\n@@ -186,7 +186,7 @@ int write_commit_graph(struct object_directory *odb,\n \n int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags);\n \n-void close_commit_graph(struct raw_object_store *);\n+void close_commit_graph(struct object_database *);\n void free_commit_graph(struct commit_graph *);\n \n /*\ndiff --git a/object-store.c b/object-store.c\nindex 58cde0313a5..f4e8f99d90f 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -44,7 +44,7 @@ struct cached_object_entry {\n \t} value;\n };\n \n-static const struct cached_object *find_cached_object(struct raw_object_store *object_store,\n+static const struct cached_object *find_cached_object(struct object_database *object_store,\n \t\t\t\t\t\t      const struct object_id *oid)\n {\n \tstatic const struct cached_object empty_tree = {\n@@ -86,7 +86,7 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n /*\n  * Return non-zero iff the path is usable as an alternate object database.\n  */\n-static int alt_odb_usable(struct raw_object_store *o,\n+static int alt_odb_usable(struct object_database *o,\n \t\t\t  struct strbuf *path,\n \t\t\t  const char *normalized_objdir, khiter_t *pos)\n {\n@@ -950,9 +950,9 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct raw_object_store *raw_object_store_new(void)\n+struct object_database *odb_new(void)\n {\n-\tstruct raw_object_store *o = xmalloc(sizeof(*o));\n+\tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n@@ -961,7 +961,7 @@ struct raw_object_store *raw_object_store_new(void)\n \treturn o;\n }\n \n-static void free_object_directories(struct raw_object_store *o)\n+static void free_object_directories(struct object_database *o)\n {\n \twhile (o->odb) {\n \t\tstruct object_directory *next;\n@@ -974,7 +974,7 @@ static void free_object_directories(struct raw_object_store *o)\n \to->odb_by_path = NULL;\n }\n \n-void raw_object_store_clear(struct raw_object_store *o)\n+void odb_clear(struct object_database *o)\n {\n \tFREE_AND_NULL(o->alternate_db);\n \ndiff --git a/object-store.h b/object-store.h\nindex c5890085352..a3be27d1171 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -87,7 +87,12 @@ struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n \n-struct raw_object_store {\n+/*\n+ * The object database encapsulates access to objects in a repository. It\n+ * manages one or more backends that store the actual objects which are\n+ * configured via alternates.\n+ */\n+struct object_database {\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -169,8 +174,8 @@ struct raw_object_store {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct raw_object_store *raw_object_store_new(void);\n-void raw_object_store_clear(struct raw_object_store *o);\n+struct object_database *odb_new(void);\n+void odb_clear(struct object_database *o);\n \n /*\n  * Create a temporary file rooted in the object database directory, or\ndiff --git a/packfile.c b/packfile.c\nindex 70c7208f027..c735b4d0135 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -359,7 +359,7 @@ void close_pack(struct packed_git *p)\n \toidset_clear(&p->bad_objects);\n }\n \n-void close_object_store(struct raw_object_store *o)\n+void close_object_store(struct object_database *o)\n {\n \tstruct packed_git *p;\n \ndiff --git a/packfile.h b/packfile.h\nindex 3a3c77cf05a..826eb7f475f 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -183,12 +183,12 @@ int close_pack_fd(struct packed_git *p);\n \n uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);\n \n-struct raw_object_store;\n+struct object_database;\n \n unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);\n void close_pack_windows(struct packed_git *);\n void close_pack(struct packed_git *);\n-void close_object_store(struct raw_object_store *o);\n+void close_object_store(struct object_database *o);\n void unuse_pack(struct pack_window **);\n void clear_delta_base_cache(void);\n struct packed_git *add_packed_git(struct repository *r, const char *path,\ndiff --git a/repository.c b/repository.c\nindex 9b3d6665fc6..07757e6e0c9 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = raw_object_store_new();\n+\trepo->objects = odb_new();\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -374,7 +374,7 @@ void repo_clear(struct repository *repo)\n \tFREE_AND_NULL(repo->worktree);\n \tFREE_AND_NULL(repo->submodule_prefix);\n \n-\traw_object_store_clear(repo->objects);\n+\todb_clear(repo->objects);\n \tFREE_AND_NULL(repo->objects);\n \n \tparsed_object_pool_clear(repo->parsed_objects);\ndiff --git a/repository.h b/repository.h\nindex c4c92b2ab9c..3a5ef9c781e 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -9,7 +9,7 @@ struct git_hash_algo;\n struct index_state;\n struct lock_file;\n struct pathspec;\n-struct raw_object_store;\n+struct object_database;\n struct submodule_cache;\n struct promisor_remote_config;\n struct remote_state;\n@@ -47,7 +47,7 @@ struct repository {\n \t/*\n \t * Holds any information related to accessing the raw object content.\n \t */\n-\tstruct raw_object_store *objects;\n+\tstruct object_database *objects;\n \n \t/*\n \t * All objects in this repository that have been parsed. This structure\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519716","messageId":"20250605-pks-object-store-wo-the-repository-v5-2-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 02/17] object-store: rename `object_directory` to `odb_source`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:52Z","receivedAt":"2025-06-05T06:47:03Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `object_directory` structure is used as an access point for a single\nobject directory like \".git/objects\". While the structure isn't yet\nfully self-contained, the intent is for it to eventually contain all\ninformation required to access objects in one specific location.\n\nWhile the name \"object directory\" is a good fit for now, this will\nchange over time as we continue with the agenda to make pluggable object\ndatabases a thing. Eventually, objects may not be accessed via any kind\nof directory at all anymore, but they could instead be backed by any\nkind of durable storage mechanism. While it seems quite far-fetched for\nnow, it is thinkable that eventually this might even be some form of a\ndatabase, for example.\n\nAs such, the current name of this structure will become worse over time\nas we evolve into the direction of pluggable ODBs. Immediate next steps\nwill start to carve out proper self-contained object directories, which\nrequires us to pass in these object directories as parameters. Based on\nour modern naming schema this means that those functions should then be\nnamed after their subsystem, which means that we would start to bake the\ncurrent name into the codebase more and more.\n\nLet's preempt this by renaming the structure. There have been a couple\nalternatives that were discussed:\n\n  - `odb_backend` was discarded because it led to the association that\n    one object database has a single backend, but the model is that one\n    alternate has one backend. Furthermore, \"backend\" is more about the\n    actual backing implementation and less about the high-level concept.\n\n  - `odb_alternate` was discarded because it is a bit of a stretch to\n    also call the main object directory an \"alternate\".\n\nInstead, pick `odb_source` as the new name. It makes it sufficiently\nclear that there can be multiple sources and does not cause confusion\nwhen mixed with the already-existing \"alternate\" terminology.\n\nIn the future, this change allows us to easily introduce for example a\n`odb_files_source` and other format-specific implementations.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c      |  18 +++----\n builtin/count-objects.c     |   4 +-\n builtin/fetch.c             |   2 +-\n builtin/fsck.c              |  14 ++---\n builtin/gc.c                |  14 ++---\n builtin/grep.c              |   2 +-\n builtin/multi-pack-index.c  |   4 +-\n builtin/submodule--helper.c |   6 +--\n bundle.c                    |   2 +-\n commit-graph.c              |  94 +++++++++++++++++-----------------\n commit-graph.h              |  14 ++---\n diagnose.c                  |   8 +--\n http-walker.c               |   2 +-\n http.c                      |   4 +-\n loose.c                     |  42 +++++++--------\n midx.c                      |   6 +--\n object-file.c               |  80 ++++++++++++++---------------\n object-file.h               |   8 +--\n object-name.c               |   6 +--\n object-store.c              | 122 ++++++++++++++++++++++----------------------\n object-store.h              |  38 +++++++++-----\n packfile.c                  |  16 +++---\n path.c                      |   2 +-\n refs.c                      |   2 +-\n repository.c                |  14 ++---\n submodule-config.c          |   2 +-\n t/helper/test-read-graph.c  |   6 +--\n tmp-objdir.c                |  24 ++++-----\n 28 files changed, 284 insertions(+), 272 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex a783a86e797..98a84315342 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \t\t\tstruct repository *repo UNUSED)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_source *source = NULL;\n \tchar *graph_name;\n \tchar *chain_name;\n \tenum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;\n@@ -101,9 +101,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n-\tgraph_name = get_commit_graph_filename(odb);\n-\tchain_name = get_commit_graph_chain_filename(odb);\n+\tsource = find_odb(the_repository, opts.obj_dir);\n+\tgraph_name = get_commit_graph_filename(source);\n+\tchain_name = get_commit_graph_chain_filename(source);\n \tif (open_commit_graph(graph_name, &fd, &st))\n \t\topened = OPENED_GRAPH;\n \telse if (errno != ENOENT)\n@@ -120,7 +120,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opened == OPENED_NONE)\n \t\treturn 0;\n \telse if (opened == OPENED_GRAPH)\n-\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);\n+\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, source);\n \telse\n \t\tgraph = load_commit_graph_chain_fd_st(the_repository, fd, &st,\n \t\t\t\t\t\t      &incomplete_chain);\n@@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \tstruct string_list pack_indexes = STRING_LIST_INIT_DUP;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct oidset commits = OIDSET_INIT;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_source *source = NULL;\n \tint result = 0;\n \tenum commit_graph_write_flags flags = 0;\n \tstruct progress *progress = NULL;\n@@ -289,10 +289,10 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n+\tsource = find_odb(the_repository, opts.obj_dir);\n \n \tif (opts.reachable) {\n-\t\tif (write_commit_graph_reachable(odb, flags, &write_opts))\n+\t\tif (write_commit_graph_reachable(source, flags, &write_opts))\n \t\t\tresult = 1;\n \t\tgoto cleanup;\n \t}\n@@ -318,7 +318,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t\tstop_progress(&progress);\n \t}\n \n-\tif (write_commit_graph(odb,\n+\tif (write_commit_graph(source,\n \t\t\t       opts.stdin_packs ? &pack_indexes : NULL,\n \t\t\t       opts.stdin_commits ? &commits : NULL,\n \t\t\t       flags,\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex a88c0c9c09a..58e0af433d1 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -80,10 +80,10 @@ static int count_cruft(const char *basename UNUSED, const char *path,\n \treturn 0;\n }\n \n-static int print_alternate(struct object_directory *odb, void *data UNUSED)\n+static int print_alternate(struct odb_source *alternate, void *data UNUSED)\n {\n \tprintf(\"alternate: \");\n-\tquote_c_style(odb->path, NULL, stdout, 0);\n+\tquote_c_style(alternate->path, NULL, stdout, 0);\n \tputchar('\\n');\n \treturn 0;\n }\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 40a0e8d2443..a890e2864d1 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2653,7 +2653,7 @@ int cmd_fetch(int argc,\n \t\t\tcommit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n \t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\", the_repository);\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->sources,\n \t\t\t\t\t     commit_graph_flags,\n \t\t\t\t\t     NULL);\n \t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\", the_repository);\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex e7d96a9c8ea..6e1474f63d5 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -956,7 +956,7 @@ int cmd_fsck(int argc,\n \t     struct repository *repo UNUSED)\n {\n \tint i;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \t/* fsck knows how to handle missing promisor objects */\n \tfetch_if_missing = 0;\n@@ -998,8 +998,8 @@ int cmd_fsck(int argc,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next)\n-\t\t\tfsck_object_dir(odb->path);\n+\t\tfor (source = the_repository->objects->sources; source; source = source->next)\n+\t\t\tfsck_object_dir(source->path);\n \n \t\tif (check_full) {\n \t\t\tstruct packed_git *p;\n@@ -1109,11 +1109,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&commit_graph_verify.args, \"commit-graph\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", source->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&commit_graph_verify.args, \"--progress\");\n \t\t\telse\n@@ -1127,11 +1127,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&midx_verify.args, \"multi-pack-index\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", source->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&midx_verify.args, \"--progress\");\n \t\t\telse\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex e33ba946e43..50a09eb07e3 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -1018,7 +1018,7 @@ int cmd_gc(int argc,\n \t}\n \n \tif (the_repository->settings.gc_write_commit_graph == 1)\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->sources,\n \t\t\t\t\t     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,\n \t\t\t\t\t     NULL);\n \n@@ -1271,7 +1271,7 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)\n \tif (loose_object_auto_limit < 0)\n \t\treturn 1;\n \n-\treturn for_each_loose_file_in_objdir(the_repository->objects->odb->path,\n+\treturn for_each_loose_file_in_objdir(the_repository->objects->sources->path,\n \t\t\t\t\t     loose_object_count,\n \t\t\t\t\t     NULL, NULL, &count);\n }\n@@ -1306,7 +1306,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t * Do not start pack-objects process\n \t * if there are no loose objects.\n \t */\n-\tif (!for_each_loose_file_in_objdir(r->objects->odb->path,\n+\tif (!for_each_loose_file_in_objdir(r->objects->sources->path,\n \t\t\t\t\t   bail_on_loose,\n \t\t\t\t\t   NULL, NULL, NULL))\n \t\treturn 0;\n@@ -1318,7 +1318,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t\tstrvec_push(&pack_proc.args, \"--quiet\");\n \telse\n \t\tstrvec_push(&pack_proc.args, \"--no-quiet\");\n-\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->odb->path);\n+\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->sources->path);\n \n \tpack_proc.in = -1;\n \n@@ -1346,7 +1346,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \telse if (data.batch_size > 0)\n \t\tdata.batch_size--; /* Decrease for equality on limit. */\n \n-\tfor_each_loose_file_in_objdir(r->objects->odb->path,\n+\tfor_each_loose_file_in_objdir(r->objects->sources->path,\n \t\t\t\t      write_loose_object_to_stdin,\n \t\t\t\t      NULL,\n \t\t\t\t      NULL,\n@@ -1611,7 +1611,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,\n \tint result = 0;\n \tstruct lock_file lk;\n \tstruct repository *r = the_repository;\n-\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->sources->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\t/*\n@@ -3083,7 +3083,7 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,\n \tunsigned int i;\n \tint result = 0;\n \tstruct lock_file lk;\n-\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->sources->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\tif (errno == EEXIST)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ce574a605b..76b1938bba5 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->odb->path);\n+\tadd_submodule_odb_by_path(subrepo->objects->sources->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex 69a97507324..f55bf53da83 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -294,8 +294,8 @@ int cmd_multi_pack_index(int argc,\n \n \tif (the_repository &&\n \t    the_repository->objects &&\n-\t    the_repository->objects->odb)\n-\t\topts.object_dir = xstrdup(the_repository->objects->odb->path);\n+\t    the_repository->objects->sources)\n+\t\topts.object_dir = xstrdup(the_repository->objects->sources->path);\n \n \targc = parse_options(argc, argv, prefix, options,\n \t\t\t     builtin_multi_pack_index_usage, 0);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 53da2116ddf..758bc6d0f24 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1582,7 +1582,7 @@ static const char alternate_error_advice[] = N_(\n );\n \n static int add_possible_reference_from_superproject(\n-\t\tstruct object_directory *odb, void *sas_cb)\n+\t\tstruct odb_source *alt_odb, void *sas_cb)\n {\n \tstruct submodule_alternate_setup *sas = sas_cb;\n \tsize_t len;\n@@ -1591,12 +1591,12 @@ static int add_possible_reference_from_superproject(\n \t * If the alternate object store is another repository, try the\n \t * standard layout with .git/(modules/<name>)+/objects\n \t */\n-\tif (strip_suffix(odb->path, \"/objects\", &len)) {\n+\tif (strip_suffix(alt_odb->path, \"/objects\", &len)) {\n \t\tstruct repository alternate;\n \t\tchar *sm_alternate;\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstruct strbuf err = STRBUF_INIT;\n-\t\tstrbuf_add(&sb, odb->path, len);\n+\t\tstrbuf_add(&sb, alt_odb->path, len);\n \n \t\tif (repo_init(&alternate, sb.buf, NULL) < 0)\n \t\t\tdie(_(\"could not get a repository handle for gitdir '%s'\"),\ndiff --git a/bundle.c b/bundle.c\nindex b0a3fee2efa..2ce7525f90d 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -233,7 +233,7 @@ int verify_bundle(struct repository *r,\n \t\t.quiet = 1,\n \t};\n \n-\tif (!r || !r->objects || !r->objects->odb)\n+\tif (!r || !r->objects || !r->objects->sources)\n \t\treturn error(_(\"need a repository to verify a bundle\"));\n \n \tfor (i = 0; i < p->nr; i++) {\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 905fcbdf0e8..12d32cdad1d 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -37,7 +37,7 @@ void git_test_write_commit_graph_or_die(void)\n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph_reachable(the_repository->objects->odb,\n+\tif (write_commit_graph_reachable(the_repository->objects->sources,\n \t\t\t\t\t flags, NULL))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n@@ -191,21 +191,21 @@ static int commit_gen_cmp(const void *va, const void *vb)\n \treturn 0;\n }\n \n-char *get_commit_graph_filename(struct object_directory *obj_dir)\n+char *get_commit_graph_filename(struct odb_source *source)\n {\n-\treturn xstrfmt(\"%s/info/commit-graph\", obj_dir->path);\n+\treturn xstrfmt(\"%s/info/commit-graph\", source->path);\n }\n \n-static char *get_split_graph_filename(struct object_directory *odb,\n+static char *get_split_graph_filename(struct odb_source *source,\n \t\t\t\t      const char *oid_hex)\n {\n-\treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", odb->path,\n+\treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", source->path,\n \t\t       oid_hex);\n }\n \n-char *get_commit_graph_chain_filename(struct object_directory *odb)\n+char *get_commit_graph_chain_filename(struct odb_source *source)\n {\n-\treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", odb->path);\n+\treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", source->path);\n }\n \n static struct commit_graph *alloc_commit_graph(void)\n@@ -250,7 +250,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_source *source)\n {\n \tvoid *graph_map;\n \tsize_t graph_size;\n@@ -269,7 +269,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \tret = parse_commit_graph(&r->settings, graph_map, graph_size);\n \n \tif (ret)\n-\t\tret->odb = odb;\n+\t\tret->odb_source = source;\n \telse\n \t\tmunmap(graph_map, graph_size);\n \n@@ -487,7 +487,7 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s,\n \n static struct commit_graph *load_commit_graph_one(struct repository *r,\n \t\t\t\t\t\t  const char *graph_file,\n-\t\t\t\t\t\t  struct object_directory *odb)\n+\t\t\t\t\t\t  struct odb_source *source)\n {\n \n \tstruct stat st;\n@@ -498,7 +498,7 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n \tif (!open_ok)\n \t\treturn NULL;\n \n-\tg = load_commit_graph_one_fd_st(r, fd, &st, odb);\n+\tg = load_commit_graph_one_fd_st(r, fd, &st, source);\n \n \tif (g)\n \t\tg->filename = xstrdup(graph_file);\n@@ -507,10 +507,10 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_v1(struct repository *r,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_source *source)\n {\n-\tchar *graph_name = get_commit_graph_filename(odb);\n-\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\tchar *graph_name = get_commit_graph_filename(source);\n+\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, source);\n \tfree(graph_name);\n \n \treturn g;\n@@ -652,7 +652,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tprepare_alt_odb(r);\n \n \tfor (i = 0; i < count; i++) {\n-\t\tstruct object_directory *odb;\n+\t\tstruct odb_source *source;\n \n \t\tif (strbuf_getline_lf(&line, fp) == EOF)\n \t\t\tbreak;\n@@ -665,9 +665,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t}\n \n \t\tvalid = 0;\n-\t\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t\tchar *graph_name = get_split_graph_filename(odb, line.buf);\n-\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\t\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\t\tchar *graph_name = get_split_graph_filename(source, line.buf);\n+\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, source);\n \n \t\t\tfree(graph_name);\n \n@@ -701,9 +701,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_chain(struct repository *r,\n-\t\t\t\t\t\t    struct object_directory *odb)\n+\t\t\t\t\t\t    struct odb_source *source)\n {\n-\tchar *chain_file = get_commit_graph_chain_filename(odb);\n+\tchar *chain_file = get_commit_graph_chain_filename(source);\n \tstruct stat st;\n \tint fd;\n \tstruct commit_graph *g = NULL;\n@@ -719,24 +719,24 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,\n }\n \n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb)\n+\t\t\t\t\t   struct odb_source *source)\n {\n-\tstruct commit_graph *g = load_commit_graph_v1(r, odb);\n+\tstruct commit_graph *g = load_commit_graph_v1(r, source);\n \n \tif (!g)\n-\t\tg = load_commit_graph_chain(r, odb);\n+\t\tg = load_commit_graph_chain(r, source);\n \n \treturn g;\n }\n \n static void prepare_commit_graph_one(struct repository *r,\n-\t\t\t\t     struct object_directory *odb)\n+\t\t\t\t     struct odb_source *source)\n {\n \n \tif (r->objects->commit_graph)\n \t\treturn;\n \n-\tr->objects->commit_graph = read_commit_graph_one(r, odb);\n+\tr->objects->commit_graph = read_commit_graph_one(r, source);\n }\n \n /*\n@@ -747,7 +747,7 @@ static void prepare_commit_graph_one(struct repository *r,\n  */\n static int prepare_commit_graph(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \t/*\n \t * Early return if there is no git dir or if the commit graph is\n@@ -779,10 +779,10 @@ static int prepare_commit_graph(struct repository *r)\n \t\treturn 0;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb;\n-\t     !r->objects->commit_graph && odb;\n-\t     odb = odb->next)\n-\t\tprepare_commit_graph_one(r, odb);\n+\tfor (source = r->objects->sources;\n+\t     !r->objects->commit_graph && source;\n+\t     source = source->next)\n+\t\tprepare_commit_graph_one(r, source);\n \treturn !!r->objects->commit_graph;\n }\n \n@@ -1137,7 +1137,7 @@ struct packed_commit_list {\n \n struct write_commit_graph_context {\n \tstruct repository *r;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *odb_source;\n \tchar *graph_name;\n \tstruct oid_array oids;\n \tstruct packed_commit_list commits;\n@@ -1870,7 +1870,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \treturn 0;\n }\n \n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_source *source,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts)\n {\n@@ -1890,7 +1890,7 @@ int write_commit_graph_reachable(struct object_directory *odb,\n \n \tstop_progress(&data.progress);\n \n-\tresult = write_commit_graph(odb, NULL, &commits,\n+\tresult = write_commit_graph(source, NULL, &commits,\n \t\t\t\t    flags, opts);\n \n \toidset_clear(&commits);\n@@ -1906,7 +1906,7 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,\n \tint dirlen;\n \tint ret = 0;\n \n-\tstrbuf_addf(&packname, \"%s/pack/\", ctx->odb->path);\n+\tstrbuf_addf(&packname, \"%s/pack/\", ctx->odb_source->path);\n \tdirlen = packname.len;\n \tif (ctx->report_progress) {\n \t\tstrbuf_addf(&progress_title,\n@@ -2060,10 +2060,10 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \n \t\tstrbuf_addf(&tmp_file,\n \t\t\t    \"%s/info/commit-graphs/tmp_graph_XXXXXX\",\n-\t\t\t    ctx->odb->path);\n+\t\t\t    ctx->odb_source->path);\n \t\tctx->graph_name = strbuf_detach(&tmp_file, NULL);\n \t} else {\n-\t\tctx->graph_name = get_commit_graph_filename(ctx->odb);\n+\t\tctx->graph_name = get_commit_graph_filename(ctx->odb_source);\n \t}\n \n \tif (safe_create_leading_directories(the_repository, ctx->graph_name)) {\n@@ -2073,7 +2073,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t}\n \n \tif (ctx->split) {\n-\t\tchar *lock_name = get_commit_graph_chain_filename(ctx->odb);\n+\t\tchar *lock_name = get_commit_graph_chain_filename(ctx->odb_source);\n \n \t\thold_lock_file_for_update_mode(&lk, lock_name,\n \t\t\t\t\t       LOCK_DIE_ON_ERROR, 0444);\n@@ -2161,7 +2161,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \n \tif (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {\n \t\tchar *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));\n-\t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb, new_base_hash);\n+\t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb_source, new_base_hash);\n \n \t\tfree(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]);\n \t\tfree(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]);\n@@ -2201,14 +2201,14 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\t\t\t}\n \t\t\t}\n \t\t} else {\n-\t\t\tchar *graph_name = get_commit_graph_filename(ctx->odb);\n+\t\t\tchar *graph_name = get_commit_graph_filename(ctx->odb_source);\n \t\t\tunlink(graph_name);\n \t\t\tfree(graph_name);\n \t\t}\n \n \t\tfree(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);\n \t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));\n-\t\tfinal_graph_name = get_split_graph_filename(ctx->odb,\n+\t\tfinal_graph_name = get_split_graph_filename(ctx->odb_source,\n \t\t\t\t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);\n \t\tfree(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);\n \t\tctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;\n@@ -2259,7 +2259,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)\n \t    flags != COMMIT_GRAPH_SPLIT_REPLACE) {\n \t\twhile (g && (g->num_commits <= st_mult(size_mult, num_commits) ||\n \t\t\t    (max_commits && num_commits > max_commits))) {\n-\t\t\tif (g->odb != ctx->odb)\n+\t\t\tif (g->odb_source != ctx->odb_source)\n \t\t\t\tbreak;\n \n \t\t\tif (unsigned_add_overflows(num_commits, g->num_commits))\n@@ -2281,10 +2281,10 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)\n \t\t    \"should be 1 with --split=replace\");\n \n \tif (ctx->num_commit_graphs_after == 2) {\n-\t\tchar *old_graph_name = get_commit_graph_filename(g->odb);\n+\t\tchar *old_graph_name = get_commit_graph_filename(g->odb_source);\n \n \t\tif (!strcmp(g->filename, old_graph_name) &&\n-\t\t    g->odb != ctx->odb) {\n+\t\t    g->odb_source != ctx->odb_source) {\n \t\t\tctx->num_commit_graphs_after = 1;\n \t\t\tctx->new_base_graph = NULL;\n \t\t}\n@@ -2456,13 +2456,13 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tif (ctx->opts && ctx->opts->expire_time)\n \t\texpire_time = ctx->opts->expire_time;\n \tif (!ctx->split) {\n-\t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->odb);\n+\t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->odb_source);\n \t\tunlink(chain_file_name);\n \t\tfree(chain_file_name);\n \t\tctx->num_commit_graphs_after = 0;\n \t}\n \n-\tstrbuf_addstr(&path, ctx->odb->path);\n+\tstrbuf_addstr(&path, ctx->odb_source->path);\n \tstrbuf_addstr(&path, \"/info/commit-graphs\");\n \tdir = opendir(path.buf);\n \n@@ -2504,7 +2504,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tstrbuf_release(&path);\n }\n \n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_source *source,\n \t\t       const struct string_list *const pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\n@@ -2513,7 +2513,7 @@ int write_commit_graph(struct object_directory *odb,\n \tstruct repository *r = the_repository;\n \tstruct write_commit_graph_context ctx = {\n \t\t.r = r,\n-\t\t.odb = odb,\n+\t\t.odb_source = source,\n \t\t.append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,\n \t\t.report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,\n \t\t.split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 20d38c100ce..0e661db1b54 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -29,8 +29,8 @@ struct repository;\n struct object_database;\n struct string_list;\n \n-char *get_commit_graph_filename(struct object_directory *odb);\n-char *get_commit_graph_chain_filename(struct object_directory *odb);\n+char *get_commit_graph_filename(struct odb_source *source);\n+char *get_commit_graph_chain_filename(struct odb_source *source);\n int open_commit_graph(const char *graph_file, int *fd, struct stat *st);\n int open_commit_graph_chain(const char *chain_file, int *fd, struct stat *st);\n \n@@ -89,7 +89,7 @@ struct commit_graph {\n \tuint32_t num_commits;\n \tstruct object_id oid;\n \tchar *filename;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *odb_source;\n \n \tuint32_t num_commits_in_base;\n \tunsigned int read_generation_data;\n@@ -115,12 +115,12 @@ struct commit_graph {\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb);\n+\t\t\t\t\t\t struct odb_source *source);\n struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t\t\t\t\t   int fd, struct stat *st,\n \t\t\t\t\t\t   int *incomplete_chain);\n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb);\n+\t\t\t\t\t   struct odb_source *source);\n \n struct repo_settings;\n \n@@ -173,10 +173,10 @@ struct commit_graph_opts {\n  * is not compatible with the commit-graph feature, then the\n  * methods will return 0 without writing a commit-graph.\n  */\n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_source *source,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts);\n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_source *source,\n \t\t       const struct string_list *pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\ndiff --git a/diagnose.c b/diagnose.c\nindex b1be74be983..d08d5643aac 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -59,13 +59,13 @@ static void dir_file_stats_objects(const char *full_path,\n \t\t\t    (uintmax_t)st.st_size);\n }\n \n-static int dir_file_stats(struct object_directory *object_dir, void *data)\n+static int dir_file_stats(struct odb_source *source, void *data)\n {\n \tstruct strbuf *buf = data;\n \n-\tstrbuf_addf(buf, \"Contents of %s:\\n\", object_dir->path);\n+\tstrbuf_addf(buf, \"Contents of %s:\\n\", source->path);\n \n-\tfor_each_file_in_pack_dir(object_dir->path, dir_file_stats_objects,\n+\tfor_each_file_in_pack_dir(source->path, dir_file_stats_objects,\n \t\t\t\t  data);\n \n \treturn 0;\n@@ -228,7 +228,7 @@ int create_diagnostics_archive(struct repository *r,\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n-\tdir_file_stats(r->objects->odb, &buf);\n+\tdir_file_stats(r->objects->sources, &buf);\n \tforeach_alt_odb(dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \ndiff --git a/http-walker.c b/http-walker.c\nindex 463f7b119ad..c374e6b2056 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -543,7 +543,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \t\tret = error(\"File %s has bad hash\", hex);\n \t} else if (req->rename < 0) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\todb_loose_path(the_repository->objects->odb, &buf, &req->oid);\n+\t\todb_loose_path(the_repository->objects->sources, &buf, &req->oid);\n \t\tret = error(\"unable to write sha1 filename %s\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\ndiff --git a/http.c b/http.c\nindex 3c029cf8947..5e15bbab3f1 100644\n--- a/http.c\n+++ b/http.c\n@@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \toidcpy(&freq->oid, oid);\n \tfreq->localfile = -1;\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->sources, &filename, oid);\n \tstrbuf_addf(&freq->tmpfile, \"%s.temp\", filename.buf);\n \n \tstrbuf_addf(&prevfile, \"%s.prev\", filename.buf);\n@@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)\n \t\tunlink_or_warn(freq->tmpfile.buf);\n \t\treturn -1;\n \t}\n-\todb_loose_path(the_repository->objects->odb, &filename, &freq->oid);\n+\todb_loose_path(the_repository->objects->sources, &filename, &freq->oid);\n \tfreq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);\n \tstrbuf_release(&filename);\n \ndiff --git a/loose.c b/loose.c\nindex bb602aaa366..fe65d5b9b0f 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -44,36 +44,36 @@ static int insert_oid_pair(kh_oid_map_t *map, const struct object_id *key, const\n \treturn 1;\n }\n \n-static int insert_loose_map(struct object_directory *odb,\n+static int insert_loose_map(struct odb_source *source,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\n {\n-\tstruct loose_object_map *map = odb->loose_map;\n+\tstruct loose_object_map *map = source->loose_map;\n \tint inserted = 0;\n \n \tinserted |= insert_oid_pair(map->to_compat, oid, compat_oid);\n \tinserted |= insert_oid_pair(map->to_storage, compat_oid, oid);\n \tif (inserted)\n-\t\toidtree_insert(odb->loose_objects_cache, compat_oid);\n+\t\toidtree_insert(source->loose_objects_cache, compat_oid);\n \n \treturn inserted;\n }\n \n-static int load_one_loose_object_map(struct repository *repo, struct object_directory *dir)\n+static int load_one_loose_object_map(struct repository *repo, struct odb_source *source)\n {\n \tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n \tFILE *fp;\n \n-\tif (!dir->loose_map)\n-\t\tloose_object_map_init(&dir->loose_map);\n-\tif (!dir->loose_objects_cache) {\n-\t\tALLOC_ARRAY(dir->loose_objects_cache, 1);\n-\t\toidtree_init(dir->loose_objects_cache);\n+\tif (!source->loose_map)\n+\t\tloose_object_map_init(&source->loose_map);\n+\tif (!source->loose_objects_cache) {\n+\t\tALLOC_ARRAY(source->loose_objects_cache, 1);\n+\t\toidtree_init(source->loose_objects_cache);\n \t}\n \n-\tinsert_loose_map(dir, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);\n-\tinsert_loose_map(dir, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);\n-\tinsert_loose_map(dir, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);\n+\tinsert_loose_map(source, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);\n+\tinsert_loose_map(source, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);\n+\tinsert_loose_map(source, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);\n \n \trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n \tfp = fopen(path.buf, \"rb\");\n@@ -93,7 +93,7 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \t\t    parse_oid_hex_algop(p, &compat_oid, &p, repo->compat_hash_algo) ||\n \t\t    p != buf.buf + buf.len)\n \t\t\tgoto err;\n-\t\tinsert_loose_map(dir, &oid, &compat_oid);\n+\t\tinsert_loose_map(source, &oid, &compat_oid);\n \t}\n \n \tstrbuf_release(&buf);\n@@ -107,15 +107,15 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \n int repo_read_loose_object_map(struct repository *repo)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_source *source;\n \n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n \tprepare_alt_odb(repo);\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tif (load_one_loose_object_map(repo, dir) < 0) {\n+\tfor (source = repo->objects->sources; source; source = source->next) {\n+\t\tif (load_one_loose_object_map(repo, source) < 0) {\n \t\t\treturn -1;\n \t\t}\n \t}\n@@ -124,7 +124,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \n int repo_write_loose_object_map(struct repository *repo)\n {\n-\tkh_oid_map_t *map = repo->objects->odb->loose_map->to_compat;\n+\tkh_oid_map_t *map = repo->objects->sources->loose_map->to_compat;\n \tstruct lock_file lock;\n \tint fd;\n \tkhiter_t iter;\n@@ -212,7 +212,7 @@ int repo_add_loose_object_map(struct repository *repo, const struct object_id *o\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tinserted = insert_loose_map(repo->objects->odb, oid, compat_oid);\n+\tinserted = insert_loose_map(repo->objects->sources, oid, compat_oid);\n \tif (inserted)\n \t\treturn write_one_object(repo, oid, compat_oid);\n \treturn 0;\n@@ -223,12 +223,12 @@ int repo_loose_object_map_oid(struct repository *repo,\n \t\t\t      const struct git_hash_algo *to,\n \t\t\t      struct object_id *dest)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_source *source;\n \tkh_oid_map_t *map;\n \tkhiter_t pos;\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tstruct loose_object_map *loose_map = dir->loose_map;\n+\tfor (source = repo->objects->sources; source; source = source->next) {\n+\t\tstruct loose_object_map *loose_map = source->loose_map;\n \t\tif (!loose_map)\n \t\t\tcontinue;\n \t\tmap = (to == repo->compat_hash_algo) ?\ndiff --git a/midx.c b/midx.c\nindex cd6e766ce2b..3c5bc821730 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -832,7 +832,7 @@ void clear_midx_file(struct repository *r)\n {\n \tstruct strbuf midx = STRBUF_INIT;\n \n-\tget_midx_filename(r->hash_algo, &midx, r->objects->odb->path);\n+\tget_midx_filename(r->hash_algo, &midx, r->objects->sources->path);\n \n \tif (r->objects && r->objects->multi_pack_index) {\n \t\tclose_midx(r->objects->multi_pack_index);\n@@ -842,8 +842,8 @@ void clear_midx_file(struct repository *r)\n \tif (remove_path(midx.buf))\n \t\tdie(_(\"failed to clear multi-pack-index at %s\"), midx.buf);\n \n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_BITMAP, NULL);\n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_REV, NULL);\n+\tclear_midx_files_ext(r->objects->sources->path, MIDX_EXT_BITMAP, NULL);\n+\tclear_midx_files_ext(r->objects->sources->path, MIDX_EXT_REV, NULL);\n \n \tstrbuf_release(&midx);\n }\ndiff --git a/object-file.c b/object-file.c\nindex 1ac04c28916..6bad1d3dd1c 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -55,12 +55,12 @@ static void fill_loose_path(struct strbuf *buf, const struct object_id *oid)\n \t}\n }\n \n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_source *source,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid)\n {\n \tstrbuf_reset(buf);\n-\tstrbuf_addstr(buf, odb->path);\n+\tstrbuf_addstr(buf, source->path);\n \tstrbuf_addch(buf, '/');\n \tfill_loose_path(buf, oid);\n \treturn buf->buf;\n@@ -88,27 +88,27 @@ int check_and_freshen_file(const char *fn, int freshen)\n \treturn 1;\n }\n \n-static int check_and_freshen_odb(struct object_directory *odb,\n+static int check_and_freshen_odb(struct odb_source *source,\n \t\t\t\t const struct object_id *oid,\n \t\t\t\t int freshen)\n {\n \tstatic struct strbuf path = STRBUF_INIT;\n-\todb_loose_path(odb, &path, oid);\n+\todb_loose_path(source, &path, oid);\n \treturn check_and_freshen_file(path.buf, freshen);\n }\n \n static int check_and_freshen_local(const struct object_id *oid, int freshen)\n {\n-\treturn check_and_freshen_odb(the_repository->objects->odb, oid, freshen);\n+\treturn check_and_freshen_odb(the_repository->objects->sources, oid, freshen);\n }\n \n static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb->next; odb; odb = odb->next) {\n-\t\tif (check_and_freshen_odb(odb, oid, freshen))\n+\tfor (source = the_repository->objects->sources->next; source; source = source->next) {\n+\t\tif (check_and_freshen_odb(source, oid, freshen))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -202,12 +202,12 @@ int stream_object_signature(struct repository *r, const struct object_id *oid)\n static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \t\t\t     struct stat *st, const char **path)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\t*path = odb_loose_path(source, &buf, oid);\n \t\tif (!lstat(*path, st))\n \t\t\treturn 0;\n \t}\n@@ -223,13 +223,13 @@ static int open_loose_object(struct repository *r,\n \t\t\t     const struct object_id *oid, const char **path)\n {\n \tint fd;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\t*path = odb_loose_path(source, &buf, oid);\n \t\tfd = git_open(*path);\n \t\tif (fd >= 0)\n \t\t\treturn fd;\n@@ -244,11 +244,11 @@ static int open_loose_object(struct repository *r,\n static int quick_has_loose(struct repository *r,\n \t\t\t   const struct object_id *oid)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tif (oidtree_contains(odb_loose_cache(odb, oid), oid))\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\tif (oidtree_contains(odb_loose_cache(source, oid), oid))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -694,7 +694,7 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,\n /* Finalize a file on disk, and close it. */\n static void close_loose_object(int fd, const char *filename)\n {\n-\tif (the_repository->objects->odb->will_destroy)\n+\tif (the_repository->objects->sources->will_destroy)\n \t\tgoto out;\n \n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n@@ -876,7 +876,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,\n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n \t\tprepare_loose_object_bulk_checkin();\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->sources, &filename, oid);\n \n \tfd = start_loose_object_common(&tmp_file, filename.buf, flags,\n \t\t\t\t       &stream, compressed, sizeof(compressed),\n@@ -1023,7 +1023,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,\n \t\tgoto cleanup;\n \t}\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->sources, &filename, oid);\n \n \t/* We finally know the object path, and create the missing dir. */\n \tdirlen = directory_size(filename.buf);\n@@ -1437,11 +1437,11 @@ int for_each_loose_file_in_objdir(const char *path,\n int for_each_loose_object(each_loose_object_fn cb, void *data,\n \t\t\t  enum for_each_object_flags flags)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n-\t\tint r = for_each_loose_file_in_objdir(odb->path, cb, NULL,\n+\tfor (source = the_repository->objects->sources; source; source = source->next) {\n+\t\tint r = for_each_loose_file_in_objdir(source->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\n \t\tif (r)\n \t\t\treturn r;\n@@ -1461,43 +1461,43 @@ static int append_loose_object(const struct object_id *oid,\n \treturn 0;\n }\n \n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n-\t\t\t\t  const struct object_id *oid)\n+struct oidtree *odb_loose_cache(struct odb_source *source,\n+\t\t\t\tconst struct object_id *oid)\n {\n \tint subdir_nr = oid->hash[0];\n \tstruct strbuf buf = STRBUF_INIT;\n-\tsize_t word_bits = bitsizeof(odb->loose_objects_subdir_seen[0]);\n+\tsize_t word_bits = bitsizeof(source->loose_objects_subdir_seen[0]);\n \tsize_t word_index = subdir_nr / word_bits;\n \tsize_t mask = (size_t)1u << (subdir_nr % word_bits);\n \tuint32_t *bitmap;\n \n \tif (subdir_nr < 0 ||\n-\t    subdir_nr >= bitsizeof(odb->loose_objects_subdir_seen))\n+\t    subdir_nr >= bitsizeof(source->loose_objects_subdir_seen))\n \t\tBUG(\"subdir_nr out of range\");\n \n-\tbitmap = &odb->loose_objects_subdir_seen[word_index];\n+\tbitmap = &source->loose_objects_subdir_seen[word_index];\n \tif (*bitmap & mask)\n-\t\treturn odb->loose_objects_cache;\n-\tif (!odb->loose_objects_cache) {\n-\t\tALLOC_ARRAY(odb->loose_objects_cache, 1);\n-\t\toidtree_init(odb->loose_objects_cache);\n+\t\treturn source->loose_objects_cache;\n+\tif (!source->loose_objects_cache) {\n+\t\tALLOC_ARRAY(source->loose_objects_cache, 1);\n+\t\toidtree_init(source->loose_objects_cache);\n \t}\n-\tstrbuf_addstr(&buf, odb->path);\n+\tstrbuf_addstr(&buf, source->path);\n \tfor_each_file_in_obj_subdir(subdir_nr, &buf,\n \t\t\t\t    append_loose_object,\n \t\t\t\t    NULL, NULL,\n-\t\t\t\t    odb->loose_objects_cache);\n+\t\t\t\t    source->loose_objects_cache);\n \t*bitmap |= mask;\n \tstrbuf_release(&buf);\n-\treturn odb->loose_objects_cache;\n+\treturn source->loose_objects_cache;\n }\n \n-void odb_clear_loose_cache(struct object_directory *odb)\n+void odb_clear_loose_cache(struct odb_source *source)\n {\n-\toidtree_clear(odb->loose_objects_cache);\n-\tFREE_AND_NULL(odb->loose_objects_cache);\n-\tmemset(&odb->loose_objects_subdir_seen, 0,\n-\t       sizeof(odb->loose_objects_subdir_seen));\n+\toidtree_clear(source->loose_objects_cache);\n+\tFREE_AND_NULL(source->loose_objects_cache);\n+\tmemset(&source->loose_objects_subdir_seen, 0,\n+\t       sizeof(source->loose_objects_subdir_seen));\n }\n \n static int check_stream_oid(git_zstream *stream,\ndiff --git a/object-file.h b/object-file.h\nindex 6f411424523..9a18859b2e0 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -24,23 +24,23 @@ enum {\n int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n \n-struct object_directory;\n+struct odb_source;\n \n /*\n  * Populate and return the loose object cache array corresponding to the\n  * given object ID.\n  */\n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n+struct oidtree *odb_loose_cache(struct odb_source *source,\n \t\t\t\tconst struct object_id *oid);\n \n /* Empty the loose object cache for the specified object directory. */\n-void odb_clear_loose_cache(struct object_directory *odb);\n+void odb_clear_loose_cache(struct odb_source *source);\n \n /*\n  * Put in `buf` the name of the file in the local object database that\n  * would be used to store a loose object with the specified oid.\n  */\n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_source *source,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid);\n \ndiff --git a/object-name.c b/object-name.c\nindex 9288b2dd245..544634d0f40 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -112,10 +112,10 @@ static enum cb_next match_prefix(const struct object_id *oid, void *arg)\n \n static void find_short_object_filename(struct disambiguate_state *ds)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n-\tfor (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next)\n-\t\toidtree_each(odb_loose_cache(odb, &ds->bin_pfx),\n+\tfor (source = ds->repo->objects->sources; source && !ds->ambiguous; source = source->next)\n+\t\toidtree_each(odb_loose_cache(source, &ds->bin_pfx),\n \t\t\t\t&ds->bin_pfx, ds->len, match_prefix, ds);\n }\n \ndiff --git a/object-store.c b/object-store.c\nindex f4e8f99d90f..5c04a1018f7 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -27,7 +27,7 @@\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n-\tstruct object_directory *, 1, fspathhash, fspatheq)\n+\tstruct odb_source *, 1, fspathhash, fspatheq)\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n@@ -104,18 +104,18 @@ static int alt_odb_usable(struct object_database *o,\n \t * Prevent the common mistake of listing the same\n \t * thing twice, or object directory itself.\n \t */\n-\tif (!o->odb_by_path) {\n+\tif (!o->source_by_path) {\n \t\tkhiter_t p;\n \n-\t\to->odb_by_path = kh_init_odb_path_map();\n-\t\tassert(!o->odb->next);\n-\t\tp = kh_put_odb_path_map(o->odb_by_path, o->odb->path, &r);\n+\t\to->source_by_path = kh_init_odb_path_map();\n+\t\tassert(!o->sources->next);\n+\t\tp = kh_put_odb_path_map(o->source_by_path, o->sources->path, &r);\n \t\tassert(r == 1); /* never used */\n-\t\tkh_value(o->odb_by_path, p) = o->odb;\n+\t\tkh_value(o->source_by_path, p) = o->sources;\n \t}\n \tif (fspatheq(path->buf, normalized_objdir))\n \t\treturn 0;\n-\t*pos = kh_put_odb_path_map(o->odb_by_path, path->buf, &r);\n+\t*pos = kh_put_odb_path_map(o->source_by_path, path->buf, &r);\n \t/* r: 0 = exists, 1 = never used, 2 = deleted */\n \treturn r == 0 ? 0 : 1;\n }\n@@ -124,7 +124,7 @@ static int alt_odb_usable(struct object_database *o,\n  * Prepare alternate object database registry.\n  *\n  * The variable alt_odb_list points at the list of struct\n- * object_directory.  The elements on this list come from\n+ * odb_source.  The elements on this list come from\n  * non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT\n  * environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates,\n  * whose contents is similar to that environment variable but can be\n@@ -141,7 +141,7 @@ static void read_info_alternates(struct repository *r,\n static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tconst char *relative_base, int depth, const char *normalized_objdir)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_source *alternate;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n \tstruct strbuf tmp = STRBUF_INIT;\n \tkhiter_t pos;\n@@ -170,19 +170,19 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n-\tCALLOC_ARRAY(ent, 1);\n-\t/* pathbuf.buf is already in r->objects->odb_by_path */\n-\tent->path = strbuf_detach(&pathbuf, NULL);\n+\tCALLOC_ARRAY(alternate, 1);\n+\t/* pathbuf.buf is already in r->objects->source_by_path */\n+\talternate->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->odb_tail = ent;\n-\tr->objects->odb_tail = &(ent->next);\n-\tent->next = NULL;\n-\tassert(r->objects->odb_by_path);\n-\tkh_value(r->objects->odb_by_path, pos) = ent;\n+\t*r->objects->sources_tail = alternate;\n+\tr->objects->sources_tail = &(alternate->next);\n+\talternate->next = NULL;\n+\tassert(r->objects->source_by_path);\n+\tkh_value(r->objects->source_by_path, pos) = alternate;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, ent->path, depth + 1);\n+\tread_info_alternates(r, alternate->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -234,7 +234,7 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->odb->path, 1);\n+\tstrbuf_realpath(&objdirbuf, r->objects->sources->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n@@ -321,9 +321,9 @@ void add_to_alternates_memory(const char *reference)\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n {\n-\tstruct object_directory *new_odb;\n+\tstruct odb_source *source;\n \n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n@@ -335,41 +335,41 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n-\tnew_odb = xcalloc(1, sizeof(*new_odb));\n-\tnew_odb->path = xstrdup(dir);\n+\tsource = xcalloc(1, sizeof(*source));\n+\tsource->path = xstrdup(dir);\n \n \t/*\n \t * Disable ref updates while a temporary odb is active, since\n \t * the objects in the database may roll back.\n \t */\n-\tnew_odb->disable_ref_updates = 1;\n-\tnew_odb->will_destroy = will_destroy;\n-\tnew_odb->next = the_repository->objects->odb;\n-\tthe_repository->objects->odb = new_odb;\n-\treturn new_odb->next;\n+\tsource->disable_ref_updates = 1;\n+\tsource->will_destroy = will_destroy;\n+\tsource->next = the_repository->objects->sources;\n+\tthe_repository->objects->sources = source;\n+\treturn source->next;\n }\n \n-static void free_object_directory(struct object_directory *odb)\n+static void free_object_directory(struct odb_source *source)\n {\n-\tfree(odb->path);\n-\todb_clear_loose_cache(odb);\n-\tloose_object_map_clear(&odb->loose_map);\n-\tfree(odb);\n+\tfree(source->path);\n+\todb_clear_loose_cache(source);\n+\tloose_object_map_clear(&source->loose_map);\n+\tfree(source);\n }\n \n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path)\n+void restore_primary_odb(struct odb_source *restore_alt, const char *old_path)\n {\n-\tstruct object_directory *cur_odb = the_repository->objects->odb;\n+\tstruct odb_source *cur_alt = the_repository->objects->sources;\n \n-\tif (strcmp(old_path, cur_odb->path))\n+\tif (strcmp(old_path, cur_alt->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n-\t\t    old_path, cur_odb->path);\n+\t\t    old_path, cur_alt->path);\n \n-\tif (cur_odb->next != restore_odb)\n+\tif (cur_alt->next != restore_alt)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->odb = restore_odb;\n-\tfree_object_directory(cur_odb);\n+\tthe_repository->objects->sources = restore_alt;\n+\tfree_object_directory(cur_alt);\n }\n \n /*\n@@ -442,15 +442,15 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_source *find_odb(struct repository *r, const char *obj_dir)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tstrbuf_realpath(&odb_path_real, odb->path, 1);\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\tstrbuf_realpath(&odb_path_real, source->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\n \t}\n@@ -458,9 +458,9 @@ struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n \tfree(obj_dir_real);\n \tstrbuf_release(&odb_path_real);\n \n-\tif (!odb)\n+\tif (!source)\n \t\tdie(_(\"could not find object directory matching %s\"), obj_dir);\n-\treturn odb;\n+\treturn source;\n }\n \n static void fill_alternate_refs_command(struct child_process *cmd,\n@@ -527,14 +527,14 @@ struct alternate_refs_data {\n \tvoid *data;\n };\n \n-static int refs_from_alternate_cb(struct object_directory *e,\n+static int refs_from_alternate_cb(struct odb_source *alternate,\n \t\t\t\t  void *data)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n \tstruct alternate_refs_data *cb = data;\n \n-\tif (!strbuf_realpath(&path, e->path, 0))\n+\tif (!strbuf_realpath(&path, alternate->path, 0))\n \t\tgoto out;\n \tif (!strbuf_strip_suffix(&path, \"/objects\"))\n \t\tgoto out;\n@@ -563,12 +563,12 @@ void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n \n int foreach_alt_odb(alt_odb_fn fn, void *cb)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_source *alternate;\n \tint r = 0;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (ent = the_repository->objects->odb->next; ent; ent = ent->next) {\n-\t\tr = fn(ent, cb);\n+\tfor (alternate = the_repository->objects->sources->next; alternate; alternate = alternate->next) {\n+\t\tr = fn(alternate, cb);\n \t\tif (r)\n \t\t\tbreak;\n \t}\n@@ -582,14 +582,14 @@ void prepare_alt_odb(struct repository *r)\n \n \tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->odb->path, 0);\n+\tread_info_alternates(r, r->objects->sources->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n int has_alt_odb(struct repository *r)\n {\n \tprepare_alt_odb(r);\n-\treturn !!r->objects->odb->next;\n+\treturn !!r->objects->sources->next;\n }\n \n int obj_read_use_lock = 0;\n@@ -963,15 +963,15 @@ struct object_database *odb_new(void)\n \n static void free_object_directories(struct object_database *o)\n {\n-\twhile (o->odb) {\n-\t\tstruct object_directory *next;\n+\twhile (o->sources) {\n+\t\tstruct odb_source *next;\n \n-\t\tnext = o->odb->next;\n-\t\tfree_object_directory(o->odb);\n-\t\to->odb = next;\n+\t\tnext = o->sources->next;\n+\t\tfree_object_directory(o->sources);\n+\t\to->sources = next;\n \t}\n-\tkh_destroy_odb_path_map(o->odb_by_path);\n-\to->odb_by_path = NULL;\n+\tkh_destroy_odb_path_map(o->source_by_path);\n+\to->source_by_path = NULL;\n }\n \n void odb_clear(struct object_database *o)\n@@ -986,7 +986,7 @@ void odb_clear(struct object_database *o)\n \to->commit_graph_attempted = 0;\n \n \tfree_object_directories(o);\n-\to->odb_tail = NULL;\n+\to->sources_tail = NULL;\n \to->loaded_alternates = 0;\n \n \tfor (size_t i = 0; i < o->cached_object_nr; i++)\ndiff --git a/object-store.h b/object-store.h\nindex a3be27d1171..d199d757d76 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -13,8 +13,20 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n-struct object_directory {\n-\tstruct object_directory *next;\n+/*\n+ * The source is the part of the object database that stores the actual\n+ * objects. It thus encapsulates the logic to read and write the specific\n+ * on-disk format. An object database can have multiple sources:\n+ *\n+ *   - The primary source, which is typically located in \"$GIT_DIR/objects\".\n+ *     This is where new objects are usually written to.\n+ *\n+ *   - Alternate sources, which are configured via \"objects/info/alternates\" or\n+ *     via the GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable. These\n+ *     alternate sources are only used to read objects.\n+ */\n+struct odb_source {\n+\tstruct odb_source *next;\n \n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n@@ -44,8 +56,8 @@ struct object_directory {\n \tint will_destroy;\n \n \t/*\n-\t * Path to the alternative object store. If this is a relative path,\n-\t * it is relative to the current working directory.\n+\t * Path to the source. If this is a relative path, it is relative to\n+\t * the current working directory.\n \t */\n \tchar *path;\n };\n@@ -53,8 +65,8 @@ struct object_directory {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct object_directory *find_odb(struct repository *r, const char *obj_dir);\n-typedef int alt_odb_fn(struct object_directory *, void *);\n+struct odb_source *find_odb(struct repository *r, const char *obj_dir);\n+typedef int alt_odb_fn(struct odb_source *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n@@ -76,12 +88,12 @@ void add_to_alternates_memory(const char *dir);\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n  */\n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy);\n+struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy);\n \n /*\n  * Restore a previous ODB replaced by set_temporary_main_odb.\n  */\n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);\n+void restore_primary_odb(struct odb_source *restore_alternate, const char *old_path);\n \n struct packed_git;\n struct multi_pack_index;\n@@ -89,7 +101,7 @@ struct cached_object_entry;\n \n /*\n  * The object database encapsulates access to objects in a repository. It\n- * manages one or more backends that store the actual objects which are\n+ * manages one or more sources that store the actual objects which are\n  * configured via alternates.\n  */\n struct object_database {\n@@ -98,16 +110,16 @@ struct object_database {\n \t * cannot be NULL after initialization). Subsequent directories are\n \t * alternates.\n \t */\n-\tstruct object_directory *odb;\n-\tstruct object_directory **odb_tail;\n-\tstruct kh_odb_path_map *odb_by_path;\n+\tstruct odb_source *sources;\n+\tstruct odb_source **sources_tail;\n+\tstruct kh_odb_path_map *source_by_path;\n \n \tint loaded_alternates;\n \n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"odb\" list when prepare_alt_odb() is run.\n+\t * populate the \"sources\" list when prepare_alt_odb() is run.\n \t */\n \tchar *alternate_db;\n \ndiff --git a/packfile.c b/packfile.c\nindex c735b4d0135..60661ad0095 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1029,16 +1029,16 @@ static void prepare_packed_git_mru(struct repository *r)\n \n static void prepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tint local = (odb == r->objects->odb);\n-\t\tprepare_multi_pack_index_one(r, odb->path, local);\n-\t\tprepare_packed_git_one(r, odb->path, local);\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\tint local = (source == r->objects->sources);\n+\t\tprepare_multi_pack_index_one(r, source->path, local);\n+\t\tprepare_packed_git_one(r, source->path, local);\n \t}\n \trearrange_packed_git(r);\n \n@@ -1048,7 +1048,7 @@ static void prepare_packed_git(struct repository *r)\n \n void reprepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tobj_read_lock();\n \n@@ -1061,8 +1061,8 @@ void reprepare_packed_git(struct repository *r)\n \tr->objects->loaded_alternates = 0;\n \tprepare_alt_odb(r);\n \n-\tfor (odb = r->objects->odb; odb; odb = odb->next)\n-\t\todb_clear_loose_cache(odb);\n+\tfor (source = r->objects->sources; source; source = source->next)\n+\t\todb_clear_loose_cache(source);\n \n \tr->objects->approximate_object_count_valid = 0;\n \tr->objects->packed_git_initialized = 0;\ndiff --git a/path.c b/path.c\nindex 3b598b2847f..c347829aa66 100644\n--- a/path.c\n+++ b/path.c\n@@ -397,7 +397,7 @@ static void adjust_git_path(struct repository *repo,\n \t\tstrbuf_splice(buf, 0, buf->len,\n \t\t\t      repo->index_file, strlen(repo->index_file));\n \telse if (dir_prefix(base, \"objects\"))\n-\t\treplace_dir(buf, git_dir_len + 7, repo->objects->odb->path);\n+\t\treplace_dir(buf, git_dir_len + 7, repo->objects->sources->path);\n \telse if (repo_settings_get_hooks_path(repo) && dir_prefix(base, \"hooks\"))\n \t\treplace_dir(buf, git_dir_len + 5, repo_settings_get_hooks_path(repo));\n \telse if (repo->different_commondir)\ndiff --git a/refs.c b/refs.c\nindex dce5c49ca2b..5f6a386cc93 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -2477,7 +2477,7 @@ int ref_transaction_prepare(struct ref_transaction *transaction,\n \t\tbreak;\n \t}\n \n-\tif (refs->repo->objects->odb->disable_ref_updates) {\n+\tif (refs->repo->objects->sources->disable_ref_updates) {\n \t\tstrbuf_addstr(err,\n \t\t\t      _(\"ref updates forbidden inside quarantine environment\"));\n \t\treturn -1;\ndiff --git a/repository.c b/repository.c\nindex 07757e6e0c9..7528beccddf 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -107,9 +107,9 @@ const char *repo_get_common_dir(struct repository *repo)\n \n const char *repo_get_object_directory(struct repository *repo)\n {\n-\tif (!repo->objects->odb)\n+\tif (!repo->objects->sources)\n \t\tBUG(\"repository hasn't been set up\");\n-\treturn repo->objects->odb->path;\n+\treturn repo->objects->sources->path;\n }\n \n const char *repo_get_index_file(struct repository *repo)\n@@ -165,14 +165,14 @@ void repo_set_gitdir(struct repository *repo,\n \n \trepo_set_commondir(repo, o->commondir);\n \n-\tif (!repo->objects->odb) {\n-\t\tCALLOC_ARRAY(repo->objects->odb, 1);\n-\t\trepo->objects->odb_tail = &repo->objects->odb->next;\n+\tif (!repo->objects->sources) {\n+\t\tCALLOC_ARRAY(repo->objects->sources, 1);\n+\t\trepo->objects->sources_tail = &repo->objects->sources->next;\n \t}\n-\texpand_base_dir(&repo->objects->odb->path, o->object_dir,\n+\texpand_base_dir(&repo->objects->sources->path, o->object_dir,\n \t\t\trepo->commondir, \"objects\");\n \n-\trepo->objects->odb->disable_ref_updates = o->disable_ref_updates;\n+\trepo->objects->sources->disable_ref_updates = o->disable_ref_updates;\n \n \tfree(repo->objects->alternate_db);\n \trepo->objects->alternate_db = xstrdup_or_null(o->alternate_db);\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 8630e27947d..b30d9365fbd 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,7 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->odb->path);\n+\t\t\t\tadd_submodule_odb_by_path(repo->objects->sources->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 8b413b644be..53b633e2ba6 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -73,15 +73,15 @@ static void dump_graph_bloom_filters(struct commit_graph *graph)\n int cmd__read_graph(int argc, const char **argv)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \tint ret = 0;\n \n \tsetup_git_directory();\n-\todb = the_repository->objects->odb;\n+\tsource = the_repository->objects->sources;\n \n \tprepare_repo_settings(the_repository);\n \n-\tgraph = read_commit_graph_one(the_repository, odb);\n+\tgraph = read_commit_graph_one(the_repository, source);\n \tif (!graph) {\n \t\tret = 1;\n \t\tgoto done;\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex c38fbeb5e8a..056484404be 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -17,7 +17,7 @@ struct tmp_objdir {\n \tstruct repository *repo;\n \tstruct strbuf path;\n \tstruct strvec env;\n-\tstruct object_directory *prev_odb;\n+\tstruct odb_source *prev_source;\n \tint will_destroy;\n };\n \n@@ -46,8 +46,8 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \tif (t == the_tmp_objdir)\n \t\tthe_tmp_objdir = NULL;\n \n-\tif (t->prev_odb)\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n+\tif (t->prev_source)\n+\t\trestore_primary_odb(t->prev_source, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -276,11 +276,11 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (!t)\n \t\treturn 0;\n \n-\tif (t->prev_odb) {\n-\t\tif (t->repo->objects->odb->will_destroy)\n+\tif (t->prev_source) {\n+\t\tif (t->repo->objects->sources->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n-\t\tt->prev_odb = NULL;\n+\t\trestore_primary_odb(t->prev_source, t->path.buf);\n+\t\tt->prev_source = NULL;\n \t}\n \n \tstrbuf_addbuf(&src, &t->path);\n@@ -309,19 +309,19 @@ void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n-\tif (t->prev_odb)\n+\tif (t->prev_source)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_odb = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_source = set_temporary_primary_odb(t->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n {\n-\tif (!the_tmp_objdir || !the_tmp_objdir->prev_odb)\n+\tif (!the_tmp_objdir || !the_tmp_objdir->prev_source)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf);\n-\tthe_tmp_objdir->prev_odb = NULL;\n+\trestore_primary_odb(the_tmp_objdir->prev_source, the_tmp_objdir->path.buf);\n+\tthe_tmp_objdir->prev_source = NULL;\n \treturn the_tmp_objdir;\n }\n \n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519714","messageId":"20250605-pks-object-store-wo-the-repository-v5-5-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:55Z","receivedAt":"2025-06-05T06:47:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `find_odb()` by passing\nin the object database in which we want to search for the source and\nadjusting all callers.\n\nRename the function to `odb_find_source()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c | 4 ++--\n midx-write.c           | 2 +-\n odb.c                  | 6 +++---\n odb.h                  | 7 ++++++-\n 4 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex f04eaba5259..77d7e88a98c 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -101,7 +101,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\tsource = find_odb(the_repository, opts.obj_dir);\n+\tsource = odb_find_source(the_repository->objects, opts.obj_dir);\n \tgraph_name = get_commit_graph_filename(source);\n \tchain_name = get_commit_graph_chain_filename(source);\n \tif (open_commit_graph(graph_name, &fd, &st))\n@@ -289,7 +289,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tsource = find_odb(the_repository, opts.obj_dir);\n+\tsource = odb_find_source(the_repository->objects, opts.obj_dir);\n \n \tif (opts.reachable) {\n \t\tif (write_commit_graph_reachable(source, flags, &write_opts))\ndiff --git a/midx-write.c b/midx-write.c\nindex ba4a94950a8..f2cfb85476e 100644\n--- a/midx-write.c\n+++ b/midx-write.c\n@@ -922,7 +922,7 @@ static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,\n \tstruct strbuf cur_path_real = STRBUF_INIT;\n \n \t/* Ensure the given object_dir is local, or a known alternate. */\n-\tfind_odb(r, obj_dir_real);\n+\todb_find_source(r->objects, obj_dir_real);\n \n \tfor (cur = get_multi_pack_index(r); cur; cur = cur->next) {\n \t\tstrbuf_realpath(&cur_path_real, cur->object_dir, 1);\ndiff --git a/odb.c b/odb.c\nindex afb16f4c693..483b9b38414 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -448,14 +448,14 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct odb_source *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir)\n {\n \tstruct odb_source *source;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n-\tfor (source = r->objects->sources; source; source = source->next) {\n+\tprepare_alt_odb(odb->repo);\n+\tfor (source = odb->sources; source; source = source->next) {\n \t\tstrbuf_realpath(&odb_path_real, source->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\ndiff --git a/odb.h b/odb.h\nindex c3851e29668..941329c6943 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -68,7 +68,6 @@ struct odb_source {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct odb_source *find_odb(struct repository *r, const char *obj_dir);\n typedef int alt_odb_fn(struct odb_source *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n@@ -195,6 +194,12 @@ struct object_database {\n struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n+/*\n+ * Find source by its object directory path. Dies in case the source couldn't\n+ * be found.\n+ */\n+struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);\n+\n /*\n  * Create a temporary file rooted in the object database directory, or\n  * die on failure. The filename is taken from \"pattern\", which should have the\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519715","messageId":"20250605-pks-object-store-wo-the-repository-v5-4-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 04/17] odb: introduce parent pointers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:54Z","receivedAt":"2025-06-05T06:47:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In subsequent commits we'll get rid of our use of `the_repository` in\n\"odb.c\" in favor of explicitly passing in a `struct object_database` or\na `struct odb_source`. In some cases though we'll need access to the\nrepository, for example to read a config value from it, but we don't\nhave a way to access the repository owning a specific object database.\n\nIntroduce parent pointers for `struct object_database` to its owning\nrepository as well as for `struct odb_source` to its owning object\ndatabase, which will allow us to adapt those use cases.\n\nNote that this change requires us to pass through the object database to\n`link_alt_odb_entry()` so that we can set up the parent pointers for any\nsource there. The callchain is adapted to pass through the object\ndatabase accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 47 +++++++++++++++++++++++++++--------------------\n odb.h        |  8 +++++++-\n repository.c |  3 ++-\n 3 files changed, 36 insertions(+), 22 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex d1025ac182d..afb16f4c693 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -135,11 +135,15 @@ static int alt_odb_usable(struct object_database *o,\n  * of the object ID, an extra slash for the first level indirection, and\n  * the terminating NUL.\n  */\n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth);\n-static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n-\tconst char *relative_base, int depth, const char *normalized_objdir)\n+\n+static int link_alt_odb_entry(struct object_database *odb,\n+\t\t\t      const struct strbuf *entry,\n+\t\t\t      const char *relative_base,\n+\t\t\t      int depth,\n+\t\t\t      const char *normalized_objdir)\n {\n \tstruct odb_source *alternate;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n@@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \twhile (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')\n \t\tstrbuf_setlen(&pathbuf, pathbuf.len - 1);\n \n-\tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n+\tif (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n \tCALLOC_ARRAY(alternate, 1);\n-\t/* pathbuf.buf is already in r->objects->source_by_path */\n+\talternate->odb = odb;\n+\t/* pathbuf.buf is already in r->objects->alternate_by_path */\n \talternate->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->sources_tail = alternate;\n-\tr->objects->sources_tail = &(alternate->next);\n+\t*odb->sources_tail = alternate;\n+\todb->sources_tail = &(alternate->next);\n \talternate->next = NULL;\n-\tassert(r->objects->source_by_path);\n-\tkh_value(r->objects->source_by_path, pos) = alternate;\n+\tassert(odb->source_by_path);\n+\tkh_value(odb->source_by_path, pos) = alternate;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, alternate->path, depth + 1);\n+\tread_info_alternates(odb, alternate->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -219,7 +224,7 @@ static const char *parse_alt_odb_entry(const char *string,\n \treturn end;\n }\n \n-static void link_alt_odb_entries(struct repository *r, const char *alt,\n+static void link_alt_odb_entries(struct object_database *odb, const char *alt,\n \t\t\t\t int sep, const char *relative_base, int depth)\n {\n \tstruct strbuf objdirbuf = STRBUF_INIT;\n@@ -234,20 +239,20 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->sources->path, 1);\n+\tstrbuf_realpath(&objdirbuf, odb->sources->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n \t\tif (!entry.len)\n \t\t\tcontinue;\n-\t\tlink_alt_odb_entry(r, &entry,\n+\t\tlink_alt_odb_entry(odb, &entry,\n \t\t\t\t   relative_base, depth, objdirbuf.buf);\n \t}\n \tstrbuf_release(&entry);\n \tstrbuf_release(&objdirbuf);\n }\n \n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth)\n {\n@@ -261,7 +266,7 @@ static void read_info_alternates(struct repository *r,\n \t\treturn;\n \t}\n \n-\tlink_alt_odb_entries(r, buf.buf, '\\n', relative_base, depth);\n+\tlink_alt_odb_entries(odb, buf.buf, '\\n', relative_base, depth);\n \tstrbuf_release(&buf);\n \tfree(path);\n }\n@@ -303,7 +308,7 @@ void add_to_alternates_file(const char *reference)\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n \t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository, reference,\n+\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n@@ -317,7 +322,7 @@ void add_to_alternates_memory(const char *reference)\n \t */\n \tprepare_alt_odb(the_repository);\n \n-\tlink_alt_odb_entries(the_repository, reference,\n+\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -336,6 +341,7 @@ struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * alternate\n \t */\n \tsource = xcalloc(1, sizeof(*source));\n+\tsource->odb = the_repository->objects;\n \tsource->path = xstrdup(dir);\n \n \t/*\n@@ -580,9 +586,9 @@ void prepare_alt_odb(struct repository *r)\n \tif (r->objects->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->sources->path, 0);\n+\tread_info_alternates(r->objects, r->objects->sources->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n@@ -950,11 +956,12 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct object_database *odb_new(void)\n+struct object_database *odb_new(struct repository *repo)\n {\n \tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n+\to->repo = repo;\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\ndiff --git a/odb.h b/odb.h\nindex 6f56b168e46..c3851e29668 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -28,6 +28,9 @@ struct repository;\n struct odb_source {\n \tstruct odb_source *next;\n \n+\t/* Object database that owns this object source. */\n+\tstruct object_database *odb;\n+\n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n \t * sacrificing accuracy due to races for speed. That includes\n@@ -105,6 +108,9 @@ struct cached_object_entry;\n  * configured via alternates.\n  */\n struct object_database {\n+\t/* Repository that owns this database. */\n+\tstruct repository *repo;\n+\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -186,7 +192,7 @@ struct object_database {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct object_database *odb_new(void);\n+struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n /*\ndiff --git a/repository.c b/repository.c\nindex 13426db0f2b..c606e1153c8 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = odb_new();\n+\trepo->objects = odb_new(repo);\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -167,6 +167,7 @@ void repo_set_gitdir(struct repository *repo,\n \n \tif (!repo->objects->sources) {\n \t\tCALLOC_ARRAY(repo->objects->sources, 1);\n+\t\trepo->objects->sources->odb = repo->objects;\n \t\trepo->objects->sources_tail = &repo->objects->sources->next;\n \t}\n \texpand_base_dir(&repo->objects->sources->path, o->object_dir,\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519720","messageId":"20250605-pks-object-store-wo-the-repository-v5-3-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:53Z","receivedAt":"2025-06-05T06:47:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In the preceding commits we have renamed the structures contained in\n\"object-store.h\" to `struct object_database` and `struct odb_backend`.\nAs such, the code files \"object-store.{c,h}\" are confusingly named now.\nRename them to \"odb.{c,h}\" accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile                                | 2 +-\n apply.c                                 | 2 +-\n archive-tar.c                           | 2 +-\n archive-zip.c                           | 2 +-\n archive.c                               | 2 +-\n attr.c                                  | 2 +-\n bisect.c                                | 2 +-\n blame.c                                 | 2 +-\n builtin/backfill.c                      | 2 +-\n builtin/blame.c                         | 2 +-\n builtin/cat-file.c                      | 2 +-\n builtin/checkout.c                      | 2 +-\n builtin/clone.c                         | 2 +-\n builtin/commit-graph.c                  | 2 +-\n builtin/commit-tree.c                   | 2 +-\n builtin/describe.c                      | 2 +-\n builtin/difftool.c                      | 2 +-\n builtin/fast-export.c                   | 2 +-\n builtin/fast-import.c                   | 2 +-\n builtin/fetch.c                         | 2 +-\n builtin/fsck.c                          | 2 +-\n builtin/grep.c                          | 2 +-\n builtin/hash-object.c                   | 2 +-\n builtin/index-pack.c                    | 2 +-\n builtin/log.c                           | 2 +-\n builtin/ls-files.c                      | 2 +-\n builtin/ls-tree.c                       | 2 +-\n builtin/merge-file.c                    | 2 +-\n builtin/merge-tree.c                    | 2 +-\n builtin/mktag.c                         | 2 +-\n builtin/mktree.c                        | 2 +-\n builtin/multi-pack-index.c              | 2 +-\n builtin/notes.c                         | 2 +-\n builtin/pack-objects.c                  | 2 +-\n builtin/pack-redundant.c                | 2 +-\n builtin/prune.c                         | 2 +-\n builtin/receive-pack.c                  | 2 +-\n builtin/remote.c                        | 2 +-\n builtin/repack.c                        | 2 +-\n builtin/replace.c                       | 2 +-\n builtin/rev-list.c                      | 2 +-\n builtin/show-ref.c                      | 2 +-\n builtin/submodule--helper.c             | 2 +-\n builtin/tag.c                           | 2 +-\n builtin/unpack-file.c                   | 2 +-\n builtin/unpack-objects.c                | 2 +-\n bulk-checkin.c                          | 2 +-\n bundle-uri.c                            | 2 +-\n bundle.c                                | 2 +-\n cache-tree.c                            | 2 +-\n combine-diff.c                          | 2 +-\n commit-graph.c                          | 2 +-\n commit-graph.h                          | 2 +-\n commit.c                                | 2 +-\n config.c                                | 2 +-\n connected.c                             | 2 +-\n contrib/coccinelle/the_repository.cocci | 2 +-\n diagnose.c                              | 2 +-\n diff.c                                  | 2 +-\n entry.c                                 | 2 +-\n fetch-pack.c                            | 2 +-\n fmt-merge-msg.c                         | 2 +-\n fsck.c                                  | 2 +-\n grep.c                                  | 2 +-\n http-backend.c                          | 2 +-\n http-push.c                             | 2 +-\n http-walker.c                           | 2 +-\n http.c                                  | 2 +-\n list-objects-filter.c                   | 2 +-\n list-objects.c                          | 2 +-\n loose.c                                 | 2 +-\n mailmap.c                               | 2 +-\n match-trees.c                           | 2 +-\n merge-blobs.c                           | 2 +-\n merge-ort.c                             | 2 +-\n meson.build                             | 2 +-\n notes-cache.c                           | 2 +-\n notes-merge.c                           | 2 +-\n notes.c                                 | 2 +-\n object-file.c                           | 2 +-\n object-file.h                           | 2 +-\n object-store.c => odb.c                 | 2 +-\n object-store.h => odb.h                 | 6 +++---\n oss-fuzz/fuzz-pack-idx.c                | 2 +-\n pack-bitmap-write.c                     | 2 +-\n pack-bitmap.c                           | 2 +-\n pack-check.c                            | 2 +-\n pack-mtimes.c                           | 2 +-\n pack-objects.h                          | 2 +-\n pack-revindex.c                         | 2 +-\n packfile.c                              | 2 +-\n packfile.h                              | 4 ++--\n path.c                                  | 2 +-\n promisor-remote.c                       | 2 +-\n protocol-caps.c                         | 2 +-\n read-cache.c                            | 2 +-\n ref-filter.c                            | 2 +-\n reflog.c                                | 2 +-\n refs.c                                  | 2 +-\n remote.c                                | 2 +-\n replace-object.c                        | 2 +-\n replace-object.h                        | 2 +-\n repository.c                            | 2 +-\n rerere.c                                | 2 +-\n revision.c                              | 2 +-\n send-pack.c                             | 2 +-\n sequencer.c                             | 2 +-\n server-info.c                           | 2 +-\n shallow.c                               | 2 +-\n streaming.c                             | 2 +-\n submodule-config.c                      | 2 +-\n submodule.c                             | 2 +-\n t/helper/test-find-pack.c               | 2 +-\n t/helper/test-pack-mtimes.c             | 2 +-\n t/helper/test-partial-clone.c           | 2 +-\n t/helper/test-read-graph.c              | 2 +-\n t/helper/test-read-midx.c               | 2 +-\n t/helper/test-ref-store.c               | 2 +-\n tag.c                                   | 2 +-\n tmp-objdir.c                            | 2 +-\n tree-walk.c                             | 2 +-\n tree.c                                  | 2 +-\n unpack-trees.c                          | 2 +-\n upload-pack.c                           | 2 +-\n walker.c                                | 2 +-\n xdiff-interface.c                       | 2 +-\n 126 files changed, 129 insertions(+), 129 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 70d1543b6b8..4b1bf897791 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1085,8 +1085,8 @@ LIB_OBJS += notes.o\n LIB_OBJS += object-file-convert.o\n LIB_OBJS += object-file.o\n LIB_OBJS += object-name.o\n-LIB_OBJS += object-store.o\n LIB_OBJS += object.o\n+LIB_OBJS += odb.o\n LIB_OBJS += oid-array.o\n LIB_OBJS += oidmap.o\n LIB_OBJS += oidset.o\ndiff --git a/apply.c b/apply.c\nindex 8bbe6ed2240..e778b4e911d 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -14,7 +14,7 @@\n #include \"abspath.h\"\n #include \"base85.h\"\n #include \"config.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"delta.h\"\n #include \"diff.h\"\n #include \"dir.h\"\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 282b48196f9..249164ea77d 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -11,7 +11,7 @@\n #include \"hex.h\"\n #include \"tar.h\"\n #include \"archive.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"streaming.h\"\n #include \"run-command.h\"\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 405da6f3d83..df8866d5bae 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -12,7 +12,7 @@\n #include \"hex.h\"\n #include \"streaming.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"userdiff.h\"\n #include \"write-or-die.h\"\ndiff --git a/archive.c b/archive.c\nindex 8309ea213e6..7fa2cc2596a 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -14,7 +14,7 @@\n #include \"pretty.h\"\n #include \"setup.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/attr.c b/attr.c\nindex 86b6109fc4e..e5680db7f65 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -22,7 +22,7 @@\n #include \"read-cache-ll.h\"\n #include \"refs.h\"\n #include \"revision.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/bisect.c b/bisect.c\nindex a327468c75b..a7939216d00 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -20,7 +20,7 @@\n #include \"commit-slab.h\"\n #include \"commit-reach.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"dir.h\"\n \ndiff --git a/blame.c b/blame.c\nindex 57daa45e899..0ceea080a80 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -3,7 +3,7 @@\n \n #include \"git-compat-util.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"cache-tree.h\"\n #include \"mergesort.h\"\n #include \"commit.h\"\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex fa82ad2f6ff..0b49baa39fa 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -13,7 +13,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"promisor-remote.h\"\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 944952e30eb..15eda60af90 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -28,7 +28,7 @@\n #include \"line-log.h\"\n #include \"progress.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"blame.h\"\n #include \"refs.h\"\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 67a5ff2b9eb..f3a925a8183 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -24,7 +24,7 @@\n #include \"pack-bitmap.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"promisor-remote.h\"\n #include \"mailmap.h\"\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex d185982f3a6..e7dd66173dd 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -20,7 +20,7 @@\n #include \"merge-ort-wrappers.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"path.h\"\n #include \"preload-index.h\"\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 91b9cd0d164..1eafeefb48d 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -25,7 +25,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 98a84315342..f04eaba5259 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -6,7 +6,7 @@\n #include \"hex.h\"\n #include \"parse-options.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"progress.h\"\n #include \"replace-object.h\"\n #include \"strbuf.h\"\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex ad6b2c93209..546069f8682 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -9,7 +9,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n #include \"commit.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 2d50883b729..96cb68e5e5d 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -19,7 +19,7 @@\n #include \"setup.h\"\n #include \"strvec.h\"\n #include \"run-command.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects.h\"\n #include \"commit-slab.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex a3b64ce6942..fac613e3bc3 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -30,7 +30,7 @@\n #include \"strbuf.h\"\n #include \"lockfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"entry.h\"\n #include \"setup.h\"\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 37c01d6c6fe..0505f289a94 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"object.h\"\n #include \"tag.h\"\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex b2839c5f439..52c792488e1 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -24,7 +24,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"mem-pool.h\"\n #include \"commit-reach.h\"\n #include \"khash.h\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex a890e2864d1..b842bc9c51b 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"oid-array.h\"\n #include \"commit.h\"\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6e1474f63d5..9abd7b25580 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 76b1938bba5..a1d7ee7af39 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -26,7 +26,7 @@\n #include \"submodule-config.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pager.h\"\n #include \"path.h\"\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex 6a99ec250d0..e28f000221f 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -11,7 +11,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex bb7925bd29f..1aabe6b8ee2 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -21,7 +21,7 @@\n #include \"packfile.h\"\n #include \"pack-revindex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"path.h\"\ndiff --git a/builtin/log.c b/builtin/log.c\nindex b450cd3bde8..fe9cc5ebecb 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -15,7 +15,7 @@\n #include \"hex.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"color.h\"\n #include \"commit.h\"\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex be74f0a03b2..821339b07d4 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -25,7 +25,7 @@\n #include \"setup.h\"\n #include \"sparse-index.h\"\n #include \"submodule.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n \n \ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 8aafc30ca48..62b6fd58c16 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -10,7 +10,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"path.h\"\n #include \"quote.h\"\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 2b16b10d2ca..9464f275629 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -7,7 +7,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"setup.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 7f41665dfd7..b1a17787bcf 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -10,7 +10,7 @@\n #include \"commit-reach.h\"\n #include \"merge-ort.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 7ac11c46d53..1809b38f937 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -6,7 +6,7 @@\n #include \"strbuf.h\"\n #include \"replace-object.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"fsck.h\"\n #include \"config.h\"\n \ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 4b478034675..016b0e5b224 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -12,7 +12,7 @@\n #include \"tree.h\"\n #include \"parse-options.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct treeent {\n \tunsigned mode;\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex f55bf53da83..aa25b06f9d0 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -7,7 +7,7 @@\n #include \"midx.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex a3f433ca4c0..783d4932ca6 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -16,7 +16,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n \n #include \"pretty.h\"\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8b33edc2ff5..99b63cb0980 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -32,7 +32,7 @@\n #include \"list.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"dir.h\"\n #include \"midx.h\"\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 5d1fc781761..3134cb8c689 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -13,7 +13,7 @@\n #include \"hex.h\"\n \n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n \n #define BLKSIZE 512\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex e930caa0c0a..7bbfb14c2be 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -17,7 +17,7 @@\n #include \"replace-object.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"shallow.h\"\n \n static const char * const prune_usage[] = {\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex a317d6c278d..0f5958c4a66 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -33,7 +33,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"protocol.h\"\n #include \"commit-reach.h\"\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 0d6755bcb71..ac5b8d2a1a6 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -14,7 +14,7 @@\n #include \"rebase.h\"\n #include \"refs.h\"\n #include \"refspec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strvec.h\"\n #include \"commit-reach.h\"\n #include \"progress.h\"\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 59214dbdfdf..16782320058 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -17,7 +17,7 @@\n #include \"midx.h\"\n #include \"packfile.h\"\n #include \"prune-packed.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"shallow.h\"\n #include \"pack.h\"\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 48c7c6a2d56..11c7e2d4c0c 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"tag.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 0984b607bf0..0ee37a32cb2 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -14,7 +14,7 @@\n #include \"object.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"parse-options.h\"\n #include \"log-tree.h\"\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 623a52a45f8..90ec1de78f9 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"refs/refs-internal.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"string-list.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 758bc6d0f24..84f7fa53424 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -28,7 +28,7 @@\n #include \"diff.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"advice.h\"\n #include \"branch.h\"\n #include \"list-objects-filter-options.h\"\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 4742b27d16e..cf2ea4b4993 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -19,7 +19,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"tag.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex e33acfc4ee4..b92fd4710a9 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static char *create_temp_file(struct object_id *oid)\n {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex e905d5f4e19..7bf395eec84 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -9,7 +9,7 @@\n #include \"git-zlib.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"delta.h\"\n #include \"pack.h\"\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 678e2ecc2c2..55406a539e7 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -17,7 +17,7 @@\n #include \"tmp-objdir.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int odb_transaction_nesting;\n \ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 9accf157b44..2e623f8627a 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -14,7 +14,7 @@\n #include \"fetch-pack.h\"\n #include \"remote.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct {\n \tenum bundle_list_heuristic heuristic;\ndiff --git a/bundle.c b/bundle.c\nindex 2ce7525f90d..e09e3c2f58c 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -7,7 +7,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/cache-tree.c b/cache-tree.c\nindex fa3858e2829..9786b32b3a1 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -10,7 +10,7 @@\n #include \"cache-tree.h\"\n #include \"bulk-checkin.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\ndiff --git a/combine-diff.c b/combine-diff.c\nindex dfae9f7995d..cf23a753407 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -2,7 +2,7 @@\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"convert.h\"\n #include \"diff.h\"\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 12d32cdad1d..6ced5b366e7 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -13,7 +13,7 @@\n #include \"refs.h\"\n #include \"hash-lookup.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"alloc.h\"\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 0e661db1b54..78ab7b875b2 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -1,7 +1,7 @@\n #ifndef COMMIT_GRAPH_H\n #define COMMIT_GRAPH_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n #define GIT_TEST_COMMIT_GRAPH \"GIT_TEST_COMMIT_GRAPH\"\ndiff --git a/commit.c b/commit.c\nindex e915b2b9a12..1d30f8ce15a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -9,7 +9,7 @@\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/config.c b/config.c\nindex b18b5617fcd..883dd066827 100644\n--- a/config.c\n+++ b/config.c\n@@ -31,7 +31,7 @@\n #include \"hashmap.h\"\n #include \"string-list.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"path.h\"\n #include \"utf8.h\"\ndiff --git a/connected.c b/connected.c\nindex 4415388beba..18c13245d8e 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"run-command.h\"\n #include \"sigchain.h\"\n #include \"connected.h\"\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 765ad689678..ea7fe1c8db7 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -77,7 +77,7 @@\n |\n - diff_setup\n + repo_diff_setup\n-// object-store.h\n+// odb.h\n |\n - read_object_file\n + repo_read_object_file\ndiff --git a/diagnose.c b/diagnose.c\nindex d08d5643aac..ad0d5c12465 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -7,7 +7,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"strvec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"repository.h\"\ndiff --git a/diff.c b/diff.c\nindex 90e8003dd11..3af108115b3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -23,7 +23,7 @@\n #include \"color.h\"\n #include \"run-command.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"userdiff.h\"\n #include \"submodule.h\"\n #include \"hashmap.h\"\ndiff --git a/entry.c b/entry.c\nindex f36ec5ad242..75d55038d7c 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -1,7 +1,7 @@\n #define USE_THE_REPOSITORY_VARIABLE\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex fa4231fee74..cf157f5d7e5 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -24,7 +24,7 @@\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"connected.h\"\n #include \"fetch-negotiator.h\"\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 501b5acdd44..1a8c972adf3 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -6,7 +6,7 @@\n #include \"environment.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"diff.h\"\n #include \"diff-merges.h\"\n #include \"hex.h\"\ndiff --git a/fsck.c b/fsck.c\nindex 8dc8472ceb3..e69baab3af7 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"dir.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"object.h\"\ndiff --git a/grep.c b/grep.c\nindex f8d535182c3..dc77e6c4631 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"grep.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\ndiff --git a/http-backend.c b/http-backend.c\nindex 0c575aa88aa..ad8c4037493 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -18,7 +18,7 @@\n #include \"url.h\"\n #include \"strvec.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"protocol.h\"\n #include \"date.h\"\n #include \"write-or-die.h\"\ndiff --git a/http-push.c b/http-push.c\nindex f9e67cabd4b..d1b1bb23711 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -20,7 +20,7 @@\n #include \"url.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n \n #ifdef EXPAT_NEEDS_XMLPARSE_H\ndiff --git a/http-walker.c b/http-walker.c\nindex c374e6b2056..05fb9ce714a 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -10,7 +10,7 @@\n #include \"transport.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct alt_base {\n \tchar *base;\ndiff --git a/http.c b/http.c\nindex 5e15bbab3f1..8f4f701a818 100644\n--- a/http.c\n+++ b/http.c\n@@ -19,7 +19,7 @@\n #include \"packfile.h\"\n #include \"string-list.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tempfile.h\"\n \n static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 78b397bc194..80fe48a52c8 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -12,7 +12,7 @@\n #include \"oidmap.h\"\n #include \"oidset.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n /* Remember to update object flag allocation in object.h */\n /*\ndiff --git a/list-objects.c b/list-objects.c\nindex 597114281f6..c50b9578584 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -14,7 +14,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace.h\"\n #include \"environment.h\"\n \ndiff --git a/loose.c b/loose.c\nindex fe65d5b9b0f..fab4041c03d 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"hash.h\"\n #include \"path.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"wrapper.h\"\ndiff --git a/mailmap.c b/mailmap.c\nindex 9e2642a043b..b18e74c2110 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -6,7 +6,7 @@\n #include \"string-list.h\"\n #include \"mailmap.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n char *git_mailmap_file;\ndiff --git a/match-trees.c b/match-trees.c\nindex 72922d5d64e..4704f95c340 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -7,7 +7,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n static int score_missing(unsigned mode)\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 53f36dbc175..ba8a3fdfd82 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -4,7 +4,7 @@\n #include \"merge-ll.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 47b3d1730ec..9f693ab1d36 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -39,7 +39,7 @@\n #include \"mem-pool.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/meson.build b/meson.build\nindex 596f5ac7110..3fad0e39987 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -396,8 +396,8 @@ libgit_sources = [\n   'object-file-convert.c',\n   'object-file.c',\n   'object-name.c',\n-  'object-store.c',\n   'object.c',\n+  'odb.c',\n   'oid-array.c',\n   'oidmap.c',\n   'oidset.c',\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 150241b15e0..344f67762b8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"notes-cache.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"repository.h\"\n #include \"commit.h\"\ndiff --git a/notes-merge.c b/notes-merge.c\nindex dae8e6a281a..de6a52e2e7f 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -8,7 +8,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"diff.h\"\ndiff --git a/notes.c b/notes.c\nindex 0a128f1de98..fc000e501d2 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -8,7 +8,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"strbuf.h\"\n #include \"tree-walk.h\"\ndiff --git a/object-file.c b/object-file.c\nindex 6bad1d3dd1c..2d3af8a77c0 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -21,7 +21,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidtree.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/object-file.h b/object-file.h\nindex 9a18859b2e0..5066638f8ec 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -3,7 +3,7 @@\n \n #include \"git-zlib.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct index_state;\n \ndiff --git a/object-store.c b/odb.c\nsimilarity index 99%\nrename from object-store.c\nrename to odb.c\nindex 5c04a1018f7..d1025ac182d 100644\n--- a/object-store.c\n+++ b/odb.c\n@@ -13,7 +13,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/object-store.h b/odb.h\nsimilarity index 99%\nrename from object-store.h\nrename to odb.h\nindex d199d757d76..6f56b168e46 100644\n--- a/object-store.h\n+++ b/odb.h\n@@ -1,5 +1,5 @@\n-#ifndef OBJECT_STORE_H\n-#define OBJECT_STORE_H\n+#ifndef ODB_H\n+#define ODB_H\n \n #include \"hashmap.h\"\n #include \"object.h\"\n@@ -352,4 +352,4 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n-#endif /* OBJECT_STORE_H */\n+#endif /* ODB_H */\ndiff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c\nindex 609a343ee3e..d2a92f34d98 100644\n--- a/oss-fuzz/fuzz-pack-idx.c\n+++ b/oss-fuzz/fuzz-pack-idx.c\n@@ -1,5 +1,5 @@\n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n \n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 7f400ee0121..37648b57125 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -4,7 +4,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex ac6d62b980c..a695a794e9b 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"repository.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects-filter-options.h\"\n #include \"midx.h\"\n #include \"config.h\"\ndiff --git a/pack-check.c b/pack-check.c\nindex 874897d6cba..67cb2cf72f2 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -8,7 +8,7 @@\n #include \"progress.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct idx_entry {\n \toff_t                offset;\ndiff --git a/pack-mtimes.c b/pack-mtimes.c\nindex 20900ca88d3..8e1f2dec0ef 100644\n--- a/pack-mtimes.c\n+++ b/pack-mtimes.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-mtimes.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 475a2d67ce3..1ac8644201b 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -1,7 +1,7 @@\n #ifndef PACK_OBJECTS_H\n #define PACK_OBJECTS_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"thread-utils.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex ffcde48870d..0cc422a1e67 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-revindex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\ndiff --git a/packfile.c b/packfile.c\nindex 60661ad0095..346c2f9ce90 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -19,7 +19,7 @@\n #include \"tree-walk.h\"\n #include \"tree.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"midx.h\"\n #include \"commit-graph.h\"\n #include \"pack-revindex.h\"\ndiff --git a/packfile.h b/packfile.h\nindex 826eb7f475f..53c3b7d3b43 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -3,10 +3,10 @@\n \n #include \"list.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n-/* in object-store.h */\n+/* in odb.h */\n struct object_info;\n \n struct packed_git {\ndiff --git a/path.c b/path.c\nindex c347829aa66..7f56eaf9930 100644\n--- a/path.c\n+++ b/path.c\n@@ -15,7 +15,7 @@\n #include \"submodule-config.h\"\n #include \"path.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"lockfile.h\"\n #include \"exec-cmd.h\"\n \ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 9d058586dfa..2baa286bfd0 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"config.h\"\n #include \"trace2.h\"\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 9b8db37a210..3022f69a1bd 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -6,7 +6,7 @@\n #include \"hash.h\"\n #include \"hex.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"string-list.h\"\n #include \"strbuf.h\"\ndiff --git a/read-cache.c b/read-cache.c\nindex c0bb760ad47..c3fa9686766 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -20,7 +20,7 @@\n #include \"refs.h\"\n #include \"dir.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 7a274633cfc..4ce45440ad1 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"wildmatch.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"repo-settings.h\"\n #include \"repository.h\"\ndiff --git a/reflog.c b/reflog.c\nindex 15d81ebea97..4f8a3b717cd 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -5,7 +5,7 @@\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"parse-options.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"reflog.h\"\n #include \"refs.h\"\n #include \"revision.h\"\ndiff --git a/refs.c b/refs.c\nindex 5f6a386cc93..0ff0e582a6b 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"hook.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"path.h\"\n #include \"submodule.h\"\ndiff --git a/remote.c b/remote.c\nindex 4099183cacd..17a842f5684 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/replace-object.c b/replace-object.c\nindex f8c5f68837f..3eae0510745 100644\n--- a/replace-object.c\n+++ b/replace-object.c\n@@ -2,7 +2,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"oidmap.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"refs.h\"\n #include \"repository.h\"\ndiff --git a/replace-object.h b/replace-object.h\nindex 3052e96a620..4c9f2a2383d 100644\n--- a/replace-object.h\n+++ b/replace-object.h\n@@ -3,7 +3,7 @@\n \n #include \"oidmap.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct replace_object {\n \tstruct oidmap_entry original;\ndiff --git a/repository.c b/repository.c\nindex 7528beccddf..13426db0f2b 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"object.h\"\n #include \"lockfile.h\"\ndiff --git a/rerere.c b/rerere.c\nindex 3cd37c5f0ae..951e4bf8b41 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -18,7 +18,7 @@\n #include \"path.h\"\n #include \"pathspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strmap.h\"\n \n #define RESOLVED 0\ndiff --git a/revision.c b/revision.c\nindex 2c36a9c179e..cdefe7d6e48 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -8,7 +8,7 @@\n #include \"hex.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"tag.h\"\n #include \"blob.h\"\ndiff --git a/send-pack.c b/send-pack.c\nindex 86592ce526d..abca2dd38a7 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"run-command.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex 1ee0abbd451..2432d0a39ec 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -13,7 +13,7 @@\n #include \"dir.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"pager.h\"\n #include \"commit.h\"\ndiff --git a/server-info.c b/server-info.c\nindex d6cd20a39d7..9bb30d9ab71 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -11,7 +11,7 @@\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"server-info.h\"\n #include \"strbuf.h\"\n #include \"tempfile.h\"\ndiff --git a/shallow.c b/shallow.c\nindex faeeeb45f98..d379756e39a 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -5,7 +5,7 @@\n #include \"repository.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"pkt-line.h\"\ndiff --git a/streaming.c b/streaming.c\nindex 6d6512e2e0d..81c42673a23 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -10,7 +10,7 @@\n #include \"streaming.h\"\n #include \"repository.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"packfile.h\"\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex b30d9365fbd..9c80f9f7b66 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -13,7 +13,7 @@\n #include \"submodule.h\"\n #include \"strbuf.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/submodule.c b/submodule.c\nindex ead3fb5dadc..9b1018877df 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -27,7 +27,7 @@\n #include \"parse-options.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c\nindex 76c2f4eba85..611a13a3261 100644\n--- a/t/helper/test-find-pack.c\n+++ b/t/helper/test-find-pack.c\n@@ -2,7 +2,7 @@\n \n #include \"test-tool.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c\nindex fdf1b13437b..d51aaa3dc40 100644\n--- a/t/helper/test-pack-mtimes.c\n+++ b/t/helper/test-pack-mtimes.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"strbuf.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pack-mtimes.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex 34f1aee5581..dba227259a2 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -1,7 +1,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n /*\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 53b633e2ba6..ef5339bbee9 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"commit-graph.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"bloom.h\"\n #include \"setup.h\"\n \ndiff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c\nindex ac81390899a..da2aa036b57 100644\n--- a/t/helper/test-read-midx.c\n+++ b/t/helper/test-read-midx.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"midx.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"packfile.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 4cfc7c90b59..2920ca59d72 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -5,7 +5,7 @@\n #include \"refs.h\"\n #include \"setup.h\"\n #include \"worktree.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"strbuf.h\"\ndiff --git a/tag.c b/tag.c\nindex 05be39067cf..5f6868bf7b1 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -5,7 +5,7 @@\n #include \"environment.h\"\n #include \"tag.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"blob.h\"\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex 056484404be..bef2f917cd2 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -10,7 +10,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"quote.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n struct tmp_objdir {\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 90655d52378..34b0fff4873 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -6,7 +6,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace2.h\"\n #include \"tree.h\"\n #include \"pathspec.h\"\ndiff --git a/tree.c b/tree.c\nindex b85f56267fb..341b7c2ff3f 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"tree.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"alloc.h\"\n #include \"tree-walk.h\"\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 471837f0329..f38c761ab98 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -26,7 +26,7 @@\n #include \"symlinks.h\"\n #include \"trace2.h\"\n #include \"fsmonitor.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"entry.h\"\n #include \"parallel-checkout.h\"\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 26f29b85b55..e994d6a901b 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -10,7 +10,7 @@\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/walker.c b/walker.c\nindex b470d43e54d..a8abe8a2e78 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"walker.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"strbuf.h\"\n #include \"tree.h\"\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 1edcd319e6e..01e6e378ea6 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"config.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"xdiff-interface.h\"\n #include \"xdiff/xtypes.h\"\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519717","messageId":"20250605-pks-object-store-wo-the-repository-v5-7-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 07/17] odb: get rid of `the_repository` in `odb_mkstemp()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:57Z","receivedAt":"2025-06-05T06:47:06Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `odb_mkstemp()` by\npassing in the object database as a parameter and adjusting all callers.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/fast-import.c |  3 ++-\n builtin/index-pack.c  |  2 +-\n bundle-uri.c          |  3 ++-\n odb.c                 |  9 +++++----\n odb.h                 |  7 ++++---\n pack-bitmap-write.c   |  3 ++-\n pack-write.c          | 10 ++++++----\n 7 files changed, 22 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 52c792488e1..413304db9b5 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -763,7 +763,8 @@ static void start_packfile(void)\n \tstruct packed_git *p;\n \tint pack_fd;\n \n-\tpack_fd = odb_mkstemp(&tmp_file, \"pack/tmp_pack_XXXXXX\");\n+\tpack_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n+\t\t\t      \"pack/tmp_pack_XXXXXX\");\n \tFLEX_ALLOC_STR(p, pack_name, tmp_file.buf);\n \tstrbuf_release(&tmp_file);\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 1aabe6b8ee2..4d4d989eb1a 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -362,7 +362,7 @@ static const char *open_pack_file(const char *pack_name)\n \t\tinput_fd = 0;\n \t\tif (!pack_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\toutput_fd = odb_mkstemp(&tmp_file,\n+\t\t\toutput_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n \t\t\t\t\t\t\"pack/tmp_pack_XXXXXX\");\n \t\t\tpack_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 2e623f8627a..f94e780e967 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -278,7 +278,8 @@ static char *find_temp_filename(void)\n \t * Find a temporary filename that is available. This is briefly\n \t * racy, but unlikely to collide.\n \t */\n-\tfd = odb_mkstemp(&name, \"bundles/tmp_uri_XXXXXX\");\n+\tfd = odb_mkstemp(the_repository->objects, &name,\n+\t\t\t \"bundles/tmp_uri_XXXXXX\");\n \tif (fd < 0) {\n \t\twarning(_(\"failed to create temporary file\"));\n \t\treturn NULL;\ndiff --git a/odb.c b/odb.c\nindex 3a3ceed5508..73410920a88 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -63,7 +63,8 @@ static const struct cached_object *find_cached_object(struct object_database *ob\n \treturn NULL;\n }\n \n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern)\n {\n \tint fd;\n \t/*\n@@ -71,15 +72,15 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n \t * restrictive except to remove write permission.\n \t */\n \tint mode = 0444;\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n \tfd = git_mkstemp_mode(temp_filename->buf, mode);\n \tif (0 <= fd)\n \t\treturn fd;\n \n \t/* slow path */\n \t/* some mkstemp implementations erase temp_filename on failure */\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n-\tsafe_create_leading_directories(the_repository, temp_filename->buf);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n+\tsafe_create_leading_directories(odb->repo, temp_filename->buf);\n \treturn xmkstemp_mode(temp_filename->buf, mode);\n }\n \ndiff --git a/odb.h b/odb.h\nindex 13f5da45f54..5de952608f3 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -201,12 +201,13 @@ void odb_clear(struct object_database *o);\n struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);\n \n /*\n- * Create a temporary file rooted in the object database directory, or\n- * die on failure. The filename is taken from \"pattern\", which should have the\n+ * Create a temporary file rooted in the primary alternate's directory, or die\n+ * on failure. The filename is taken from \"pattern\", which should have the\n  * usual \"XXXXXX\" trailer, and the resulting filename is written into the\n  * \"template\" buffer. Returns the open descriptor.\n  */\n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern);\n \n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 37648b57125..c847369eaaa 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1052,7 +1052,8 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n \n \tstruct bitmap_disk_header header;\n \n-\tint fd = odb_mkstemp(&tmp_file, \"pack/tmp_bitmap_XXXXXX\");\n+\tint fd = odb_mkstemp(writer->repo->objects, &tmp_file,\n+\t\t\t     \"pack/tmp_bitmap_XXXXXX\");\n \n \tif (writer->pseudo_merges_nr)\n \t\toptions |= BITMAP_OPT_PSEUDO_MERGES;\ndiff --git a/pack-write.c b/pack-write.c\nindex 6b06315f80a..eccdc798e36 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -84,7 +84,8 @@ const char *write_idx_file(struct repository *repo,\n \t} else {\n \t\tif (!index_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_idx_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_idx_XXXXXX\");\n \t\t\tindex_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(index_name);\n@@ -259,7 +260,8 @@ char *write_rev_file_order(struct repository *repo,\n \tif (flags & WRITE_REV) {\n \t\tif (!rev_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_rev_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_rev_XXXXXX\");\n \t\t\tpath = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(rev_name);\n@@ -342,7 +344,7 @@ static char *write_mtimes_file(struct repository *repo,\n \tif (!to_pack)\n \t\tBUG(\"cannot call write_mtimes_file with NULL packing_data\");\n \n-\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n \tmtimes_name = strbuf_detach(&tmp_file, NULL);\n \tf = hashfd(repo->hash_algo, fd, mtimes_name);\n \n@@ -531,7 +533,7 @@ struct hashfile *create_tmp_packfile(struct repository *repo,\n \tstruct strbuf tmpname = STRBUF_INIT;\n \tint fd;\n \n-\tfd = odb_mkstemp(&tmpname, \"pack/tmp_pack_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmpname, \"pack/tmp_pack_XXXXXX\");\n \t*pack_tmp_name = strbuf_detach(&tmpname, NULL);\n \treturn hashfd(repo->hash_algo, fd, *pack_tmp_name);\n }\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519718","messageId":"20250605-pks-object-store-wo-the-repository-v5-6-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 06/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:56Z","receivedAt":"2025-06-05T06:47:06Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `assert_oid_type()` by\npassing in the object database as a parameter and adjusting all callers.\n\nRename the function to `odb_assert_oid_type()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-tree.c | 2 +-\n commit.c              | 2 +-\n odb.c                 | 5 +++--\n odb.h                 | 3 ++-\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 546069f8682..31cfd9bd15d 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -48,7 +48,7 @@ static int parse_parent_arg_callback(const struct option *opt,\n \tif (repo_get_oid_commit(the_repository, arg, &oid))\n \t\tdie(_(\"not a valid object name %s\"), arg);\n \n-\tassert_oid_type(&oid, OBJ_COMMIT);\n+\todb_assert_oid_type(the_repository->objects, &oid, OBJ_COMMIT);\n \tnew_parent(lookup_commit(the_repository, &oid), parents);\n \treturn 0;\n }\ndiff --git a/commit.c b/commit.c\nindex 1d30f8ce15a..aa65183d8b6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1706,7 +1706,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,\n \t/* Not having i18n.commitencoding is the same as having utf-8 */\n \tencoding_is_utf8 = is_encoding_utf8(git_commit_encoding);\n \n-\tassert_oid_type(tree, OBJ_TREE);\n+\todb_assert_oid_type(the_repository->objects, tree, OBJ_TREE);\n \n \tif (memchr(msg, '\\0', msg_len))\n \t\treturn error(\"a NUL byte in commit log message not allowed.\");\ndiff --git a/odb.c b/odb.c\nindex 483b9b38414..3a3ceed5508 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -946,9 +946,10 @@ int has_object(struct repository *r, const struct object_id *oid,\n \treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n }\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect)\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex 941329c6943..13f5da45f54 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -302,7 +302,8 @@ enum {\n int has_object(struct repository *r, const struct object_id *oid,\n \t       unsigned flags);\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect);\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect);\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519719","messageId":"20250605-pks-object-store-wo-the-repository-v5-8-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:58Z","receivedAt":"2025-06-05T06:47:06Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions to manage alternates all depend on `the_repository`.\nRefactor them to accept an object database as parameter and adjusting\nall callers. The functions are renamed accordingly.\n\nNote that right now the situation is still somewhat weird because we end\nup using the path provided by the object store's repository anyway. This\nwill be adapted over time though so that we instead store the path to\nthe primary object directory in the object database itself.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/clone.c           | 10 +++++----\n builtin/fsck.c            |  6 +++---\n builtin/grep.c            |  2 +-\n builtin/repack.c          |  3 ++-\n commit-graph.c            |  4 ++--\n loose.c                   |  2 +-\n object-file.c             | 10 ++++-----\n object-name.c             |  2 +-\n odb.c                     | 44 ++++++++++++++++++---------------------\n odb.h                     | 53 ++++++++++++++++++++++++++++++++---------------\n packfile.c                |  4 ++--\n submodule.c               |  3 ++-\n t/helper/test-ref-store.c |  2 +-\n tmp-objdir.c              |  2 +-\n 14 files changed, 83 insertions(+), 64 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 1eafeefb48d..3aabdf6570b 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -171,7 +171,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)\n \t} else {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstrbuf_addf(&sb, \"%s/objects\", ref_git);\n-\t\tadd_to_alternates_file(sb.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \t}\n \n@@ -212,12 +212,14 @@ static void copy_alternates(struct strbuf *src, const char *src_repo)\n \t\tif (!line.len || line.buf[0] == '#')\n \t\t\tcontinue;\n \t\tif (is_absolute_path(line.buf)) {\n-\t\t\tadd_to_alternates_file(line.buf);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   line.buf);\n \t\t\tcontinue;\n \t\t}\n \t\tabs_path = mkpathdup(\"%s/objects/%s\", src_repo, line.buf);\n \t\tif (!normalize_path_copy(abs_path, abs_path))\n-\t\t\tadd_to_alternates_file(abs_path);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   abs_path);\n \t\telse\n \t\t\twarning(\"skipping invalid relative alternate: %s/%s\",\n \t\t\t\tsrc_repo, line.buf);\n@@ -352,7 +354,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)\n \t\tstruct strbuf alt = STRBUF_INIT;\n \t\tget_common_dir(&alt, src_repo);\n \t\tstrbuf_addstr(&alt, \"/objects\");\n-\t\tadd_to_alternates_file(alt.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, alt.buf);\n \t\tstrbuf_release(&alt);\n \t} else {\n \t\tstruct strbuf src = STRBUF_INIT;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 9abd7b25580..014aa1344e2 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -997,7 +997,7 @@ int cmd_fsck(int argc,\n \t\tfor_each_packed_object(the_repository,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (source = the_repository->objects->sources; source; source = source->next)\n \t\t\tfsck_object_dir(source->path);\n \n@@ -1108,7 +1108,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_commit_graph) {\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n@@ -1126,7 +1126,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_multi_pack_index) {\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex a1d7ee7af39..336cfcab6fb 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -462,7 +462,7 @@ static int grep_submodule(struct grep_opt *opt,\n \n \t/*\n \t * NEEDSWORK: repo_read_gitmodules() might call\n-\t * add_to_alternates_memory() via config_from_gitmodules(). This\n+\t * odb_add_to_alternates_memory() via config_from_gitmodules(). This\n \t * operation causes a race condition with concurrent object readings\n \t * performed by the worker threads. That's why we need obj_read_lock()\n \t * here. It should be removed once it's no longer necessary to add the\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 16782320058..8145474cf8d 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -1256,7 +1256,8 @@ int cmd_repack(int argc,\n \tif (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)\n \t\tdie(_(incremental_bitmap_conflict_error));\n \n-\tif (write_bitmaps && po_args.local && has_alt_odb(the_repository)) {\n+\tif (write_bitmaps && po_args.local &&\n+\t    odb_has_alternates(the_repository->objects)) {\n \t\t/*\n \t\t * When asked to do a local repack, but we have\n \t\t * packfiles that are inherited from an alternate, then\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 6ced5b366e7..59265f89385 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -649,7 +649,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tcount = st->st_size / (the_hash_algo->hexsz + 1);\n \tCALLOC_ARRAY(oids, count);\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (i = 0; i < count; i++) {\n \t\tstruct odb_source *source;\n@@ -778,7 +778,7 @@ static int prepare_commit_graph(struct repository *r)\n \tif (!commit_graph_compatible(r))\n \t\treturn 0;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources;\n \t     !r->objects->commit_graph && source;\n \t     source = source->next)\ndiff --git a/loose.c b/loose.c\nindex fab4041c03d..519f5db7935 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -112,7 +112,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tprepare_alt_odb(repo);\n+\todb_prepare_alternates(repo->objects);\n \n \tfor (source = repo->objects->sources; source; source = source->next) {\n \t\tif (load_one_loose_object_map(repo, source) < 0) {\ndiff --git a/object-file.c b/object-file.c\nindex 2d3af8a77c0..04da19a1a3b 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -106,7 +106,7 @@ static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n \tstruct odb_source *source;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (source = the_repository->objects->sources->next; source; source = source->next) {\n \t\tif (check_and_freshen_odb(source, oid, freshen))\n \t\t\treturn 1;\n@@ -205,7 +205,7 @@ static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \tstruct odb_source *source;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources; source; source = source->next) {\n \t\t*path = odb_loose_path(source, &buf, oid);\n \t\tif (!lstat(*path, st))\n@@ -227,7 +227,7 @@ static int open_loose_object(struct repository *r,\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources; source; source = source->next) {\n \t\t*path = odb_loose_path(source, &buf, oid);\n \t\tfd = git_open(*path);\n@@ -246,7 +246,7 @@ static int quick_has_loose(struct repository *r,\n {\n \tstruct odb_source *source;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources; source; source = source->next) {\n \t\tif (oidtree_contains(odb_loose_cache(source, oid), oid))\n \t\t\treturn 1;\n@@ -1439,7 +1439,7 @@ int for_each_loose_object(each_loose_object_fn cb, void *data,\n {\n \tstruct odb_source *source;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\tint r = for_each_loose_file_in_objdir(source->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\ndiff --git a/object-name.c b/object-name.c\nindex 544634d0f40..381536e900e 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -376,7 +376,7 @@ static int init_object_disambiguation(struct repository *r,\n \tds->hex_pfx[len] = '\\0';\n \tds->repo = r;\n \tds->bin_pfx.algo = algo ? hash_algo_by_ptr(algo) : GIT_HASH_UNKNOWN;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \treturn 0;\n }\n \ndiff --git a/odb.c b/odb.c\nindex 73410920a88..42862ef7fe7 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -272,10 +272,11 @@ static void read_info_alternates(struct object_database *odb,\n \tfree(path);\n }\n \n-void add_to_alternates_file(const char *reference)\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *reference)\n {\n \tstruct lock_file lock = LOCK_INIT;\n-\tchar *alts = repo_git_path(the_repository, \"objects/info/alternates\");\n+\tchar *alts = repo_git_path(odb->repo, \"objects/info/alternates\");\n \tFILE *in, *out;\n \tint found = 0;\n \n@@ -308,22 +309,23 @@ void add_to_alternates_file(const char *reference)\n \t\tfprintf_or_die(out, \"%s\\n\", reference);\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n-\t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n+\t\tif (odb->loaded_alternates)\n+\t\t\tlink_alt_odb_entries(odb, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n }\n \n-void add_to_alternates_memory(const char *reference)\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *reference)\n {\n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(odb);\n \n-\tlink_alt_odb_entries(the_repository->objects, reference,\n+\tlink_alt_odb_entries(odb, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -335,7 +337,7 @@ struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n@@ -379,12 +381,6 @@ void restore_primary_odb(struct odb_source *restore_alt, const char *old_path)\n \tfree_object_directory(cur_alt);\n }\n \n-/*\n- * Compute the exact path an alternate is at and returns it. In case of\n- * error NULL is returned and the human readable error is added to `err`\n- * `path` may be relative and should point to $GIT_DIR.\n- * `err` must not be null.\n- */\n char *compute_alternate_path(const char *path, struct strbuf *err)\n {\n \tchar *ref_git = NULL;\n@@ -455,7 +451,7 @@ struct odb_source *odb_find_source(struct object_database *odb, const char *obj_\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(odb->repo);\n+\todb_prepare_alternates(odb);\n \tfor (source = odb->sources; source; source = source->next) {\n \t\tstrbuf_realpath(&odb_path_real, source->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n@@ -573,7 +569,7 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \tstruct odb_source *alternate;\n \tint r = 0;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (alternate = the_repository->objects->sources->next; alternate; alternate = alternate->next) {\n \t\tr = fn(alternate, cb);\n \t\tif (r)\n@@ -582,21 +578,21 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \treturn r;\n }\n \n-void prepare_alt_odb(struct repository *r)\n+void odb_prepare_alternates(struct object_database *odb)\n {\n-\tif (r->objects->loaded_alternates)\n+\tif (odb->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(odb, odb->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r->objects, r->objects->sources->path, 0);\n-\tr->objects->loaded_alternates = 1;\n+\tread_info_alternates(odb, odb->sources->path, 0);\n+\todb->loaded_alternates = 1;\n }\n \n-int has_alt_odb(struct repository *r)\n+int odb_has_alternates(struct object_database *odb)\n {\n-\tprepare_alt_odb(r);\n-\treturn !!r->objects->sources->next;\n+\todb_prepare_alternates(odb);\n+\treturn !!odb->sources->next;\n }\n \n int obj_read_use_lock = 0;\ndiff --git a/odb.h b/odb.h\nindex 5de952608f3..eba16929a81 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -13,6 +13,14 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n+/*\n+ * Compute the exact path an alternate is at and returns it. In case of\n+ * error NULL is returned and the human readable error is added to `err`\n+ * `path` may be relative and should point to $GIT_DIR.\n+ * `err` must not be null.\n+ */\n+char *compute_alternate_path(const char *path, struct strbuf *err);\n+\n /*\n  * The source is the part of the object database that stores the actual\n  * objects. It thus encapsulates the logic to read and write the specific\n@@ -65,27 +73,11 @@ struct odb_source {\n \tchar *path;\n };\n \n-void prepare_alt_odb(struct repository *r);\n-int has_alt_odb(struct repository *r);\n-char *compute_alternate_path(const char *path, struct strbuf *err);\n typedef int alt_odb_fn(struct odb_source *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n \n-/*\n- * Add the directory to the on-disk alternates file; the new entry will also\n- * take effect in the current process.\n- */\n-void add_to_alternates_file(const char *dir);\n-\n-/*\n- * Add the directory to the in-memory list of alternates (along with any\n- * recursive alternates it points to), but do not modify the on-disk alternates\n- * file.\n- */\n-void add_to_alternates_memory(const char *dir);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -124,7 +116,7 @@ struct object_database {\n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"sources\" list when prepare_alt_odb() is run.\n+\t * populate the \"sources\" list when odb_prepare_alternates() is run.\n \t */\n \tchar *alternate_db;\n \n@@ -209,6 +201,33 @@ struct odb_source *odb_find_source(struct object_database *odb, const char *obj_\n int odb_mkstemp(struct object_database *odb,\n \t\tstruct strbuf *temp_filename, const char *pattern);\n \n+/*\n+ * Prepare alternate object sources for the given database by reading\n+ * \"objects/info/alternates\" and opening the respective sources.\n+ */\n+void odb_prepare_alternates(struct object_database *odb);\n+\n+/*\n+ * Check whether the object database has any alternates. The primary object\n+ * source does not count as alternate.\n+ */\n+int odb_has_alternates(struct object_database *odb);\n+\n+/*\n+ * Add the directory to the on-disk alternates file; the new entry will also\n+ * take effect in the current process.\n+ */\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *dir);\n+\n+/*\n+ * Add the directory to the in-memory list of alternate sources (along with any\n+ * recursive alternates it points to), but do not modify the on-disk alternates\n+ * file.\n+ */\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *dir);\n+\n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\n \t\t\t    enum object_type *type,\ndiff --git a/packfile.c b/packfile.c\nindex 346c2f9ce90..ac0e29e99b9 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1034,7 +1034,7 @@ static void prepare_packed_git(struct repository *r)\n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources; source; source = source->next) {\n \t\tint local = (source == r->objects->sources);\n \t\tprepare_multi_pack_index_one(r, source->path, local);\n@@ -1059,7 +1059,7 @@ void reprepare_packed_git(struct repository *r)\n \t * the lifetime of the process.\n \t */\n \tr->objects->loaded_alternates = 0;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (source = r->objects->sources; source; source = source->next)\n \t\todb_clear_loose_cache(source);\ndiff --git a/submodule.c b/submodule.c\nindex 9b1018877df..386be234230 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -189,7 +189,8 @@ int register_all_submodule_odb_as_alternates(void)\n \tint ret = added_submodule_odb_paths.nr;\n \n \tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\tadd_to_alternates_memory(added_submodule_odb_paths.items[i].string);\n+\t\todb_add_to_alternates_memory(the_repository->objects,\n+\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n \tif (ret) {\n \t\tstring_list_clear(&added_submodule_odb_paths, 0);\n \t\ttrace2_data_intmax(\"submodule\", the_repository,\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 2920ca59d72..8d9a271845c 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -79,7 +79,7 @@ static const char **get_store(const char **argv, struct ref_store **refs)\n \t\tif (!repo_submodule_path_append(the_repository,\n \t\t\t\t\t\t&sb, gitdir, \"objects/\"))\n \t\t\tdie(\"computing submodule path failed\");\n-\t\tadd_to_alternates_memory(sb.buf);\n+\t\todb_add_to_alternates_memory(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \n \t\t*refs = repo_get_submodule_ref_store(the_repository, gitdir);\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex bef2f917cd2..4120badf5ce 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -304,7 +304,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)\n \n void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n {\n-\tadd_to_alternates_memory(t->path.buf);\n+\todb_add_to_alternates_memory(t->repo->objects, t->path.buf);\n }\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519721","messageId":"20250605-pks-object-store-wo-the-repository-v5-10-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 10/17] odb: get rid of `the_repository` when handling the primary source","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:47:00Z","receivedAt":"2025-06-05T06:47:07Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions `set_temporary_primary_odb()` and `restore_primary_odb()`\nare responsible for managing a temporary primary source for the\ndatabase. Both of these functions implicitly rely on `the_repository`.\n\nRefactor them to instead take an explicit object database parameter as\nargument and adjust callers. Rename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 27 +++++++++++++++------------\n odb.h        | 26 +++++++++++++++-----------\n tmp-objdir.c | 10 ++++++----\n 3 files changed, 36 insertions(+), 27 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex d83f7416e9e..b154e91953d 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -329,7 +329,8 @@ void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,\n+\t\t\t\t\t\t    const char *dir, int will_destroy)\n {\n \tstruct odb_source *source;\n \n@@ -337,14 +338,14 @@ struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\todb_prepare_alternates(the_repository->objects);\n+\todb_prepare_alternates(odb);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n \tsource = xcalloc(1, sizeof(*source));\n-\tsource->odb = the_repository->objects;\n+\tsource->odb = odb;\n \tsource->path = xstrdup(dir);\n \n \t/*\n@@ -353,8 +354,8 @@ struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t */\n \tsource->disable_ref_updates = 1;\n \tsource->will_destroy = will_destroy;\n-\tsource->next = the_repository->objects->sources;\n-\tthe_repository->objects->sources = source;\n+\tsource->next = odb->sources;\n+\todb->sources = source;\n \treturn source->next;\n }\n \n@@ -366,19 +367,21 @@ static void free_object_directory(struct odb_source *source)\n \tfree(source);\n }\n \n-void restore_primary_odb(struct odb_source *restore_alt, const char *old_path)\n+void odb_restore_primary_source(struct object_database *odb,\n+\t\t\t\tstruct odb_source *restore_source,\n+\t\t\t\tconst char *old_path)\n {\n-\tstruct odb_source *cur_alt = the_repository->objects->sources;\n+\tstruct odb_source *cur_source = odb->sources;\n \n-\tif (strcmp(old_path, cur_alt->path))\n+\tif (strcmp(old_path, cur_source->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n-\t\t    old_path, cur_alt->path);\n+\t\t    old_path, cur_source->path);\n \n-\tif (cur_alt->next != restore_alt)\n+\tif (cur_source->next != restore_source)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->sources = restore_alt;\n-\tfree_object_directory(cur_alt);\n+\todb->sources = restore_source;\n+\tfree_object_directory(cur_source);\n }\n \n char *compute_alternate_path(const char *path, struct strbuf *err)\ndiff --git a/odb.h b/odb.h\nindex 7e65e9707c1..4e2d1004f8a 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -73,17 +73,6 @@ struct odb_source {\n \tchar *path;\n };\n \n-/*\n- * Replace the current writable object directory with the specified temporary\n- * object directory; returns the former primary object directory.\n- */\n-struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy);\n-\n-/*\n- * Restore a previous ODB replaced by set_temporary_main_odb.\n- */\n-void restore_primary_odb(struct odb_source *restore_alternate, const char *old_path);\n-\n struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n@@ -187,6 +176,21 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Replace the current writable object directory with the specified temporary\n+ * object directory; returns the former primary source.\n+ */\n+struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,\n+\t\t\t\t\t\t    const char *dir, int will_destroy);\n+\n+/*\n+ * Restore the primary source that was previously replaced by\n+ * `odb_set_temporary_primary_source()`.\n+ */\n+void odb_restore_primary_source(struct object_database *odb,\n+\t\t\t\tstruct odb_source *restore_source,\n+\t\t\t\tconst char *old_path);\n+\n /*\n  * Iterate through all alternates of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex 4120badf5ce..ae01eae9c41 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -47,7 +47,7 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \t\tthe_tmp_objdir = NULL;\n \n \tif (t->prev_source)\n-\t\trestore_primary_odb(t->prev_source, t->path.buf);\n+\t\todb_restore_primary_source(t->repo->objects, t->prev_source, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -279,7 +279,7 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (t->prev_source) {\n \t\tif (t->repo->objects->sources->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_source, t->path.buf);\n+\t\todb_restore_primary_source(t->repo->objects, t->prev_source, t->path.buf);\n \t\tt->prev_source = NULL;\n \t}\n \n@@ -311,7 +311,8 @@ void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n \tif (t->prev_source)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_source = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_source = odb_set_temporary_primary_source(t->repo->objects,\n+\t\t\t\t\t\t\t  t->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n@@ -320,7 +321,8 @@ struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n \tif (!the_tmp_objdir || !the_tmp_objdir->prev_source)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_source, the_tmp_objdir->path.buf);\n+\todb_restore_primary_source(the_tmp_objdir->repo->objects,\n+\t\t\t\t   the_tmp_objdir->prev_source, the_tmp_objdir->path.buf);\n \tthe_tmp_objdir->prev_source = NULL;\n \treturn the_tmp_objdir;\n }\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519723","messageId":"20250605-pks-object-store-wo-the-repository-v5-9-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:46:59Z","receivedAt":"2025-06-05T06:47:08Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"There are a couple of iterator-style functions that execute a callback\nfor each instance of a given set, all of which currently depend on\n`the_repository`. Refactor them to instead take an object database as\nparameter so that we can get rid of this dependency.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/count-objects.c     |  2 +-\n builtin/receive-pack.c      |  3 ++-\n builtin/submodule--helper.c |  3 ++-\n diagnose.c                  |  2 +-\n fetch-pack.c                |  3 ++-\n odb.c                       | 36 +++++++++++++++++++-----------------\n odb.h                       | 23 ++++++++++++++++++-----\n revision.c                  |  3 ++-\n 8 files changed, 47 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex 58e0af433d1..f687647931e 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -159,7 +159,7 @@ int cmd_count_objects(int argc,\n \t\tprintf(\"prune-packable: %lu\\n\", packed_loose);\n \t\tprintf(\"garbage: %lu\\n\", garbage);\n \t\tprintf(\"size-garbage: %s\\n\", garbage_buf.buf);\n-\t\tforeach_alt_odb(print_alternate, NULL);\n+\t\todb_for_each_alternate(the_repository->objects, print_alternate, NULL);\n \t\tstrbuf_release(&loose_buf);\n \t\tstrbuf_release(&pack_buf);\n \t\tstrbuf_release(&garbage_buf);\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 0f5958c4a66..7ea273d93e4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -359,7 +359,8 @@ static void write_head_info(void)\n \n \trefs_for_each_fullref_in(get_main_ref_store(the_repository), \"\",\n \t\t\t\t exclude_patterns, show_ref_cb, &seen);\n-\tfor_each_alternate_ref(show_one_alternate_ref, &seen);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   show_one_alternate_ref, &seen);\n \n \toidset_clear(&seen);\n \tstrvec_clear(&excludes_vector);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 84f7fa53424..7ca483cab52 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1668,7 +1668,8 @@ static void prepare_possible_alternates(const char *sm_name,\n \t\tdie(_(\"Value '%s' for submodule.alternateErrorStrategy is not recognized\"), error_strategy);\n \n \tif (!strcmp(sm_alternate, \"superproject\"))\n-\t\tforeach_alt_odb(add_possible_reference_from_superproject, &sas);\n+\t\todb_for_each_alternate(the_repository->objects,\n+\t\t\t\t       add_possible_reference_from_superproject, &sas);\n \telse if (!strcmp(sm_alternate, \"no\"))\n \t\t; /* do nothing */\n \telse\ndiff --git a/diagnose.c b/diagnose.c\nindex ad0d5c12465..5092bf80d35 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -229,7 +229,7 @@ int create_diagnostics_archive(struct repository *r,\n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n \tdir_file_stats(r->objects->sources, &buf);\n-\tforeach_alt_odb(dir_file_stats, &buf);\n+\todb_for_each_alternate(r->objects, dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \n \tstrbuf_reset(&buf);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex cf157f5d7e5..47fa7fa4c49 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -115,7 +115,8 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,\n \tsize_t i;\n \n \tif (!initialized) {\n-\t\tfor_each_alternate_ref(cache_one_alternate, &cache);\n+\t\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t\t   cache_one_alternate, &cache);\n \t\tinitialized = 1;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex 42862ef7fe7..d83f7416e9e 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -494,8 +494,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n }\n \n static void read_alternate_refs(const char *path,\n-\t\t\t\talternate_ref_fn *cb,\n-\t\t\t\tvoid *data)\n+\t\t\t\todb_for_each_alternate_ref_fn *cb,\n+\t\t\t\tvoid *payload)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tstruct strbuf line = STRBUF_INIT;\n@@ -517,7 +517,7 @@ static void read_alternate_refs(const char *path,\n \t\t\tbreak;\n \t\t}\n \n-\t\tcb(&oid, data);\n+\t\tcb(&oid, payload);\n \t}\n \n \tfclose(fh);\n@@ -526,16 +526,16 @@ static void read_alternate_refs(const char *path,\n }\n \n struct alternate_refs_data {\n-\talternate_ref_fn *fn;\n-\tvoid *data;\n+\todb_for_each_alternate_ref_fn *fn;\n+\tvoid *payload;\n };\n \n static int refs_from_alternate_cb(struct odb_source *alternate,\n-\t\t\t\t  void *data)\n+\t\t\t\t  void *payload)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n-\tstruct alternate_refs_data *cb = data;\n+\tstruct alternate_refs_data *cb = payload;\n \n \tif (!strbuf_realpath(&path, alternate->path, 0))\n \t\tgoto out;\n@@ -549,29 +549,31 @@ static int refs_from_alternate_cb(struct odb_source *alternate,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->data);\n+\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n \treturn 0;\n }\n \n-void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload)\n {\n-\tstruct alternate_refs_data cb;\n-\tcb.fn = fn;\n-\tcb.data = data;\n-\tforeach_alt_odb(refs_from_alternate_cb, &cb);\n+\tstruct alternate_refs_data data;\n+\tdata.fn = cb;\n+\tdata.payload = payload;\n+\todb_for_each_alternate(odb, refs_from_alternate_cb, &data);\n }\n \n-int foreach_alt_odb(alt_odb_fn fn, void *cb)\n+int odb_for_each_alternate(struct object_database *odb,\n+\t\t\t odb_for_each_alternate_fn cb, void *payload)\n {\n \tstruct odb_source *alternate;\n \tint r = 0;\n \n-\todb_prepare_alternates(the_repository->objects);\n-\tfor (alternate = the_repository->objects->sources->next; alternate; alternate = alternate->next) {\n-\t\tr = fn(alternate, cb);\n+\todb_prepare_alternates(odb);\n+\tfor (alternate = odb->sources->next; alternate; alternate = alternate->next) {\n+\t\tr = cb(alternate, payload);\n \t\tif (r)\n \t\t\tbreak;\n \t}\ndiff --git a/odb.h b/odb.h\nindex eba16929a81..7e65e9707c1 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -73,11 +73,6 @@ struct odb_source {\n \tchar *path;\n };\n \n-typedef int alt_odb_fn(struct odb_source *, void *);\n-int foreach_alt_odb(alt_odb_fn, void*);\n-typedef void alternate_ref_fn(const struct object_id *oid, void *);\n-void for_each_alternate_ref(alternate_ref_fn, void *);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -192,6 +187,24 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Iterate through all alternates of the database and execute the provided\n+ * callback function for each of them. Stop iterating once the callback\n+ * function returns a non-zero value, in which case the value is bubbled up\n+ * from the callback.\n+ */\n+typedef int odb_for_each_alternate_fn(struct odb_source *, void *);\n+int odb_for_each_alternate(struct object_database *odb,\n+\t\t\t   odb_for_each_alternate_fn cb, void *payload);\n+\n+/*\n+ * Iterate through all alternates of the database and yield their respective\n+ * references.\n+ */\n+typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n+\n /*\n  * Create a temporary file rooted in the primary alternate's directory, or die\n  * on failure. The filename is taken from \"pattern\", which should have the\ndiff --git a/revision.c b/revision.c\nindex cdefe7d6e48..b0364f556ee 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1907,7 +1907,8 @@ static void add_alternate_refs_to_pending(struct rev_info *revs,\n \tstruct add_alternate_refs_data data;\n \tdata.revs = revs;\n \tdata.flags = flags;\n-\tfor_each_alternate_ref(add_one_alternate_ref, &data);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   add_one_alternate_ref, &data);\n }\n \n static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519722","messageId":"20250605-pks-object-store-wo-the-repository-v5-12-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:47:02Z","receivedAt":"2025-06-05T06:47:09Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"All of the external functions provided by the object database subsystem\ndon't depend on `the_repository` anymore, but some internal functions\nstill do. Refactor those cases by plumbing through the repository that\nowns the object database.\n\nThis change allows us to get rid of the `USE_THE_REPOSITORY_VARIABLE`\npreprocessor define.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex decf261dec6..d6ca5b92ab8 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"commit-graph.h\"\n@@ -476,12 +474,13 @@ void odb_add_submodule_source_by_path(struct object_database *odb,\n \tstring_list_insert(&odb->submodule_source_paths, path);\n }\n \n-static void fill_alternate_refs_command(struct child_process *cmd,\n+static void fill_alternate_refs_command(struct repository *repo,\n+\t\t\t\t\tstruct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n \tconst char *value;\n \n-\tif (!git_config_get_value(\"core.alternateRefsCommand\", &value)) {\n+\tif (!repo_config_get_value(repo, \"core.alternateRefsCommand\", &value)) {\n \t\tcmd->use_shell = 1;\n \n \t\tstrvec_push(&cmd->args, value);\n@@ -493,7 +492,7 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \t\tstrvec_push(&cmd->args, \"for-each-ref\");\n \t\tstrvec_push(&cmd->args, \"--format=%(objectname)\");\n \n-\t\tif (!git_config_get_value(\"core.alternateRefsPrefixes\", &value)) {\n+\t\tif (!repo_config_get_value(repo, \"core.alternateRefsPrefixes\", &value)) {\n \t\t\tstrvec_push(&cmd->args, \"--\");\n \t\t\tstrvec_split(&cmd->args, value);\n \t\t}\n@@ -503,7 +502,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \tcmd->out = -1;\n }\n \n-static void read_alternate_refs(const char *path,\n+static void read_alternate_refs(struct repository *repo,\n+\t\t\t\tconst char *path,\n \t\t\t\todb_for_each_alternate_ref_fn *cb,\n \t\t\t\tvoid *payload)\n {\n@@ -511,7 +511,7 @@ static void read_alternate_refs(const char *path,\n \tstruct strbuf line = STRBUF_INIT;\n \tFILE *fh;\n \n-\tfill_alternate_refs_command(&cmd, path);\n+\tfill_alternate_refs_command(repo, &cmd, path);\n \n \tif (start_command(&cmd))\n \t\treturn;\n@@ -521,7 +521,7 @@ static void read_alternate_refs(const char *path,\n \t\tstruct object_id oid;\n \t\tconst char *p;\n \n-\t\tif (parse_oid_hex(line.buf, &oid, &p) || *p) {\n+\t\tif (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) {\n \t\t\twarning(_(\"invalid line while parsing alternate refs: %s\"),\n \t\t\t\tline.buf);\n \t\t\tbreak;\n@@ -559,7 +559,7 @@ static int refs_from_alternate_cb(struct odb_source *alternate,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n+\tread_alternate_refs(alternate->odb->repo, path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, the_repository->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n \t\tif (oi->contentp)\n \t\t\t*oi->contentp = xmemdupz(co->buf, co->size);\n \t\toi->whence = OI_CACHED;\n@@ -763,10 +763,10 @@ static int oid_object_info_convert(struct repository *r,\n \tvoid *content;\n \tint ret;\n \n-\tif (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) {\n+\tif (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) {\n \t\tif (do_die)\n \t\t\tdie(_(\"missing mapping of %s to %s\"),\n-\t\t\t    oid_to_hex(input_oid), the_hash_algo->name);\n+\t\t\t    oid_to_hex(input_oid), r->hash_algo->name);\n \t\treturn -1;\n \t}\n \n@@ -797,8 +797,8 @@ static int oid_object_info_convert(struct repository *r,\n \t\tstruct strbuf outbuf = STRBUF_INIT;\n \n \t\tif (type != OBJ_BLOB) {\n-\t\t\tret = convert_object_file(the_repository, &outbuf,\n-\t\t\t\t\t\t  the_hash_algo, input_algo,\n+\t\t\tret = convert_object_file(r, &outbuf,\n+\t\t\t\t\t\t  r->hash_algo, input_algo,\n \t\t\t\t\t\t  content, size, type, !do_die);\n \t\t\tfree(content);\n \t\t\tif (ret == -1)\n@@ -944,9 +944,9 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + the_hash_algo->hexsz > isize ||\n+\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex((char *) buffer + ref_length, &actual_oid)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519724","messageId":"20250605-pks-object-store-wo-the-repository-v5-11-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 11/17] odb: get rid of `the_repository` when handling submodule sources","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:47:01Z","receivedAt":"2025-06-05T06:47:09Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"--recursive\" flag for git-grep(1) allows users to grep for a string\nacross submodule boundaries. To make this work we add each submodule's\nobject sources to our own object database so that the objects can be\naccessed directly.\n\nThe infrastructure for this depends on a global string list of submodule\npaths. The caller is expected to call `add_submodule_odb_by_path()` for\neach source and the object database will then eventually register all\nsubmodule sources via `do_oid_object_info_extended()` in case it isn't\nable to look up a specific object.\n\nThis reliance on global state is of course suboptimal with regards to\nour libification efforts.\n\nRefactor the logic so that the list of submodule sources is instead\ntracked in the object database itself. This allows us to lose the\ncondition of `r == the_repository` before registering submodule sources\nas we only ever add submodule sources to `the_repository` anyway. As\nsuch, behaviour before and after this refactoring should always be the\nsame.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/grep.c     |  3 ++-\n odb.c              | 37 +++++++++++++++++++++++++++++++------\n odb.h              | 15 +++++++++++++++\n submodule-config.c |  3 ++-\n submodule.c        | 26 --------------------------\n submodule.h        |  9 ---------\n 6 files changed, 50 insertions(+), 43 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 336cfcab6fb..cfcf916bce1 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,8 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->sources->path);\n+\todb_add_submodule_source_by_path(the_repository->objects,\n+\t\t\t\t\t subrepo->objects->sources->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/odb.c b/odb.c\nindex b154e91953d..decf261dec6 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -24,6 +24,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"submodule.h\"\n+#include \"trace2.h\"\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n@@ -469,6 +470,12 @@ struct odb_source *odb_find_source(struct object_database *odb, const char *obj_\n \treturn source;\n }\n \n+void odb_add_submodule_source_by_path(struct object_database *odb,\n+\t\t\t\t      const char *path)\n+{\n+\tstring_list_insert(&odb->submodule_source_paths, path);\n+}\n+\n static void fill_alternate_refs_command(struct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n@@ -623,6 +630,23 @@ void disable_obj_read_lock(void)\n \n int fetch_if_missing = 1;\n \n+static int register_all_submodule_sources(struct object_database *odb)\n+{\n+\tint ret = odb->submodule_source_paths.nr;\n+\n+\tfor (size_t i = 0; i < odb->submodule_source_paths.nr; i++)\n+\t\todb_add_to_alternates_memory(odb,\n+\t\t\t\t\t     odb->submodule_source_paths.items[i].string);\n+\tif (ret) {\n+\t\tstring_list_clear(&odb->submodule_source_paths, 0);\n+\t\ttrace2_data_intmax(\"submodule\", odb->repo,\n+\t\t\t\t   \"register_all_submodule_sources/registered\", ret);\n+\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n+\t\t\tBUG(\"register_all_submodule_sources() called\");\n+\t}\n+\treturn ret;\n+}\n+\n static int do_oid_object_info_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n@@ -676,13 +700,12 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t}\n \n \t\t/*\n-\t\t * If r is the_repository, this might be an attempt at\n-\t\t * accessing a submodule object as if it were in the_repository\n-\t\t * (having called add_submodule_odb() on that submodule's ODB).\n-\t\t * If any such ODBs exist, register them and try again.\n+\t\t * This might be an attempt at accessing a submodule object as\n+\t\t * if it were in main object store (having called\n+\t\t * `odb_add_submodule_source_by_path()` on that submodule's\n+\t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (r == the_repository &&\n-\t\t    register_all_submodule_odb_as_alternates())\n+\t\tif (register_all_submodule_sources(r->objects))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n@@ -968,6 +991,7 @@ struct object_database *odb_new(struct repository *repo)\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n+\tstring_list_init_dup(&o->submodule_source_paths);\n \treturn o;\n }\n \n@@ -1017,4 +1041,5 @@ void odb_clear(struct object_database *o)\n \to->packed_git = NULL;\n \n \thashmap_clear(&o->pack_map);\n+\tstring_list_clear(&o->submodule_source_paths, 0);\n }\ndiff --git a/odb.h b/odb.h\nindex 4e2d1004f8a..0ea9d4faa70 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -6,6 +6,7 @@\n #include \"list.h\"\n #include \"oidset.h\"\n #include \"oidmap.h\"\n+#include \"string-list.h\"\n #include \"thread-utils.h\"\n \n struct oidmap;\n@@ -165,6 +166,12 @@ struct object_database {\n \t * packs.\n \t */\n \tunsigned packed_git_initialized : 1;\n+\n+\t/*\n+\t * Submodule source paths that will be added as additional sources to\n+\t * allow lookup of submodule objects via the main object database.\n+\t */\n+\tstruct string_list submodule_source_paths;\n };\n \n struct object_database *odb_new(struct repository *repo);\n@@ -191,6 +198,14 @@ void odb_restore_primary_source(struct object_database *odb,\n \t\t\t\tstruct odb_source *restore_source,\n \t\t\t\tconst char *old_path);\n \n+/*\n+ * Call odb_add_submodule_source_by_path() to add the submodule at the given\n+ * path to a list. The object stores of all submodules in that list will be\n+ * added as additional sources in the object store when looking up objects.\n+ */\n+void odb_add_submodule_source_by_path(struct object_database *odb,\n+\t\t\t\t      const char *path);\n+\n /*\n  * Iterate through all alternates of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 9c80f9f7b66..a9f72107888 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,8 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->sources->path);\n+\t\t\t\todb_add_submodule_source_by_path(the_repository->objects,\n+\t\t\t\t\t\t\t\t repo->objects->sources->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/submodule.c b/submodule.c\nindex 386be234230..788c9e55ed3 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -31,7 +31,6 @@\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\n-#include \"trace2.h\"\n \n static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;\n static int initialized_fetch_ref_tips;\n@@ -176,31 +175,6 @@ void stage_updated_gitmodules(struct index_state *istate)\n \t\tdie(_(\"staging updated .gitmodules failed\"));\n }\n \n-static struct string_list added_submodule_odb_paths = STRING_LIST_INIT_DUP;\n-\n-void add_submodule_odb_by_path(const char *path)\n-{\n-\tstring_list_insert(&added_submodule_odb_paths, path);\n-}\n-\n-int register_all_submodule_odb_as_alternates(void)\n-{\n-\tint i;\n-\tint ret = added_submodule_odb_paths.nr;\n-\n-\tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\todb_add_to_alternates_memory(the_repository->objects,\n-\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n-\tif (ret) {\n-\t\tstring_list_clear(&added_submodule_odb_paths, 0);\n-\t\ttrace2_data_intmax(\"submodule\", the_repository,\n-\t\t\t\t   \"register_all_submodule_odb_as_alternates/registered\", ret);\n-\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n-\t\t\tBUG(\"register_all_submodule_odb_as_alternates() called\");\n-\t}\n-\treturn ret;\n-}\n-\n void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\t\t\t\t     const char *path)\n {\ndiff --git a/submodule.h b/submodule.h\nindex db980c1d083..b10e16e6c06 100644\n--- a/submodule.h\n+++ b/submodule.h\n@@ -104,15 +104,6 @@ int submodule_uses_gitfile(const char *path);\n #define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)\n int bad_to_remove_submodule(const char *path, unsigned flags);\n \n-/*\n- * Call add_submodule_odb_by_path() to add the submodule at the given\n- * path to a list. When register_all_submodule_odb_as_alternates() is\n- * called, the object stores of all submodules in that list will be\n- * added as alternates in the_repository.\n- */\n-void add_submodule_odb_by_path(const char *path);\n-int register_all_submodule_odb_as_alternates(void);\n-\n /*\n  * Checks if there are submodule changes in a..b. If a is the null OID,\n  * checks b and all its ancestors instead.\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519725","messageId":"20250605-pks-object-store-wo-the-repository-v5-13-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 13/17] odb: rename `oid_object_info()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:47:03Z","receivedAt":"2025-06-05T06:47:11Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `oid_object_info()` to `odb_read_object_info()` as well as their\n`_extended()` variant to match other functions related to the object\ndatabase and our modern coding guidelines.\n\nIntroduce compatibility wrappers so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n archive.c                     |  2 +-\n blame.c                       |  4 +--\n builtin/blame.c               |  4 +--\n builtin/cat-file.c            | 26 ++++++++++---------\n builtin/describe.c            |  3 ++-\n builtin/fast-export.c         |  2 +-\n builtin/fast-import.c         | 17 ++++++------\n builtin/fsck.c                |  7 ++---\n builtin/gc.c                  |  2 +-\n builtin/grep.c                |  2 +-\n builtin/index-pack.c          | 13 +++++-----\n builtin/ls-files.c            |  2 +-\n builtin/ls-tree.c             |  4 +--\n builtin/mktree.c              |  8 +++---\n builtin/pack-objects.c        | 30 ++++++++++++----------\n builtin/prune.c               |  4 +--\n builtin/repack.c              |  2 +-\n builtin/replace.c             | 10 ++++----\n builtin/rev-list.c            |  6 +++--\n builtin/tag.c                 |  4 +--\n builtin/unpack-objects.c      |  2 +-\n commit-graph.c                |  2 +-\n commit.c                      |  3 ++-\n diff.c                        | 18 ++++++-------\n fetch-pack.c                  |  4 +--\n list-objects-filter.c         |  2 +-\n log-tree.c                    |  2 +-\n merge-ort.c                   |  4 +--\n object-file.c                 |  2 +-\n object-file.h                 |  2 +-\n object-name.c                 | 16 ++++++------\n object.c                      |  6 ++---\n odb.c                         | 60 ++++++++++++++++++++++---------------------\n odb.h                         | 46 +++++++++++++++++++++++++++------\n pack-bitmap-write.c           |  4 +--\n pack-bitmap.c                 |  8 +++---\n packfile.c                    |  5 ++--\n promisor-remote.c             |  4 +--\n protocol-caps.c               |  2 +-\n reachable.c                   |  2 +-\n read-cache.c                  |  6 ++---\n ref-filter.c                  |  4 +--\n remote.c                      |  5 ++--\n sequencer.c                   |  5 ++--\n streaming.c                   |  8 +++---\n submodule.c                   |  5 ++--\n t/helper/test-partial-clone.c |  2 +-\n tag.c                         |  2 +-\n 48 files changed, 213 insertions(+), 170 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 7fa2cc2596a..f2511d530d5 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,\n \n \t/* Stream it? */\n \tif (S_ISREG(mode) && !args->convert &&\n-\t    oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&\n+\t    odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&\n \t    size > repo_settings_get_big_file_threshold(the_repository))\n \t\treturn write_entry(args, oid, path.buf, path.len, mode, NULL, size);\n \ndiff --git a/blame.c b/blame.c\nindex 0ceea080a80..97db3355af4 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,\n \t\tunsigned short mode;\n \n \t\tif (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&\n-\t\t    oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)\n+\t\t    odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n \n@@ -1245,7 +1245,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,\n \t\treturn 0;\n \tif (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))\n \t\tgoto error_out;\n-\tif (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)\n+\tif (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\n \treturn 0;\n  error_out:\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 15eda60af90..91586e6852b 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -837,7 +837,7 @@ static int is_a_rev(const char *name)\n \n \tif (repo_get_oid(the_repository, name, &oid))\n \t\treturn 0;\n-\treturn OBJ_NONE < oid_object_info(the_repository, &oid, NULL);\n+\treturn OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);\n }\n \n static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n@@ -848,7 +848,7 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n \toidcpy(&oid, oid_ret);\n \twhile (1) {\n \t\tstruct object *obj;\n-\t\tint kind = oid_object_info(r, &oid, NULL);\n+\t\tint kind = odb_read_object_info(r->objects, &oid, NULL);\n \t\tif (kind == OBJ_COMMIT) {\n \t\t\toidcpy(oid_ret, &oid);\n \t\t\treturn 0;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex f3a925a8183..f7595fdb04e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -132,7 +132,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \tswitch (opt) {\n \tcase 't':\n \t\toi.typep = &type;\n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tprintf(\"%s\\n\", type_name(type));\n \t\tret = 0;\n@@ -146,7 +146,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\toi.contentp = (void**)&buf;\n \t\t}\n \n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \n \t\tif (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {\n@@ -180,7 +180,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t/* else fallthrough */\n \n \tcase 'p':\n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Not a valid object name %s\", obj_name);\n \n@@ -217,7 +217,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \n \t\tif (exp_type_id == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n-\t\t\tif (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n \t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n \t\t\t\t\t\t\t\t     &oid,\n \t\t\t\t\t\t\t\t     &type,\n@@ -235,7 +236,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\t} else\n \t\t\t\toidcpy(&blob_oid, &oid);\n \n-\t\t\tif (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &blob_oid, NULL) == OBJ_BLOB) {\n \t\t\t\tret = stream_blob(&blob_oid);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n@@ -294,7 +296,7 @@ struct expand_data {\n \n \t/*\n \t * After a mark_query run, this object_info is set up to be\n-\t * passed to oid_object_info_extended. It will point to the data\n+\t * passed to odb_read_object_info_extended. It will point to the data\n \t * elements above, so you can retrieve the response from there.\n \t */\n \tstruct object_info info;\n@@ -484,12 +486,12 @@ static void batch_object_write(const char *obj_name,\n \t\t\tdata->info.sizep = &data->size;\n \n \t\tif (pack)\n-\t\t\tret = packed_object_info(the_repository, pack, offset,\n-\t\t\t\t\t\t &data->info);\n+\t\t\tret = packed_object_info(the_repository, pack,\n+\t\t\t\t\t\t offset, &data->info);\n \t\telse\n-\t\t\tret = oid_object_info_extended(the_repository,\n-\t\t\t\t\t\t       &data->oid, &data->info,\n-\t\t\t\t\t\t       OBJECT_INFO_LOOKUP_REPLACE);\n+\t\t\tret = odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t    &data->oid, &data->info,\n+\t\t\t\t\t\t\t    OBJECT_INFO_LOOKUP_REPLACE);\n \t\tif (ret < 0) {\n \t\t\treport_object_status(opt, obj_name, &data->oid, \"missing\");\n \t\t\treturn;\n@@ -872,7 +874,7 @@ static int batch_objects(struct batch_options *opt)\n \n \t/*\n \t * Expand once with our special mark_query flag, which will prime the\n-\t * object_info to be handed to oid_object_info_extended for each\n+\t * object_info to be handed to odb_read_object_info_extended for each\n \t * object.\n \t */\n \tmemset(&data, 0, sizeof(data));\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 96cb68e5e5d..fbf305d7624 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\n-\telse if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)\n+\telse if (odb_read_object_info(the_repository->objects,\n+\t\t\t\t      &oid, NULL) == OBJ_BLOB)\n \t\tdescribe_blob(oid, &sb);\n \telse\n \t\tdie(_(\"%s is neither a commit nor blob\"), arg);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 0505f289a94..6c93cf0a8aa 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\n \n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 413304db9b5..2718376f2c9 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1756,8 +1756,8 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint\n \tstruct object_entry *e;\n \te = find_object(oid);\n \tif (!e) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\toid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\te = insert_object(oid);\n@@ -2416,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)\n \t\tenum object_type expected = S_ISDIR(mode) ?\n \t\t\t\t\t\tOBJ_TREE: OBJ_BLOB;\n \t\tenum object_type type = oe ? oe->type :\n-\t\t\t\t\toid_object_info(the_repository, &oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\t\t\t\todb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"%s not found: %s\",\n \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n@@ -2553,7 +2553,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttype_name(oe->type), command_buf.buf);\n \t} else if (!is_null_oid(&oid)) {\n-\t\tenum object_type type = oid_object_info(the_repository, &oid,\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects, &oid,\n \t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n@@ -2895,7 +2895,8 @@ static void parse_new_tag(const char *arg)\n \t} else if (!repo_get_oid(the_repository, from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n-\t\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t    &oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -3085,8 +3086,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tif (!oe) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 014aa1344e2..6e3465b0266 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,\n \tconst char *ret;\n \n \tif (type == OBJ_NONE)\n-\t\ttype = oid_object_info(the_repository, oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t    oid, NULL);\n \n \tret = type_name(type);\n \tif (!ret)\n@@ -232,8 +233,8 @@ static void mark_unreachable_referents(const struct object_id *oid)\n \t * (and we want to avoid parsing blobs).\n \t */\n \tif (obj->type == OBJ_NONE) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\t&obj->oid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &obj->oid, NULL);\n \t\tif (type > 0)\n \t\t\tobject_as_type(obj, type, 0);\n \t}\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 50a09eb07e3..ff551fab439 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -1080,7 +1080,7 @@ static int dfs_on_ref(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tcommit = lookup_commit(the_repository, oid);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex cfcf916bce1..1435d462cd1 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobj_read_lock();\n-\t\tobject_type = oid_object_info(subrepo, oid, NULL);\n+\t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n \t\tdata = read_object_with_reference(subrepo,\n \t\t\t\t\t\t  oid, OBJ_TREE,\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 4d4d989eb1a..d0b16908122 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -260,7 +260,8 @@ static unsigned check_object(struct object *obj)\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t&obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n \t\t\t      oid_to_hex(&obj->oid));\n@@ -908,7 +909,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\tenum object_type has_type;\n \t\tunsigned long has_size;\n \t\tread_lock();\n-\t\thas_type = oid_object_info(the_repository, oid, &has_size);\n+\t\thas_type = odb_read_object_info(the_repository->objects, oid, &has_size);\n \t\tif (has_type < 0)\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n@@ -1501,9 +1502,9 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \t\tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \t\tfor (i = 0; i < nr_ref_deltas; i++) {\n \t\t\tstruct ref_delta_entry *d = sorted_by_pos[i];\n-\t\t\tif (!oid_object_info_extended(the_repository, &d->oid,\n-\t\t\t\t\t\t      NULL,\n-\t\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t   &d->oid, NULL,\n+\t\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\tcontinue;\n \t\t\toid_array_append(&to_fetch, &d->oid);\n \t\t}\n@@ -1829,7 +1830,7 @@ static void repack_local_links(void)\n \toidset_iter_init(&outgoing_links, &iter);\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct object_info info = OBJECT_INFO_INIT;\n-\t\tif (oid_object_info_extended(the_repository, oid, &info, 0))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))\n \t\t\t/* Missing; assume it is a promisor object */\n \t\t\tcontinue;\n \t\tif (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 821339b07d4..ff975e7be06 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -251,7 +251,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(repo, oid, &size) < 0)\n+\t\tif (odb_read_object_info(repo->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 62b6fd58c16..4d616dd5282 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -27,7 +27,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\n@@ -217,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,\n \n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)\n \t\t\txsnprintf(size_text, sizeof(size_text), \"BAD\");\n \t\telse\n \t\t\txsnprintf(size_text, sizeof(size_text),\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 016b0e5b224..81df7f6099f 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -124,10 +124,10 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)\n \n \t/* Check the type of object identified by oid without fetching objects */\n \toi.typep = &obj_type;\n-\tif (oid_object_info_extended(the_repository, &oid, &oi,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t     OBJECT_INFO_QUICK |\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t  OBJECT_INFO_QUICK |\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n \t\tobj_type = -1;\n \n \tif (obj_type < 0) {\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 99b63cb0980..da35d684081 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2154,10 +2154,10 @@ static void prefetch_to_pack(uint32_t object_index_start) {\n \tfor (i = object_index_start; i < to_pack.nr_objects; i++) {\n \t\tstruct object_entry *entry = to_pack.objects + i;\n \n-\t\tif (!oid_object_info_extended(the_repository,\n-\t\t\t\t\t      &entry->idx.oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &entry->idx.oid,\n+\t\t\t\t\t\t   NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &entry->idx.oid);\n \t}\n@@ -2298,19 +2298,19 @@ static void check_object(struct object_entry *entry, uint32_t object_index)\n \n \t\t/*\n \t\t * No choice but to fall back to the recursive delta walk\n-\t\t * with oid_object_info() to find about the object type\n+\t\t * with odb_read_object_info() to find about the object type\n \t\t * at this point...\n \t\t */\n \t\tgive_up:\n \t\tunuse_pack(&w_curs);\n \t}\n \n-\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n \t\tif (repo_has_promisor_remote(the_repository)) {\n \t\t\tprefetch_to_pack(object_index);\n-\t\t\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\t\t\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\t\t\ttype = -1;\n \t\t} else {\n \t\t\ttype = -1;\n@@ -2384,12 +2384,13 @@ static void drop_reused_delta(struct object_entry *entry)\n \tif (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {\n \t\t/*\n \t\t * We failed to get the info from this pack for some reason;\n-\t\t * fall back to oid_object_info, which may find another copy.\n+\t\t * fall back to odb_read_object_info, which may find another copy.\n \t\t * And if that fails, the error will be recorded in oe_type(entry)\n \t\t * and dealt with in prepare_pack().\n \t\t */\n \t\toe_set_type(entry,\n-\t\t\t    oid_object_info(the_repository, &entry->idx.oid, &size));\n+\t\t\t    odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &entry->idx.oid, &size));\n \t} else {\n \t\toe_set_type(entry, type);\n \t}\n@@ -2677,7 +2678,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n \n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tif (oid_object_info(the_repository, &e->idx.oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &e->idx.oid, &size) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"),\n \t\t\t    oid_to_hex(&e->idx.oid));\n \t\tpacking_data_unlock(&to_pack);\n@@ -4063,7 +4065,7 @@ static void add_objects_in_unpacked_packs(void)\n static int add_loose_object(const struct object_id *oid, const char *path,\n \t\t\t    void *data UNUSED)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\twarning(_(\"loose object at %s could not be examined\"), path);\n@@ -4449,7 +4451,7 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED,\n static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)\n {\n \tstruct object_info info = OBJECT_INFO_INIT;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &info, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))\n \t\tBUG(\"should_include_obj should only be called on existing objects\");\n \treturn info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;\n }\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 7bbfb14c2be..339017c7ccf 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -99,8 +99,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \tif (st.st_mtime > expire)\n \t\treturn 0;\n \tif (show_only || verbose) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tprintf(\"%s %s\\n\", oid_to_hex(oid),\n \t\t       (type > 0) ? type_name(type) : \"unknown\");\n \t}\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 8145474cf8d..a89c2b704fb 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -707,7 +707,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,\n \tif (oidset_insert(&data->seen, oid))\n \t\treturn 0; /* already seen */\n \n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tfprintf(data->f->fp, \"%s%s\\n\", data->preferred ? \"+\" : \"\",\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 11c7e2d4c0c..5ff2ab723cb 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -65,8 +65,8 @@ static int show_reference(const char *refname,\n \t\t\tif (repo_get_oid(data->repo, refname, &object))\n \t\t\t\treturn error(_(\"failed to resolve '%s' as a valid ref\"), refname);\n \n-\t\t\tobj_type = oid_object_info(data->repo, &object, NULL);\n-\t\t\trepl_type = oid_object_info(data->repo, oid, NULL);\n+\t\t\tobj_type = odb_read_object_info(data->repo->objects, &object, NULL);\n+\t\t\trepl_type = odb_read_object_info(data->repo->objects, oid, NULL);\n \n \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, type_name(obj_type),\n \t\t\t       oid_to_hex(oid), type_name(repl_type));\n@@ -185,8 +185,8 @@ static int replace_object_oid(const char *object_ref,\n \tstruct strbuf err = STRBUF_INIT;\n \tint res = 0;\n \n-\tobj_type = oid_object_info(the_repository, object, NULL);\n-\trepl_type = oid_object_info(the_repository, repl, NULL);\n+\tobj_type = odb_read_object_info(the_repository->objects, object, NULL);\n+\trepl_type = odb_read_object_info(the_repository->objects, repl, NULL);\n \tif (!force && obj_type != repl_type)\n \t\treturn error(_(\"Objects must be of the same type.\\n\"\n \t\t\t       \"'%s' points to a replaced object of type '%s'\\n\"\n@@ -334,7 +334,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)\n \tif (repo_get_oid(the_repository, object_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), object_ref);\n \n-\ttype = oid_object_info(the_repository, &old_oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &old_oid, NULL);\n \tif (type < 0)\n \t\treturn error(_(\"unable to get object type for %s\"),\n \t\t\t     oid_to_hex(&old_oid));\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 0ee37a32cb2..4d0c460f186 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -110,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)\n \toff_t size;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \toi.disk_sizep = &size;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\tdie(_(\"unable to get disk usage of %s\"), oid_to_hex(&obj->oid));\n \treturn size;\n }\n@@ -346,7 +347,8 @@ static void show_commit(struct commit *commit, void *data)\n static int finish_object(struct object *obj, const char *name, void *cb_data)\n {\n \tstruct rev_list_info *info = cb_data;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, NULL, 0) < 0) {\n \t\tfinish_object__ma(obj, name);\n \t\treturn 1;\n \t}\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex cf2ea4b4993..e0b27396c6b 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -304,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,\n \tstruct strbuf header = STRBUF_INIT;\n \tint should_edit;\n \n-\ttype = oid_object_info(the_repository, object, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, object, NULL);\n \tif (type <= OBJ_NONE)\n \t\tdie(_(\"bad object type.\"));\n \n@@ -401,7 +401,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 7bf395eec84..405e78bc592 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -232,7 +232,7 @@ static int check_object(struct object *obj, enum object_type type,\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n \t\tobj->flags |= FLAG_WRITTEN;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 59265f89385..5f482d3377f 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1862,7 +1862,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT)\n \t\toidset_insert(data->commits, oid);\n \n \tdisplay_progress(data->progress, oidset_size(data->commits));\ndiff --git a/commit.c b/commit.c\nindex aa65183d8b6..d4aa9c7a5f8 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -585,7 +585,8 @@ int repo_parse_commit_internal(struct repository *r,\n \t\treturn 0;\n \t}\n \n-\tif (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)\n+\tif (odb_read_object_info_extended(r->objects, &item->object.oid,\n+\t\t\t\t\t  &oi, flags) < 0)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/diff.c b/diff.c\nindex 3af108115b3..dca87e164fb 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4230,14 +4230,14 @@ int diff_populate_filespec(struct repository *r,\n \t\t\tinfo.contentp = &s->data;\n \n \t\tif (options && options->missing_object_cb) {\n-\t\t\tif (!oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t\t\t      OBJECT_INFO_SKIP_FETCH_OBJECT))\n+\t\t\tif (!odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t   OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t\t\t   OBJECT_INFO_SKIP_FETCH_OBJECT))\n \t\t\t\tgoto object_read;\n \t\t\toptions->missing_object_cb(options->missing_object_data);\n \t\t}\n-\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \n object_read:\n@@ -4252,8 +4252,8 @@ int diff_populate_filespec(struct repository *r,\n \t\t}\n \t\tif (!info.contentp) {\n \t\t\tinfo.contentp = &s->data;\n-\t\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \t\t}\n \t\ts->should_free = 1;\n@@ -7019,8 +7019,8 @@ void diff_add_if_missing(struct repository *r,\n {\n \tif (filespec && filespec->oid_valid &&\n \t    !S_ISGITLINK(filespec->mode) &&\n-\t    oid_object_info_extended(r, &filespec->oid, NULL,\n-\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t    odb_read_object_info_extended(r->objects, &filespec->oid, NULL,\n+\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\toid_array_append(to_fetch, &filespec->oid);\n }\n \ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 47fa7fa4c49..0f5de1c94d1 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -149,8 +149,8 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \t}\n \n \twhile (1) {\n-\t\tif (oid_object_info_extended(the_repository, oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n \t\t\treturn NULL;\n \t\tif (type == OBJ_TAG) {\n \t\t\tstruct tag *tag = (struct tag *)\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 80fe48a52c8..7ecd4d9ef50 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -310,7 +310,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \t\tassert(obj->type == OBJ_BLOB);\n \t\tassert((obj->flags & SEEN) == 0);\n \n-\t\tt = oid_object_info(r, &obj->oid, &object_length);\n+\t\tt = odb_read_object_info(r->objects, &obj->oid, &object_length);\n \t\tif (t != OBJ_BLOB) { /* probably OBJ_NONE */\n \t\t\t/*\n \t\t\t * We DO NOT have the blob locally, so we cannot\ndiff --git a/log-tree.c b/log-tree.c\nindex 1d05dc1c701..233bf9f227c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -176,7 +176,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,\n \t\treturn 0;\n \t}\n \n-\tobjtype = oid_object_info(the_repository, oid, NULL);\n+\tobjtype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (objtype < 0)\n \t\treturn 0;\n \tobj = lookup_object_by_type(the_repository, oid, objtype);\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 9f693ab1d36..f29417040c1 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -4385,8 +4385,8 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \n \t\t\tif ((ci->filemask & side_mask) &&\n \t\t\t    S_ISREG(vi->mode) &&\n-\t\t\t    oid_object_info_extended(opt->repo, &vi->oid, NULL,\n-\t\t\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t\t\t    odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,\n+\t\t\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\toid_array_append(&to_fetch, &vi->oid);\n \t\t}\n \t}\ndiff --git a/object-file.c b/object-file.c\nindex 04da19a1a3b..3d674d1093e 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1108,7 +1108,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)\n \toi.typep = &type;\n \toi.sizep = &len;\n \toi.contentp = &buf;\n-\tif (oid_object_info_extended(the_repository, oid, &oi, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0))\n \t\treturn error(_(\"cannot read object for %s\"), oid_to_hex(oid));\n \tif (compat) {\n \t\tif (repo_oid_to_algop(repo, oid, compat, &compat_oid))\ndiff --git a/object-file.h b/object-file.h\nindex 5066638f8ec..67b4ffc4808 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -8,7 +8,7 @@\n struct index_state;\n \n /*\n- * Set this to 0 to prevent oid_object_info_extended() from fetching missing\n+ * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing\n  * blobs. This has a difference only if extensions.partialClone is set.\n  *\n  * Its default value is 1.\ndiff --git a/object-name.c b/object-name.c\nindex 381536e900e..e225eb602cf 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -251,7 +251,7 @@ static int disambiguate_commit_only(struct repository *r,\n \t\t\t\t    const struct object_id *oid,\n \t\t\t\t    void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_COMMIT;\n }\n \n@@ -262,7 +262,7 @@ static int disambiguate_committish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -279,7 +279,7 @@ static int disambiguate_tree_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_TREE;\n }\n \n@@ -290,7 +290,7 @@ static int disambiguate_treeish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_TREE || kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -307,7 +307,7 @@ static int disambiguate_blob_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_BLOB;\n }\n \n@@ -399,7 +399,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t\treturn 0;\n \n \thash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);\n-\ttype = oid_object_info(ds->repo, oid, NULL);\n+\ttype = odb_read_object_info(ds->repo->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\t/*\n@@ -514,8 +514,8 @@ static int sort_ambiguous(const void *va, const void *vb, void *ctx)\n {\n \tstruct repository *sort_ambiguous_repo = ctx;\n \tconst struct object_id *a = va, *b = vb;\n-\tint a_type = oid_object_info(sort_ambiguous_repo, a, NULL);\n-\tint b_type = oid_object_info(sort_ambiguous_repo, b, NULL);\n+\tint a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL);\n+\tint b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL);\n \tint a_type_sort;\n \tint b_type_sort;\n \ndiff --git a/object.c b/object.c\nindex 3b15469139d..868d89eed42 100644\n--- a/object.c\n+++ b/object.c\n@@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,\n \tstruct object *o = lookup_unknown_object(r, name);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = oid_object_info(r, name, NULL);\n+\t\tint type = odb_read_object_info(r->objects, name, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\n@@ -315,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t}\n \n \tif ((!obj || obj->type == OBJ_BLOB) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_BLOB) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {\n \t\tif (!skip_hash && stream_object_signature(r, repl) < 0) {\n \t\t\terror(_(\"hash mismatch %s\"), oid_to_hex(oid));\n \t\t\treturn NULL;\n@@ -331,7 +331,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t */\n \tif (skip_hash && discard_tree &&\n \t    (!obj || obj->type == OBJ_TREE) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_TREE) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex d6ca5b92ab8..c3fe7917161 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -647,7 +647,7 @@ static int register_all_submodule_sources(struct object_database *odb)\n \treturn ret;\n }\n \n-static int do_oid_object_info_extended(struct repository *r,\n+static int do_oid_object_info_extended(struct object_database *odb,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n {\n@@ -660,7 +660,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \n \n \tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n-\t\treal = lookup_replace_object(r, oid);\n+\t\treal = lookup_replace_object(odb->repo, oid);\n \n \tif (is_null_oid(real))\n \t\treturn -1;\n@@ -668,7 +668,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \tif (!oi)\n \t\toi = &blank_oi;\n \n-\tco = find_cached_object(r->objects, real);\n+\tco = find_cached_object(odb, real);\n \tif (co) {\n \t\tif (oi->typep)\n \t\t\t*(oi->typep) = co->type;\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, odb->repo->hash_algo);\n \t\tif (oi->contentp)\n \t\t\t*oi->contentp = xmemdupz(co->buf, co->size);\n \t\toi->whence = OI_CACHED;\n@@ -685,17 +685,17 @@ static int do_oid_object_info_extended(struct repository *r,\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(r, real, &e))\n+\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\tbreak;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!loose_object_info(r, real, oi, flags))\n+\t\tif (!loose_object_info(odb->repo, real, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\tif (!(flags & OBJECT_INFO_QUICK)) {\n-\t\t\treprepare_packed_git(r);\n-\t\t\tif (find_pack_entry(r, real, &e))\n+\t\t\treprepare_packed_git(odb->repo);\n+\t\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\t\tbreak;\n \t\t}\n \n@@ -705,15 +705,15 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * `odb_add_submodule_source_by_path()` on that submodule's\n \t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (register_all_submodule_sources(r->objects))\n+\t\tif (register_all_submodule_sources(odb))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n \t\t/* Check if it is a missing object */\n-\t\tif (fetch_if_missing && repo_has_promisor_remote(r) &&\n+\t\tif (fetch_if_missing && repo_has_promisor_remote(odb->repo) &&\n \t\t    !already_retried &&\n \t\t    !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n-\t\t\tpromisor_remote_get_direct(r, real, 1);\n+\t\t\tpromisor_remote_get_direct(odb->repo, real, 1);\n \t\t\talready_retried = 1;\n \t\t\tcontinue;\n \t\t}\n@@ -723,7 +723,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t\tif ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))\n \t\t\t\tdie(_(\"replacement %s not found for %s\"),\n \t\t\t\t    oid_to_hex(real), oid_to_hex(oid));\n-\t\t\tif ((p = has_packed_and_bad(r, real)))\n+\t\t\tif ((p = has_packed_and_bad(odb->repo, real)))\n \t\t\t\tdie(_(\"packed object %s (stored in %s) is corrupt\"),\n \t\t\t\t    oid_to_hex(real), p->pack_name);\n \t\t}\n@@ -736,10 +736,10 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(r, e.p, e.offset, oi);\n+\trtype = packed_object_info(odb->repo, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real);\n-\t\treturn do_oid_object_info_extended(r, real, oi, 0);\n+\t\treturn do_oid_object_info_extended(odb, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -787,7 +787,7 @@ static int oid_object_info_convert(struct repository *r,\n \t\toi = &new_oi;\n \t}\n \n-\tret = oid_object_info_extended(r, &oid, oi, flags);\n+\tret = odb_read_object_info_extended(r->objects, &oid, oi, flags);\n \tif (ret)\n \t\treturn -1;\n \tif (oi == input_oi)\n@@ -830,33 +830,35 @@ static int oid_object_info_convert(struct repository *r,\n \treturn ret;\n }\n \n-int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n-\t\t\t     struct object_info *oi, unsigned flags)\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags)\n {\n \tint ret;\n \n-\tif (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo))\n-\t\treturn oid_object_info_convert(r, oid, oi, flags);\n+\tif (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo))\n+\t\treturn oid_object_info_convert(odb->repo, oid, oi, flags);\n \n \tobj_read_lock();\n-\tret = do_oid_object_info_extended(r, oid, oi, flags);\n+\tret = do_oid_object_info_extended(odb, oid, oi, flags);\n \tobj_read_unlock();\n \treturn ret;\n }\n \n \n /* returns enum object_type or negative */\n-int oid_object_info(struct repository *r,\n-\t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (odb_read_object_info_extended(odb, oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n@@ -887,7 +889,7 @@ int pretend_object_file(struct repository *repo,\n \n /*\n  * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call oid_object_info_extended() and give\n+ * deal with them should arrange to call odb_read_object_info_extended() and give\n  * error messages themselves.\n  */\n void *repo_read_object_file(struct repository *r,\n@@ -902,7 +904,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (oid_object_info_extended(r, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -968,13 +970,13 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(odb, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex 0ea9d4faa70..b37a9c5d20f 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -265,9 +265,6 @@ void *repo_read_object_file(struct repository *r,\n \t\t\t    enum object_type *type,\n \t\t\t    unsigned long *size);\n \n-/* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n-\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -336,9 +333,24 @@ struct object_info {\n /* Die if object corruption (not just an object being missing) was detected. */\n #define OBJECT_INFO_DIE_IF_CORRUPT 32\n \n-int oid_object_info_extended(struct repository *r,\n-\t\t\t     const struct object_id *,\n-\t\t\t     struct object_info *, unsigned flags);\n+/*\n+ * Read object info from the object database and populate the `object_info`\n+ * structure. Returns 0 on success, a negative error code otherwise.\n+ */\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags);\n+\n+/*\n+ * Read a subset of object info for the given object ID. Returns an `enum\n+ * object_type` on success, a negative error code otherwise. If successful and\n+ * `sizep` is non-NULL, then the size of the object will be written to the\n+ * pointer.\n+ */\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep);\n \n enum {\n \t/* Retry packed storage after checking packed and loose storage */\n@@ -360,7 +372,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: repo_read_object_file(),\n- * read_object_with_reference(), oid_object_info() and oid_object_info_extended().\n+ * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -368,7 +380,7 @@ void odb_assert_oid_type(struct object_database *odb,\n  * reading functions. However, beware that in these cases zlib inflation won't\n  * be performed in parallel, losing performance.\n  *\n- * TODO: oid_object_info_extended()'s call stack has a recursive behavior. If\n+ * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If\n  * any of its callees end up calling it, this recursive call won't benefit from\n  * parallel inflation.\n  */\n@@ -416,4 +428,22 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n+/* Compatibility wrappers, to be removed once Git 2.51 has been released. */\n+#include \"repository.h\"\n+\n+static inline int oid_object_info_extended(struct repository *r,\n+\t\t\t\t\t   const struct object_id *oid,\n+\t\t\t\t\t   struct object_info *oi,\n+\t\t\t\t\t   unsigned flags)\n+{\n+\treturn odb_read_object_info_extended(r->objects, oid, oi, flags);\n+}\n+\n+static inline int oid_object_info(struct repository *r,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  unsigned long *sizep)\n+{\n+\treturn odb_read_object_info(r->objects, oid, sizep);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex c847369eaaa..c5183b619c1 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -144,8 +144,8 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\treal_type = oid_object_info(writer->to_pack->repo,\n-\t\t\t\t\t\t    &entry->idx.oid, NULL);\n+\t\t\treal_type = odb_read_object_info(writer->to_pack->repo->objects,\n+\t\t\t\t\t\t\t &entry->idx.oid, NULL);\n \t\t\tbreak;\n \t\t}\n \ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex a695a794e9b..bcbb71f7502 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -1868,8 +1868,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,\n \t\tsize_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git);\n \t\tstruct eindex *eindex = &bitmap_git->ext_index;\n \t\tstruct object *obj = eindex->objects[eindex_pos];\n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid,\n+\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"), oid_to_hex(&obj->oid));\n \t}\n \n@@ -3220,8 +3220,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)\n \t\t\t\t       i)))\n \t\t\tcontinue;\n \n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects,\n+\t\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get disk usage of '%s'\"),\n \t\t\t    oid_to_hex(&obj->oid));\n \ndiff --git a/packfile.c b/packfile.c\nindex ac0e29e99b9..af9ccfdba62 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1321,7 +1321,7 @@ static int retry_bad_packed_offset(struct repository *r,\n \t\treturn OBJ_BAD;\n \tnth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));\n \tmark_bad_packed_object(p, &oid);\n-\ttype = oid_object_info(r, &oid, NULL);\n+\ttype = odb_read_object_info(r->objects, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1849,7 +1849,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\t\t\toi.typep = &type;\n \t\t\t\toi.sizep = &base_size;\n \t\t\t\toi.contentp = &base;\n-\t\t\t\tif (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)\n+\t\t\t\tif (odb_read_object_info_extended(r->objects, &base_oid,\n+\t\t\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\t\t\tbase = NULL;\n \n \t\t\t\texternal_base = base;\ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 2baa286bfd0..be6f82d12f8 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -245,8 +245,8 @@ static int remove_fetched_oids(struct repository *repo,\n \tstruct object_id *new_oids;\n \n \tfor (i = 0; i < oid_nr; i++)\n-\t\tif (oid_object_info_extended(repo, &old_oids[i], NULL,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n+\t\tif (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n \t\t\tremaining[i] = 1;\n \t\t\tremaining_nr++;\n \t\t}\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 3022f69a1bd..ecdd0dc58d5 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -64,7 +64,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,\n \t\tstrbuf_addstr(&send_buffer, oid_str);\n \n \t\tif (info->size) {\n-\t\t\tif (oid_object_info(r, &oid, &object_size) < 0) {\n+\t\t\tif (odb_read_object_info(r->objects, &oid, &object_size) < 0) {\n \t\t\t\tstrbuf_addstr(&send_buffer, \" \");\n \t\t\t} else {\n \t\t\t\tstrbuf_addf(&send_buffer, \" %lu\", object_size);\ndiff --git a/reachable.c b/reachable.c\nindex 9dc748f0b9a..e984b68a0c4 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -211,7 +211,7 @@ static void add_recent_object(const struct object_id *oid,\n \t * later processing, and the revision machinery expects\n \t * commits and tags to have been parsed.\n \t */\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object info for %s\", oid_to_hex(oid));\n \ndiff --git a/read-cache.c b/read-cache.c\nindex c3fa9686766..7d5bccf95dc 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3729,9 +3729,9 @@ void prefetch_cache_entries(const struct index_state *istate,\n \n \t\tif (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))\n \t\t\tcontinue;\n-\t\tif (!oid_object_info_extended(the_repository, &ce->oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &ce->oid, NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &ce->oid);\n \t}\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 4ce45440ad1..f9f2c512a8c 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2302,8 +2302,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj\n \t\toi->info.sizep = &oi->size;\n \t\toi->info.typep = &oi->type;\n \t}\n-\tif (oid_object_info_extended(the_repository, &oi->oid, &oi->info,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\tif (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\treturn strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n \t\t\t\t       oid_to_hex(&oi->oid), ref->refname);\n \tif (oi->info.disk_sizep && oi->disk_size < 0)\ndiff --git a/remote.c b/remote.c\nindex 17a842f5684..72c36239d31 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1182,7 +1182,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,\n \t\tBUG(\"'%s' is not a valid object, \"\n \t\t    \"match_explicit_lhs() should catch this!\",\n \t\t    matched_src_name);\n-\ttype = oid_object_info(the_repository, &oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \tif (type == OBJ_COMMIT) {\n \t\tadvise(_(\"The <src> part of the refspec is a commit object.\\n\"\n \t\t\t \"Did you mean to create a new branch by pushing to\\n\"\n@@ -1412,7 +1412,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &ref->new_oid, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\ndiff --git a/sequencer.c b/sequencer.c\nindex 2432d0a39ec..193459405f8 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5503,9 +5503,8 @@ int sequencer_pick_revisions(struct repository *r,\n \n \t\tif (!repo_get_oid(r, name, &oid)) {\n \t\t\tif (!lookup_commit_reference_gently(r, &oid, 1)) {\n-\t\t\t\tenum object_type type = oid_object_info(r,\n-\t\t\t\t\t\t\t\t\t&oid,\n-\t\t\t\t\t\t\t\t\tNULL);\n+\t\t\t\tenum object_type type = odb_read_object_info(r->objects,\n+\t\t\t\t\t\t\t\t\t     &oid, NULL);\n \t\t\t\tres = error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\t    name, type_name(type));\n \t\t\t\tgoto out;\ndiff --git a/streaming.c b/streaming.c\nindex 81c42673a23..4b13827668e 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -44,7 +44,7 @@ struct git_istream {\n \n \tunion {\n \t\tstruct {\n-\t\t\tchar *buf; /* from oid_object_info_extended() */\n+\t\t\tchar *buf; /* from odb_read_object_info_extended() */\n \t\t\tunsigned long read_ptr;\n \t\t} incore;\n \n@@ -403,8 +403,8 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,\n \toi.typep = type;\n \toi.sizep = &st->size;\n \toi.contentp = (void **)&st->u.incore.buf;\n-\treturn oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t\tOBJECT_INFO_DIE_IF_CORRUPT);\n+\treturn odb_read_object_info_extended(r->objects, oid, &oi,\n+\t\t\t\t\t     OBJECT_INFO_DIE_IF_CORRUPT);\n }\n \n /*****************************************************************************\n@@ -422,7 +422,7 @@ static int istream_source(struct git_istream *st,\n \n \toi.typep = type;\n \toi.sizep = &size;\n-\tstatus = oid_object_info_extended(r, oid, &oi, 0);\n+\tstatus = odb_read_object_info_extended(r->objects, oid, &oi, 0);\n \tif (status < 0)\n \t\treturn status;\n \ndiff --git a/submodule.c b/submodule.c\nindex 788c9e55ed3..f8373a9ea7d 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -968,7 +968,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n \t\treturn 0;\n \t}\n \n-\ttype = oid_object_info(&subrepo, oid, NULL);\n+\ttype = odb_read_object_info(subrepo.objects, oid, NULL);\n \n \tswitch (type) {\n \tcase OBJ_COMMIT:\n@@ -1752,8 +1752,7 @@ static int fetch_start_failure(struct strbuf *err UNUSED,\n static int commit_missing_in_sub(const struct object_id *oid, void *data)\n {\n \tstruct repository *subrepo = data;\n-\n-\tenum object_type type = oid_object_info(subrepo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(subrepo->objects, oid, NULL);\n \n \treturn type != OBJ_COMMIT;\n }\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex dba227259a2..d8488007493 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -23,7 +23,7 @@ static void object_info(const char *gitdir, const char *oid_hex)\n \t\tdie(\"could not init repo\");\n \tif (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo))\n \t\tdie(\"could not parse oid\");\n-\tif (oid_object_info_extended(&r, &oid, &oi, 0))\n+\tif (odb_read_object_info_extended(r.objects, &oid, &oi, 0))\n \t\tdie(\"could not obtain object info\");\n \tprintf(\"%d\\n\", (int) size);\n \ndiff --git a/tag.c b/tag.c\nindex 5f6868bf7b1..144048fd5e0 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \tunsigned long size;\n \tint ret;\n \n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519726","messageId":"20250605-pks-object-store-wo-the-repository-v5-14-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 14/17] odb: rename `repo_read_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:47:04Z","receivedAt":"2025-06-05T06:47:12Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `repo_read_object_file()` to `odb_read_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  | 10 +++++-----\n archive.c                |  2 +-\n attr.c                   |  2 +-\n bisect.c                 |  6 +++---\n blame.c                  | 13 ++++++-------\n builtin/cat-file.c       | 26 +++++++++++---------------\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  6 +++---\n builtin/fast-import.c    |  8 ++++----\n builtin/grep.c           |  8 ++++----\n builtin/index-pack.c     |  8 ++++----\n builtin/log.c            |  2 +-\n builtin/merge-tree.c     | 12 ++++++------\n builtin/mktag.c          |  4 ++--\n builtin/notes.c          |  6 +++---\n builtin/pack-objects.c   | 30 +++++++++++++++---------------\n builtin/tag.c            |  4 ++--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c |  4 ++--\n bundle.c                 |  2 +-\n combine-diff.c           |  2 +-\n commit.c                 |  6 +++---\n config.c                 |  2 +-\n dir.c                    |  2 +-\n entry.c                  |  4 ++--\n fmt-merge-msg.c          |  4 ++--\n fsck.c                   |  2 +-\n grep.c                   |  4 ++--\n http-push.c              |  4 ++--\n mailmap.c                |  2 +-\n match-trees.c            |  4 ++--\n merge-blobs.c            |  8 ++++----\n merge-ort.c              |  2 +-\n notes-cache.c            |  2 +-\n notes-merge.c            |  2 +-\n notes.c                  | 13 +++++++------\n object.c                 |  2 +-\n odb.c                    | 19 +++++++------------\n odb.h                    | 29 +++++++++++++++++++++++------\n read-cache.c             |  6 +++---\n reflog.c                 |  4 ++--\n rerere.c                 |  5 ++---\n submodule-config.c       |  4 ++--\n tag.c                    |  6 +++---\n tree-walk.c              |  6 +++---\n tree.c                   |  4 ++--\n xdiff-interface.c        |  2 +-\n 47 files changed, 157 insertions(+), 150 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex e778b4e911d..a34ced04625 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3210,8 +3210,8 @@ static int apply_binary(struct apply_state *state,\n \t\tunsigned long size;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t       &size);\n+\t\tresult = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t\t &type, &size);\n \t\tif (!result)\n \t\t\treturn error(_(\"the necessary postimage %s for \"\n \t\t\t\t       \"'%s' cannot be read\"),\n@@ -3273,8 +3273,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tunsigned long sz;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t       &sz);\n+\t\tresult = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t &type, &sz);\n \t\tif (!result)\n \t\t\treturn -1;\n \t\t/* XXX read_sha1_file NUL-terminates */\n@@ -3503,7 +3503,7 @@ static int resolve_to(struct image *image, const struct object_id *result_id)\n \n \timage_clear(image);\n \n-\tdata = repo_read_object_file(the_repository, result_id, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, result_id, &type, &size);\n \tif (!data || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(result_id));\n \tstrbuf_attach(&image->buf, data, size, size + 1);\ndiff --git a/archive.c b/archive.c\nindex f2511d530d5..f5a9d45c8d3 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -98,7 +98,7 @@ static void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t       (args->tree ? &args->tree->object.oid : NULL), oid);\n \n \tpath += args->baselen;\n-\tbuffer = repo_read_object_file(the_repository, oid, type, sizep);\n+\tbuffer = odb_read_object(the_repository->objects, oid, type, sizep);\n \tif (buffer && S_ISREG(mode)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tsize_t size = 0;\ndiff --git a/attr.c b/attr.c\nindex e5680db7f65..d1daeb0b4d9 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -779,7 +779,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,\n \tif (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))\n \t\treturn NULL;\n \n-\tbuf = repo_read_object_file(istate->repo, &oid, &type, &sz);\n+\tbuf = odb_read_object(istate->repo->objects, &oid, &type, &sz);\n \tif (!buf || type != OBJ_BLOB) {\n \t\tfree(buf);\n \t\treturn NULL;\ndiff --git a/bisect.c b/bisect.c\nindex a7939216d00..f24474542ec 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -155,9 +155,9 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tunsigned commit_flags = commit->object.flags;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &commit->object.oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &commit->object.oid, &type,\n+\t\t\t\t\t    &size);\n \t\tconst char *subject_start;\n \t\tint subject_len;\n \ndiff --git a/blame.c b/blame.c\nindex 97db3355af4..858d2d74df9 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1041,9 +1041,9 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\t\t\t    &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n-\t\t\tfile->ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t  &o->blob_oid, &type,\n-\t\t\t\t\t\t\t  &file_size);\n+\t\t\tfile->ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t    &o->blob_oid, &type,\n+\t\t\t\t\t\t    &file_size);\n \t\tfile->size = file_size;\n \n \t\tif (!file->ptr)\n@@ -2869,10 +2869,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\n \t\telse\n-\t\t\tsb->final_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &o->blob_oid,\n-\t\t\t\t\t\t\t      &type,\n-\t\t\t\t\t\t\t      &sb->final_buf_size);\n+\t\t\tsb->final_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&o->blob_oid, &type,\n+\t\t\t\t\t\t\t&sb->final_buf_size);\n \n \t\tif (!sb->final_buf)\n \t\t\tdie(_(\"cannot read blob %s for path %s\"),\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex f7595fdb04e..90a3e159d11 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -74,7 +74,7 @@ static int filter_object(const char *path, unsigned mode,\n {\n \tenum object_type type;\n \n-\t*buf = repo_read_object_file(the_repository, oid, &type, size);\n+\t*buf = odb_read_object(the_repository->objects, oid, &type, size);\n \tif (!*buf)\n \t\treturn error(_(\"cannot read object %s '%s'\"),\n \t\t\t     oid_to_hex(oid), path);\n@@ -197,8 +197,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\tret = stream_blob(&oid);\n \t\t\tgoto cleanup;\n \t\t}\n-\t\tbuf = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t      &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"Cannot read object %s\", obj_name);\n \n@@ -219,10 +219,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\tstruct object_id blob_oid;\n \t\t\tif (odb_read_object_info(the_repository->objects,\n \t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n-\t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t     &oid,\n-\t\t\t\t\t\t\t\t     &type,\n-\t\t\t\t\t\t\t\t     &size);\n+\t\t\t\tchar *buffer = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t       &oid, &type, &size);\n \t\t\t\tconst char *target;\n \n \t\t\t\tif (!buffer)\n@@ -403,10 +401,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\t\tif (!textconv_object(the_repository,\n \t\t\t\t\t\t     data->rest, 0100644, oid,\n \t\t\t\t\t\t     1, &contents, &size))\n-\t\t\t\t\tcontents = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t\t oid,\n-\t\t\t\t\t\t\t\t\t &type,\n-\t\t\t\t\t\t\t\t\t &size);\n+\t\t\t\t\tcontents = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t\t   oid, &type, &size);\n \t\t\t\tif (!contents)\n \t\t\t\t\tdie(\"could not convert '%s' %s\",\n \t\t\t\t\t    oid_to_hex(oid), data->rest);\n@@ -423,8 +419,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\tunsigned long size;\n \t\tvoid *contents;\n \n-\t\tcontents = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t &size);\n+\t\tcontents = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &type, &size);\n \t\tif (!contents)\n \t\t\tdie(\"object %s disappeared\", oid_to_hex(oid));\n \n@@ -533,8 +529,8 @@ static void batch_object_write(const char *obj_name,\n \t\t\tsize_t s = data->size;\n \t\t\tchar *buf = NULL;\n \n-\t\t\tbuf = repo_read_object_file(the_repository, &data->oid, &data->type,\n-\t\t\t\t\t\t    &data->size);\n+\t\t\tbuf = odb_read_object(the_repository->objects, &data->oid,\n+\t\t\t\t\t      &data->type, &data->size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"), oid_to_hex(&data->oid));\n \t\t\tbuf = replace_idents_using_mailmap(buf, &s);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex fac613e3bc3..e4bc1f83169 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -320,7 +320,7 @@ static char *get_symlink(struct repository *repo,\n \t} else {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tdata = repo_read_object_file(repo, oid, &type, &size);\n+\t\tdata = odb_read_object(repo->objects, oid, &type, &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\n \t\t\t\toid_to_hex(oid), path);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 6c93cf0a8aa..33f304dd0ad 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -323,7 +323,7 @@ static void export_blob(const struct object_id *oid)\n \t\tobject = (struct object *)lookup_blob(the_repository, oid);\n \t\teaten = 0;\n \t} else {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"could not read blob %s\", oid_to_hex(oid));\n \t\tif (check_object_signature(the_repository, oid, buf, size,\n@@ -869,8 +869,8 @@ static void handle_tag(const char *name, struct tag *tag)\n \t\treturn;\n \t}\n \n-\tbuf = repo_read_object_file(the_repository, &tag->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(\"could not read tag %s\", oid_to_hex(&tag->object.oid));\n \tmessage = memmem(buf, size, \"\\n\\n\", 2);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 2718376f2c9..1973c504e25 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf || type != OBJ_TREE)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t}\n@@ -3002,7 +3002,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \tchar *buf;\n \n \tif (!oe || oe->pack_id == MAX_PACK_ID) {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t} else {\n \t\ttype = oe->type;\n \t\tbuf = gfi_unpack_entry(oe, &size);\n@@ -3110,8 +3110,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \t\tbuf = gfi_unpack_entry(oe, &size);\n \t} else {\n \t\tenum object_type unused;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &unused,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t      &unused, &size);\n \t}\n \tif (!buf)\n \t\tdie(\"Can't load object %s\", oid_to_hex(oid));\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 1435d462cd1..5de61dfffe8 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -573,8 +573,8 @@ static int grep_cache(struct grep_opt *opt,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t     &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t       &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree %s\"), oid_to_hex(&ce->oid));\n \t\t\tinit_tree_desc(&tree, &ce->oid, data, size);\n@@ -666,8 +666,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry.oid, &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry.oid, &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree (%s)\"),\n \t\t\t\t    oid_to_hex(&entry.oid));\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d0b16908122..180d261f6ce 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -914,8 +914,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), oid_to_hex(oid));\n-\t\thas_data = repo_read_object_file(the_repository, oid,\n-\t\t\t\t\t\t &has_type, &has_size);\n+\t\thas_data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &has_type, &has_size);\n \t\tread_unlock();\n \t\tif (!data)\n \t\t\tdata = new_data = get_data_from_pack(obj_entry);\n@@ -1521,8 +1521,8 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \n \t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n-\t\tdata = repo_read_object_file(the_repository, &d->oid, &type,\n-\t\t\t\t\t     &size);\n+\t\tdata = odb_read_object(the_repository->objects, &d->oid,\n+\t\t\t\t       &type, &size);\n \t\tif (!data)\n \t\t\tcontinue;\n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex fe9cc5ebecb..f2040b18159 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -714,7 +714,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tunsigned long offset = 0;\n \n \tif (!buf)\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex b1a17787bcf..cf8b06cadc7 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -75,9 +75,9 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \tconst char *path = entry->path;\n \n \tif (!entry->stage)\n-\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t     &entry->blob->object.oid, &type,\n-\t\t\t\t\t     size);\n+\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t       &entry->blob->object.oid, &type,\n+\t\t\t\t       size);\n \tbase = NULL;\n \tif (entry->stage == 1) {\n \t\tbase = entry->blob;\n@@ -100,9 +100,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)\n \tenum object_type type;\n \twhile (entry) {\n \t\tif (entry->stage == 2)\n-\t\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry->blob->object.oid,\n-\t\t\t\t\t\t     &type, size);\n+\t\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry->blob->object.oid,\n+\t\t\t\t\t       &type, size);\n \t\tentry = entry->link;\n \t}\n \treturn NULL;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 1809b38f937..1b391119de8 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -54,8 +54,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)\n \tvoid *buffer;\n \tconst struct object_id *repl;\n \n-\tbuffer = repo_read_object_file(the_repository, tagged_oid, &type,\n-\t\t\t\t       &size);\n+\tbuffer = odb_read_object(the_repository->objects, tagged_oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\tdie(_(\"could not read tagged object '%s'\"),\n \t\t    oid_to_hex(tagged_oid));\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 783d4932ca6..a9529b1696a 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -152,7 +152,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (buf) {\n \t\tif (size)\n \t\t\twrite_or_die(fd, buf, size);\n@@ -319,7 +319,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tstrbuf_init(&msg->buf, 0);\n \tif (repo_get_oid(the_repository, arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(value = repo_read_object_file(the_repository, &object, &type, &len)))\n+\tif (!(value = odb_read_object(the_repository->objects, &object, &type, &len)))\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n \tif (type != OBJ_BLOB) {\n \t\tstrbuf_release(&msg->buf);\n@@ -722,7 +722,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,\n \t\tunsigned long size;\n \t\tenum object_type type;\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tchar *prev_buf = repo_read_object_file(the_repository, note, &type, &size);\n+\t\tchar *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \t\tif (!prev_buf)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(note));\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex da35d684081..580a5c1996b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -337,13 +337,13 @@ static void *get_delta(struct object_entry *entry)\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &entry->idx.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &entry->idx.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(_(\"unable to read %s\"), oid_to_hex(&entry->idx.oid));\n-\tbase_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t &DELTA(entry)->idx.oid, &type,\n-\t\t\t\t\t &base_size);\n+\tbase_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t   &DELTA(entry)->idx.oid, &type,\n+\t\t\t\t   &base_size);\n \tif (!base_buf)\n \t\tdie(\"unable to read %s\",\n \t\t    oid_to_hex(&DELTA(entry)->idx.oid));\n@@ -506,9 +506,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \t\t\t\t       &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n-\t\t\tbuf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t    &entry->idx.oid, &type,\n-\t\t\t\t\t\t    &size);\n+\t\t\tbuf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t      &entry->idx.oid, &type,\n+\t\t\t\t\t      &size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&entry->idx.oid));\n@@ -1895,7 +1895,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \t/* Did not find one.  Either we got a bogus request or\n \t * we need to read and perhaps cache.\n \t */\n-\tdata = repo_read_object_file(the_repository, oid, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!data)\n \t\treturn NULL;\n \tif (type != OBJ_TREE) {\n@@ -2762,9 +2762,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t/* Load data if not already done */\n \tif (!trg->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\ttrg->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &trg_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\ttrg->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &trg_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!trg->data)\n \t\t\tdie(_(\"object %s cannot be read\"),\n@@ -2777,9 +2777,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t}\n \tif (!src->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tsrc->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &src_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\tsrc->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &src_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!src->data) {\n \t\t\tif (src_entry->preferred_base) {\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex e0b27396c6b..46cbf892e34 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -244,7 +244,7 @@ static void write_tag_body(int fd, const struct object_id *oid)\n \tstruct strbuf payload = STRBUF_INIT;\n \tstruct strbuf signature = STRBUF_INIT;\n \n-\torig = buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\torig = buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn;\n \tif (parse_signature(buf, size, &payload, &signature)) {\n@@ -407,7 +407,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {\n+\t\tif ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) {\n \t\t\tsubject_len = find_commit_subject(buf, &subject_start);\n \t\t\tstrbuf_insert(sb, sb->len, subject_start, subject_len);\n \t\t} else {\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex b92fd4710a9..4360872ae07 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -14,7 +14,7 @@ static char *create_temp_file(struct object_id *oid)\n \tunsigned long size;\n \tint fd;\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 405e78bc592..4bc6575a574 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -516,8 +516,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \tif (resolve_against_held(nr, &base_oid, delta_data, delta_size))\n \t\treturn;\n \n-\tbase = repo_read_object_file(the_repository, &base_oid, &type,\n-\t\t\t\t     &base_size);\n+\tbase = odb_read_object(the_repository->objects, &base_oid,\n+\t\t\t       &type, &base_size);\n \tif (!base) {\n \t\terror(\"failed to read delta-pack base object %s\",\n \t\t      oid_to_hex(&base_oid));\ndiff --git a/bundle.c b/bundle.c\nindex e09e3c2f58c..717f056a454 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -305,7 +305,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n \tif (revs->max_age == -1 && revs->min_age == -1)\n \t\tgoto out;\n \n-\tbuf = repo_read_object_file(the_repository, &tag->oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->oid, &type, &size);\n \tif (!buf)\n \t\tgoto out;\n \tline = memmem(buf, size, \"\\ntagger \", 8);\ndiff --git a/combine-diff.c b/combine-diff.c\nindex cf23a753407..4ea2dc93c4f 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -325,7 +325,7 @@ static char *grab_blob(struct repository *r,\n \t\t*size = fill_textconv(r, textconv, df, &blob);\n \t\tfree_filespec(df);\n \t} else {\n-\t\tblob = repo_read_object_file(r, oid, &type, size);\n+\t\tblob = odb_read_object(r->objects, oid, &type, size);\n \t\tif (!blob)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(oid));\n \t\tif (type != OBJ_BLOB)\ndiff --git a/commit.c b/commit.c\nindex d4aa9c7a5f8..28ee6b73ae6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -374,7 +374,7 @@ const void *repo_get_commit_buffer(struct repository *r,\n \tif (!ret) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n+\t\tret = odb_read_object(r->objects, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n \t\t\t    oid_to_hex(&commit->object.oid));\n@@ -1275,8 +1275,8 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h\n \tdesc = merge_remote_util(parent);\n \tif (!desc || !desc->obj)\n \t\treturn;\n-\tbuf = repo_read_object_file(the_repository, &desc->obj->oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &desc->obj->oid,\n+\t\t\t      &type, &size);\n \tif (!buf || type != OBJ_TAG)\n \t\tgoto free_return;\n \tif (!parse_signature(buf, size, &payload, &signature))\ndiff --git a/config.c b/config.c\nindex 883dd066827..142c37215a8 100644\n--- a/config.c\n+++ b/config.c\n@@ -1942,7 +1942,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n \tunsigned long size;\n \tint ret;\n \n-\tbuf = repo_read_object_file(repo, oid, &type, &size);\n+\tbuf = odb_read_object(repo->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(_(\"unable to load config blob object '%s'\"), name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/dir.c b/dir.c\nindex a374972b624..cb7bd873b17 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -302,7 +302,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t*size_out = 0;\n \t*data_out = NULL;\n \n-\tdata = repo_read_object_file(the_repository, oid, &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn -1;\ndiff --git a/entry.c b/entry.c\nindex 75d55038d7c..cae02eb5039 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -93,8 +93,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tunsigned long ul;\n-\tvoid *blob_data = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t&type, &ul);\n+\tvoid *blob_data = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t  &type, &ul);\n \n \t*size = ul;\n \tif (blob_data) {\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 1a8c972adf3..40174efa3de 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -526,8 +526,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t    &type, &size);\n \t\tchar *origbuf = buf;\n \t\tunsigned long len = size;\n \t\tstruct signature_check sigc = { NULL };\ndiff --git a/fsck.c b/fsck.c\nindex e69baab3af7..23965e1880f 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1293,7 +1293,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,\n \t\tif (oidset_contains(blobs_done, oid))\n \t\t\tcontinue;\n \n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf) {\n \t\t\tif (is_promisor_object(the_repository, oid))\n \t\t\t\tcontinue;\ndiff --git a/grep.c b/grep.c\nindex dc77e6c4631..932647e4a65 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1931,8 +1931,8 @@ static int grep_source_load_oid(struct grep_source *gs)\n {\n \tenum object_type type;\n \n-\tgs->buf = repo_read_object_file(gs->repo, gs->identifier, &type,\n-\t\t\t\t\t&gs->size);\n+\tgs->buf = odb_read_object(gs->repo->objects, gs->identifier,\n+\t\t\t\t  &type, &gs->size);\n \tif (!gs->buf)\n \t\treturn error(_(\"'%s': unable to read %s\"),\n \t\t\t     gs->name,\ndiff --git a/http-push.c b/http-push.c\nindex d1b1bb23711..9481825abfb 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -369,8 +369,8 @@ static void start_put(struct transfer_request *request)\n \tssize_t size;\n \tgit_zstream stream;\n \n-\tunpacked = repo_read_object_file(the_repository, &request->obj->oid,\n-\t\t\t\t\t &type, &len);\n+\tunpacked = odb_read_object(the_repository->objects, &request->obj->oid,\n+\t\t\t\t   &type, &len);\n \thdrlen = format_object_header(hdr, sizeof(hdr), type, len);\n \n \t/* Set it up */\ndiff --git a/mailmap.c b/mailmap.c\nindex b18e74c2110..56c72102d9e 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -196,7 +196,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \tif (repo_get_oid(the_repository, name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = repo_read_object_file(the_repository, &oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/match-trees.c b/match-trees.c\nindex 4704f95c340..5a8a5c39b04 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -63,7 +63,7 @@ static void *fill_tree_desc_strict(struct repository *r,\n \tenum object_type type;\n \tunsigned long size;\n \n-\tbuffer = repo_read_object_file(r, hash, &type, &size);\n+\tbuffer = odb_read_object(r->objects, hash, &type, &size);\n \tif (!buffer)\n \t\tdie(\"unable to read tree (%s)\", oid_to_hex(hash));\n \tif (type != OBJ_TREE)\n@@ -199,7 +199,7 @@ static int splice_tree(struct repository *r,\n \tif (*subpath)\n \t\tsubpath++;\n \n-\tbuf = repo_read_object_file(r, oid1, &type, &sz);\n+\tbuf = odb_read_object(r->objects, oid1, &type, &sz);\n \tif (!buf)\n \t\tdie(\"cannot read tree %s\", oid_to_hex(oid1));\n \tinit_tree_desc(&desc, oid1, buf, sz);\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex ba8a3fdfd82..6fc27994171 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -12,8 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n \tunsigned long size;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &obj->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &obj->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\treturn -1;\n \tif (type != OBJ_BLOB) {\n@@ -79,8 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path,\n \t\t\treturn NULL;\n \t\tif (!our)\n \t\t\tour = their;\n-\t\treturn repo_read_object_file(the_repository, &our->object.oid,\n-\t\t\t\t\t     &type, size);\n+\t\treturn odb_read_object(the_repository->objects, &our->object.oid,\n+\t\t\t\t       &type, size);\n \t}\n \n \tif (fill_mmfile_blob(&f1, our) < 0)\ndiff --git a/merge-ort.c b/merge-ort.c\nindex f29417040c1..473ff61e36e 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -3629,7 +3629,7 @@ static int read_oid_strbuf(struct merge_options *opt,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf) {\n \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n \t\t\t path, NULL, NULL, NULL,\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 344f67762b8..dd56feed6e8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -87,7 +87,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\n \t\treturn NULL;\n-\tvalue = repo_read_object_file(the_repository, value_oid, &type, &size);\n+\tvalue = odb_read_object(the_repository->objects, value_oid, &type, &size);\n \n \t*outsize = size;\n \treturn value;\ndiff --git a/notes-merge.c b/notes-merge.c\nindex de6a52e2e7f..586939939f2 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -340,7 +340,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n {\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buf = repo_read_object_file(the_repository, note, &type, &size);\n+\tvoid *buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"cannot read note %s for object %s\",\ndiff --git a/notes.c b/notes.c\nindex fc000e501d2..73eb5f00cf5 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -816,15 +816,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \n \t/* read in both note blob objects */\n \tif (!is_null_oid(new_oid))\n-\t\tnew_msg = repo_read_object_file(the_repository, new_oid,\n-\t\t\t\t\t\t&new_type, &new_len);\n+\t\tnew_msg = odb_read_object(the_repository->objects, new_oid,\n+\t\t\t\t\t  &new_type, &new_len);\n \tif (!new_msg || !new_len || new_type != OBJ_BLOB) {\n \t\tfree(new_msg);\n \t\treturn 0;\n \t}\n \tif (!is_null_oid(cur_oid))\n-\t\tcur_msg = repo_read_object_file(the_repository, cur_oid,\n-\t\t\t\t\t\t&cur_type, &cur_len);\n+\t\tcur_msg = odb_read_object(the_repository->objects, cur_oid,\n+\t\t\t\t\t  &cur_type, &cur_len);\n \tif (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {\n \t\tfree(cur_msg);\n \t\tfree(new_msg);\n@@ -880,7 +880,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\treturn 0;\n \n \t/* read_sha1_file NUL-terminates */\n-\tdata = repo_read_object_file(the_repository, oid, &t, &len);\n+\tdata = odb_read_object(the_repository->objects, oid, &t, &len);\n \tif (t != OBJ_BLOB || !data || !len) {\n \t\tfree(data);\n \t\treturn t != OBJ_BLOB || !data;\n@@ -1290,7 +1290,8 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tif (!oid)\n \t\treturn;\n \n-\tif (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {\n+\tif (!(msg = odb_read_object(the_repository->objects, oid, &type, &msglen)) ||\n+\t    type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn;\n \t}\ndiff --git a/object.c b/object.c\nindex 868d89eed42..c1553ee4330 100644\n--- a/object.c\n+++ b/object.c\n@@ -335,7 +335,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \n-\tbuffer = repo_read_object_file(r, oid, &type, &size);\n+\tbuffer = odb_read_object(r->objects, oid, &type, &size);\n \tif (buffer) {\n \t\tif (!skip_hash &&\n \t\t    check_object_signature(r, repl, buffer, size, type) < 0) {\ndiff --git a/odb.c b/odb.c\nindex c3fe7917161..fc39fbe12d8 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -30,7 +30,7 @@ KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n- * want repo_read_object_file() to be able to return, but yet you do not want\n+ * want odb_read_object() to be able to return, but yet you do not want\n  * to write them into the object store (e.g. a browse-only\n  * application).\n  */\n@@ -887,15 +887,10 @@ int pretend_object_file(struct repository *repo,\n \treturn 0;\n }\n \n-/*\n- * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call odb_read_object_info_extended() and give\n- * error messages themselves.\n- */\n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size)\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tunsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE;\n@@ -904,7 +899,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(odb, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -926,7 +921,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = repo_read_object_file(r, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\ndiff --git a/odb.h b/odb.h\nindex b37a9c5d20f..a4a5154fd0f 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -140,7 +140,7 @@ struct object_database {\n \n \t/*\n \t * This is meant to hold a *small* number of objects that you would\n-\t * want repo_read_object_file() to be able to return, but yet you do not want\n+\t * want odb_read_object() to be able to return, but yet you do not want\n \t * to write them into the object store (e.g. a browse-only\n \t * application).\n \t */\n@@ -260,10 +260,19 @@ void odb_add_to_alternates_file(struct object_database *odb,\n void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t\t  const char *dir);\n \n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size);\n+/*\n+ * Read an object from the database. Returns the object data and assigns object\n+ * type and size to the `type` and `size` pointers, if these pointers are\n+ * non-NULL. Returns a `NULL` pointer in case the object does not exist.\n+ *\n+ * This function dies on corrupt objects; the callers who want to deal with\n+ * them should arrange to call odb_read_object_info_extended() and give error\n+ * messages themselves.\n+ */\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size);\n \n /*\n  * Add an object file to the in-memory object store, without writing it\n@@ -371,7 +380,7 @@ void odb_assert_oid_type(struct object_database *odb,\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n- * following functions in parallel: repo_read_object_file(),\n+ * following functions in parallel: odb_read_object(),\n  * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n@@ -446,4 +455,12 @@ static inline int oid_object_info(struct repository *r,\n \treturn odb_read_object_info(r->objects, oid, sizep);\n }\n \n+static inline void *repo_read_object_file(struct repository *r,\n+\t\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t\t  enum object_type *type,\n+\t\t\t\t\t  unsigned long *size)\n+{\n+\treturn odb_read_object(r->objects, oid, type, size);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/read-cache.c b/read-cache.c\nindex 7d5bccf95dc..531d87e7905 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -254,7 +254,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n \tif (strbuf_readlink(&sb, ce->name, expected_size))\n \t\treturn -1;\n \n-\tbuffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &ce->oid, &type, &size);\n \tif (buffer) {\n \t\tif (size == sb.len)\n \t\t\tmatch = memcmp(buffer, sb.buf, size);\n@@ -3485,8 +3485,8 @@ void *read_blob_data_from_index(struct index_state *istate,\n \t}\n \tif (pos < 0)\n \t\treturn NULL;\n-\tdata = repo_read_object_file(the_repository, &istate->cache[pos]->oid,\n-\t\t\t\t     &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, &istate->cache[pos]->oid,\n+\t\t\t       &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn NULL;\ndiff --git a/reflog.c b/reflog.c\nindex 4f8a3b717cd..747b82eada8 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -140,8 +140,8 @@ static int tree_is_complete(const struct object_id *oid)\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t   &size);\n+\t\tvoid *data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t     &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\treturn 0;\ndiff --git a/rerere.c b/rerere.c\nindex 951e4bf8b41..8bb97c98229 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -1000,9 +1000,8 @@ static int handle_cache(struct index_state *istate,\n \t\t\tbreak;\n \t\ti = ce_stage(ce) - 1;\n \t\tif (!mmfile[i].ptr) {\n-\t\t\tmmfile[i].ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &ce->oid, &type,\n-\t\t\t\t\t\t\t      &size);\n+\t\t\tmmfile[i].ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&ce->oid, &type, &size);\n \t\t\tif (!mmfile[i].ptr)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&ce->oid));\ndiff --git a/submodule-config.c b/submodule-config.c\nindex a9f72107888..ea3a087a8bb 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -743,8 +743,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \tif (submodule)\n \t\tgoto out;\n \n-\tconfig = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t       &config_size);\n+\tconfig = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t &type, &config_size);\n \tif (!config || type != OBJ_BLOB)\n \t\tgoto out;\n \ndiff --git a/tag.c b/tag.c\nindex 144048fd5e0..1d52686ee10 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -60,7 +60,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\t\t\trepo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),\n \t\t\t\ttype_name(type));\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n@@ -222,8 +222,8 @@ int parse_tag(struct tag *item)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tdata = repo_read_object_file(the_repository, &item->object.oid, &type,\n-\t\t\t\t     &size);\n+\tdata = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t       &type, &size);\n \tif (!data)\n \t\treturn error(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 34b0fff4873..766af99f466 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -795,9 +795,9 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\t */\n \t\t\tretval = DANGLING_SYMLINK;\n \n-\t\t\tcontents = repo_read_object_file(r,\n-\t\t\t\t\t\t    &current_tree_oid, &type,\n-\t\t\t\t\t\t    &link_len);\n+\t\t\tcontents = odb_read_object(r->objects,\n+\t\t\t\t\t\t   &current_tree_oid, &type,\n+\t\t\t\t\t\t   &link_len);\n \n \t\t\tif (!contents)\n \t\t\t\tgoto done;\ndiff --git a/tree.c b/tree.c\nindex 341b7c2ff3f..1ef743d90f4 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -193,8 +193,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tbuffer = repo_read_object_file(the_repository, &item->object.oid,\n-\t\t\t\t       &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 01e6e378ea6..0e5d38c9600 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -187,7 +187,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n \t\treturn;\n \t}\n \n-\tptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);\n+\tptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!ptr->ptr || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \tptr->size = size;\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519727","messageId":"20250605-pks-object-store-wo-the-repository-v5-15-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 15/17] odb: rename `has_object()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:47:05Z","receivedAt":"2025-06-05T06:47:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `has_object()` to `odb_has_object()` to match other functions\nrelated to the object database and our modern coding guidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  |  2 +-\n builtin/backfill.c       |  4 ++--\n builtin/cat-file.c       |  4 ++--\n builtin/clone.c          |  2 +-\n builtin/fetch.c          | 17 +++++++++--------\n builtin/fsck.c           |  2 +-\n builtin/index-pack.c     |  4 ++--\n builtin/pack-objects.c   |  4 ++--\n builtin/receive-pack.c   |  4 ++--\n builtin/remote.c         |  4 ++--\n builtin/show-ref.c       |  4 ++--\n builtin/unpack-objects.c |  4 ++--\n bulk-checkin.c           |  4 ++--\n cache-tree.c             | 15 ++++++++-------\n commit-graph.c           |  2 +-\n commit.c                 |  2 +-\n fetch-pack.c             |  8 ++++----\n http-push.c              | 14 ++++++++------\n http-walker.c            |  8 ++++----\n list-objects.c           |  4 ++--\n notes.c                  |  4 ++--\n odb.c                    |  6 +++---\n odb.h                    | 12 ++++++++++--\n reflog.c                 |  2 +-\n refs.c                   |  3 ++-\n remote.c                 |  2 +-\n send-pack.c              |  2 +-\n shallow.c                | 12 ++++++------\n upload-pack.c            |  2 +-\n walker.c                 |  4 ++--\n 30 files changed, 87 insertions(+), 74 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex a34ced04625..a6836692d0c 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3204,7 +3204,7 @@ static int apply_binary(struct apply_state *state,\n \t\treturn 0; /* deletion patch */\n \t}\n \n-\tif (has_object(the_repository, &oid, 0)) {\n+\tif (odb_has_object(the_repository->objects, &oid, 0)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n \t\tunsigned long size;\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex 0b49baa39fa..80056abe473 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -67,8 +67,8 @@ static int fill_missing_blobs(const char *path UNUSED,\n \t\treturn 0;\n \n \tfor (size_t i = 0; i < list->nr; i++) {\n-\t\tif (!has_object(ctx->repo, &list->oid[i],\n-\t\t\t\tOBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_has_object(ctx->repo->objects, &list->oid[i],\n+\t\t\t\t    OBJECT_INFO_FOR_PREFETCH))\n \t\t\toid_array_append(&ctx->current_batch, &list->oid[i]);\n \t}\n \ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 90a3e159d11..01672ec74bd 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -160,8 +160,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\tgoto cleanup;\n \n \tcase 'e':\n-\t\tret = !has_object(the_repository, &oid,\n-\t\t\t\t  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n+\t\tret = !odb_has_object(the_repository->objects, &oid,\n+\t\t\t\t      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n \t\tgoto cleanup;\n \n \tcase 'w':\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 3aabdf6570b..6d08abed37c 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -506,7 +506,7 @@ static void write_followtags(const struct ref *refs, const char *msg)\n \t\t\tcontinue;\n \t\tif (ends_with(ref->name, \"^{}\"))\n \t\t\tcontinue;\n-\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\tcontinue;\n \t\trefs_update_ref(get_main_ref_store(the_repository), msg,\n \t\t\t\tref->name, &ref->old_oid, NULL, 0,\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex b842bc9c51b..65ea6c84368 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -366,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t */\n \t\tif (ends_with(ref->name, \"^{}\")) {\n \t\t\tif (item &&\n-\t\t\t    !has_object(the_repository, &ref->old_oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &ref->old_oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &ref->old_oid) &&\n-\t\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\t\tclear_item(item);\n \t\t\titem = NULL;\n@@ -382,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t * fetch.\n \t\t */\n \t\tif (item &&\n-\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\tclear_item(item);\n \n@@ -403,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t * checked to see if it needs fetching.\n \t */\n \tif (item &&\n-\t    !has_object(the_repository, &item->oid, 0) &&\n+\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t    !oidset_contains(&fetch_oids, &item->oid))\n \t\tclear_item(item);\n \n@@ -910,8 +910,8 @@ static int update_local_ref(struct ref *ref,\n \tstruct commit *current = NULL, *updated;\n \tint fast_forward = 0;\n \n-\tif (!has_object(the_repository, &ref->new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, &ref->new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \n \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n@@ -1330,7 +1330,8 @@ static int check_exist_and_connected(struct ref *ref_map)\n \t * we need all direct targets to exist.\n \t */\n \tfor (r = rm; r; r = r->next) {\n-\t\tif (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (!odb_has_object(the_repository->objects, &r->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED))\n \t\t\treturn -1;\n \t}\n \n@@ -1485,7 +1486,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)\n \t\t\tstruct object_id oid;\n \t\t\tif (repo_get_oid(the_repository, s, &oid))\n \t\t\t\tdie(_(\"%s is not a valid object\"), s);\n-\t\t\tif (!has_object(the_repository, &oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &oid, 0))\n \t\t\t\tdie(_(\"the object %s does not exist\"), s);\n \t\t\toid_array_append(oids, &oid);\n \t\t\tcontinue;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6e3465b0266..0084cf7400b 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -161,7 +161,7 @@ static int mark_object(struct object *obj, enum object_type type,\n \t\treturn 0;\n \n \tif (!(obj->flags & HAS_OBJ)) {\n-\t\tif (parent && !has_object(the_repository, &obj->oid, 1)) {\n+\t\tif (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {\n \t\t\tprintf_ln(_(\"broken link from %7s %s\\n\"\n \t\t\t\t    \"              to %7s %s\"),\n \t\t\t\t  printable_type(&parent->oid, parent->type),\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 180d261f6ce..19c67a85344 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -893,8 +893,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \n \tif (startup_info->have_repository) {\n \t\tread_lock();\n-\t\tcollision_test_needed = has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_FETCH_PROMISOR);\n+\t\tcollision_test_needed = odb_has_object(the_repository->objects, oid,\n+\t\t\t\t\t\t       HAS_OBJECT_FETCH_PROMISOR);\n \t\tread_unlock();\n \t}\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 580a5c1996b..06bdeb4223b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3968,7 +3968,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void\n \t * Quietly ignore ALL missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0))\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0))\n \t\treturn;\n \n \tshow_object(obj, name, data);\n@@ -3982,7 +3982,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,\n \t * Quietly ignore EXPECTED missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0) &&\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0) &&\n \t    is_promisor_object(to_pack.repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 7ea273d93e4..26e77d70726 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1509,8 +1509,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \t}\n \n \tif (!is_null_oid(new_oid) &&\n-\t    !has_object(the_repository, new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(\"unpack should have generated %s, \"\n \t\t      \"but I can't find it!\", oid_to_hex(new_oid));\n \t\tret = \"bad pack\";\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex ac5b8d2a1a6..7cbda285ebe 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -454,8 +454,8 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \t\t\tinfo->status = PUSH_STATUS_UPTODATE;\n \t\telse if (is_null_oid(&ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_CREATE;\n-\t\telse if (has_object(the_repository, &ref->old_oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t\telse if (odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t\t\t ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_FASTFORWARD;\n \t\telse\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 90ec1de78f9..117709cb076 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -35,8 +35,8 @@ static void show_one(const struct show_one_options *opts,\n \tconst char *hex;\n \tstruct object_id peeled;\n \n-\tif (!has_object(the_repository, oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(\"git show-ref: bad ref %s (%s)\", refname,\n \t\t    oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 4bc6575a574..a69d59eb50c 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -449,8 +449,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\tdelta_data = get_data(delta_size);\n \t\tif (!delta_data)\n \t\t\treturn;\n-\t\tif (has_object(the_repository, &base_oid,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, &base_oid,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t; /* Ok we have this one */\n \t\telse if (resolve_against_held(nr, &base_oid,\n \t\t\t\t\t      delta_data, delta_size))\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 55406a539e7..16df86c0ba8 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -130,8 +130,8 @@ static void flush_batch_fsync(void)\n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n \t/* The object may already exist in the repository */\n-\tif (has_object(the_repository, oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 1;\n \n \t/* Might want to keep the list sorted */\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 9786b32b3a1..a4bc14ad15c 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -239,8 +239,8 @@ int cache_tree_fully_valid(struct cache_tree *it)\n \tif (!it)\n \t\treturn 0;\n \tif (it->entry_count < 0 ||\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0;\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tif (!cache_tree_fully_valid(it->down[i]->cache_tree))\n@@ -292,8 +292,8 @@ static int update_one(struct cache_tree *it,\n \t}\n \n \tif (0 <= it->entry_count &&\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn it->entry_count;\n \n \t/*\n@@ -399,8 +399,9 @@ static int update_one(struct cache_tree *it,\n \t\tce_missing_ok = mode == S_IFGITLINK || missing_ok ||\n \t\t\t!must_check_existence(ce);\n \t\tif (is_null_oid(oid) ||\n-\t\t    (!ce_missing_ok && !has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n+\t\t    (!ce_missing_ok &&\n+\t\t     !odb_has_object(the_repository->objects, oid,\n+\t\t\t\t     HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n \t\t\tstrbuf_release(&buffer);\n \t\t\tif (expected_missing)\n \t\t\t\treturn -1;\n@@ -448,7 +449,7 @@ static int update_one(struct cache_tree *it,\n \t\tstruct object_id oid;\n \t\thash_object_file(the_hash_algo, buffer.buf, buffer.len,\n \t\t\t\t OBJ_TREE, &oid);\n-\t\tif (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\toidcpy(&it->oid, &oid);\n \t\telse\n \t\t\tto_invalidate = 1;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 5f482d3377f..bd7b6f5338b 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1040,7 +1040,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje\n \t\treturn NULL;\n \tif (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos))\n \t\treturn NULL;\n-\tif (commit_graph_paranoia && !has_object(repo, id, 0))\n+\tif (commit_graph_paranoia && !odb_has_object(repo->objects, id, 0))\n \t\treturn NULL;\n \n \tcommit = lookup_commit(repo, id);\ndiff --git a/commit.c b/commit.c\nindex 28ee6b73ae6..15115125c36 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -575,7 +575,7 @@ int repo_parse_commit_internal(struct repository *r,\n \t\tif (commit_graph_paranoia == -1)\n \t\t\tcommit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);\n \n-\t\tif (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {\n+\t\tif (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {\n \t\t\tunparse_commit(r, &item->object.oid);\n \t\t\treturn quiet_on_missing ? -1 :\n \t\t\t\terror(_(\"commit %s exists in commit-graph but not in the object database\"),\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 0f5de1c94d1..5e74235fc06 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -142,7 +142,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \tcommit = lookup_commit_in_graph(the_repository, oid);\n \tif (commit) {\n \t\tif (mark_tags_complete_and_check_obj_db) {\n-\t\t\tif (!has_object(the_repository, oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\t\t\tdie_in_commit_graph_only(oid);\n \t\t}\n \t\treturn commit;\n@@ -770,7 +770,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,\n \t\tif (!commit) {\n \t\t\tstruct object *o;\n \n-\t\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\t\tcontinue;\n \t\t\to = parse_object(the_repository, &ref->old_oid);\n \t\t\tif (!o || o->type != OBJ_COMMIT)\n@@ -1984,8 +1984,8 @@ static void update_shallow(struct fetch_pack_args *args,\n \t\tstruct oid_array extra = OID_ARRAY_INIT;\n \t\tstruct object_id *oid = si->shallow->oid;\n \t\tfor (i = 0; i < si->shallow->nr; i++)\n-\t\t\tif (has_object(the_repository, &oid[i],\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &oid[i],\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\toid_array_append(&extra, &oid[i]);\n \t\tif (extra.nr) {\n \t\t\tsetup_alternate_shallow(&shallow_lock,\ndiff --git a/http-push.c b/http-push.c\nindex 9481825abfb..beb41732fb6 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1447,8 +1447,8 @@ static void one_remote_ref(const char *refname)\n \t * may be required for updating server info later.\n \t */\n \tif (repo->can_update_info_refs &&\n-\t    !has_object(the_repository, &ref->old_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tobj = lookup_unknown_object(the_repository, &ref->old_oid);\n \t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n \t\t\toid_to_hex(&ref->old_oid), refname);\n@@ -1653,14 +1653,16 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t\treturn error(\"Remote HEAD symrefs too deep\");\n \t\tif (is_null_oid(&head_oid))\n \t\t\treturn error(\"Unable to resolve remote HEAD\");\n-\t\tif (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &head_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", oid_to_hex(&head_oid));\n \n \t\t/* Remote branch must resolve to a known object */\n \t\tif (is_null_oid(&remote_ref->old_oid))\n \t\t\treturn error(\"Unable to resolve remote branch %s\",\n \t\t\t\t     remote_ref->name);\n-\t\tif (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &remote_ref->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, oid_to_hex(&remote_ref->old_oid));\n \n \t\t/* Remote branch must be an ancestor of remote HEAD */\n@@ -1881,8 +1883,8 @@ int cmd_main(int argc, const char **argv)\n \t\tif (!force_all &&\n \t\t    !is_null_oid(&ref->old_oid) &&\n \t\t    !ref->force) {\n-\t\t\tif (!has_object(the_repository, &ref->old_oid,\n-\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t\t    !ref_newer(&ref->peer_ref->new_oid,\n \t\t\t\t       &ref->old_oid)) {\n \t\t\t\t/*\ndiff --git a/http-walker.c b/http-walker.c\nindex 05fb9ce714a..0f7ae46d7f1 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -138,8 +138,8 @@ static int fill_active_slot(void *data UNUSED)\n \tlist_for_each_safe(pos, tmp, head) {\n \t\tobj_req = list_entry(pos, struct object_request, node);\n \t\tif (obj_req->state == WAITING) {\n-\t\t\tif (has_object(the_repository, &obj_req->oid,\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\tobj_req->state = COMPLETE;\n \t\t\telse {\n \t\t\t\tstart_object_request(obj_req);\n@@ -497,8 +497,8 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \tif (!obj_req)\n \t\treturn error(\"Couldn't find request for %s in the queue\", hex);\n \n-\tif (has_object(the_repository, &obj_req->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tif (obj_req->req)\n \t\t\tabort_http_object_request(&obj_req->req);\n \t\tabort_object_request(obj_req);\ndiff --git a/list-objects.c b/list-objects.c\nindex c50b9578584..42c17d95739 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -74,8 +74,8 @@ static void process_blob(struct traversal_context *ctx,\n \t * of missing objects.\n \t */\n \tif (ctx->revs->exclude_promisor_objects &&\n-\t    !has_object(the_repository, &obj->oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t    !odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t    is_promisor_object(ctx->revs->repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/notes.c b/notes.c\nindex 73eb5f00cf5..97b995f3f2d 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -794,8 +794,8 @@ static int prune_notes_helper(const struct object_id *object_oid,\n \tstruct note_delete_list **l = (struct note_delete_list **) cb_data;\n \tstruct note_delete_list *n;\n \n-\tif (has_object(the_repository, object_oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, object_oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0; /* nothing to do for this note */\n \n \t/* failed to find object => prune this note */\ndiff --git a/odb.c b/odb.c\nindex fc39fbe12d8..4dccb9215d8 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -871,7 +871,7 @@ int pretend_object_file(struct repository *repo,\n \tchar *co_buf;\n \n \thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (has_object(repo, oid, 0) ||\n+\tif (odb_has_object(repo->objects, oid, 0) ||\n \t    find_cached_object(repo->objects, oid))\n \t\treturn 0;\n \n@@ -953,7 +953,7 @@ void *read_object_with_reference(struct repository *r,\n \t}\n }\n \n-int has_object(struct repository *r, const struct object_id *oid,\n+int odb_has_object(struct object_database *odb, const struct object_id *oid,\n \t       unsigned flags)\n {\n \tunsigned object_info_flags = 0;\n@@ -965,7 +965,7 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\ndiff --git a/odb.h b/odb.h\nindex a4a5154fd0f..2532c490461 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -372,8 +372,9 @@ enum {\n  * Returns 1 if the object exists. This function will not lazily fetch objects\n  * in a partial clone by default.\n  */\n-int has_object(struct repository *r, const struct object_id *oid,\n-\t       unsigned flags);\n+int odb_has_object(struct object_database *odb,\n+\t\t   const struct object_id *oid,\n+\t\t   unsigned flags);\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect);\n@@ -463,4 +464,11 @@ static inline void *repo_read_object_file(struct repository *r,\n \treturn odb_read_object(r->objects, oid, type, size);\n }\n \n+static inline int has_object(struct repository *r,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     unsigned flags)\n+{\n+\treturn odb_has_object(r->objects, oid, flags);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/reflog.c b/reflog.c\nindex 747b82eada8..39c205fd26e 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -152,7 +152,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tinit_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size);\n \tcomplete = 1;\n \twhile (tree_entry(&desc, &entry)) {\n-\t\tif (!has_object(the_repository, &entry.oid,\n+\t\tif (!odb_has_object(the_repository->objects, &entry.oid,\n \t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/refs.c b/refs.c\nindex 0ff0e582a6b..26e5c2a7d9c 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -376,7 +376,8 @@ int ref_resolves_to_object(const char *refname,\n {\n \tif (flags & REF_ISBROKEN)\n \t\treturn 0;\n-\tif (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (!odb_has_object(repo->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(_(\"%s does not point to a valid object!\"), refname);\n \t\treturn 0;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 72c36239d31..5edf2a9f4b2 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1703,7 +1703,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\tif (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {\n \t\t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n-\t\t\telse if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\t\telse if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n \t\t\telse if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||\n \t\t\t\t !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))\ndiff --git a/send-pack.c b/send-pack.c\nindex abca2dd38a7..d029f748232 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -45,7 +45,7 @@ int option_parse_push_signed(const struct option *opt,\n static void feed_object(struct repository *r,\n \t\t\tconst struct object_id *oid, FILE *fh, int negative)\n {\n-\tif (negative && !has_object(r, oid, 0))\n+\tif (negative && !odb_has_object(r->objects, oid, 0))\n \t\treturn;\n \n \tif (negative)\ndiff --git a/shallow.c b/shallow.c\nindex d379756e39a..ef3adb635fd 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -310,8 +310,8 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n \tif (graft->nr_parent != -1)\n \t\treturn 0;\n \tif (data->flags & QUICK) {\n-\t\tif (!has_object(the_repository, &graft->oid,\n-\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &graft->oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn 0;\n \t} else if (data->flags & SEEN_ONLY) {\n \t\tstruct commit *c = lookup_commit(the_repository, &graft->oid);\n@@ -477,8 +477,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)\n \tALLOC_ARRAY(info->ours, sa->nr);\n \tALLOC_ARRAY(info->theirs, sa->nr);\n \tfor (size_t i = 0; i < sa->nr; i++) {\n-\t\tif (has_object(the_repository, sa->oid + i,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\tif (odb_has_object(the_repository->objects, sa->oid + i,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t\tstruct commit_graft *graft;\n \t\t\tgraft = lookup_commit_graft(the_repository,\n \t\t\t\t\t\t    &sa->oid[i]);\n@@ -515,8 +515,8 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)\n \tfor (i = dst = 0; i < info->nr_theirs; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->theirs[dst] = info->theirs[i];\n-\t\tif (has_object(the_repository, oid + info->theirs[i],\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, oid + info->theirs[i],\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\tdst++;\n \t}\n \tinfo->nr_theirs = dst;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex e994d6a901b..4f26f6afc77 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -509,7 +509,7 @@ static int got_oid(struct upload_pack_data *data,\n {\n \tif (get_oid_hex(hex, oid))\n \t\tdie(\"git upload-pack: expected SHA1 object, got '%s'\", hex);\n-\tif (!has_object(the_repository, oid, 0))\n+\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\treturn -1;\n \treturn do_got_oid(data, oid);\n }\ndiff --git a/walker.c b/walker.c\nindex a8abe8a2e78..d131af04c7b 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -150,8 +150,8 @@ static int process(struct walker *walker, struct object *obj)\n \t\treturn 0;\n \tobj->flags |= SEEN;\n \n-\tif (has_object(the_repository, &obj->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t/* We already have it, so we should scan it now. */\n \t\tobj->flags |= TO_SCAN;\n \t}\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519728","messageId":"20250605-pks-object-store-wo-the-repository-v5-16-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 16/17] odb: rename `pretend_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:47:06Z","receivedAt":"2025-06-05T06:47:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `pretend_object_file()` to `odb_pretend_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nNo compatibility wrapper is introduces as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n blame.c |  3 ++-\n odb.c   | 18 +++++++++---------\n odb.h   |  6 +++---\n 3 files changed, 14 insertions(+), 13 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 858d2d74df9..dce5c8d855c 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -277,7 +277,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \tconvert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);\n \torigin->file.ptr = buf.buf;\n \torigin->file.size = buf.len;\n-\tpretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);\n+\todb_pretend_object(the_repository->objects, buf.buf, buf.len,\n+\t\t\t   OBJ_BLOB, &origin->blob_oid);\n \n \t/*\n \t * Read the current index, replace the path entry with\ndiff --git a/odb.c b/odb.c\nindex 4dccb9215d8..f6231a0556d 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -863,21 +863,21 @@ int odb_read_object_info(struct object_database *odb,\n \treturn type;\n }\n \n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid)\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid)\n {\n \tstruct cached_object_entry *co;\n \tchar *co_buf;\n \n-\thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (odb_has_object(repo->objects, oid, 0) ||\n-\t    find_cached_object(repo->objects, oid))\n+\thash_object_file(odb->repo->hash_algo, buf, len, type, oid);\n+\tif (odb_has_object(odb, oid, 0) ||\n+\t    find_cached_object(odb, oid))\n \t\treturn 0;\n \n-\tALLOC_GROW(repo->objects->cached_objects,\n-\t\t   repo->objects->cached_object_nr + 1, repo->objects->cached_object_alloc);\n-\tco = &repo->objects->cached_objects[repo->objects->cached_object_nr++];\n+\tALLOC_GROW(odb->cached_objects,\n+\t\t   odb->cached_object_nr + 1, odb->cached_object_alloc);\n+\tco = &odb->cached_objects[odb->cached_object_nr++];\n \tco->value.size = len;\n \tco->value.type = type;\n \tco_buf = xmalloc(len);\ndiff --git a/odb.h b/odb.h\nindex 2532c490461..e4c51f8c38e 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -282,9 +282,9 @@ void *odb_read_object(struct object_database *odb,\n  * object in persistent storage before writing any other new objects\n  * that reference it.\n  */\n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid);\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid);\n \n struct object_info {\n \t/* Request */\n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"519729","messageId":"20250605-pks-object-store-wo-the-repository-v5-17-779d1c28774b@pks.im","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im","subject":"[PATCH v5 17/17] odb: rename `read_object_with_reference()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-05T06:47:07Z","receivedAt":"2025-06-05T06:47:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `read_object_with_reference()` to `odb_read_object_peeled()` to\nmatch other functions related to the object database and our modern\ncoding guidelines. Furthermore though, the old name didn't really\ndescribe very well what this function actually does, which is to walk\ndown any commit and tag objects until an object of the required type has\nbeen found. This is generally referred to as \"peeling\", so the new name\nshould be way more descriptive.\n\nNo compatibility wrapper is introduces as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/user-manual.adoc |  4 ++--\n builtin/cat-file.c             |  4 ++--\n builtin/fast-import.c          | 19 ++++++++-----------\n builtin/grep.c                 |  9 +++------\n builtin/pack-objects.c         |  4 ++--\n odb.c                          | 17 +++++++++--------\n odb.h                          | 15 +++++++--------\n tree-walk.c                    | 10 ++++------\n 8 files changed, 37 insertions(+), 45 deletions(-)\n\ndiff --git a/Documentation/user-manual.adoc b/Documentation/user-manual.adoc\nindex d2b478ad232..e86b2ad9f8a 100644\n--- a/Documentation/user-manual.adoc\n+++ b/Documentation/user-manual.adoc\n@@ -4301,11 +4301,11 @@ Now, for the meat:\n \n -----------------------------------------------------------------------------\n         case 0:\n-                buf = read_object_with_reference(sha1, argv[1], &size, NULL);\n+                buf = odb_read_object_peeled(r->objects, sha1, argv[1], &size, NULL);\n -----------------------------------------------------------------------------\n \n This is how you read a blob (actually, not only a blob, but any type of\n-object).  To know how the function `read_object_with_reference()` actually\n+object).  To know how the function `odb_read_object_peeled()` actually\n works, find the source code for it (something like `git grep\n read_object_with | grep \":[a-z]\"` in the Git repository), and read\n the source.\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 01672ec74bd..08afecbf57c 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -246,8 +246,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\t * fall-back to the usual case.\n \t\t\t */\n \t\t}\n-\t\tbuf = read_object_with_reference(the_repository, &oid,\n-\t\t\t\t\t\t exp_type_id, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &oid,\n+\t\t\t\t\t     exp_type_id, &size, NULL);\n \n \t\tif (use_mailmap) {\n \t\t\tsize_t s = size;\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 1973c504e25..b1389c59211 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -2535,10 +2535,9 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!repo_get_oid(the_repository, p, &commit_oid)) {\n \t\tunsigned long size;\n-\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t       &commit_oid,\n-\t\t\t\t\t\t       OBJ_COMMIT, &size,\n-\t\t\t\t\t\t       &commit_oid);\n+\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t   &commit_oid, OBJ_COMMIT, &size,\n+\t\t\t\t\t\t   &commit_oid);\n \t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\tdie(\"Not a valid commit: %s\", p);\n \t\tfree(buf);\n@@ -2604,9 +2603,8 @@ static void parse_from_existing(struct branch *b)\n \t\tunsigned long size;\n \t\tchar *buf;\n \n-\t\tbuf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t &b->oid, OBJ_COMMIT, &size,\n-\t\t\t\t\t\t &b->oid);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &b->oid,\n+\t\t\t\t\t     OBJ_COMMIT, &size, &b->oid);\n \t\tparse_from_commit(b, buf, size);\n \t\tfree(buf);\n \t}\n@@ -2699,10 +2697,9 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!repo_get_oid(the_repository, from, &n->oid)) {\n \t\t\tunsigned long size;\n-\t\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t\t       &n->oid,\n-\t\t\t\t\t\t\t       OBJ_COMMIT,\n-\t\t\t\t\t\t\t       &size, &n->oid);\n+\t\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t\t   &n->oid, OBJ_COMMIT,\n+\t\t\t\t\t\t\t   &size, &n->oid);\n \t\t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\t\tdie(\"Not a valid commit: %s\", from);\n \t\t\tfree(buf);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 5de61dfffe8..39273d9c0fd 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -522,9 +522,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tobj_read_lock();\n \t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n-\t\tdata = read_object_with_reference(subrepo,\n-\t\t\t\t\t\t  oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(subrepo->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \n@@ -705,9 +703,8 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \n-\t\tdata = read_object_with_reference(opt->repo,\n-\t\t\t\t\t\t  &obj->oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(opt->repo->objects, &obj->oid,\n+\t\t\t\t\t      OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(&obj->oid));\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 06bdeb4223b..e88a13dbb9f 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2055,8 +2055,8 @@ static void add_preferred_base(struct object_id *oid)\n \tif (window <= num_preferred_base++)\n \t\treturn;\n \n-\tdata = read_object_with_reference(the_repository, oid,\n-\t\t\t\t\t  OBJ_TREE, &size, &tree_oid);\n+\tdata = odb_read_object_peeled(the_repository->objects, oid,\n+\t\t\t\t      OBJ_TREE, &size, &tree_oid);\n \tif (!data)\n \t\treturn;\n \ndiff --git a/odb.c b/odb.c\nindex f6231a0556d..7d4db7cb49c 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -905,11 +905,11 @@ void *odb_read_object(struct object_database *odb,\n \treturn data;\n }\n \n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *actual_oid_return)\n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *actual_oid_return)\n {\n \tenum object_type type;\n \tvoid *buffer;\n@@ -921,7 +921,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(odb, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\n@@ -941,9 +941,10 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n+\t\tif (ref_length + odb->repo->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid,\n+\t\t\t\t      odb->repo->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\ndiff --git a/odb.h b/odb.h\nindex e4c51f8c38e..e922f256802 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -274,6 +274,12 @@ void *odb_read_object(struct object_database *odb,\n \t\t      enum object_type *type,\n \t\t      unsigned long *size);\n \n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *oid_ret);\n+\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -382,7 +388,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: odb_read_object(),\n- * read_object_with_reference(), odb_read_object_info() and odb().\n+ * odb_read_object_peeled(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -431,13 +437,6 @@ enum for_each_object_flags {\n \tFOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),\n };\n \n-\n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *oid_ret);\n-\n /* Compatibility wrappers, to be removed once Git 2.51 has been released. */\n #include \"repository.h\"\n \ndiff --git a/tree-walk.c b/tree-walk.c\nindex 766af99f466..e449a1320e5 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -90,7 +90,7 @@ void *fill_tree_descriptor(struct repository *r,\n \tvoid *buf = NULL;\n \n \tif (oid) {\n-\t\tbuf = read_object_with_reference(r, oid, OBJ_TREE, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(r->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!buf)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \t}\n@@ -611,7 +611,7 @@ int get_tree_entry(struct repository *r,\n \tunsigned long size;\n \tstruct object_id root;\n \n-\ttree = read_object_with_reference(r, tree_oid, OBJ_TREE, &size, &root);\n+\ttree = odb_read_object_peeled(r->objects, tree_oid, OBJ_TREE, &size, &root);\n \tif (!tree)\n \t\treturn -1;\n \n@@ -681,10 +681,8 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n \t\t\tunsigned long size;\n-\t\t\ttree = read_object_with_reference(r,\n-\t\t\t\t\t\t\t  &current_tree_oid,\n-\t\t\t\t\t\t\t  OBJ_TREE, &size,\n-\t\t\t\t\t\t\t  &root);\n+\t\t\ttree = odb_read_object_peeled(r->objects, &current_tree_oid,\n+\t\t\t\t\t\t      OBJ_TREE, &size, &root);\n \t\t\tif (!tree)\n \t\t\t\tgoto done;\n \n\n-- \n2.50.0.rc1.591.g9c95f17f64.dirty\n\n"},{"id":"520891","messageId":"yeimqezalnffifo57opsmngxdyggu2rv53mj3plp5alx37j6pl@slkxiv4brpso","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-2-779d1c28774b@pks.im","subject":"Re: [PATCH v5 02/17] object-store: rename `object_directory` to `odb_source`","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-06-30T02:02:04Z","receivedAt":"2025-06-30T02:07:33Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/06/05 08:46AM, Patrick Steinhardt wrote:\n> The `object_directory` structure is used as an access point for a single\n> object directory like \".git/objects\". While the structure isn't yet\n> fully self-contained, the intent is for it to eventually contain all\n> information required to access objects in one specific location.\n> \n> While the name \"object directory\" is a good fit for now, this will\n> change over time as we continue with the agenda to make pluggable object\n> databases a thing. Eventually, objects may not be accessed via any kind\n> of directory at all anymore, but they could instead be backed by any\n> kind of durable storage mechanism. While it seems quite far-fetched for\n> now, it is thinkable that eventually this might even be some form of a\n> database, for example.\n> \n> As such, the current name of this structure will become worse over time\n> as we evolve into the direction of pluggable ODBs. Immediate next steps\n> will start to carve out proper self-contained object directories, which\n> requires us to pass in these object directories as parameters. Based on\n> our modern naming schema this means that those functions should then be\n> named after their subsystem, which means that we would start to bake the\n> current name into the codebase more and more.\n> \n> Let's preempt this by renaming the structure. There have been a couple\n> alternatives that were discussed:\n> \n>   - `odb_backend` was discarded because it led to the association that\n>     one object database has a single backend, but the model is that one\n>     alternate has one backend. Furthermore, \"backend\" is more about the\n>     actual backing implementation and less about the high-level concept.\n> \n>   - `odb_alternate` was discarded because it is a bit of a stretch to\n>     also call the main object directory an \"alternate\".\n> \n> Instead, pick `odb_source` as the new name. It makes it sufficiently\n> clear that there can be multiple sources and does not cause confusion\n> when mixed with the already-existing \"alternate\" terminology.\n\nI'm biased, but I think the new name fits well ;)\n\n> \n> In the future, this change allows us to easily introduce for example a\n> `odb_files_source` and other format-specific implementations.\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n[snip]\n> -struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n> +struct odb_source *find_odb(struct repository *r, const char *obj_dir)\n\nSince we renamed `object_directory` to `odb_source`, should instead call\nthis function `find_odb_source`?\n\nOtherwise, the renames in this patch look good to me.\n\n-Justin\n"},{"id":"520892","messageId":"xgbzzqyfnfmjmtucnq3qd3bfqdal6vjkaap3xfspeetbs6ontk@4vclbvlreere","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-4-779d1c28774b@pks.im","subject":"Re: [PATCH v5 04/17] odb: introduce parent pointers","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-06-30T02:34:12Z","receivedAt":"2025-06-30T02:39:41Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/06/05 08:46AM, Patrick Steinhardt wrote:\n> In subsequent commits we'll get rid of our use of `the_repository` in\n> \"odb.c\" in favor of explicitly passing in a `struct object_database` or\n> a `struct odb_source`. In some cases though we'll need access to the\n> repository, for example to read a config value from it, but we don't\n> have a way to access the repository owning a specific object database.\n> \n> Introduce parent pointers for `struct object_database` to its owning\n> repository as well as for `struct odb_source` to its owning object\n> database, which will allow us to adapt those use cases.\n\nOk so in this patch we are introducing the parent pointers and setting\nthem up, but not actually using them for anything yet.\n\n> Note that this change requires us to pass through the object database to\n> `link_alt_odb_entry()` so that we can set up the parent pointers for any\n> source there. The callchain is adapted to pass through the object\n> database accordingly.\n\nOk IIUC, for `link_alt_odb_entry()`, the reason we to pass `struct\nobject_database` instead of `struct odb_source` is because the sources\nneed to be set up with the pointer to the parent odb. That makes sense.\n\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  odb.c        | 47 +++++++++++++++++++++++++++--------------------\n>  odb.h        |  8 +++++++-\n>  repository.c |  3 ++-\n>  3 files changed, 36 insertions(+), 22 deletions(-)\n> \n> diff --git a/odb.c b/odb.c\n> index d1025ac182d..afb16f4c693 100644\n> --- a/odb.c\n> +++ b/odb.c\n> @@ -135,11 +135,15 @@ static int alt_odb_usable(struct object_database *o,\n>   * of the object ID, an extra slash for the first level indirection, and\n>   * the terminating NUL.\n>   */\n> -static void read_info_alternates(struct repository *r,\n> +static void read_info_alternates(struct object_database *odb,\n>  \t\t\t\t const char *relative_base,\n>  \t\t\t\t int depth);\n> -static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n> -\tconst char *relative_base, int depth, const char *normalized_objdir)\n> +\n> +static int link_alt_odb_entry(struct object_database *odb,\n> +\t\t\t      const struct strbuf *entry,\n> +\t\t\t      const char *relative_base,\n> +\t\t\t      int depth,\n> +\t\t\t      const char *normalized_objdir)\n>  {\n>  \tstruct odb_source *alternate;\n>  \tstruct strbuf pathbuf = STRBUF_INIT;\n> @@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n>  \twhile (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')\n>  \t\tstrbuf_setlen(&pathbuf, pathbuf.len - 1);\n>  \n> -\tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n> +\tif (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))\n>  \t\tgoto error;\n>  \n>  \tCALLOC_ARRAY(alternate, 1);\n> -\t/* pathbuf.buf is already in r->objects->source_by_path */\n> +\talternate->odb = odb;\n> +\t/* pathbuf.buf is already in r->objects->alternate_by_path */\n\nShould this comment instead say \"odb->source_by_path\"?\n\nThe remaining restructuring in this patch looks good.\n\n-Justin\n"},{"id":"520893","messageId":"ymga4fqaki4sszepcgbrvco4qinurmc4ebadik5cog4a2qnke3@ihjhtngygpr6","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-5-779d1c28774b@pks.im","subject":"Re: [PATCH v5 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-06-30T02:36:41Z","receivedAt":"2025-06-30T02:42:08Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/06/05 08:46AM, Patrick Steinhardt wrote:\n> Get rid of our dependency on `the_repository` in `find_odb()` by passing\n> in the object database in which we want to search for the source and\n> adjusting all callers.\n> \n> Rename the function to `odb_find_source()`.\n\nOk, this addresses a previous comment about renaming \"find_odb()\".\n\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n"},{"id":"520894","messageId":"zsrwwg5mhxx7xk53i7czza5sageivnm2hxj5nlvunpe4gzrrjq@n5ne6qwovyom","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-8-779d1c28774b@pks.im","subject":"Re: [PATCH v5 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-06-30T02:56:05Z","receivedAt":"2025-06-30T03:01:33Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/06/05 08:46AM, Patrick Steinhardt wrote:\n> The functions to manage alternates all depend on `the_repository`.\n> Refactor them to accept an object database as parameter and adjusting\n\ns/parameter and adjusting/a parameter and adjust/\n\n> all callers. The functions are renamed accordingly.\n> \n> Note that right now the situation is still somewhat weird because we end\n> up using the path provided by the object store's repository anyway. This\n> will be adapted over time though so that we instead store the path to\n> the primary object directory in the object database itself.\n\nJust to clarify, are we walking about the path to the alternate odb? I'm\nnot quite sure I follow.\n\nThe renames and refactors in this patch look good.\n\n-Justin\n\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n"},{"id":"520895","messageId":"dzc7sculdp4orsvpi5kdf6h6tcgmtbz3c2ttzgiubbrhprtrpf@flzrwl5tso4z","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-16-779d1c28774b@pks.im","subject":"Re: [PATCH v5 16/17] odb: rename `pretend_object_file()`","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-06-30T03:14:23Z","receivedAt":"2025-06-30T03:19:50Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/06/05 08:47AM, Patrick Steinhardt wrote:\n> Rename `pretend_object_file()` to `odb_pretend_object()` to match other\n> functions related to the object database and our modern coding\n> guidelines.\n> \n> No compatibility wrapper is introduces as the function is not used a lot\n\ns/introduces/introduced\n\n> throughout our codebase.\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n"},{"id":"520896","messageId":"nwxweqp6yd7zdstvlps3dq3jnewzxsfnisgd5ripxtmwbklrmg@zre2usdx5uvg","threadId":"63403","inReplyTo":"20250605-pks-object-store-wo-the-repository-v5-17-779d1c28774b@pks.im","subject":"Re: [PATCH v5 17/17] odb: rename `read_object_with_reference()`","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-06-30T03:15:51Z","receivedAt":"2025-06-30T03:21:23Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/06/05 08:47AM, Patrick Steinhardt wrote:\n> Rename `read_object_with_reference()` to `odb_read_object_peeled()` to\n> match other functions related to the object database and our modern\n> coding guidelines. Furthermore though, the old name didn't really\n> describe very well what this function actually does, which is to walk\n> down any commit and tag objects until an object of the required type has\n> been found. This is generally referred to as \"peeling\", so the new name\n> should be way more descriptive.\n> \n> No compatibility wrapper is introduces as the function is not used a lot\n> throughout our codebase.\n\nSame small typo:\n\ns/introduces/introduced/\n\nThe change itself looks good though :)\n\n-Justin\n"},{"id":"521021","messageId":"aGPR8K_WxZj7jJvk@pks.im","threadId":"63403","inReplyTo":"yeimqezalnffifo57opsmngxdyggu2rv53mj3plp5alx37j6pl@slkxiv4brpso","subject":"Re: [PATCH v5 02/17] object-store: rename `object_directory` to `odb_source`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:17:52Z","receivedAt":"2025-07-01T12:17:58Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Jun 29, 2025 at 09:02:04PM -0500, Justin Tobler wrote:\n> On 25/06/05 08:46AM, Patrick Steinhardt wrote:\n> [snip]\n> > -struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n> > +struct odb_source *find_odb(struct repository *r, const char *obj_dir)\n> \n> Since we renamed `object_directory` to `odb_source`, should instead call\n> this function `find_odb_source`?\n> \n> Otherwise, the renames in this patch look good to me.\n\nThe name gets adjusted to `odb_find_source()` in a later patch.\n\nPatrick\n"},{"id":"521022","messageId":"aGPR9zMyN1AZ4uUh@pks.im","threadId":"63403","inReplyTo":"xgbzzqyfnfmjmtucnq3qd3bfqdal6vjkaap3xfspeetbs6ontk@4vclbvlreere","subject":"Re: [PATCH v5 04/17] odb: introduce parent pointers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:17:59Z","receivedAt":"2025-07-01T12:18:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Jun 29, 2025 at 09:34:12PM -0500, Justin Tobler wrote:\n> > @@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n> >  \twhile (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')\n> >  \t\tstrbuf_setlen(&pathbuf, pathbuf.len - 1);\n> >  \n> > -\tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n> > +\tif (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))\n> >  \t\tgoto error;\n> >  \n> >  \tCALLOC_ARRAY(alternate, 1);\n> > -\t/* pathbuf.buf is already in r->objects->source_by_path */\n> > +\talternate->odb = odb;\n> > +\t/* pathbuf.buf is already in r->objects->alternate_by_path */\n> \n> Should this comment instead say \"odb->source_by_path\"?\n> \n> The remaining restructuring in this patch looks good.\n\nAh, good catch. I think I botched conflict resolution here.\n\nPatrick\n"},{"id":"521023","messageId":"aGPR_L__pP-4gBJl@pks.im","threadId":"63403","inReplyTo":"zsrwwg5mhxx7xk53i7czza5sageivnm2hxj5nlvunpe4gzrrjq@n5ne6qwovyom","subject":"Re: [PATCH v5 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:18:04Z","receivedAt":"2025-07-01T12:18:10Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Jun 29, 2025 at 09:56:05PM -0500, Justin Tobler wrote:\n> On 25/06/05 08:46AM, Patrick Steinhardt wrote:\n> > all callers. The functions are renamed accordingly.\n> > \n> > Note that right now the situation is still somewhat weird because we end\n> > up using the path provided by the object store's repository anyway. This\n> > will be adapted over time though so that we instead store the path to\n> > the primary object directory in the object database itself.\n> \n> Just to clarify, are we walking about the path to the alternate odb? I'm\n> not quite sure I follow.\n\nYeah, this is phrased a bit weirdly. What I wanted to say is that we\nbasically end up using `repo_git_path(odb->repo, ...)` anyway, so we\ncould have just passed in the repository itself.\n\nI'll rephrase the commit message a bit.\n\nPatrick\n"},{"id":"521024","messageId":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH v6 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:12Z","receivedAt":"2025-07-01T12:22:22Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series refactors the object store subsystem to become more\nself-contained by getting rid of `the_repository`. Instead of passing in\nthe repository explicitly, we start to pass in the object store itself,\nwhich is in contrast to many other refactorings we did, but in line with\nwhat we did for the ref store, as well.\n\nThis series also starts to properly scope functions to the carved out\nobject database subsystem, which requires a bit of shuffling. This\nallows us to have a short-and-sweet `odb_` prefix for functions and\nprepares us for a future with pluggable object backends.\n\nThe series is structured as follows:\n\n  - Patches 1 to 3 rename `struct object_store` and `struct\n    object_directory` as well as the code files.\n\n  - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n\n  - Patches 13 to 17 adjust the name of remaining functions so that they\n    can be clearly attributed to the ODB. I'm happy to kick these\n    patches out of this series and resend them at a later point in case\n    they create too much turmoil.\n\nThis series is built on top of 6f84262c44a (The eleventh batch,\n2025-05-05) with ps/object-store-cleanup at 8a9e27be821 (object-store:\ndrop `repo_has_object_file()`, 2025-04-29) merged into it. There are a\ncouple of trivial conflicts when merged with \"seen\", I have appended the\nmerge conflict resolution as a patch at the end of this mail.\n\nChanges in v2:\n  - Fix for a copy-and-pasted commit message.\n  - Rename `struct odb_backend` to `struct odb_alternate`. I'm happy to\n    revert to the previous name if we ultimately think it's the better\n    suited one.\n  - A couple of fixes to move changes into the correct commit. `git\n    rebase -x 'meson compile -C build'` is now clean.\n  - I _didn't_ back out the rename to \"odb.{c,h}\". Junio has already\n    fixed the fallout, so it's probably more work for him to kick it out\n    again than to just leave it in.\n  - Link to v1: https://lore.kernel.org/r/20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im\n\nChanges in v3:\n  - Polishing for some comments and commit messages.\n  - Link to v2: https://lore.kernel.org/r/20250509-pks-object-store-wo-the-repository-v2-0-103f59bf8e28@pks.im\n\nChanges in v4:\n  - Rebased the patch series on top of 7014b55638d (A bit more topics\n    for -rc1, 2025-05-30). This fixes a couple of merge conflicts, most\n    importantly with jk/no-funny-object-types.\n  - Rename `struct odb_alternate` to `odb_source`.\n  - Link to v3: https://lore.kernel.org/r/20250514-pks-object-store-wo-the-repository-v3-0-47df1d4ead22@pks.im\n\nChanges in v5:\n  - Some polishing to fix leftover terminology from previous rounds.\n  - Link to v4: https://lore.kernel.org/r/20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im\n\nChanges in v6:\n  - Fix a mis-merged comment.\n  - A couple of commit message improvements.\n  - Link to v5: https://lore.kernel.org/r/20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (17):\n      object-store: rename `raw_object_store` to `object_database`\n      object-store: rename `object_directory` to `odb_source`\n      object-store: rename files to \"odb.{c,h}\"\n      odb: introduce parent pointers\n      odb: get rid of `the_repository` in `find_odb()`\n      odb: get rid of `the_repository` in `assert_oid_type()`\n      odb: get rid of `the_repository` in `odb_mkstemp()`\n      odb: get rid of `the_repository` when handling alternates\n      odb: get rid of `the_repository`  in `for_each()` functions\n      odb: get rid of `the_repository` when handling the primary source\n      odb: get rid of `the_repository` when handling submodule sources\n      odb: trivial refactorings to get rid of `the_repository`\n      odb: rename `oid_object_info()`\n      odb: rename `repo_read_object_file()`\n      odb: rename `has_object()`\n      odb: rename `pretend_object_file()`\n      odb: rename `read_object_with_reference()`\n\n Documentation/user-manual.adoc          |   4 +-\n Makefile                                |   2 +-\n apply.c                                 |  14 +-\n archive-tar.c                           |   2 +-\n archive-zip.c                           |   2 +-\n archive.c                               |   6 +-\n attr.c                                  |   4 +-\n bisect.c                                |   8 +-\n blame.c                                 |  22 +-\n builtin/backfill.c                      |   6 +-\n builtin/blame.c                         |   6 +-\n builtin/cat-file.c                      |  62 ++---\n builtin/checkout.c                      |   2 +-\n builtin/clone.c                         |  14 +-\n builtin/commit-graph.c                  |  20 +-\n builtin/commit-tree.c                   |   4 +-\n builtin/count-objects.c                 |   6 +-\n builtin/describe.c                      |   5 +-\n builtin/difftool.c                      |   4 +-\n builtin/fast-export.c                   |  10 +-\n builtin/fast-import.c                   |  49 ++--\n builtin/fetch.c                         |  21 +-\n builtin/fsck.c                          |  31 ++-\n builtin/gc.c                            |  16 +-\n builtin/grep.c                          |  26 +-\n builtin/hash-object.c                   |   2 +-\n builtin/index-pack.c                    |  29 +-\n builtin/log.c                           |   4 +-\n builtin/ls-files.c                      |   4 +-\n builtin/ls-tree.c                       |   6 +-\n builtin/merge-file.c                    |   2 +-\n builtin/merge-tree.c                    |  14 +-\n builtin/mktag.c                         |   6 +-\n builtin/mktree.c                        |  10 +-\n builtin/multi-pack-index.c              |   6 +-\n builtin/notes.c                         |   8 +-\n builtin/pack-objects.c                  |  70 ++---\n builtin/pack-redundant.c                |   2 +-\n builtin/prune.c                         |   6 +-\n builtin/receive-pack.c                  |   9 +-\n builtin/remote.c                        |   6 +-\n builtin/repack.c                        |   7 +-\n builtin/replace.c                       |  12 +-\n builtin/rev-list.c                      |   8 +-\n builtin/show-ref.c                      |   6 +-\n builtin/submodule--helper.c             |  11 +-\n builtin/tag.c                           |  10 +-\n builtin/unpack-file.c                   |   4 +-\n builtin/unpack-objects.c                |  12 +-\n bulk-checkin.c                          |   6 +-\n bundle-uri.c                            |   5 +-\n bundle.c                                |   6 +-\n cache-tree.c                            |  17 +-\n combine-diff.c                          |   4 +-\n commit-graph.c                          | 106 +++----\n commit-graph.h                          |  20 +-\n commit.c                                |  15 +-\n config.c                                |   4 +-\n connected.c                             |   2 +-\n contrib/coccinelle/the_repository.cocci |   2 +-\n diagnose.c                              |  12 +-\n diff.c                                  |  20 +-\n dir.c                                   |   2 +-\n entry.c                                 |   6 +-\n fetch-pack.c                            |  17 +-\n fmt-merge-msg.c                         |   6 +-\n fsck.c                                  |   4 +-\n grep.c                                  |   6 +-\n http-backend.c                          |   2 +-\n http-push.c                             |  20 +-\n http-walker.c                           |  12 +-\n http.c                                  |   6 +-\n list-objects-filter.c                   |   4 +-\n list-objects.c                          |   6 +-\n log-tree.c                              |   2 +-\n loose.c                                 |  46 ++--\n mailmap.c                               |   4 +-\n match-trees.c                           |   6 +-\n merge-blobs.c                           |  10 +-\n merge-ort.c                             |   8 +-\n meson.build                             |   2 +-\n midx-write.c                            |   2 +-\n midx.c                                  |   6 +-\n notes-cache.c                           |   4 +-\n notes-merge.c                           |   4 +-\n notes.c                                 |  19 +-\n object-file.c                           |  94 +++----\n object-file.h                           |  12 +-\n object-name.c                           |  24 +-\n object-store.h                          | 338 -----------------------\n object.c                                |   8 +-\n object-store.c => odb.c                 | 413 +++++++++++++++-------------\n odb.h                                   | 473 ++++++++++++++++++++++++++++++++\n oss-fuzz/fuzz-pack-idx.c                |   2 +-\n pack-bitmap-write.c                     |   9 +-\n pack-bitmap.c                           |  10 +-\n pack-check.c                            |   2 +-\n pack-mtimes.c                           |   2 +-\n pack-objects.h                          |   2 +-\n pack-revindex.c                         |   2 +-\n pack-write.c                            |  10 +-\n packfile.c                              |  29 +-\n packfile.h                              |   8 +-\n path.c                                  |   4 +-\n promisor-remote.c                       |   6 +-\n protocol-caps.c                         |   4 +-\n reachable.c                             |   2 +-\n read-cache.c                            |  14 +-\n ref-filter.c                            |   6 +-\n reflog.c                                |   8 +-\n refs.c                                  |   7 +-\n remote.c                                |   9 +-\n replace-object.c                        |   2 +-\n replace-object.h                        |   2 +-\n repository.c                            |  21 +-\n repository.h                            |   4 +-\n rerere.c                                |   7 +-\n revision.c                              |   5 +-\n send-pack.c                             |   4 +-\n sequencer.c                             |   7 +-\n server-info.c                           |   2 +-\n shallow.c                               |  14 +-\n streaming.c                             |  10 +-\n submodule-config.c                      |   9 +-\n submodule.c                             |  32 +--\n submodule.h                             |   9 -\n t/helper/test-find-pack.c               |   2 +-\n t/helper/test-pack-mtimes.c             |   2 +-\n t/helper/test-partial-clone.c           |   4 +-\n t/helper/test-read-graph.c              |   8 +-\n t/helper/test-read-midx.c               |   2 +-\n t/helper/test-ref-store.c               |   4 +-\n tag.c                                   |  10 +-\n tmp-objdir.c                            |  30 +-\n tree-walk.c                             |  18 +-\n tree.c                                  |   6 +-\n unpack-trees.c                          |   2 +-\n upload-pack.c                           |   4 +-\n walker.c                                |   6 +-\n xdiff-interface.c                       |   4 +-\n 140 files changed, 1453 insertions(+), 1298 deletions(-)\n\nRange-diff versus v5:\n\n 1:  9df738c135b =  1:  55efa04c9b5 object-store: rename `raw_object_store` to `object_database`\n 2:  85ee1dd80f0 =  2:  9e259ec9129 object-store: rename `object_directory` to `odb_source`\n 3:  8a9e759fcfa =  3:  4bef9e8ca2e object-store: rename files to \"odb.{c,h}\"\n 4:  872828f8061 !  4:  4a82e103b22 odb: introduce parent pointers\n    @@ odb.c: static int link_alt_odb_entry(struct repository *r, const struct strbuf *\n      \t\tgoto error;\n      \n      \tCALLOC_ARRAY(alternate, 1);\n    --\t/* pathbuf.buf is already in r->objects->source_by_path */\n     +\talternate->odb = odb;\n    -+\t/* pathbuf.buf is already in r->objects->alternate_by_path */\n    + \t/* pathbuf.buf is already in r->objects->source_by_path */\n      \talternate->path = strbuf_detach(&pathbuf, NULL);\n      \n      \t/* add the alternate entry */\n 5:  bf292f80e6a =  5:  d1096993665 odb: get rid of `the_repository` in `find_odb()`\n 6:  03f57d8efbc =  6:  8bd70f6e303 odb: get rid of `the_repository` in `assert_oid_type()`\n 7:  2aafcbaf706 =  7:  97cd748c462 odb: get rid of `the_repository` in `odb_mkstemp()`\n 8:  9a9eaa9fe0f !  8:  bfc550d81e6 odb: get rid of `the_repository` when handling alternates\n    @@ Commit message\n         odb: get rid of `the_repository` when handling alternates\n     \n         The functions to manage alternates all depend on `the_repository`.\n    -    Refactor them to accept an object database as parameter and adjusting\n    -    all callers. The functions are renamed accordingly.\n    +    Refactor them to accept an object database as a parameter and adjust all\n    +    callers. The functions are renamed accordingly.\n     \n         Note that right now the situation is still somewhat weird because we end\n    -    up using the path provided by the object store's repository anyway. This\n    -    will be adapted over time though so that we instead store the path to\n    -    the primary object directory in the object database itself.\n    +    up using the object store path provided by the object store's repository\n    +    anyway. Consequently, we could have instead passed in a pointer to the\n    +    repository instead of passing in the pointer to the object store. This\n    +    will be addressed in subsequent commits though, where we will start to\n    +    use the path owned by the object store itself.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n     \n 9:  1618716a75f =  9:  34649c4cbe1 odb: get rid of `the_repository`  in `for_each()` functions\n10:  9c282be2a37 = 10:  5954680f7be odb: get rid of `the_repository` when handling the primary source\n11:  eb31130c720 = 11:  25b07546210 odb: get rid of `the_repository` when handling submodule sources\n12:  a5d6a5fb8a1 = 12:  945c95ba26c odb: trivial refactorings to get rid of `the_repository`\n13:  61e3cb25aa2 = 13:  624c80b44cb odb: rename `oid_object_info()`\n14:  1ab82f81ff5 = 14:  366c2733c69 odb: rename `repo_read_object_file()`\n15:  427eb9893b9 = 15:  cf287279010 odb: rename `has_object()`\n16:  bdf62e5cf47 ! 16:  42c14c70181 odb: rename `pretend_object_file()`\n    @@ Commit message\n         functions related to the object database and our modern coding\n         guidelines.\n     \n    -    No compatibility wrapper is introduces as the function is not used a lot\n    +    No compatibility wrapper is introduced as the function is not used a lot\n         throughout our codebase.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n17:  550d4a75562 ! 17:  ad0b56350b0 odb: rename `read_object_with_reference()`\n    @@ Commit message\n         been found. This is generally referred to as \"peeling\", so the new name\n         should be way more descriptive.\n     \n    -    No compatibility wrapper is introduces as the function is not used a lot\n    +    No compatibility wrapper is introduced as the function is not used a lot\n         throughout our codebase.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n\n---\nbase-commit: 7014b55638da979331baf8dc31c4e1d697cf2d67\nchange-id: 20250505-pks-object-store-wo-the-repository-9c6cbdf8d4b1\n\n"},{"id":"521025","messageId":"20250701-pks-object-store-wo-the-repository-v6-1-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:13Z","receivedAt":"2025-07-01T12:22:25Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `raw_object_store` structure is the central entry point for reading\nand writing objects in a repository. The main purpose of this structure\nis to manage object directories and provide an interface to access and\nwrite objects in those object directories.\n\nRight now, many of the functions associated with the raw object store\nimplicitly rely on `the_repository` to get access to its `objects`\npointer, which is the `raw_object_store`. As we want to generally get\nrid of using `the_repository` across our codebase we will have to\nconvert this implicit dependency on this global variable into an\nexplicit parameter.\n\nThis conversion can be done by simply passing in an explicit pointer to\na repository and then using its `->objects` pointer. But there is a\nsecond effort underway, which is to make the object subsystem more\nselfcontained so that we can eventually have pluggable object backends.\nAs such, passing in a repository wouldn't make a ton of sense, and the\ngoal is to convert the object store interfaces such that we always pass\nin a reference to the `raw_object_store` instead.\n\nThis will expose the `raw_object_store` type to a lot more callers\nthough, which surfaces that this type is named somewhat awkwardly. The\n\"raw_\" prefix makes readers wonder whether there is a non-raw variant of\nthe object store, but there isn't. Furthermore, we nowadays want to name\nfunctions in a way that they can be clearly attributed to a specific\nsubsystem, but calling them e.g. `raw_object_store_has_object()` is just\ntoo unwieldy, even when dropping the \"raw_\" prefix.\n\nInstead, rename the structure to `object_database`. This term is already\nused a lot throughout our codebase, and it cannot easily be mistaken for\n\"object directories\", either. Furthermore, its acronym ODB is already\nwell-known and works well as part of a function's name, like for example\n`odb_has_object()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n commit-graph.c |  2 +-\n commit-graph.h |  4 ++--\n object-store.c | 12 ++++++------\n object-store.h | 11 ++++++++---\n packfile.c     |  2 +-\n packfile.h     |  4 ++--\n repository.c   |  4 ++--\n repository.h   |  4 ++--\n 8 files changed, 24 insertions(+), 19 deletions(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex ad3943b6906..905fcbdf0e8 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -829,7 +829,7 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)\n \treturn NULL;\n }\n \n-void close_commit_graph(struct raw_object_store *o)\n+void close_commit_graph(struct object_database *o)\n {\n \tif (!o->commit_graph)\n \t\treturn;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 13f662827d4..20d38c100ce 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -26,7 +26,7 @@ void git_test_write_commit_graph_or_die(void);\n struct commit;\n struct bloom_filter_settings;\n struct repository;\n-struct raw_object_store;\n+struct object_database;\n struct string_list;\n \n char *get_commit_graph_filename(struct object_directory *odb);\n@@ -186,7 +186,7 @@ int write_commit_graph(struct object_directory *odb,\n \n int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags);\n \n-void close_commit_graph(struct raw_object_store *);\n+void close_commit_graph(struct object_database *);\n void free_commit_graph(struct commit_graph *);\n \n /*\ndiff --git a/object-store.c b/object-store.c\nindex 58cde0313a5..f4e8f99d90f 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -44,7 +44,7 @@ struct cached_object_entry {\n \t} value;\n };\n \n-static const struct cached_object *find_cached_object(struct raw_object_store *object_store,\n+static const struct cached_object *find_cached_object(struct object_database *object_store,\n \t\t\t\t\t\t      const struct object_id *oid)\n {\n \tstatic const struct cached_object empty_tree = {\n@@ -86,7 +86,7 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n /*\n  * Return non-zero iff the path is usable as an alternate object database.\n  */\n-static int alt_odb_usable(struct raw_object_store *o,\n+static int alt_odb_usable(struct object_database *o,\n \t\t\t  struct strbuf *path,\n \t\t\t  const char *normalized_objdir, khiter_t *pos)\n {\n@@ -950,9 +950,9 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct raw_object_store *raw_object_store_new(void)\n+struct object_database *odb_new(void)\n {\n-\tstruct raw_object_store *o = xmalloc(sizeof(*o));\n+\tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n@@ -961,7 +961,7 @@ struct raw_object_store *raw_object_store_new(void)\n \treturn o;\n }\n \n-static void free_object_directories(struct raw_object_store *o)\n+static void free_object_directories(struct object_database *o)\n {\n \twhile (o->odb) {\n \t\tstruct object_directory *next;\n@@ -974,7 +974,7 @@ static void free_object_directories(struct raw_object_store *o)\n \to->odb_by_path = NULL;\n }\n \n-void raw_object_store_clear(struct raw_object_store *o)\n+void odb_clear(struct object_database *o)\n {\n \tFREE_AND_NULL(o->alternate_db);\n \ndiff --git a/object-store.h b/object-store.h\nindex c5890085352..a3be27d1171 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -87,7 +87,12 @@ struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n \n-struct raw_object_store {\n+/*\n+ * The object database encapsulates access to objects in a repository. It\n+ * manages one or more backends that store the actual objects which are\n+ * configured via alternates.\n+ */\n+struct object_database {\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -169,8 +174,8 @@ struct raw_object_store {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct raw_object_store *raw_object_store_new(void);\n-void raw_object_store_clear(struct raw_object_store *o);\n+struct object_database *odb_new(void);\n+void odb_clear(struct object_database *o);\n \n /*\n  * Create a temporary file rooted in the object database directory, or\ndiff --git a/packfile.c b/packfile.c\nindex 70c7208f027..c735b4d0135 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -359,7 +359,7 @@ void close_pack(struct packed_git *p)\n \toidset_clear(&p->bad_objects);\n }\n \n-void close_object_store(struct raw_object_store *o)\n+void close_object_store(struct object_database *o)\n {\n \tstruct packed_git *p;\n \ndiff --git a/packfile.h b/packfile.h\nindex 3a3c77cf05a..826eb7f475f 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -183,12 +183,12 @@ int close_pack_fd(struct packed_git *p);\n \n uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);\n \n-struct raw_object_store;\n+struct object_database;\n \n unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);\n void close_pack_windows(struct packed_git *);\n void close_pack(struct packed_git *);\n-void close_object_store(struct raw_object_store *o);\n+void close_object_store(struct object_database *o);\n void unuse_pack(struct pack_window **);\n void clear_delta_base_cache(void);\n struct packed_git *add_packed_git(struct repository *r, const char *path,\ndiff --git a/repository.c b/repository.c\nindex 9b3d6665fc6..07757e6e0c9 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = raw_object_store_new();\n+\trepo->objects = odb_new();\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -374,7 +374,7 @@ void repo_clear(struct repository *repo)\n \tFREE_AND_NULL(repo->worktree);\n \tFREE_AND_NULL(repo->submodule_prefix);\n \n-\traw_object_store_clear(repo->objects);\n+\todb_clear(repo->objects);\n \tFREE_AND_NULL(repo->objects);\n \n \tparsed_object_pool_clear(repo->parsed_objects);\ndiff --git a/repository.h b/repository.h\nindex c4c92b2ab9c..3a5ef9c781e 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -9,7 +9,7 @@ struct git_hash_algo;\n struct index_state;\n struct lock_file;\n struct pathspec;\n-struct raw_object_store;\n+struct object_database;\n struct submodule_cache;\n struct promisor_remote_config;\n struct remote_state;\n@@ -47,7 +47,7 @@ struct repository {\n \t/*\n \t * Holds any information related to accessing the raw object content.\n \t */\n-\tstruct raw_object_store *objects;\n+\tstruct object_database *objects;\n \n \t/*\n \t * All objects in this repository that have been parsed. This structure\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521026","messageId":"20250701-pks-object-store-wo-the-repository-v6-2-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 02/17] object-store: rename `object_directory` to `odb_source`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:14Z","receivedAt":"2025-07-01T12:22:29Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `object_directory` structure is used as an access point for a single\nobject directory like \".git/objects\". While the structure isn't yet\nfully self-contained, the intent is for it to eventually contain all\ninformation required to access objects in one specific location.\n\nWhile the name \"object directory\" is a good fit for now, this will\nchange over time as we continue with the agenda to make pluggable object\ndatabases a thing. Eventually, objects may not be accessed via any kind\nof directory at all anymore, but they could instead be backed by any\nkind of durable storage mechanism. While it seems quite far-fetched for\nnow, it is thinkable that eventually this might even be some form of a\ndatabase, for example.\n\nAs such, the current name of this structure will become worse over time\nas we evolve into the direction of pluggable ODBs. Immediate next steps\nwill start to carve out proper self-contained object directories, which\nrequires us to pass in these object directories as parameters. Based on\nour modern naming schema this means that those functions should then be\nnamed after their subsystem, which means that we would start to bake the\ncurrent name into the codebase more and more.\n\nLet's preempt this by renaming the structure. There have been a couple\nalternatives that were discussed:\n\n  - `odb_backend` was discarded because it led to the association that\n    one object database has a single backend, but the model is that one\n    alternate has one backend. Furthermore, \"backend\" is more about the\n    actual backing implementation and less about the high-level concept.\n\n  - `odb_alternate` was discarded because it is a bit of a stretch to\n    also call the main object directory an \"alternate\".\n\nInstead, pick `odb_source` as the new name. It makes it sufficiently\nclear that there can be multiple sources and does not cause confusion\nwhen mixed with the already-existing \"alternate\" terminology.\n\nIn the future, this change allows us to easily introduce for example a\n`odb_files_source` and other format-specific implementations.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c      |  18 +++----\n builtin/count-objects.c     |   4 +-\n builtin/fetch.c             |   2 +-\n builtin/fsck.c              |  14 ++---\n builtin/gc.c                |  14 ++---\n builtin/grep.c              |   2 +-\n builtin/multi-pack-index.c  |   4 +-\n builtin/submodule--helper.c |   6 +--\n bundle.c                    |   2 +-\n commit-graph.c              |  94 +++++++++++++++++-----------------\n commit-graph.h              |  14 ++---\n diagnose.c                  |   8 +--\n http-walker.c               |   2 +-\n http.c                      |   4 +-\n loose.c                     |  42 +++++++--------\n midx.c                      |   6 +--\n object-file.c               |  80 ++++++++++++++---------------\n object-file.h               |   8 +--\n object-name.c               |   6 +--\n object-store.c              | 122 ++++++++++++++++++++++----------------------\n object-store.h              |  38 +++++++++-----\n packfile.c                  |  16 +++---\n path.c                      |   2 +-\n refs.c                      |   2 +-\n repository.c                |  14 ++---\n submodule-config.c          |   2 +-\n t/helper/test-read-graph.c  |   6 +--\n tmp-objdir.c                |  24 ++++-----\n 28 files changed, 284 insertions(+), 272 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex a783a86e797..98a84315342 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \t\t\tstruct repository *repo UNUSED)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_source *source = NULL;\n \tchar *graph_name;\n \tchar *chain_name;\n \tenum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;\n@@ -101,9 +101,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n-\tgraph_name = get_commit_graph_filename(odb);\n-\tchain_name = get_commit_graph_chain_filename(odb);\n+\tsource = find_odb(the_repository, opts.obj_dir);\n+\tgraph_name = get_commit_graph_filename(source);\n+\tchain_name = get_commit_graph_chain_filename(source);\n \tif (open_commit_graph(graph_name, &fd, &st))\n \t\topened = OPENED_GRAPH;\n \telse if (errno != ENOENT)\n@@ -120,7 +120,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opened == OPENED_NONE)\n \t\treturn 0;\n \telse if (opened == OPENED_GRAPH)\n-\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);\n+\t\tgraph = load_commit_graph_one_fd_st(the_repository, fd, &st, source);\n \telse\n \t\tgraph = load_commit_graph_chain_fd_st(the_repository, fd, &st,\n \t\t\t\t\t\t      &incomplete_chain);\n@@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \tstruct string_list pack_indexes = STRING_LIST_INIT_DUP;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct oidset commits = OIDSET_INIT;\n-\tstruct object_directory *odb = NULL;\n+\tstruct odb_source *source = NULL;\n \tint result = 0;\n \tenum commit_graph_write_flags flags = 0;\n \tstruct progress *progress = NULL;\n@@ -289,10 +289,10 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\todb = find_odb(the_repository, opts.obj_dir);\n+\tsource = find_odb(the_repository, opts.obj_dir);\n \n \tif (opts.reachable) {\n-\t\tif (write_commit_graph_reachable(odb, flags, &write_opts))\n+\t\tif (write_commit_graph_reachable(source, flags, &write_opts))\n \t\t\tresult = 1;\n \t\tgoto cleanup;\n \t}\n@@ -318,7 +318,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t\tstop_progress(&progress);\n \t}\n \n-\tif (write_commit_graph(odb,\n+\tif (write_commit_graph(source,\n \t\t\t       opts.stdin_packs ? &pack_indexes : NULL,\n \t\t\t       opts.stdin_commits ? &commits : NULL,\n \t\t\t       flags,\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex a88c0c9c09a..58e0af433d1 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -80,10 +80,10 @@ static int count_cruft(const char *basename UNUSED, const char *path,\n \treturn 0;\n }\n \n-static int print_alternate(struct object_directory *odb, void *data UNUSED)\n+static int print_alternate(struct odb_source *alternate, void *data UNUSED)\n {\n \tprintf(\"alternate: \");\n-\tquote_c_style(odb->path, NULL, stdout, 0);\n+\tquote_c_style(alternate->path, NULL, stdout, 0);\n \tputchar('\\n');\n \treturn 0;\n }\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 40a0e8d2443..a890e2864d1 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2653,7 +2653,7 @@ int cmd_fetch(int argc,\n \t\t\tcommit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n \t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\", the_repository);\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->sources,\n \t\t\t\t\t     commit_graph_flags,\n \t\t\t\t\t     NULL);\n \t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\", the_repository);\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex e7d96a9c8ea..6e1474f63d5 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -956,7 +956,7 @@ int cmd_fsck(int argc,\n \t     struct repository *repo UNUSED)\n {\n \tint i;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \t/* fsck knows how to handle missing promisor objects */\n \tfetch_if_missing = 0;\n@@ -998,8 +998,8 @@ int cmd_fsck(int argc,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next)\n-\t\t\tfsck_object_dir(odb->path);\n+\t\tfor (source = the_repository->objects->sources; source; source = source->next)\n+\t\t\tfsck_object_dir(source->path);\n \n \t\tif (check_full) {\n \t\t\tstruct packed_git *p;\n@@ -1109,11 +1109,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&commit_graph_verify.args, \"commit-graph\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", source->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&commit_graph_verify.args, \"--progress\");\n \t\t\telse\n@@ -1127,11 +1127,11 @@ int cmd_fsck(int argc,\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n \t\tprepare_alt_odb(the_repository);\n-\t\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n+\t\tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\n \t\t\tstrvec_pushl(&midx_verify.args, \"multi-pack-index\",\n-\t\t\t\t     \"verify\", \"--object-dir\", odb->path, NULL);\n+\t\t\t\t     \"verify\", \"--object-dir\", source->path, NULL);\n \t\t\tif (show_progress)\n \t\t\t\tstrvec_push(&midx_verify.args, \"--progress\");\n \t\t\telse\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex e33ba946e43..50a09eb07e3 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -1018,7 +1018,7 @@ int cmd_gc(int argc,\n \t}\n \n \tif (the_repository->settings.gc_write_commit_graph == 1)\n-\t\twrite_commit_graph_reachable(the_repository->objects->odb,\n+\t\twrite_commit_graph_reachable(the_repository->objects->sources,\n \t\t\t\t\t     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,\n \t\t\t\t\t     NULL);\n \n@@ -1271,7 +1271,7 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)\n \tif (loose_object_auto_limit < 0)\n \t\treturn 1;\n \n-\treturn for_each_loose_file_in_objdir(the_repository->objects->odb->path,\n+\treturn for_each_loose_file_in_objdir(the_repository->objects->sources->path,\n \t\t\t\t\t     loose_object_count,\n \t\t\t\t\t     NULL, NULL, &count);\n }\n@@ -1306,7 +1306,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t * Do not start pack-objects process\n \t * if there are no loose objects.\n \t */\n-\tif (!for_each_loose_file_in_objdir(r->objects->odb->path,\n+\tif (!for_each_loose_file_in_objdir(r->objects->sources->path,\n \t\t\t\t\t   bail_on_loose,\n \t\t\t\t\t   NULL, NULL, NULL))\n \t\treturn 0;\n@@ -1318,7 +1318,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \t\tstrvec_push(&pack_proc.args, \"--quiet\");\n \telse\n \t\tstrvec_push(&pack_proc.args, \"--no-quiet\");\n-\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->odb->path);\n+\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->sources->path);\n \n \tpack_proc.in = -1;\n \n@@ -1346,7 +1346,7 @@ static int pack_loose(struct maintenance_run_opts *opts)\n \telse if (data.batch_size > 0)\n \t\tdata.batch_size--; /* Decrease for equality on limit. */\n \n-\tfor_each_loose_file_in_objdir(r->objects->odb->path,\n+\tfor_each_loose_file_in_objdir(r->objects->sources->path,\n \t\t\t\t      write_loose_object_to_stdin,\n \t\t\t\t      NULL,\n \t\t\t\t      NULL,\n@@ -1611,7 +1611,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,\n \tint result = 0;\n \tstruct lock_file lk;\n \tstruct repository *r = the_repository;\n-\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->sources->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\t/*\n@@ -3083,7 +3083,7 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,\n \tunsigned int i;\n \tint result = 0;\n \tstruct lock_file lk;\n-\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\n+\tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->sources->path);\n \n \tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\tif (errno == EEXIST)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ce574a605b..76b1938bba5 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->odb->path);\n+\tadd_submodule_odb_by_path(subrepo->objects->sources->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex 69a97507324..f55bf53da83 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -294,8 +294,8 @@ int cmd_multi_pack_index(int argc,\n \n \tif (the_repository &&\n \t    the_repository->objects &&\n-\t    the_repository->objects->odb)\n-\t\topts.object_dir = xstrdup(the_repository->objects->odb->path);\n+\t    the_repository->objects->sources)\n+\t\topts.object_dir = xstrdup(the_repository->objects->sources->path);\n \n \targc = parse_options(argc, argv, prefix, options,\n \t\t\t     builtin_multi_pack_index_usage, 0);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 53da2116ddf..758bc6d0f24 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1582,7 +1582,7 @@ static const char alternate_error_advice[] = N_(\n );\n \n static int add_possible_reference_from_superproject(\n-\t\tstruct object_directory *odb, void *sas_cb)\n+\t\tstruct odb_source *alt_odb, void *sas_cb)\n {\n \tstruct submodule_alternate_setup *sas = sas_cb;\n \tsize_t len;\n@@ -1591,12 +1591,12 @@ static int add_possible_reference_from_superproject(\n \t * If the alternate object store is another repository, try the\n \t * standard layout with .git/(modules/<name>)+/objects\n \t */\n-\tif (strip_suffix(odb->path, \"/objects\", &len)) {\n+\tif (strip_suffix(alt_odb->path, \"/objects\", &len)) {\n \t\tstruct repository alternate;\n \t\tchar *sm_alternate;\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstruct strbuf err = STRBUF_INIT;\n-\t\tstrbuf_add(&sb, odb->path, len);\n+\t\tstrbuf_add(&sb, alt_odb->path, len);\n \n \t\tif (repo_init(&alternate, sb.buf, NULL) < 0)\n \t\t\tdie(_(\"could not get a repository handle for gitdir '%s'\"),\ndiff --git a/bundle.c b/bundle.c\nindex b0a3fee2efa..2ce7525f90d 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -233,7 +233,7 @@ int verify_bundle(struct repository *r,\n \t\t.quiet = 1,\n \t};\n \n-\tif (!r || !r->objects || !r->objects->odb)\n+\tif (!r || !r->objects || !r->objects->sources)\n \t\treturn error(_(\"need a repository to verify a bundle\"));\n \n \tfor (i = 0; i < p->nr; i++) {\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 905fcbdf0e8..12d32cdad1d 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -37,7 +37,7 @@ void git_test_write_commit_graph_or_die(void)\n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph_reachable(the_repository->objects->odb,\n+\tif (write_commit_graph_reachable(the_repository->objects->sources,\n \t\t\t\t\t flags, NULL))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n@@ -191,21 +191,21 @@ static int commit_gen_cmp(const void *va, const void *vb)\n \treturn 0;\n }\n \n-char *get_commit_graph_filename(struct object_directory *obj_dir)\n+char *get_commit_graph_filename(struct odb_source *source)\n {\n-\treturn xstrfmt(\"%s/info/commit-graph\", obj_dir->path);\n+\treturn xstrfmt(\"%s/info/commit-graph\", source->path);\n }\n \n-static char *get_split_graph_filename(struct object_directory *odb,\n+static char *get_split_graph_filename(struct odb_source *source,\n \t\t\t\t      const char *oid_hex)\n {\n-\treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", odb->path,\n+\treturn xstrfmt(\"%s/info/commit-graphs/graph-%s.graph\", source->path,\n \t\t       oid_hex);\n }\n \n-char *get_commit_graph_chain_filename(struct object_directory *odb)\n+char *get_commit_graph_chain_filename(struct odb_source *source)\n {\n-\treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", odb->path);\n+\treturn xstrfmt(\"%s/info/commit-graphs/commit-graph-chain\", source->path);\n }\n \n static struct commit_graph *alloc_commit_graph(void)\n@@ -250,7 +250,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_source *source)\n {\n \tvoid *graph_map;\n \tsize_t graph_size;\n@@ -269,7 +269,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \tret = parse_commit_graph(&r->settings, graph_map, graph_size);\n \n \tif (ret)\n-\t\tret->odb = odb;\n+\t\tret->odb_source = source;\n \telse\n \t\tmunmap(graph_map, graph_size);\n \n@@ -487,7 +487,7 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s,\n \n static struct commit_graph *load_commit_graph_one(struct repository *r,\n \t\t\t\t\t\t  const char *graph_file,\n-\t\t\t\t\t\t  struct object_directory *odb)\n+\t\t\t\t\t\t  struct odb_source *source)\n {\n \n \tstruct stat st;\n@@ -498,7 +498,7 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n \tif (!open_ok)\n \t\treturn NULL;\n \n-\tg = load_commit_graph_one_fd_st(r, fd, &st, odb);\n+\tg = load_commit_graph_one_fd_st(r, fd, &st, source);\n \n \tif (g)\n \t\tg->filename = xstrdup(graph_file);\n@@ -507,10 +507,10 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_v1(struct repository *r,\n-\t\t\t\t\t\t struct object_directory *odb)\n+\t\t\t\t\t\t struct odb_source *source)\n {\n-\tchar *graph_name = get_commit_graph_filename(odb);\n-\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\tchar *graph_name = get_commit_graph_filename(source);\n+\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, source);\n \tfree(graph_name);\n \n \treturn g;\n@@ -652,7 +652,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tprepare_alt_odb(r);\n \n \tfor (i = 0; i < count; i++) {\n-\t\tstruct object_directory *odb;\n+\t\tstruct odb_source *source;\n \n \t\tif (strbuf_getline_lf(&line, fp) == EOF)\n \t\t\tbreak;\n@@ -665,9 +665,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t}\n \n \t\tvalid = 0;\n-\t\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t\tchar *graph_name = get_split_graph_filename(odb, line.buf);\n-\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, odb);\n+\t\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\t\tchar *graph_name = get_split_graph_filename(source, line.buf);\n+\t\t\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, source);\n \n \t\t\tfree(graph_name);\n \n@@ -701,9 +701,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n }\n \n static struct commit_graph *load_commit_graph_chain(struct repository *r,\n-\t\t\t\t\t\t    struct object_directory *odb)\n+\t\t\t\t\t\t    struct odb_source *source)\n {\n-\tchar *chain_file = get_commit_graph_chain_filename(odb);\n+\tchar *chain_file = get_commit_graph_chain_filename(source);\n \tstruct stat st;\n \tint fd;\n \tstruct commit_graph *g = NULL;\n@@ -719,24 +719,24 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,\n }\n \n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb)\n+\t\t\t\t\t   struct odb_source *source)\n {\n-\tstruct commit_graph *g = load_commit_graph_v1(r, odb);\n+\tstruct commit_graph *g = load_commit_graph_v1(r, source);\n \n \tif (!g)\n-\t\tg = load_commit_graph_chain(r, odb);\n+\t\tg = load_commit_graph_chain(r, source);\n \n \treturn g;\n }\n \n static void prepare_commit_graph_one(struct repository *r,\n-\t\t\t\t     struct object_directory *odb)\n+\t\t\t\t     struct odb_source *source)\n {\n \n \tif (r->objects->commit_graph)\n \t\treturn;\n \n-\tr->objects->commit_graph = read_commit_graph_one(r, odb);\n+\tr->objects->commit_graph = read_commit_graph_one(r, source);\n }\n \n /*\n@@ -747,7 +747,7 @@ static void prepare_commit_graph_one(struct repository *r,\n  */\n static int prepare_commit_graph(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \t/*\n \t * Early return if there is no git dir or if the commit graph is\n@@ -779,10 +779,10 @@ static int prepare_commit_graph(struct repository *r)\n \t\treturn 0;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb;\n-\t     !r->objects->commit_graph && odb;\n-\t     odb = odb->next)\n-\t\tprepare_commit_graph_one(r, odb);\n+\tfor (source = r->objects->sources;\n+\t     !r->objects->commit_graph && source;\n+\t     source = source->next)\n+\t\tprepare_commit_graph_one(r, source);\n \treturn !!r->objects->commit_graph;\n }\n \n@@ -1137,7 +1137,7 @@ struct packed_commit_list {\n \n struct write_commit_graph_context {\n \tstruct repository *r;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *odb_source;\n \tchar *graph_name;\n \tstruct oid_array oids;\n \tstruct packed_commit_list commits;\n@@ -1870,7 +1870,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \treturn 0;\n }\n \n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_source *source,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts)\n {\n@@ -1890,7 +1890,7 @@ int write_commit_graph_reachable(struct object_directory *odb,\n \n \tstop_progress(&data.progress);\n \n-\tresult = write_commit_graph(odb, NULL, &commits,\n+\tresult = write_commit_graph(source, NULL, &commits,\n \t\t\t\t    flags, opts);\n \n \toidset_clear(&commits);\n@@ -1906,7 +1906,7 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,\n \tint dirlen;\n \tint ret = 0;\n \n-\tstrbuf_addf(&packname, \"%s/pack/\", ctx->odb->path);\n+\tstrbuf_addf(&packname, \"%s/pack/\", ctx->odb_source->path);\n \tdirlen = packname.len;\n \tif (ctx->report_progress) {\n \t\tstrbuf_addf(&progress_title,\n@@ -2060,10 +2060,10 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \n \t\tstrbuf_addf(&tmp_file,\n \t\t\t    \"%s/info/commit-graphs/tmp_graph_XXXXXX\",\n-\t\t\t    ctx->odb->path);\n+\t\t\t    ctx->odb_source->path);\n \t\tctx->graph_name = strbuf_detach(&tmp_file, NULL);\n \t} else {\n-\t\tctx->graph_name = get_commit_graph_filename(ctx->odb);\n+\t\tctx->graph_name = get_commit_graph_filename(ctx->odb_source);\n \t}\n \n \tif (safe_create_leading_directories(the_repository, ctx->graph_name)) {\n@@ -2073,7 +2073,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t}\n \n \tif (ctx->split) {\n-\t\tchar *lock_name = get_commit_graph_chain_filename(ctx->odb);\n+\t\tchar *lock_name = get_commit_graph_chain_filename(ctx->odb_source);\n \n \t\thold_lock_file_for_update_mode(&lk, lock_name,\n \t\t\t\t\t       LOCK_DIE_ON_ERROR, 0444);\n@@ -2161,7 +2161,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \n \tif (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {\n \t\tchar *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));\n-\t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb, new_base_hash);\n+\t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb_source, new_base_hash);\n \n \t\tfree(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]);\n \t\tfree(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]);\n@@ -2201,14 +2201,14 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\t\t\t}\n \t\t\t}\n \t\t} else {\n-\t\t\tchar *graph_name = get_commit_graph_filename(ctx->odb);\n+\t\t\tchar *graph_name = get_commit_graph_filename(ctx->odb_source);\n \t\t\tunlink(graph_name);\n \t\t\tfree(graph_name);\n \t\t}\n \n \t\tfree(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);\n \t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));\n-\t\tfinal_graph_name = get_split_graph_filename(ctx->odb,\n+\t\tfinal_graph_name = get_split_graph_filename(ctx->odb_source,\n \t\t\t\t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);\n \t\tfree(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);\n \t\tctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;\n@@ -2259,7 +2259,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)\n \t    flags != COMMIT_GRAPH_SPLIT_REPLACE) {\n \t\twhile (g && (g->num_commits <= st_mult(size_mult, num_commits) ||\n \t\t\t    (max_commits && num_commits > max_commits))) {\n-\t\t\tif (g->odb != ctx->odb)\n+\t\t\tif (g->odb_source != ctx->odb_source)\n \t\t\t\tbreak;\n \n \t\t\tif (unsigned_add_overflows(num_commits, g->num_commits))\n@@ -2281,10 +2281,10 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)\n \t\t    \"should be 1 with --split=replace\");\n \n \tif (ctx->num_commit_graphs_after == 2) {\n-\t\tchar *old_graph_name = get_commit_graph_filename(g->odb);\n+\t\tchar *old_graph_name = get_commit_graph_filename(g->odb_source);\n \n \t\tif (!strcmp(g->filename, old_graph_name) &&\n-\t\t    g->odb != ctx->odb) {\n+\t\t    g->odb_source != ctx->odb_source) {\n \t\t\tctx->num_commit_graphs_after = 1;\n \t\t\tctx->new_base_graph = NULL;\n \t\t}\n@@ -2456,13 +2456,13 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tif (ctx->opts && ctx->opts->expire_time)\n \t\texpire_time = ctx->opts->expire_time;\n \tif (!ctx->split) {\n-\t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->odb);\n+\t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->odb_source);\n \t\tunlink(chain_file_name);\n \t\tfree(chain_file_name);\n \t\tctx->num_commit_graphs_after = 0;\n \t}\n \n-\tstrbuf_addstr(&path, ctx->odb->path);\n+\tstrbuf_addstr(&path, ctx->odb_source->path);\n \tstrbuf_addstr(&path, \"/info/commit-graphs\");\n \tdir = opendir(path.buf);\n \n@@ -2504,7 +2504,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tstrbuf_release(&path);\n }\n \n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_source *source,\n \t\t       const struct string_list *const pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\n@@ -2513,7 +2513,7 @@ int write_commit_graph(struct object_directory *odb,\n \tstruct repository *r = the_repository;\n \tstruct write_commit_graph_context ctx = {\n \t\t.r = r,\n-\t\t.odb = odb,\n+\t\t.odb_source = source,\n \t\t.append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,\n \t\t.report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,\n \t\t.split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 20d38c100ce..0e661db1b54 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -29,8 +29,8 @@ struct repository;\n struct object_database;\n struct string_list;\n \n-char *get_commit_graph_filename(struct object_directory *odb);\n-char *get_commit_graph_chain_filename(struct object_directory *odb);\n+char *get_commit_graph_filename(struct odb_source *source);\n+char *get_commit_graph_chain_filename(struct odb_source *source);\n int open_commit_graph(const char *graph_file, int *fd, struct stat *st);\n int open_commit_graph_chain(const char *chain_file, int *fd, struct stat *st);\n \n@@ -89,7 +89,7 @@ struct commit_graph {\n \tuint32_t num_commits;\n \tstruct object_id oid;\n \tchar *filename;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *odb_source;\n \n \tuint32_t num_commits_in_base;\n \tunsigned int read_generation_data;\n@@ -115,12 +115,12 @@ struct commit_graph {\n \n struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,\n \t\t\t\t\t\t int fd, struct stat *st,\n-\t\t\t\t\t\t struct object_directory *odb);\n+\t\t\t\t\t\t struct odb_source *source);\n struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \t\t\t\t\t\t   int fd, struct stat *st,\n \t\t\t\t\t\t   int *incomplete_chain);\n struct commit_graph *read_commit_graph_one(struct repository *r,\n-\t\t\t\t\t   struct object_directory *odb);\n+\t\t\t\t\t   struct odb_source *source);\n \n struct repo_settings;\n \n@@ -173,10 +173,10 @@ struct commit_graph_opts {\n  * is not compatible with the commit-graph feature, then the\n  * methods will return 0 without writing a commit-graph.\n  */\n-int write_commit_graph_reachable(struct object_directory *odb,\n+int write_commit_graph_reachable(struct odb_source *source,\n \t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_opts *opts);\n-int write_commit_graph(struct object_directory *odb,\n+int write_commit_graph(struct odb_source *source,\n \t\t       const struct string_list *pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\ndiff --git a/diagnose.c b/diagnose.c\nindex b1be74be983..d08d5643aac 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -59,13 +59,13 @@ static void dir_file_stats_objects(const char *full_path,\n \t\t\t    (uintmax_t)st.st_size);\n }\n \n-static int dir_file_stats(struct object_directory *object_dir, void *data)\n+static int dir_file_stats(struct odb_source *source, void *data)\n {\n \tstruct strbuf *buf = data;\n \n-\tstrbuf_addf(buf, \"Contents of %s:\\n\", object_dir->path);\n+\tstrbuf_addf(buf, \"Contents of %s:\\n\", source->path);\n \n-\tfor_each_file_in_pack_dir(object_dir->path, dir_file_stats_objects,\n+\tfor_each_file_in_pack_dir(source->path, dir_file_stats_objects,\n \t\t\t\t  data);\n \n \treturn 0;\n@@ -228,7 +228,7 @@ int create_diagnostics_archive(struct repository *r,\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n-\tdir_file_stats(r->objects->odb, &buf);\n+\tdir_file_stats(r->objects->sources, &buf);\n \tforeach_alt_odb(dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \ndiff --git a/http-walker.c b/http-walker.c\nindex 463f7b119ad..c374e6b2056 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -543,7 +543,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \t\tret = error(\"File %s has bad hash\", hex);\n \t} else if (req->rename < 0) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\todb_loose_path(the_repository->objects->odb, &buf, &req->oid);\n+\t\todb_loose_path(the_repository->objects->sources, &buf, &req->oid);\n \t\tret = error(\"unable to write sha1 filename %s\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\ndiff --git a/http.c b/http.c\nindex 3c029cf8947..5e15bbab3f1 100644\n--- a/http.c\n+++ b/http.c\n@@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \toidcpy(&freq->oid, oid);\n \tfreq->localfile = -1;\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->sources, &filename, oid);\n \tstrbuf_addf(&freq->tmpfile, \"%s.temp\", filename.buf);\n \n \tstrbuf_addf(&prevfile, \"%s.prev\", filename.buf);\n@@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)\n \t\tunlink_or_warn(freq->tmpfile.buf);\n \t\treturn -1;\n \t}\n-\todb_loose_path(the_repository->objects->odb, &filename, &freq->oid);\n+\todb_loose_path(the_repository->objects->sources, &filename, &freq->oid);\n \tfreq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);\n \tstrbuf_release(&filename);\n \ndiff --git a/loose.c b/loose.c\nindex bb602aaa366..fe65d5b9b0f 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -44,36 +44,36 @@ static int insert_oid_pair(kh_oid_map_t *map, const struct object_id *key, const\n \treturn 1;\n }\n \n-static int insert_loose_map(struct object_directory *odb,\n+static int insert_loose_map(struct odb_source *source,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\n {\n-\tstruct loose_object_map *map = odb->loose_map;\n+\tstruct loose_object_map *map = source->loose_map;\n \tint inserted = 0;\n \n \tinserted |= insert_oid_pair(map->to_compat, oid, compat_oid);\n \tinserted |= insert_oid_pair(map->to_storage, compat_oid, oid);\n \tif (inserted)\n-\t\toidtree_insert(odb->loose_objects_cache, compat_oid);\n+\t\toidtree_insert(source->loose_objects_cache, compat_oid);\n \n \treturn inserted;\n }\n \n-static int load_one_loose_object_map(struct repository *repo, struct object_directory *dir)\n+static int load_one_loose_object_map(struct repository *repo, struct odb_source *source)\n {\n \tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n \tFILE *fp;\n \n-\tif (!dir->loose_map)\n-\t\tloose_object_map_init(&dir->loose_map);\n-\tif (!dir->loose_objects_cache) {\n-\t\tALLOC_ARRAY(dir->loose_objects_cache, 1);\n-\t\toidtree_init(dir->loose_objects_cache);\n+\tif (!source->loose_map)\n+\t\tloose_object_map_init(&source->loose_map);\n+\tif (!source->loose_objects_cache) {\n+\t\tALLOC_ARRAY(source->loose_objects_cache, 1);\n+\t\toidtree_init(source->loose_objects_cache);\n \t}\n \n-\tinsert_loose_map(dir, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);\n-\tinsert_loose_map(dir, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);\n-\tinsert_loose_map(dir, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);\n+\tinsert_loose_map(source, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);\n+\tinsert_loose_map(source, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);\n+\tinsert_loose_map(source, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);\n \n \trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n \tfp = fopen(path.buf, \"rb\");\n@@ -93,7 +93,7 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \t\t    parse_oid_hex_algop(p, &compat_oid, &p, repo->compat_hash_algo) ||\n \t\t    p != buf.buf + buf.len)\n \t\t\tgoto err;\n-\t\tinsert_loose_map(dir, &oid, &compat_oid);\n+\t\tinsert_loose_map(source, &oid, &compat_oid);\n \t}\n \n \tstrbuf_release(&buf);\n@@ -107,15 +107,15 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire\n \n int repo_read_loose_object_map(struct repository *repo)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_source *source;\n \n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n \tprepare_alt_odb(repo);\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tif (load_one_loose_object_map(repo, dir) < 0) {\n+\tfor (source = repo->objects->sources; source; source = source->next) {\n+\t\tif (load_one_loose_object_map(repo, source) < 0) {\n \t\t\treturn -1;\n \t\t}\n \t}\n@@ -124,7 +124,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \n int repo_write_loose_object_map(struct repository *repo)\n {\n-\tkh_oid_map_t *map = repo->objects->odb->loose_map->to_compat;\n+\tkh_oid_map_t *map = repo->objects->sources->loose_map->to_compat;\n \tstruct lock_file lock;\n \tint fd;\n \tkhiter_t iter;\n@@ -212,7 +212,7 @@ int repo_add_loose_object_map(struct repository *repo, const struct object_id *o\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tinserted = insert_loose_map(repo->objects->odb, oid, compat_oid);\n+\tinserted = insert_loose_map(repo->objects->sources, oid, compat_oid);\n \tif (inserted)\n \t\treturn write_one_object(repo, oid, compat_oid);\n \treturn 0;\n@@ -223,12 +223,12 @@ int repo_loose_object_map_oid(struct repository *repo,\n \t\t\t      const struct git_hash_algo *to,\n \t\t\t      struct object_id *dest)\n {\n-\tstruct object_directory *dir;\n+\tstruct odb_source *source;\n \tkh_oid_map_t *map;\n \tkhiter_t pos;\n \n-\tfor (dir = repo->objects->odb; dir; dir = dir->next) {\n-\t\tstruct loose_object_map *loose_map = dir->loose_map;\n+\tfor (source = repo->objects->sources; source; source = source->next) {\n+\t\tstruct loose_object_map *loose_map = source->loose_map;\n \t\tif (!loose_map)\n \t\t\tcontinue;\n \t\tmap = (to == repo->compat_hash_algo) ?\ndiff --git a/midx.c b/midx.c\nindex cd6e766ce2b..3c5bc821730 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -832,7 +832,7 @@ void clear_midx_file(struct repository *r)\n {\n \tstruct strbuf midx = STRBUF_INIT;\n \n-\tget_midx_filename(r->hash_algo, &midx, r->objects->odb->path);\n+\tget_midx_filename(r->hash_algo, &midx, r->objects->sources->path);\n \n \tif (r->objects && r->objects->multi_pack_index) {\n \t\tclose_midx(r->objects->multi_pack_index);\n@@ -842,8 +842,8 @@ void clear_midx_file(struct repository *r)\n \tif (remove_path(midx.buf))\n \t\tdie(_(\"failed to clear multi-pack-index at %s\"), midx.buf);\n \n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_BITMAP, NULL);\n-\tclear_midx_files_ext(r->objects->odb->path, MIDX_EXT_REV, NULL);\n+\tclear_midx_files_ext(r->objects->sources->path, MIDX_EXT_BITMAP, NULL);\n+\tclear_midx_files_ext(r->objects->sources->path, MIDX_EXT_REV, NULL);\n \n \tstrbuf_release(&midx);\n }\ndiff --git a/object-file.c b/object-file.c\nindex 1ac04c28916..6bad1d3dd1c 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -55,12 +55,12 @@ static void fill_loose_path(struct strbuf *buf, const struct object_id *oid)\n \t}\n }\n \n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_source *source,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid)\n {\n \tstrbuf_reset(buf);\n-\tstrbuf_addstr(buf, odb->path);\n+\tstrbuf_addstr(buf, source->path);\n \tstrbuf_addch(buf, '/');\n \tfill_loose_path(buf, oid);\n \treturn buf->buf;\n@@ -88,27 +88,27 @@ int check_and_freshen_file(const char *fn, int freshen)\n \treturn 1;\n }\n \n-static int check_and_freshen_odb(struct object_directory *odb,\n+static int check_and_freshen_odb(struct odb_source *source,\n \t\t\t\t const struct object_id *oid,\n \t\t\t\t int freshen)\n {\n \tstatic struct strbuf path = STRBUF_INIT;\n-\todb_loose_path(odb, &path, oid);\n+\todb_loose_path(source, &path, oid);\n \treturn check_and_freshen_file(path.buf, freshen);\n }\n \n static int check_and_freshen_local(const struct object_id *oid, int freshen)\n {\n-\treturn check_and_freshen_odb(the_repository->objects->odb, oid, freshen);\n+\treturn check_and_freshen_odb(the_repository->objects->sources, oid, freshen);\n }\n \n static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb->next; odb; odb = odb->next) {\n-\t\tif (check_and_freshen_odb(odb, oid, freshen))\n+\tfor (source = the_repository->objects->sources->next; source; source = source->next) {\n+\t\tif (check_and_freshen_odb(source, oid, freshen))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -202,12 +202,12 @@ int stream_object_signature(struct repository *r, const struct object_id *oid)\n static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \t\t\t     struct stat *st, const char **path)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\t*path = odb_loose_path(source, &buf, oid);\n \t\tif (!lstat(*path, st))\n \t\t\treturn 0;\n \t}\n@@ -223,13 +223,13 @@ static int open_loose_object(struct repository *r,\n \t\t\t     const struct object_id *oid, const char **path)\n {\n \tint fd;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\t*path = odb_loose_path(odb, &buf, oid);\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\t*path = odb_loose_path(source, &buf, oid);\n \t\tfd = git_open(*path);\n \t\tif (fd >= 0)\n \t\t\treturn fd;\n@@ -244,11 +244,11 @@ static int open_loose_object(struct repository *r,\n static int quick_has_loose(struct repository *r,\n \t\t\t   const struct object_id *oid)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tif (oidtree_contains(odb_loose_cache(odb, oid), oid))\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\tif (oidtree_contains(odb_loose_cache(source, oid), oid))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n@@ -694,7 +694,7 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,\n /* Finalize a file on disk, and close it. */\n static void close_loose_object(int fd, const char *filename)\n {\n-\tif (the_repository->objects->odb->will_destroy)\n+\tif (the_repository->objects->sources->will_destroy)\n \t\tgoto out;\n \n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n@@ -876,7 +876,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,\n \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n \t\tprepare_loose_object_bulk_checkin();\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->sources, &filename, oid);\n \n \tfd = start_loose_object_common(&tmp_file, filename.buf, flags,\n \t\t\t\t       &stream, compressed, sizeof(compressed),\n@@ -1023,7 +1023,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,\n \t\tgoto cleanup;\n \t}\n \n-\todb_loose_path(the_repository->objects->odb, &filename, oid);\n+\todb_loose_path(the_repository->objects->sources, &filename, oid);\n \n \t/* We finally know the object path, and create the missing dir. */\n \tdirlen = directory_size(filename.buf);\n@@ -1437,11 +1437,11 @@ int for_each_loose_file_in_objdir(const char *path,\n int for_each_loose_object(each_loose_object_fn cb, void *data,\n \t\t\t  enum for_each_object_flags flags)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (odb = the_repository->objects->odb; odb; odb = odb->next) {\n-\t\tint r = for_each_loose_file_in_objdir(odb->path, cb, NULL,\n+\tfor (source = the_repository->objects->sources; source; source = source->next) {\n+\t\tint r = for_each_loose_file_in_objdir(source->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\n \t\tif (r)\n \t\t\treturn r;\n@@ -1461,43 +1461,43 @@ static int append_loose_object(const struct object_id *oid,\n \treturn 0;\n }\n \n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n-\t\t\t\t  const struct object_id *oid)\n+struct oidtree *odb_loose_cache(struct odb_source *source,\n+\t\t\t\tconst struct object_id *oid)\n {\n \tint subdir_nr = oid->hash[0];\n \tstruct strbuf buf = STRBUF_INIT;\n-\tsize_t word_bits = bitsizeof(odb->loose_objects_subdir_seen[0]);\n+\tsize_t word_bits = bitsizeof(source->loose_objects_subdir_seen[0]);\n \tsize_t word_index = subdir_nr / word_bits;\n \tsize_t mask = (size_t)1u << (subdir_nr % word_bits);\n \tuint32_t *bitmap;\n \n \tif (subdir_nr < 0 ||\n-\t    subdir_nr >= bitsizeof(odb->loose_objects_subdir_seen))\n+\t    subdir_nr >= bitsizeof(source->loose_objects_subdir_seen))\n \t\tBUG(\"subdir_nr out of range\");\n \n-\tbitmap = &odb->loose_objects_subdir_seen[word_index];\n+\tbitmap = &source->loose_objects_subdir_seen[word_index];\n \tif (*bitmap & mask)\n-\t\treturn odb->loose_objects_cache;\n-\tif (!odb->loose_objects_cache) {\n-\t\tALLOC_ARRAY(odb->loose_objects_cache, 1);\n-\t\toidtree_init(odb->loose_objects_cache);\n+\t\treturn source->loose_objects_cache;\n+\tif (!source->loose_objects_cache) {\n+\t\tALLOC_ARRAY(source->loose_objects_cache, 1);\n+\t\toidtree_init(source->loose_objects_cache);\n \t}\n-\tstrbuf_addstr(&buf, odb->path);\n+\tstrbuf_addstr(&buf, source->path);\n \tfor_each_file_in_obj_subdir(subdir_nr, &buf,\n \t\t\t\t    append_loose_object,\n \t\t\t\t    NULL, NULL,\n-\t\t\t\t    odb->loose_objects_cache);\n+\t\t\t\t    source->loose_objects_cache);\n \t*bitmap |= mask;\n \tstrbuf_release(&buf);\n-\treturn odb->loose_objects_cache;\n+\treturn source->loose_objects_cache;\n }\n \n-void odb_clear_loose_cache(struct object_directory *odb)\n+void odb_clear_loose_cache(struct odb_source *source)\n {\n-\toidtree_clear(odb->loose_objects_cache);\n-\tFREE_AND_NULL(odb->loose_objects_cache);\n-\tmemset(&odb->loose_objects_subdir_seen, 0,\n-\t       sizeof(odb->loose_objects_subdir_seen));\n+\toidtree_clear(source->loose_objects_cache);\n+\tFREE_AND_NULL(source->loose_objects_cache);\n+\tmemset(&source->loose_objects_subdir_seen, 0,\n+\t       sizeof(source->loose_objects_subdir_seen));\n }\n \n static int check_stream_oid(git_zstream *stream,\ndiff --git a/object-file.h b/object-file.h\nindex 6f411424523..9a18859b2e0 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -24,23 +24,23 @@ enum {\n int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n \n-struct object_directory;\n+struct odb_source;\n \n /*\n  * Populate and return the loose object cache array corresponding to the\n  * given object ID.\n  */\n-struct oidtree *odb_loose_cache(struct object_directory *odb,\n+struct oidtree *odb_loose_cache(struct odb_source *source,\n \t\t\t\tconst struct object_id *oid);\n \n /* Empty the loose object cache for the specified object directory. */\n-void odb_clear_loose_cache(struct object_directory *odb);\n+void odb_clear_loose_cache(struct odb_source *source);\n \n /*\n  * Put in `buf` the name of the file in the local object database that\n  * would be used to store a loose object with the specified oid.\n  */\n-const char *odb_loose_path(struct object_directory *odb,\n+const char *odb_loose_path(struct odb_source *source,\n \t\t\t   struct strbuf *buf,\n \t\t\t   const struct object_id *oid);\n \ndiff --git a/object-name.c b/object-name.c\nindex 9288b2dd245..544634d0f40 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -112,10 +112,10 @@ static enum cb_next match_prefix(const struct object_id *oid, void *arg)\n \n static void find_short_object_filename(struct disambiguate_state *ds)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n-\tfor (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next)\n-\t\toidtree_each(odb_loose_cache(odb, &ds->bin_pfx),\n+\tfor (source = ds->repo->objects->sources; source && !ds->ambiguous; source = source->next)\n+\t\toidtree_each(odb_loose_cache(source, &ds->bin_pfx),\n \t\t\t\t&ds->bin_pfx, ds->len, match_prefix, ds);\n }\n \ndiff --git a/object-store.c b/object-store.c\nindex f4e8f99d90f..5c04a1018f7 100644\n--- a/object-store.c\n+++ b/object-store.c\n@@ -27,7 +27,7 @@\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n-\tstruct object_directory *, 1, fspathhash, fspatheq)\n+\tstruct odb_source *, 1, fspathhash, fspatheq)\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n@@ -104,18 +104,18 @@ static int alt_odb_usable(struct object_database *o,\n \t * Prevent the common mistake of listing the same\n \t * thing twice, or object directory itself.\n \t */\n-\tif (!o->odb_by_path) {\n+\tif (!o->source_by_path) {\n \t\tkhiter_t p;\n \n-\t\to->odb_by_path = kh_init_odb_path_map();\n-\t\tassert(!o->odb->next);\n-\t\tp = kh_put_odb_path_map(o->odb_by_path, o->odb->path, &r);\n+\t\to->source_by_path = kh_init_odb_path_map();\n+\t\tassert(!o->sources->next);\n+\t\tp = kh_put_odb_path_map(o->source_by_path, o->sources->path, &r);\n \t\tassert(r == 1); /* never used */\n-\t\tkh_value(o->odb_by_path, p) = o->odb;\n+\t\tkh_value(o->source_by_path, p) = o->sources;\n \t}\n \tif (fspatheq(path->buf, normalized_objdir))\n \t\treturn 0;\n-\t*pos = kh_put_odb_path_map(o->odb_by_path, path->buf, &r);\n+\t*pos = kh_put_odb_path_map(o->source_by_path, path->buf, &r);\n \t/* r: 0 = exists, 1 = never used, 2 = deleted */\n \treturn r == 0 ? 0 : 1;\n }\n@@ -124,7 +124,7 @@ static int alt_odb_usable(struct object_database *o,\n  * Prepare alternate object database registry.\n  *\n  * The variable alt_odb_list points at the list of struct\n- * object_directory.  The elements on this list come from\n+ * odb_source.  The elements on this list come from\n  * non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT\n  * environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates,\n  * whose contents is similar to that environment variable but can be\n@@ -141,7 +141,7 @@ static void read_info_alternates(struct repository *r,\n static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tconst char *relative_base, int depth, const char *normalized_objdir)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_source *alternate;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n \tstruct strbuf tmp = STRBUF_INIT;\n \tkhiter_t pos;\n@@ -170,19 +170,19 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n-\tCALLOC_ARRAY(ent, 1);\n-\t/* pathbuf.buf is already in r->objects->odb_by_path */\n-\tent->path = strbuf_detach(&pathbuf, NULL);\n+\tCALLOC_ARRAY(alternate, 1);\n+\t/* pathbuf.buf is already in r->objects->source_by_path */\n+\talternate->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->odb_tail = ent;\n-\tr->objects->odb_tail = &(ent->next);\n-\tent->next = NULL;\n-\tassert(r->objects->odb_by_path);\n-\tkh_value(r->objects->odb_by_path, pos) = ent;\n+\t*r->objects->sources_tail = alternate;\n+\tr->objects->sources_tail = &(alternate->next);\n+\talternate->next = NULL;\n+\tassert(r->objects->source_by_path);\n+\tkh_value(r->objects->source_by_path, pos) = alternate;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, ent->path, depth + 1);\n+\tread_info_alternates(r, alternate->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -234,7 +234,7 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->odb->path, 1);\n+\tstrbuf_realpath(&objdirbuf, r->objects->sources->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n@@ -321,9 +321,9 @@ void add_to_alternates_memory(const char *reference)\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n {\n-\tstruct object_directory *new_odb;\n+\tstruct odb_source *source;\n \n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n@@ -335,41 +335,41 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n-\tnew_odb = xcalloc(1, sizeof(*new_odb));\n-\tnew_odb->path = xstrdup(dir);\n+\tsource = xcalloc(1, sizeof(*source));\n+\tsource->path = xstrdup(dir);\n \n \t/*\n \t * Disable ref updates while a temporary odb is active, since\n \t * the objects in the database may roll back.\n \t */\n-\tnew_odb->disable_ref_updates = 1;\n-\tnew_odb->will_destroy = will_destroy;\n-\tnew_odb->next = the_repository->objects->odb;\n-\tthe_repository->objects->odb = new_odb;\n-\treturn new_odb->next;\n+\tsource->disable_ref_updates = 1;\n+\tsource->will_destroy = will_destroy;\n+\tsource->next = the_repository->objects->sources;\n+\tthe_repository->objects->sources = source;\n+\treturn source->next;\n }\n \n-static void free_object_directory(struct object_directory *odb)\n+static void free_object_directory(struct odb_source *source)\n {\n-\tfree(odb->path);\n-\todb_clear_loose_cache(odb);\n-\tloose_object_map_clear(&odb->loose_map);\n-\tfree(odb);\n+\tfree(source->path);\n+\todb_clear_loose_cache(source);\n+\tloose_object_map_clear(&source->loose_map);\n+\tfree(source);\n }\n \n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path)\n+void restore_primary_odb(struct odb_source *restore_alt, const char *old_path)\n {\n-\tstruct object_directory *cur_odb = the_repository->objects->odb;\n+\tstruct odb_source *cur_alt = the_repository->objects->sources;\n \n-\tif (strcmp(old_path, cur_odb->path))\n+\tif (strcmp(old_path, cur_alt->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n-\t\t    old_path, cur_odb->path);\n+\t\t    old_path, cur_alt->path);\n \n-\tif (cur_odb->next != restore_odb)\n+\tif (cur_alt->next != restore_alt)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->odb = restore_odb;\n-\tfree_object_directory(cur_odb);\n+\tthe_repository->objects->sources = restore_alt;\n+\tfree_object_directory(cur_alt);\n }\n \n /*\n@@ -442,15 +442,15 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_source *find_odb(struct repository *r, const char *obj_dir)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tstrbuf_realpath(&odb_path_real, odb->path, 1);\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\tstrbuf_realpath(&odb_path_real, source->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\n \t}\n@@ -458,9 +458,9 @@ struct object_directory *find_odb(struct repository *r, const char *obj_dir)\n \tfree(obj_dir_real);\n \tstrbuf_release(&odb_path_real);\n \n-\tif (!odb)\n+\tif (!source)\n \t\tdie(_(\"could not find object directory matching %s\"), obj_dir);\n-\treturn odb;\n+\treturn source;\n }\n \n static void fill_alternate_refs_command(struct child_process *cmd,\n@@ -527,14 +527,14 @@ struct alternate_refs_data {\n \tvoid *data;\n };\n \n-static int refs_from_alternate_cb(struct object_directory *e,\n+static int refs_from_alternate_cb(struct odb_source *alternate,\n \t\t\t\t  void *data)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n \tstruct alternate_refs_data *cb = data;\n \n-\tif (!strbuf_realpath(&path, e->path, 0))\n+\tif (!strbuf_realpath(&path, alternate->path, 0))\n \t\tgoto out;\n \tif (!strbuf_strip_suffix(&path, \"/objects\"))\n \t\tgoto out;\n@@ -563,12 +563,12 @@ void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n \n int foreach_alt_odb(alt_odb_fn fn, void *cb)\n {\n-\tstruct object_directory *ent;\n+\tstruct odb_source *alternate;\n \tint r = 0;\n \n \tprepare_alt_odb(the_repository);\n-\tfor (ent = the_repository->objects->odb->next; ent; ent = ent->next) {\n-\t\tr = fn(ent, cb);\n+\tfor (alternate = the_repository->objects->sources->next; alternate; alternate = alternate->next) {\n+\t\tr = fn(alternate, cb);\n \t\tif (r)\n \t\t\tbreak;\n \t}\n@@ -582,14 +582,14 @@ void prepare_alt_odb(struct repository *r)\n \n \tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->odb->path, 0);\n+\tread_info_alternates(r, r->objects->sources->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n int has_alt_odb(struct repository *r)\n {\n \tprepare_alt_odb(r);\n-\treturn !!r->objects->odb->next;\n+\treturn !!r->objects->sources->next;\n }\n \n int obj_read_use_lock = 0;\n@@ -963,15 +963,15 @@ struct object_database *odb_new(void)\n \n static void free_object_directories(struct object_database *o)\n {\n-\twhile (o->odb) {\n-\t\tstruct object_directory *next;\n+\twhile (o->sources) {\n+\t\tstruct odb_source *next;\n \n-\t\tnext = o->odb->next;\n-\t\tfree_object_directory(o->odb);\n-\t\to->odb = next;\n+\t\tnext = o->sources->next;\n+\t\tfree_object_directory(o->sources);\n+\t\to->sources = next;\n \t}\n-\tkh_destroy_odb_path_map(o->odb_by_path);\n-\to->odb_by_path = NULL;\n+\tkh_destroy_odb_path_map(o->source_by_path);\n+\to->source_by_path = NULL;\n }\n \n void odb_clear(struct object_database *o)\n@@ -986,7 +986,7 @@ void odb_clear(struct object_database *o)\n \to->commit_graph_attempted = 0;\n \n \tfree_object_directories(o);\n-\to->odb_tail = NULL;\n+\to->sources_tail = NULL;\n \to->loaded_alternates = 0;\n \n \tfor (size_t i = 0; i < o->cached_object_nr; i++)\ndiff --git a/object-store.h b/object-store.h\nindex a3be27d1171..d199d757d76 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -13,8 +13,20 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n-struct object_directory {\n-\tstruct object_directory *next;\n+/*\n+ * The source is the part of the object database that stores the actual\n+ * objects. It thus encapsulates the logic to read and write the specific\n+ * on-disk format. An object database can have multiple sources:\n+ *\n+ *   - The primary source, which is typically located in \"$GIT_DIR/objects\".\n+ *     This is where new objects are usually written to.\n+ *\n+ *   - Alternate sources, which are configured via \"objects/info/alternates\" or\n+ *     via the GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable. These\n+ *     alternate sources are only used to read objects.\n+ */\n+struct odb_source {\n+\tstruct odb_source *next;\n \n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n@@ -44,8 +56,8 @@ struct object_directory {\n \tint will_destroy;\n \n \t/*\n-\t * Path to the alternative object store. If this is a relative path,\n-\t * it is relative to the current working directory.\n+\t * Path to the source. If this is a relative path, it is relative to\n+\t * the current working directory.\n \t */\n \tchar *path;\n };\n@@ -53,8 +65,8 @@ struct object_directory {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct object_directory *find_odb(struct repository *r, const char *obj_dir);\n-typedef int alt_odb_fn(struct object_directory *, void *);\n+struct odb_source *find_odb(struct repository *r, const char *obj_dir);\n+typedef int alt_odb_fn(struct odb_source *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n@@ -76,12 +88,12 @@ void add_to_alternates_memory(const char *dir);\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n  */\n-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy);\n+struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy);\n \n /*\n  * Restore a previous ODB replaced by set_temporary_main_odb.\n  */\n-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);\n+void restore_primary_odb(struct odb_source *restore_alternate, const char *old_path);\n \n struct packed_git;\n struct multi_pack_index;\n@@ -89,7 +101,7 @@ struct cached_object_entry;\n \n /*\n  * The object database encapsulates access to objects in a repository. It\n- * manages one or more backends that store the actual objects which are\n+ * manages one or more sources that store the actual objects which are\n  * configured via alternates.\n  */\n struct object_database {\n@@ -98,16 +110,16 @@ struct object_database {\n \t * cannot be NULL after initialization). Subsequent directories are\n \t * alternates.\n \t */\n-\tstruct object_directory *odb;\n-\tstruct object_directory **odb_tail;\n-\tstruct kh_odb_path_map *odb_by_path;\n+\tstruct odb_source *sources;\n+\tstruct odb_source **sources_tail;\n+\tstruct kh_odb_path_map *source_by_path;\n \n \tint loaded_alternates;\n \n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"odb\" list when prepare_alt_odb() is run.\n+\t * populate the \"sources\" list when prepare_alt_odb() is run.\n \t */\n \tchar *alternate_db;\n \ndiff --git a/packfile.c b/packfile.c\nindex c735b4d0135..60661ad0095 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1029,16 +1029,16 @@ static void prepare_packed_git_mru(struct repository *r)\n \n static void prepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n \tprepare_alt_odb(r);\n-\tfor (odb = r->objects->odb; odb; odb = odb->next) {\n-\t\tint local = (odb == r->objects->odb);\n-\t\tprepare_multi_pack_index_one(r, odb->path, local);\n-\t\tprepare_packed_git_one(r, odb->path, local);\n+\tfor (source = r->objects->sources; source; source = source->next) {\n+\t\tint local = (source == r->objects->sources);\n+\t\tprepare_multi_pack_index_one(r, source->path, local);\n+\t\tprepare_packed_git_one(r, source->path, local);\n \t}\n \trearrange_packed_git(r);\n \n@@ -1048,7 +1048,7 @@ static void prepare_packed_git(struct repository *r)\n \n void reprepare_packed_git(struct repository *r)\n {\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \n \tobj_read_lock();\n \n@@ -1061,8 +1061,8 @@ void reprepare_packed_git(struct repository *r)\n \tr->objects->loaded_alternates = 0;\n \tprepare_alt_odb(r);\n \n-\tfor (odb = r->objects->odb; odb; odb = odb->next)\n-\t\todb_clear_loose_cache(odb);\n+\tfor (source = r->objects->sources; source; source = source->next)\n+\t\todb_clear_loose_cache(source);\n \n \tr->objects->approximate_object_count_valid = 0;\n \tr->objects->packed_git_initialized = 0;\ndiff --git a/path.c b/path.c\nindex 3b598b2847f..c347829aa66 100644\n--- a/path.c\n+++ b/path.c\n@@ -397,7 +397,7 @@ static void adjust_git_path(struct repository *repo,\n \t\tstrbuf_splice(buf, 0, buf->len,\n \t\t\t      repo->index_file, strlen(repo->index_file));\n \telse if (dir_prefix(base, \"objects\"))\n-\t\treplace_dir(buf, git_dir_len + 7, repo->objects->odb->path);\n+\t\treplace_dir(buf, git_dir_len + 7, repo->objects->sources->path);\n \telse if (repo_settings_get_hooks_path(repo) && dir_prefix(base, \"hooks\"))\n \t\treplace_dir(buf, git_dir_len + 5, repo_settings_get_hooks_path(repo));\n \telse if (repo->different_commondir)\ndiff --git a/refs.c b/refs.c\nindex dce5c49ca2b..5f6a386cc93 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -2477,7 +2477,7 @@ int ref_transaction_prepare(struct ref_transaction *transaction,\n \t\tbreak;\n \t}\n \n-\tif (refs->repo->objects->odb->disable_ref_updates) {\n+\tif (refs->repo->objects->sources->disable_ref_updates) {\n \t\tstrbuf_addstr(err,\n \t\t\t      _(\"ref updates forbidden inside quarantine environment\"));\n \t\treturn -1;\ndiff --git a/repository.c b/repository.c\nindex 07757e6e0c9..7528beccddf 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -107,9 +107,9 @@ const char *repo_get_common_dir(struct repository *repo)\n \n const char *repo_get_object_directory(struct repository *repo)\n {\n-\tif (!repo->objects->odb)\n+\tif (!repo->objects->sources)\n \t\tBUG(\"repository hasn't been set up\");\n-\treturn repo->objects->odb->path;\n+\treturn repo->objects->sources->path;\n }\n \n const char *repo_get_index_file(struct repository *repo)\n@@ -165,14 +165,14 @@ void repo_set_gitdir(struct repository *repo,\n \n \trepo_set_commondir(repo, o->commondir);\n \n-\tif (!repo->objects->odb) {\n-\t\tCALLOC_ARRAY(repo->objects->odb, 1);\n-\t\trepo->objects->odb_tail = &repo->objects->odb->next;\n+\tif (!repo->objects->sources) {\n+\t\tCALLOC_ARRAY(repo->objects->sources, 1);\n+\t\trepo->objects->sources_tail = &repo->objects->sources->next;\n \t}\n-\texpand_base_dir(&repo->objects->odb->path, o->object_dir,\n+\texpand_base_dir(&repo->objects->sources->path, o->object_dir,\n \t\t\trepo->commondir, \"objects\");\n \n-\trepo->objects->odb->disable_ref_updates = o->disable_ref_updates;\n+\trepo->objects->sources->disable_ref_updates = o->disable_ref_updates;\n \n \tfree(repo->objects->alternate_db);\n \trepo->objects->alternate_db = xstrdup_or_null(o->alternate_db);\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 8630e27947d..b30d9365fbd 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,7 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->odb->path);\n+\t\t\t\tadd_submodule_odb_by_path(repo->objects->sources->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 8b413b644be..53b633e2ba6 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -73,15 +73,15 @@ static void dump_graph_bloom_filters(struct commit_graph *graph)\n int cmd__read_graph(int argc, const char **argv)\n {\n \tstruct commit_graph *graph = NULL;\n-\tstruct object_directory *odb;\n+\tstruct odb_source *source;\n \tint ret = 0;\n \n \tsetup_git_directory();\n-\todb = the_repository->objects->odb;\n+\tsource = the_repository->objects->sources;\n \n \tprepare_repo_settings(the_repository);\n \n-\tgraph = read_commit_graph_one(the_repository, odb);\n+\tgraph = read_commit_graph_one(the_repository, source);\n \tif (!graph) {\n \t\tret = 1;\n \t\tgoto done;\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex c38fbeb5e8a..056484404be 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -17,7 +17,7 @@ struct tmp_objdir {\n \tstruct repository *repo;\n \tstruct strbuf path;\n \tstruct strvec env;\n-\tstruct object_directory *prev_odb;\n+\tstruct odb_source *prev_source;\n \tint will_destroy;\n };\n \n@@ -46,8 +46,8 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \tif (t == the_tmp_objdir)\n \t\tthe_tmp_objdir = NULL;\n \n-\tif (t->prev_odb)\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n+\tif (t->prev_source)\n+\t\trestore_primary_odb(t->prev_source, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -276,11 +276,11 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (!t)\n \t\treturn 0;\n \n-\tif (t->prev_odb) {\n-\t\tif (t->repo->objects->odb->will_destroy)\n+\tif (t->prev_source) {\n+\t\tif (t->repo->objects->sources->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_odb, t->path.buf);\n-\t\tt->prev_odb = NULL;\n+\t\trestore_primary_odb(t->prev_source, t->path.buf);\n+\t\tt->prev_source = NULL;\n \t}\n \n \tstrbuf_addbuf(&src, &t->path);\n@@ -309,19 +309,19 @@ void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n-\tif (t->prev_odb)\n+\tif (t->prev_source)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_odb = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_source = set_temporary_primary_odb(t->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n {\n-\tif (!the_tmp_objdir || !the_tmp_objdir->prev_odb)\n+\tif (!the_tmp_objdir || !the_tmp_objdir->prev_source)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf);\n-\tthe_tmp_objdir->prev_odb = NULL;\n+\trestore_primary_odb(the_tmp_objdir->prev_source, the_tmp_objdir->path.buf);\n+\tthe_tmp_objdir->prev_source = NULL;\n \treturn the_tmp_objdir;\n }\n \n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521027","messageId":"20250701-pks-object-store-wo-the-repository-v6-3-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:15Z","receivedAt":"2025-07-01T12:22:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In the preceding commits we have renamed the structures contained in\n\"object-store.h\" to `struct object_database` and `struct odb_backend`.\nAs such, the code files \"object-store.{c,h}\" are confusingly named now.\nRename them to \"odb.{c,h}\" accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile                                | 2 +-\n apply.c                                 | 2 +-\n archive-tar.c                           | 2 +-\n archive-zip.c                           | 2 +-\n archive.c                               | 2 +-\n attr.c                                  | 2 +-\n bisect.c                                | 2 +-\n blame.c                                 | 2 +-\n builtin/backfill.c                      | 2 +-\n builtin/blame.c                         | 2 +-\n builtin/cat-file.c                      | 2 +-\n builtin/checkout.c                      | 2 +-\n builtin/clone.c                         | 2 +-\n builtin/commit-graph.c                  | 2 +-\n builtin/commit-tree.c                   | 2 +-\n builtin/describe.c                      | 2 +-\n builtin/difftool.c                      | 2 +-\n builtin/fast-export.c                   | 2 +-\n builtin/fast-import.c                   | 2 +-\n builtin/fetch.c                         | 2 +-\n builtin/fsck.c                          | 2 +-\n builtin/grep.c                          | 2 +-\n builtin/hash-object.c                   | 2 +-\n builtin/index-pack.c                    | 2 +-\n builtin/log.c                           | 2 +-\n builtin/ls-files.c                      | 2 +-\n builtin/ls-tree.c                       | 2 +-\n builtin/merge-file.c                    | 2 +-\n builtin/merge-tree.c                    | 2 +-\n builtin/mktag.c                         | 2 +-\n builtin/mktree.c                        | 2 +-\n builtin/multi-pack-index.c              | 2 +-\n builtin/notes.c                         | 2 +-\n builtin/pack-objects.c                  | 2 +-\n builtin/pack-redundant.c                | 2 +-\n builtin/prune.c                         | 2 +-\n builtin/receive-pack.c                  | 2 +-\n builtin/remote.c                        | 2 +-\n builtin/repack.c                        | 2 +-\n builtin/replace.c                       | 2 +-\n builtin/rev-list.c                      | 2 +-\n builtin/show-ref.c                      | 2 +-\n builtin/submodule--helper.c             | 2 +-\n builtin/tag.c                           | 2 +-\n builtin/unpack-file.c                   | 2 +-\n builtin/unpack-objects.c                | 2 +-\n bulk-checkin.c                          | 2 +-\n bundle-uri.c                            | 2 +-\n bundle.c                                | 2 +-\n cache-tree.c                            | 2 +-\n combine-diff.c                          | 2 +-\n commit-graph.c                          | 2 +-\n commit-graph.h                          | 2 +-\n commit.c                                | 2 +-\n config.c                                | 2 +-\n connected.c                             | 2 +-\n contrib/coccinelle/the_repository.cocci | 2 +-\n diagnose.c                              | 2 +-\n diff.c                                  | 2 +-\n entry.c                                 | 2 +-\n fetch-pack.c                            | 2 +-\n fmt-merge-msg.c                         | 2 +-\n fsck.c                                  | 2 +-\n grep.c                                  | 2 +-\n http-backend.c                          | 2 +-\n http-push.c                             | 2 +-\n http-walker.c                           | 2 +-\n http.c                                  | 2 +-\n list-objects-filter.c                   | 2 +-\n list-objects.c                          | 2 +-\n loose.c                                 | 2 +-\n mailmap.c                               | 2 +-\n match-trees.c                           | 2 +-\n merge-blobs.c                           | 2 +-\n merge-ort.c                             | 2 +-\n meson.build                             | 2 +-\n notes-cache.c                           | 2 +-\n notes-merge.c                           | 2 +-\n notes.c                                 | 2 +-\n object-file.c                           | 2 +-\n object-file.h                           | 2 +-\n object-store.c => odb.c                 | 2 +-\n object-store.h => odb.h                 | 6 +++---\n oss-fuzz/fuzz-pack-idx.c                | 2 +-\n pack-bitmap-write.c                     | 2 +-\n pack-bitmap.c                           | 2 +-\n pack-check.c                            | 2 +-\n pack-mtimes.c                           | 2 +-\n pack-objects.h                          | 2 +-\n pack-revindex.c                         | 2 +-\n packfile.c                              | 2 +-\n packfile.h                              | 4 ++--\n path.c                                  | 2 +-\n promisor-remote.c                       | 2 +-\n protocol-caps.c                         | 2 +-\n read-cache.c                            | 2 +-\n ref-filter.c                            | 2 +-\n reflog.c                                | 2 +-\n refs.c                                  | 2 +-\n remote.c                                | 2 +-\n replace-object.c                        | 2 +-\n replace-object.h                        | 2 +-\n repository.c                            | 2 +-\n rerere.c                                | 2 +-\n revision.c                              | 2 +-\n send-pack.c                             | 2 +-\n sequencer.c                             | 2 +-\n server-info.c                           | 2 +-\n shallow.c                               | 2 +-\n streaming.c                             | 2 +-\n submodule-config.c                      | 2 +-\n submodule.c                             | 2 +-\n t/helper/test-find-pack.c               | 2 +-\n t/helper/test-pack-mtimes.c             | 2 +-\n t/helper/test-partial-clone.c           | 2 +-\n t/helper/test-read-graph.c              | 2 +-\n t/helper/test-read-midx.c               | 2 +-\n t/helper/test-ref-store.c               | 2 +-\n tag.c                                   | 2 +-\n tmp-objdir.c                            | 2 +-\n tree-walk.c                             | 2 +-\n tree.c                                  | 2 +-\n unpack-trees.c                          | 2 +-\n upload-pack.c                           | 2 +-\n walker.c                                | 2 +-\n xdiff-interface.c                       | 2 +-\n 126 files changed, 129 insertions(+), 129 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 70d1543b6b8..4b1bf897791 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1085,8 +1085,8 @@ LIB_OBJS += notes.o\n LIB_OBJS += object-file-convert.o\n LIB_OBJS += object-file.o\n LIB_OBJS += object-name.o\n-LIB_OBJS += object-store.o\n LIB_OBJS += object.o\n+LIB_OBJS += odb.o\n LIB_OBJS += oid-array.o\n LIB_OBJS += oidmap.o\n LIB_OBJS += oidset.o\ndiff --git a/apply.c b/apply.c\nindex 8bbe6ed2240..e778b4e911d 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -14,7 +14,7 @@\n #include \"abspath.h\"\n #include \"base85.h\"\n #include \"config.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"delta.h\"\n #include \"diff.h\"\n #include \"dir.h\"\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 282b48196f9..249164ea77d 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -11,7 +11,7 @@\n #include \"hex.h\"\n #include \"tar.h\"\n #include \"archive.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"streaming.h\"\n #include \"run-command.h\"\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 405da6f3d83..df8866d5bae 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -12,7 +12,7 @@\n #include \"hex.h\"\n #include \"streaming.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"userdiff.h\"\n #include \"write-or-die.h\"\ndiff --git a/archive.c b/archive.c\nindex 8309ea213e6..7fa2cc2596a 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -14,7 +14,7 @@\n #include \"pretty.h\"\n #include \"setup.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/attr.c b/attr.c\nindex 86b6109fc4e..e5680db7f65 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -22,7 +22,7 @@\n #include \"read-cache-ll.h\"\n #include \"refs.h\"\n #include \"revision.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/bisect.c b/bisect.c\nindex a327468c75b..a7939216d00 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -20,7 +20,7 @@\n #include \"commit-slab.h\"\n #include \"commit-reach.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"dir.h\"\n \ndiff --git a/blame.c b/blame.c\nindex 57daa45e899..0ceea080a80 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -3,7 +3,7 @@\n \n #include \"git-compat-util.h\"\n #include \"refs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"cache-tree.h\"\n #include \"mergesort.h\"\n #include \"commit.h\"\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex fa82ad2f6ff..0b49baa39fa 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -13,7 +13,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"promisor-remote.h\"\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 944952e30eb..15eda60af90 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -28,7 +28,7 @@\n #include \"line-log.h\"\n #include \"progress.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"blame.h\"\n #include \"refs.h\"\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 67a5ff2b9eb..f3a925a8183 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -24,7 +24,7 @@\n #include \"pack-bitmap.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"promisor-remote.h\"\n #include \"mailmap.h\"\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex d185982f3a6..e7dd66173dd 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -20,7 +20,7 @@\n #include \"merge-ort-wrappers.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"path.h\"\n #include \"preload-index.h\"\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 91b9cd0d164..1eafeefb48d 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -25,7 +25,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 98a84315342..f04eaba5259 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -6,7 +6,7 @@\n #include \"hex.h\"\n #include \"parse-options.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"progress.h\"\n #include \"replace-object.h\"\n #include \"strbuf.h\"\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex ad6b2c93209..546069f8682 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -9,7 +9,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n #include \"commit.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 2d50883b729..96cb68e5e5d 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -19,7 +19,7 @@\n #include \"setup.h\"\n #include \"strvec.h\"\n #include \"run-command.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects.h\"\n #include \"commit-slab.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex a3b64ce6942..fac613e3bc3 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -30,7 +30,7 @@\n #include \"strbuf.h\"\n #include \"lockfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"entry.h\"\n #include \"setup.h\"\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 37c01d6c6fe..0505f289a94 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"object.h\"\n #include \"tag.h\"\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex b2839c5f439..52c792488e1 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -24,7 +24,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"mem-pool.h\"\n #include \"commit-reach.h\"\n #include \"khash.h\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex a890e2864d1..b842bc9c51b 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -14,7 +14,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"oid-array.h\"\n #include \"commit.h\"\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6e1474f63d5..9abd7b25580 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 76b1938bba5..a1d7ee7af39 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -26,7 +26,7 @@\n #include \"submodule-config.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pager.h\"\n #include \"path.h\"\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex 6a99ec250d0..e28f000221f 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -11,7 +11,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex bb7925bd29f..1aabe6b8ee2 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -21,7 +21,7 @@\n #include \"packfile.h\"\n #include \"pack-revindex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"path.h\"\ndiff --git a/builtin/log.c b/builtin/log.c\nindex b450cd3bde8..fe9cc5ebecb 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -15,7 +15,7 @@\n #include \"hex.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"color.h\"\n #include \"commit.h\"\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex be74f0a03b2..821339b07d4 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -25,7 +25,7 @@\n #include \"setup.h\"\n #include \"sparse-index.h\"\n #include \"submodule.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n \n \ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 8aafc30ca48..62b6fd58c16 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -10,7 +10,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tree.h\"\n #include \"path.h\"\n #include \"quote.h\"\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 2b16b10d2ca..9464f275629 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -7,7 +7,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"setup.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 7f41665dfd7..b1a17787bcf 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -10,7 +10,7 @@\n #include \"commit-reach.h\"\n #include \"merge-ort.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 7ac11c46d53..1809b38f937 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -6,7 +6,7 @@\n #include \"strbuf.h\"\n #include \"replace-object.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"fsck.h\"\n #include \"config.h\"\n \ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 4b478034675..016b0e5b224 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -12,7 +12,7 @@\n #include \"tree.h\"\n #include \"parse-options.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct treeent {\n \tunsigned mode;\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex f55bf53da83..aa25b06f9d0 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -7,7 +7,7 @@\n #include \"midx.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex a3f433ca4c0..783d4932ca6 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -16,7 +16,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n \n #include \"pretty.h\"\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8b33edc2ff5..99b63cb0980 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -32,7 +32,7 @@\n #include \"list.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"dir.h\"\n #include \"midx.h\"\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 5d1fc781761..3134cb8c689 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -13,7 +13,7 @@\n #include \"hex.h\"\n \n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n \n #define BLKSIZE 512\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex e930caa0c0a..7bbfb14c2be 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -17,7 +17,7 @@\n #include \"replace-object.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"shallow.h\"\n \n static const char * const prune_usage[] = {\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex a317d6c278d..0f5958c4a66 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -33,7 +33,7 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"protocol.h\"\n #include \"commit-reach.h\"\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 0d6755bcb71..ac5b8d2a1a6 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -14,7 +14,7 @@\n #include \"rebase.h\"\n #include \"refs.h\"\n #include \"refspec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strvec.h\"\n #include \"commit-reach.h\"\n #include \"progress.h\"\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 59214dbdfdf..16782320058 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -17,7 +17,7 @@\n #include \"midx.h\"\n #include \"packfile.h\"\n #include \"prune-packed.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"shallow.h\"\n #include \"pack.h\"\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 48c7c6a2d56..11c7e2d4c0c 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"tag.h\"\n #include \"wildmatch.h\"\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 0984b607bf0..0ee37a32cb2 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -14,7 +14,7 @@\n #include \"object.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"parse-options.h\"\n #include \"log-tree.h\"\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 623a52a45f8..90ec1de78f9 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"refs/refs-internal.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"string-list.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 758bc6d0f24..84f7fa53424 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -28,7 +28,7 @@\n #include \"diff.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"advice.h\"\n #include \"branch.h\"\n #include \"list-objects-filter-options.h\"\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 4742b27d16e..cf2ea4b4993 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -19,7 +19,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"tag.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex e33acfc4ee4..b92fd4710a9 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static char *create_temp_file(struct object_id *oid)\n {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex e905d5f4e19..7bf395eec84 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -9,7 +9,7 @@\n #include \"git-zlib.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"delta.h\"\n #include \"pack.h\"\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 678e2ecc2c2..55406a539e7 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -17,7 +17,7 @@\n #include \"tmp-objdir.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int odb_transaction_nesting;\n \ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 9accf157b44..2e623f8627a 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -14,7 +14,7 @@\n #include \"fetch-pack.h\"\n #include \"remote.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static struct {\n \tenum bundle_list_heuristic heuristic;\ndiff --git a/bundle.c b/bundle.c\nindex 2ce7525f90d..e09e3c2f58c 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -7,7 +7,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/cache-tree.c b/cache-tree.c\nindex fa3858e2829..9786b32b3a1 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -10,7 +10,7 @@\n #include \"cache-tree.h\"\n #include \"bulk-checkin.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"read-cache-ll.h\"\n #include \"replace-object.h\"\n #include \"repository.h\"\ndiff --git a/combine-diff.c b/combine-diff.c\nindex dfae9f7995d..cf23a753407 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -2,7 +2,7 @@\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"convert.h\"\n #include \"diff.h\"\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 12d32cdad1d..6ced5b366e7 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -13,7 +13,7 @@\n #include \"refs.h\"\n #include \"hash-lookup.h\"\n #include \"commit-graph.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"alloc.h\"\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 0e661db1b54..78ab7b875b2 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -1,7 +1,7 @@\n #ifndef COMMIT_GRAPH_H\n #define COMMIT_GRAPH_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n #define GIT_TEST_COMMIT_GRAPH \"GIT_TEST_COMMIT_GRAPH\"\ndiff --git a/commit.c b/commit.c\nindex e915b2b9a12..1d30f8ce15a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -9,7 +9,7 @@\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/config.c b/config.c\nindex b18b5617fcd..883dd066827 100644\n--- a/config.c\n+++ b/config.c\n@@ -31,7 +31,7 @@\n #include \"hashmap.h\"\n #include \"string-list.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pager.h\"\n #include \"path.h\"\n #include \"utf8.h\"\ndiff --git a/connected.c b/connected.c\nindex 4415388beba..18c13245d8e 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"run-command.h\"\n #include \"sigchain.h\"\n #include \"connected.h\"\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 765ad689678..ea7fe1c8db7 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -77,7 +77,7 @@\n |\n - diff_setup\n + repo_diff_setup\n-// object-store.h\n+// odb.h\n |\n - read_object_file\n + repo_read_object_file\ndiff --git a/diagnose.c b/diagnose.c\nindex d08d5643aac..ad0d5c12465 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -7,7 +7,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"strvec.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"repository.h\"\ndiff --git a/diff.c b/diff.c\nindex 90e8003dd11..3af108115b3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -23,7 +23,7 @@\n #include \"color.h\"\n #include \"run-command.h\"\n #include \"utf8.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"userdiff.h\"\n #include \"submodule.h\"\n #include \"hashmap.h\"\ndiff --git a/entry.c b/entry.c\nindex f36ec5ad242..75d55038d7c 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -1,7 +1,7 @@\n #define USE_THE_REPOSITORY_VARIABLE\n \n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"dir.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex fa4231fee74..cf157f5d7e5 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -24,7 +24,7 @@\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"connected.h\"\n #include \"fetch-negotiator.h\"\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 501b5acdd44..1a8c972adf3 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -6,7 +6,7 @@\n #include \"environment.h\"\n #include \"refs.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"diff.h\"\n #include \"diff-merges.h\"\n #include \"hex.h\"\ndiff --git a/fsck.c b/fsck.c\nindex 8dc8472ceb3..e69baab3af7 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"dir.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"object.h\"\ndiff --git a/grep.c b/grep.c\nindex f8d535182c3..dc77e6c4631 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"grep.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\ndiff --git a/http-backend.c b/http-backend.c\nindex 0c575aa88aa..ad8c4037493 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -18,7 +18,7 @@\n #include \"url.h\"\n #include \"strvec.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"protocol.h\"\n #include \"date.h\"\n #include \"write-or-die.h\"\ndiff --git a/http-push.c b/http-push.c\nindex f9e67cabd4b..d1b1bb23711 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -20,7 +20,7 @@\n #include \"url.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n \n #ifdef EXPAT_NEEDS_XMLPARSE_H\ndiff --git a/http-walker.c b/http-walker.c\nindex c374e6b2056..05fb9ce714a 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -10,7 +10,7 @@\n #include \"transport.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct alt_base {\n \tchar *base;\ndiff --git a/http.c b/http.c\nindex 5e15bbab3f1..8f4f701a818 100644\n--- a/http.c\n+++ b/http.c\n@@ -19,7 +19,7 @@\n #include \"packfile.h\"\n #include \"string-list.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"tempfile.h\"\n \n static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 78b397bc194..80fe48a52c8 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -12,7 +12,7 @@\n #include \"oidmap.h\"\n #include \"oidset.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n /* Remember to update object flag allocation in object.h */\n /*\ndiff --git a/list-objects.c b/list-objects.c\nindex 597114281f6..c50b9578584 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -14,7 +14,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace.h\"\n #include \"environment.h\"\n \ndiff --git a/loose.c b/loose.c\nindex fe65d5b9b0f..fab4041c03d 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"hash.h\"\n #include \"path.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"wrapper.h\"\ndiff --git a/mailmap.c b/mailmap.c\nindex 9e2642a043b..b18e74c2110 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -6,7 +6,7 @@\n #include \"string-list.h\"\n #include \"mailmap.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n char *git_mailmap_file;\ndiff --git a/match-trees.c b/match-trees.c\nindex 72922d5d64e..4704f95c340 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -7,7 +7,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n static int score_missing(unsigned mode)\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 53f36dbc175..ba8a3fdfd82 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -4,7 +4,7 @@\n #include \"merge-ll.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 47b3d1730ec..9f693ab1d36 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -39,7 +39,7 @@\n #include \"mem-pool.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/meson.build b/meson.build\nindex 596f5ac7110..3fad0e39987 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -396,8 +396,8 @@ libgit_sources = [\n   'object-file-convert.c',\n   'object-file.c',\n   'object-name.c',\n-  'object-store.c',\n   'object.c',\n+  'odb.c',\n   'oid-array.c',\n   'oidmap.c',\n   'oidset.c',\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 150241b15e0..344f67762b8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"notes-cache.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pretty.h\"\n #include \"repository.h\"\n #include \"commit.h\"\ndiff --git a/notes-merge.c b/notes-merge.c\nindex dae8e6a281a..de6a52e2e7f 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -8,7 +8,7 @@\n #include \"refs.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"diff.h\"\ndiff --git a/notes.c b/notes.c\nindex 0a128f1de98..fc000e501d2 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -8,7 +8,7 @@\n #include \"notes.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"utf8.h\"\n #include \"strbuf.h\"\n #include \"tree-walk.h\"\ndiff --git a/object-file.c b/object-file.c\nindex 6bad1d3dd1c..2d3af8a77c0 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -21,7 +21,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidtree.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/object-file.h b/object-file.h\nindex 9a18859b2e0..5066638f8ec 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -3,7 +3,7 @@\n \n #include \"git-zlib.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct index_state;\n \ndiff --git a/object-store.c b/odb.c\nsimilarity index 99%\nrename from object-store.c\nrename to odb.c\nindex 5c04a1018f7..d1025ac182d 100644\n--- a/object-store.c\n+++ b/odb.c\n@@ -13,7 +13,7 @@\n #include \"loose.h\"\n #include \"object-file-convert.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"promisor-remote.h\"\ndiff --git a/object-store.h b/odb.h\nsimilarity index 99%\nrename from object-store.h\nrename to odb.h\nindex d199d757d76..6f56b168e46 100644\n--- a/object-store.h\n+++ b/odb.h\n@@ -1,5 +1,5 @@\n-#ifndef OBJECT_STORE_H\n-#define OBJECT_STORE_H\n+#ifndef ODB_H\n+#define ODB_H\n \n #include \"hashmap.h\"\n #include \"object.h\"\n@@ -352,4 +352,4 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n-#endif /* OBJECT_STORE_H */\n+#endif /* ODB_H */\ndiff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c\nindex 609a343ee3e..d2a92f34d98 100644\n--- a/oss-fuzz/fuzz-pack-idx.c\n+++ b/oss-fuzz/fuzz-pack-idx.c\n@@ -1,5 +1,5 @@\n #include \"git-compat-util.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n \n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 7f400ee0121..37648b57125 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -4,7 +4,7 @@\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex ac6d62b980c..a695a794e9b 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -17,7 +17,7 @@\n #include \"packfile.h\"\n #include \"repository.h\"\n #include \"trace2.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"list-objects-filter-options.h\"\n #include \"midx.h\"\n #include \"config.h\"\ndiff --git a/pack-check.c b/pack-check.c\nindex 874897d6cba..67cb2cf72f2 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -8,7 +8,7 @@\n #include \"progress.h\"\n #include \"packfile.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct idx_entry {\n \toff_t                offset;\ndiff --git a/pack-mtimes.c b/pack-mtimes.c\nindex 20900ca88d3..8e1f2dec0ef 100644\n--- a/pack-mtimes.c\n+++ b/pack-mtimes.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-mtimes.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 475a2d67ce3..1ac8644201b 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -1,7 +1,7 @@\n #ifndef PACK_OBJECTS_H\n #define PACK_OBJECTS_H\n \n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"thread-utils.h\"\n #include \"pack.h\"\n #include \"packfile.h\"\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex ffcde48870d..0cc422a1e67 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"pack-revindex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\ndiff --git a/packfile.c b/packfile.c\nindex 60661ad0095..346c2f9ce90 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -19,7 +19,7 @@\n #include \"tree-walk.h\"\n #include \"tree.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"midx.h\"\n #include \"commit-graph.h\"\n #include \"pack-revindex.h\"\ndiff --git a/packfile.h b/packfile.h\nindex 826eb7f475f..53c3b7d3b43 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -3,10 +3,10 @@\n \n #include \"list.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n \n-/* in object-store.h */\n+/* in odb.h */\n struct object_info;\n \n struct packed_git {\ndiff --git a/path.c b/path.c\nindex c347829aa66..7f56eaf9930 100644\n--- a/path.c\n+++ b/path.c\n@@ -15,7 +15,7 @@\n #include \"submodule-config.h\"\n #include \"path.h\"\n #include \"packfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"lockfile.h\"\n #include \"exec-cmd.h\"\n \ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 9d058586dfa..2baa286bfd0 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -3,7 +3,7 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"config.h\"\n #include \"trace2.h\"\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 9b8db37a210..3022f69a1bd 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -6,7 +6,7 @@\n #include \"hash.h\"\n #include \"hex.h\"\n #include \"object.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n #include \"string-list.h\"\n #include \"strbuf.h\"\ndiff --git a/read-cache.c b/read-cache.c\nindex c0bb760ad47..c3fa9686766 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -20,7 +20,7 @@\n #include \"refs.h\"\n #include \"dir.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 7a274633cfc..4ce45440ad1 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"wildmatch.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"repo-settings.h\"\n #include \"repository.h\"\ndiff --git a/reflog.c b/reflog.c\nindex 15d81ebea97..4f8a3b717cd 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -5,7 +5,7 @@\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"parse-options.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"reflog.h\"\n #include \"refs.h\"\n #include \"revision.h\"\ndiff --git a/refs.c b/refs.c\nindex 5f6a386cc93..0ff0e582a6b 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -19,7 +19,7 @@\n #include \"run-command.h\"\n #include \"hook.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"path.h\"\n #include \"submodule.h\"\ndiff --git a/remote.c b/remote.c\nindex 4099183cacd..17a842f5684 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -12,7 +12,7 @@\n #include \"refs.h\"\n #include \"refspec.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/replace-object.c b/replace-object.c\nindex f8c5f68837f..3eae0510745 100644\n--- a/replace-object.c\n+++ b/replace-object.c\n@@ -2,7 +2,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"oidmap.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"refs.h\"\n #include \"repository.h\"\ndiff --git a/replace-object.h b/replace-object.h\nindex 3052e96a620..4c9f2a2383d 100644\n--- a/replace-object.h\n+++ b/replace-object.h\n@@ -3,7 +3,7 @@\n \n #include \"oidmap.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n \n struct replace_object {\n \tstruct oidmap_entry original;\ndiff --git a/repository.c b/repository.c\nindex 7528beccddf..13426db0f2b 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"config.h\"\n #include \"object.h\"\n #include \"lockfile.h\"\ndiff --git a/rerere.c b/rerere.c\nindex 3cd37c5f0ae..951e4bf8b41 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -18,7 +18,7 @@\n #include \"path.h\"\n #include \"pathspec.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strmap.h\"\n \n #define RESOLVED 0\ndiff --git a/revision.c b/revision.c\nindex 2c36a9c179e..cdefe7d6e48 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -8,7 +8,7 @@\n #include \"hex.h\"\n #include \"object-name.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oidset.h\"\n #include \"tag.h\"\n #include \"blob.h\"\ndiff --git a/send-pack.c b/send-pack.c\nindex 86592ce526d..abca2dd38a7 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -4,7 +4,7 @@\n #include \"date.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"run-command.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex 1ee0abbd451..2432d0a39ec 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -13,7 +13,7 @@\n #include \"dir.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"object.h\"\n #include \"pager.h\"\n #include \"commit.h\"\ndiff --git a/server-info.c b/server-info.c\nindex d6cd20a39d7..9bb30d9ab71 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -11,7 +11,7 @@\n #include \"packfile.h\"\n #include \"path.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"server-info.h\"\n #include \"strbuf.h\"\n #include \"tempfile.h\"\ndiff --git a/shallow.c b/shallow.c\nindex faeeeb45f98..d379756e39a 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -5,7 +5,7 @@\n #include \"repository.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"pkt-line.h\"\ndiff --git a/streaming.c b/streaming.c\nindex 6d6512e2e0d..81c42673a23 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -10,7 +10,7 @@\n #include \"streaming.h\"\n #include \"repository.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"replace-object.h\"\n #include \"packfile.h\"\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex b30d9365fbd..9c80f9f7b66 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -13,7 +13,7 @@\n #include \"submodule.h\"\n #include \"strbuf.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"parse-options.h\"\n #include \"thread-utils.h\"\n #include \"tree-walk.h\"\ndiff --git a/submodule.c b/submodule.c\nindex ead3fb5dadc..9b1018877df 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -27,7 +27,7 @@\n #include \"parse-options.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c\nindex 76c2f4eba85..611a13a3261 100644\n--- a/t/helper/test-find-pack.c\n+++ b/t/helper/test-find-pack.c\n@@ -2,7 +2,7 @@\n \n #include \"test-tool.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c\nindex fdf1b13437b..d51aaa3dc40 100644\n--- a/t/helper/test-pack-mtimes.c\n+++ b/t/helper/test-pack-mtimes.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"strbuf.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"packfile.h\"\n #include \"pack-mtimes.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex 34f1aee5581..dba227259a2 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -1,7 +1,7 @@\n #include \"test-tool.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"setup.h\"\n \n /*\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 53b633e2ba6..ef5339bbee9 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -3,7 +3,7 @@\n #include \"test-tool.h\"\n #include \"commit-graph.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"bloom.h\"\n #include \"setup.h\"\n \ndiff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c\nindex ac81390899a..da2aa036b57 100644\n--- a/t/helper/test-read-midx.c\n+++ b/t/helper/test-read-midx.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"midx.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"pack-bitmap.h\"\n #include \"packfile.h\"\n #include \"setup.h\"\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 4cfc7c90b59..2920ca59d72 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -5,7 +5,7 @@\n #include \"refs.h\"\n #include \"setup.h\"\n #include \"worktree.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"path.h\"\n #include \"repository.h\"\n #include \"strbuf.h\"\ndiff --git a/tag.c b/tag.c\nindex 05be39067cf..5f6868bf7b1 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -5,7 +5,7 @@\n #include \"environment.h\"\n #include \"tag.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"blob.h\"\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex 056484404be..bef2f917cd2 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -10,7 +10,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"quote.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"repository.h\"\n \n struct tmp_objdir {\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 90655d52378..34b0fff4873 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -6,7 +6,7 @@\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"trace2.h\"\n #include \"tree.h\"\n #include \"pathspec.h\"\ndiff --git a/tree.c b/tree.c\nindex b85f56267fb..341b7c2ff3f 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -4,7 +4,7 @@\n #include \"hex.h\"\n #include \"tree.h\"\n #include \"object-name.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"alloc.h\"\n #include \"tree-walk.h\"\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 471837f0329..f38c761ab98 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -26,7 +26,7 @@\n #include \"symlinks.h\"\n #include \"trace2.h\"\n #include \"fsmonitor.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"promisor-remote.h\"\n #include \"entry.h\"\n #include \"parallel-checkout.h\"\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 26f29b85b55..e994d6a901b 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -10,7 +10,7 @@\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"oid-array.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/walker.c b/walker.c\nindex b470d43e54d..a8abe8a2e78 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -5,7 +5,7 @@\n #include \"hex.h\"\n #include \"walker.h\"\n #include \"repository.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"commit.h\"\n #include \"strbuf.h\"\n #include \"tree.h\"\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 1edcd319e6e..01e6e378ea6 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -5,7 +5,7 @@\n #include \"gettext.h\"\n #include \"config.h\"\n #include \"hex.h\"\n-#include \"object-store.h\"\n+#include \"odb.h\"\n #include \"strbuf.h\"\n #include \"xdiff-interface.h\"\n #include \"xdiff/xtypes.h\"\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521028","messageId":"20250701-pks-object-store-wo-the-repository-v6-4-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 04/17] odb: introduce parent pointers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:16Z","receivedAt":"2025-07-01T12:22:35Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In subsequent commits we'll get rid of our use of `the_repository` in\n\"odb.c\" in favor of explicitly passing in a `struct object_database` or\na `struct odb_source`. In some cases though we'll need access to the\nrepository, for example to read a config value from it, but we don't\nhave a way to access the repository owning a specific object database.\n\nIntroduce parent pointers for `struct object_database` to its owning\nrepository as well as for `struct odb_source` to its owning object\ndatabase, which will allow us to adapt those use cases.\n\nNote that this change requires us to pass through the object database to\n`link_alt_odb_entry()` so that we can set up the parent pointers for any\nsource there. The callchain is adapted to pass through the object\ndatabase accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 45 ++++++++++++++++++++++++++-------------------\n odb.h        |  8 +++++++-\n repository.c |  3 ++-\n 3 files changed, 35 insertions(+), 21 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex d1025ac182d..0464d7f54a2 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -135,11 +135,15 @@ static int alt_odb_usable(struct object_database *o,\n  * of the object ID, an extra slash for the first level indirection, and\n  * the terminating NUL.\n  */\n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth);\n-static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n-\tconst char *relative_base, int depth, const char *normalized_objdir)\n+\n+static int link_alt_odb_entry(struct object_database *odb,\n+\t\t\t      const struct strbuf *entry,\n+\t\t\t      const char *relative_base,\n+\t\t\t      int depth,\n+\t\t\t      const char *normalized_objdir)\n {\n \tstruct odb_source *alternate;\n \tstruct strbuf pathbuf = STRBUF_INIT;\n@@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,\n \twhile (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')\n \t\tstrbuf_setlen(&pathbuf, pathbuf.len - 1);\n \n-\tif (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))\n+\tif (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))\n \t\tgoto error;\n \n \tCALLOC_ARRAY(alternate, 1);\n+\talternate->odb = odb;\n \t/* pathbuf.buf is already in r->objects->source_by_path */\n \talternate->path = strbuf_detach(&pathbuf, NULL);\n \n \t/* add the alternate entry */\n-\t*r->objects->sources_tail = alternate;\n-\tr->objects->sources_tail = &(alternate->next);\n+\t*odb->sources_tail = alternate;\n+\todb->sources_tail = &(alternate->next);\n \talternate->next = NULL;\n-\tassert(r->objects->source_by_path);\n-\tkh_value(r->objects->source_by_path, pos) = alternate;\n+\tassert(odb->source_by_path);\n+\tkh_value(odb->source_by_path, pos) = alternate;\n \n \t/* recursively add alternates */\n-\tread_info_alternates(r, alternate->path, depth + 1);\n+\tread_info_alternates(odb, alternate->path, depth + 1);\n \tret = 0;\n  error:\n \tstrbuf_release(&tmp);\n@@ -219,7 +224,7 @@ static const char *parse_alt_odb_entry(const char *string,\n \treturn end;\n }\n \n-static void link_alt_odb_entries(struct repository *r, const char *alt,\n+static void link_alt_odb_entries(struct object_database *odb, const char *alt,\n \t\t\t\t int sep, const char *relative_base, int depth)\n {\n \tstruct strbuf objdirbuf = STRBUF_INIT;\n@@ -234,20 +239,20 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,\n \t\treturn;\n \t}\n \n-\tstrbuf_realpath(&objdirbuf, r->objects->sources->path, 1);\n+\tstrbuf_realpath(&objdirbuf, odb->sources->path, 1);\n \n \twhile (*alt) {\n \t\talt = parse_alt_odb_entry(alt, sep, &entry);\n \t\tif (!entry.len)\n \t\t\tcontinue;\n-\t\tlink_alt_odb_entry(r, &entry,\n+\t\tlink_alt_odb_entry(odb, &entry,\n \t\t\t\t   relative_base, depth, objdirbuf.buf);\n \t}\n \tstrbuf_release(&entry);\n \tstrbuf_release(&objdirbuf);\n }\n \n-static void read_info_alternates(struct repository *r,\n+static void read_info_alternates(struct object_database *odb,\n \t\t\t\t const char *relative_base,\n \t\t\t\t int depth)\n {\n@@ -261,7 +266,7 @@ static void read_info_alternates(struct repository *r,\n \t\treturn;\n \t}\n \n-\tlink_alt_odb_entries(r, buf.buf, '\\n', relative_base, depth);\n+\tlink_alt_odb_entries(odb, buf.buf, '\\n', relative_base, depth);\n \tstrbuf_release(&buf);\n \tfree(path);\n }\n@@ -303,7 +308,7 @@ void add_to_alternates_file(const char *reference)\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n \t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository, reference,\n+\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n@@ -317,7 +322,7 @@ void add_to_alternates_memory(const char *reference)\n \t */\n \tprepare_alt_odb(the_repository);\n \n-\tlink_alt_odb_entries(the_repository, reference,\n+\tlink_alt_odb_entries(the_repository->objects, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -336,6 +341,7 @@ struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * alternate\n \t */\n \tsource = xcalloc(1, sizeof(*source));\n+\tsource->odb = the_repository->objects;\n \tsource->path = xstrdup(dir);\n \n \t/*\n@@ -580,9 +586,9 @@ void prepare_alt_odb(struct repository *r)\n \tif (r->objects->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r, r->objects->sources->path, 0);\n+\tread_info_alternates(r->objects, r->objects->sources->path, 0);\n \tr->objects->loaded_alternates = 1;\n }\n \n@@ -950,11 +956,12 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)\n \t\t    type_name(expect));\n }\n \n-struct object_database *odb_new(void)\n+struct object_database *odb_new(struct repository *repo)\n {\n \tstruct object_database *o = xmalloc(sizeof(*o));\n \n \tmemset(o, 0, sizeof(*o));\n+\to->repo = repo;\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\ndiff --git a/odb.h b/odb.h\nindex 6f56b168e46..c3851e29668 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -28,6 +28,9 @@ struct repository;\n struct odb_source {\n \tstruct odb_source *next;\n \n+\t/* Object database that owns this object source. */\n+\tstruct object_database *odb;\n+\n \t/*\n \t * Used to store the results of readdir(3) calls when we are OK\n \t * sacrificing accuracy due to races for speed. That includes\n@@ -105,6 +108,9 @@ struct cached_object_entry;\n  * configured via alternates.\n  */\n struct object_database {\n+\t/* Repository that owns this database. */\n+\tstruct repository *repo;\n+\n \t/*\n \t * Set of all object directories; the main directory is first (and\n \t * cannot be NULL after initialization). Subsequent directories are\n@@ -186,7 +192,7 @@ struct object_database {\n \tunsigned packed_git_initialized : 1;\n };\n \n-struct object_database *odb_new(void);\n+struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n /*\ndiff --git a/repository.c b/repository.c\nindex 13426db0f2b..c606e1153c8 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)\n \n void initialize_repository(struct repository *repo)\n {\n-\trepo->objects = odb_new();\n+\trepo->objects = odb_new(repo);\n \trepo->remote_state = remote_state_new();\n \trepo->parsed_objects = parsed_object_pool_new(repo);\n \tALLOC_ARRAY(repo->index, 1);\n@@ -167,6 +167,7 @@ void repo_set_gitdir(struct repository *repo,\n \n \tif (!repo->objects->sources) {\n \t\tCALLOC_ARRAY(repo->objects->sources, 1);\n+\t\trepo->objects->sources->odb = repo->objects;\n \t\trepo->objects->sources_tail = &repo->objects->sources->next;\n \t}\n \texpand_base_dir(&repo->objects->sources->path, o->object_dir,\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521029","messageId":"20250701-pks-object-store-wo-the-repository-v6-5-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:17Z","receivedAt":"2025-07-01T12:22:39Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `find_odb()` by passing\nin the object database in which we want to search for the source and\nadjusting all callers.\n\nRename the function to `odb_find_source()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c | 4 ++--\n midx-write.c           | 2 +-\n odb.c                  | 6 +++---\n odb.h                  | 7 ++++++-\n 4 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex f04eaba5259..77d7e88a98c 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -101,7 +101,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,\n \tif (opts.progress)\n \t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\tsource = find_odb(the_repository, opts.obj_dir);\n+\tsource = odb_find_source(the_repository->objects, opts.obj_dir);\n \tgraph_name = get_commit_graph_filename(source);\n \tchain_name = get_commit_graph_chain_filename(source);\n \tif (open_commit_graph(graph_name, &fd, &st))\n@@ -289,7 +289,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tsource = find_odb(the_repository, opts.obj_dir);\n+\tsource = odb_find_source(the_repository->objects, opts.obj_dir);\n \n \tif (opts.reachable) {\n \t\tif (write_commit_graph_reachable(source, flags, &write_opts))\ndiff --git a/midx-write.c b/midx-write.c\nindex ba4a94950a8..f2cfb85476e 100644\n--- a/midx-write.c\n+++ b/midx-write.c\n@@ -922,7 +922,7 @@ static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,\n \tstruct strbuf cur_path_real = STRBUF_INIT;\n \n \t/* Ensure the given object_dir is local, or a known alternate. */\n-\tfind_odb(r, obj_dir_real);\n+\todb_find_source(r->objects, obj_dir_real);\n \n \tfor (cur = get_multi_pack_index(r); cur; cur = cur->next) {\n \t\tstrbuf_realpath(&cur_path_real, cur->object_dir, 1);\ndiff --git a/odb.c b/odb.c\nindex 0464d7f54a2..240fc62ca2b 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -448,14 +448,14 @@ char *compute_alternate_path(const char *path, struct strbuf *err)\n \treturn ref_git;\n }\n \n-struct odb_source *find_odb(struct repository *r, const char *obj_dir)\n+struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir)\n {\n \tstruct odb_source *source;\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n-\tfor (source = r->objects->sources; source; source = source->next) {\n+\tprepare_alt_odb(odb->repo);\n+\tfor (source = odb->sources; source; source = source->next) {\n \t\tstrbuf_realpath(&odb_path_real, source->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n \t\t\tbreak;\ndiff --git a/odb.h b/odb.h\nindex c3851e29668..941329c6943 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -68,7 +68,6 @@ struct odb_source {\n void prepare_alt_odb(struct repository *r);\n int has_alt_odb(struct repository *r);\n char *compute_alternate_path(const char *path, struct strbuf *err);\n-struct odb_source *find_odb(struct repository *r, const char *obj_dir);\n typedef int alt_odb_fn(struct odb_source *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n@@ -195,6 +194,12 @@ struct object_database {\n struct object_database *odb_new(struct repository *repo);\n void odb_clear(struct object_database *o);\n \n+/*\n+ * Find source by its object directory path. Dies in case the source couldn't\n+ * be found.\n+ */\n+struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);\n+\n /*\n  * Create a temporary file rooted in the object database directory, or\n  * die on failure. The filename is taken from \"pattern\", which should have the\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521030","messageId":"20250701-pks-object-store-wo-the-repository-v6-6-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 06/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:18Z","receivedAt":"2025-07-01T12:22:42Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `assert_oid_type()` by\npassing in the object database as a parameter and adjusting all callers.\n\nRename the function to `odb_assert_oid_type()`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-tree.c | 2 +-\n commit.c              | 2 +-\n odb.c                 | 5 +++--\n odb.h                 | 3 ++-\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 546069f8682..31cfd9bd15d 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -48,7 +48,7 @@ static int parse_parent_arg_callback(const struct option *opt,\n \tif (repo_get_oid_commit(the_repository, arg, &oid))\n \t\tdie(_(\"not a valid object name %s\"), arg);\n \n-\tassert_oid_type(&oid, OBJ_COMMIT);\n+\todb_assert_oid_type(the_repository->objects, &oid, OBJ_COMMIT);\n \tnew_parent(lookup_commit(the_repository, &oid), parents);\n \treturn 0;\n }\ndiff --git a/commit.c b/commit.c\nindex 1d30f8ce15a..aa65183d8b6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1706,7 +1706,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,\n \t/* Not having i18n.commitencoding is the same as having utf-8 */\n \tencoding_is_utf8 = is_encoding_utf8(git_commit_encoding);\n \n-\tassert_oid_type(tree, OBJ_TREE);\n+\todb_assert_oid_type(the_repository->objects, tree, OBJ_TREE);\n \n \tif (memchr(msg, '\\0', msg_len))\n \t\treturn error(\"a NUL byte in commit log message not allowed.\");\ndiff --git a/odb.c b/odb.c\nindex 240fc62ca2b..d0ca2990774 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -946,9 +946,10 @@ int has_object(struct repository *r, const struct object_id *oid,\n \treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n }\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect)\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex 941329c6943..13f5da45f54 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -302,7 +302,8 @@ enum {\n int has_object(struct repository *r, const struct object_id *oid,\n \t       unsigned flags);\n \n-void assert_oid_type(const struct object_id *oid, enum object_type expect);\n+void odb_assert_oid_type(struct object_database *odb,\n+\t\t\t const struct object_id *oid, enum object_type expect);\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521031","messageId":"20250701-pks-object-store-wo-the-repository-v6-7-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 07/17] odb: get rid of `the_repository` in `odb_mkstemp()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:19Z","receivedAt":"2025-07-01T12:22:45Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Get rid of our dependency on `the_repository` in `odb_mkstemp()` by\npassing in the object database as a parameter and adjusting all callers.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/fast-import.c |  3 ++-\n builtin/index-pack.c  |  2 +-\n bundle-uri.c          |  3 ++-\n odb.c                 |  9 +++++----\n odb.h                 |  7 ++++---\n pack-bitmap-write.c   |  3 ++-\n pack-write.c          | 10 ++++++----\n 7 files changed, 22 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 52c792488e1..413304db9b5 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -763,7 +763,8 @@ static void start_packfile(void)\n \tstruct packed_git *p;\n \tint pack_fd;\n \n-\tpack_fd = odb_mkstemp(&tmp_file, \"pack/tmp_pack_XXXXXX\");\n+\tpack_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n+\t\t\t      \"pack/tmp_pack_XXXXXX\");\n \tFLEX_ALLOC_STR(p, pack_name, tmp_file.buf);\n \tstrbuf_release(&tmp_file);\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 1aabe6b8ee2..4d4d989eb1a 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -362,7 +362,7 @@ static const char *open_pack_file(const char *pack_name)\n \t\tinput_fd = 0;\n \t\tif (!pack_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\toutput_fd = odb_mkstemp(&tmp_file,\n+\t\t\toutput_fd = odb_mkstemp(the_repository->objects, &tmp_file,\n \t\t\t\t\t\t\"pack/tmp_pack_XXXXXX\");\n \t\t\tpack_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 2e623f8627a..f94e780e967 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -278,7 +278,8 @@ static char *find_temp_filename(void)\n \t * Find a temporary filename that is available. This is briefly\n \t * racy, but unlikely to collide.\n \t */\n-\tfd = odb_mkstemp(&name, \"bundles/tmp_uri_XXXXXX\");\n+\tfd = odb_mkstemp(the_repository->objects, &name,\n+\t\t\t \"bundles/tmp_uri_XXXXXX\");\n \tif (fd < 0) {\n \t\twarning(_(\"failed to create temporary file\"));\n \t\treturn NULL;\ndiff --git a/odb.c b/odb.c\nindex d0ca2990774..8967e9fd548 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -63,7 +63,8 @@ static const struct cached_object *find_cached_object(struct object_database *ob\n \treturn NULL;\n }\n \n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern)\n {\n \tint fd;\n \t/*\n@@ -71,15 +72,15 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)\n \t * restrictive except to remove write permission.\n \t */\n \tint mode = 0444;\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n \tfd = git_mkstemp_mode(temp_filename->buf, mode);\n \tif (0 <= fd)\n \t\treturn fd;\n \n \t/* slow path */\n \t/* some mkstemp implementations erase temp_filename on failure */\n-\trepo_git_path_replace(the_repository, temp_filename, \"objects/%s\", pattern);\n-\tsafe_create_leading_directories(the_repository, temp_filename->buf);\n+\trepo_git_path_replace(odb->repo, temp_filename, \"objects/%s\", pattern);\n+\tsafe_create_leading_directories(odb->repo, temp_filename->buf);\n \treturn xmkstemp_mode(temp_filename->buf, mode);\n }\n \ndiff --git a/odb.h b/odb.h\nindex 13f5da45f54..5de952608f3 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -201,12 +201,13 @@ void odb_clear(struct object_database *o);\n struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);\n \n /*\n- * Create a temporary file rooted in the object database directory, or\n- * die on failure. The filename is taken from \"pattern\", which should have the\n+ * Create a temporary file rooted in the primary alternate's directory, or die\n+ * on failure. The filename is taken from \"pattern\", which should have the\n  * usual \"XXXXXX\" trailer, and the resulting filename is written into the\n  * \"template\" buffer. Returns the open descriptor.\n  */\n-int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);\n+int odb_mkstemp(struct object_database *odb,\n+\t\tstruct strbuf *temp_filename, const char *pattern);\n \n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 37648b57125..c847369eaaa 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1052,7 +1052,8 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n \n \tstruct bitmap_disk_header header;\n \n-\tint fd = odb_mkstemp(&tmp_file, \"pack/tmp_bitmap_XXXXXX\");\n+\tint fd = odb_mkstemp(writer->repo->objects, &tmp_file,\n+\t\t\t     \"pack/tmp_bitmap_XXXXXX\");\n \n \tif (writer->pseudo_merges_nr)\n \t\toptions |= BITMAP_OPT_PSEUDO_MERGES;\ndiff --git a/pack-write.c b/pack-write.c\nindex 6b06315f80a..eccdc798e36 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -84,7 +84,8 @@ const char *write_idx_file(struct repository *repo,\n \t} else {\n \t\tif (!index_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_idx_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_idx_XXXXXX\");\n \t\t\tindex_name = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(index_name);\n@@ -259,7 +260,8 @@ char *write_rev_file_order(struct repository *repo,\n \tif (flags & WRITE_REV) {\n \t\tif (!rev_name) {\n \t\t\tstruct strbuf tmp_file = STRBUF_INIT;\n-\t\t\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_rev_XXXXXX\");\n+\t\t\tfd = odb_mkstemp(repo->objects, &tmp_file,\n+\t\t\t\t\t \"pack/tmp_rev_XXXXXX\");\n \t\t\tpath = strbuf_detach(&tmp_file, NULL);\n \t\t} else {\n \t\t\tunlink(rev_name);\n@@ -342,7 +344,7 @@ static char *write_mtimes_file(struct repository *repo,\n \tif (!to_pack)\n \t\tBUG(\"cannot call write_mtimes_file with NULL packing_data\");\n \n-\tfd = odb_mkstemp(&tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmp_file, \"pack/tmp_mtimes_XXXXXX\");\n \tmtimes_name = strbuf_detach(&tmp_file, NULL);\n \tf = hashfd(repo->hash_algo, fd, mtimes_name);\n \n@@ -531,7 +533,7 @@ struct hashfile *create_tmp_packfile(struct repository *repo,\n \tstruct strbuf tmpname = STRBUF_INIT;\n \tint fd;\n \n-\tfd = odb_mkstemp(&tmpname, \"pack/tmp_pack_XXXXXX\");\n+\tfd = odb_mkstemp(repo->objects, &tmpname, \"pack/tmp_pack_XXXXXX\");\n \t*pack_tmp_name = strbuf_detach(&tmpname, NULL);\n \treturn hashfd(repo->hash_algo, fd, *pack_tmp_name);\n }\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521032","messageId":"20250701-pks-object-store-wo-the-repository-v6-8-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:20Z","receivedAt":"2025-07-01T12:22:48Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions to manage alternates all depend on `the_repository`.\nRefactor them to accept an object database as a parameter and adjust all\ncallers. The functions are renamed accordingly.\n\nNote that right now the situation is still somewhat weird because we end\nup using the object store path provided by the object store's repository\nanyway. Consequently, we could have instead passed in a pointer to the\nrepository instead of passing in the pointer to the object store. This\nwill be addressed in subsequent commits though, where we will start to\nuse the path owned by the object store itself.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/clone.c           | 10 +++++----\n builtin/fsck.c            |  6 +++---\n builtin/grep.c            |  2 +-\n builtin/repack.c          |  3 ++-\n commit-graph.c            |  4 ++--\n loose.c                   |  2 +-\n object-file.c             | 10 ++++-----\n object-name.c             |  2 +-\n odb.c                     | 44 ++++++++++++++++++---------------------\n odb.h                     | 53 ++++++++++++++++++++++++++++++++---------------\n packfile.c                |  4 ++--\n submodule.c               |  3 ++-\n t/helper/test-ref-store.c |  2 +-\n tmp-objdir.c              |  2 +-\n 14 files changed, 83 insertions(+), 64 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 1eafeefb48d..3aabdf6570b 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -171,7 +171,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)\n \t} else {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tstrbuf_addf(&sb, \"%s/objects\", ref_git);\n-\t\tadd_to_alternates_file(sb.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \t}\n \n@@ -212,12 +212,14 @@ static void copy_alternates(struct strbuf *src, const char *src_repo)\n \t\tif (!line.len || line.buf[0] == '#')\n \t\t\tcontinue;\n \t\tif (is_absolute_path(line.buf)) {\n-\t\t\tadd_to_alternates_file(line.buf);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   line.buf);\n \t\t\tcontinue;\n \t\t}\n \t\tabs_path = mkpathdup(\"%s/objects/%s\", src_repo, line.buf);\n \t\tif (!normalize_path_copy(abs_path, abs_path))\n-\t\t\tadd_to_alternates_file(abs_path);\n+\t\t\todb_add_to_alternates_file(the_repository->objects,\n+\t\t\t\t\t\t   abs_path);\n \t\telse\n \t\t\twarning(\"skipping invalid relative alternate: %s/%s\",\n \t\t\t\tsrc_repo, line.buf);\n@@ -352,7 +354,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)\n \t\tstruct strbuf alt = STRBUF_INIT;\n \t\tget_common_dir(&alt, src_repo);\n \t\tstrbuf_addstr(&alt, \"/objects\");\n-\t\tadd_to_alternates_file(alt.buf);\n+\t\todb_add_to_alternates_file(the_repository->objects, alt.buf);\n \t\tstrbuf_release(&alt);\n \t} else {\n \t\tstruct strbuf src = STRBUF_INIT;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 9abd7b25580..014aa1344e2 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -997,7 +997,7 @@ int cmd_fsck(int argc,\n \t\tfor_each_packed_object(the_repository,\n \t\t\t\t       mark_packed_for_connectivity, NULL, 0);\n \t} else {\n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (source = the_repository->objects->sources; source; source = source->next)\n \t\t\tfsck_object_dir(source->path);\n \n@@ -1108,7 +1108,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_commit_graph) {\n \t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\t\tchild_process_init(&commit_graph_verify);\n \t\t\tcommit_graph_verify.git_cmd = 1;\n@@ -1126,7 +1126,7 @@ int cmd_fsck(int argc,\n \tif (the_repository->settings.core_multi_pack_index) {\n \t\tstruct child_process midx_verify = CHILD_PROCESS_INIT;\n \n-\t\tprepare_alt_odb(the_repository);\n+\t\todb_prepare_alternates(the_repository->objects);\n \t\tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\t\tchild_process_init(&midx_verify);\n \t\t\tmidx_verify.git_cmd = 1;\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex a1d7ee7af39..336cfcab6fb 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -462,7 +462,7 @@ static int grep_submodule(struct grep_opt *opt,\n \n \t/*\n \t * NEEDSWORK: repo_read_gitmodules() might call\n-\t * add_to_alternates_memory() via config_from_gitmodules(). This\n+\t * odb_add_to_alternates_memory() via config_from_gitmodules(). This\n \t * operation causes a race condition with concurrent object readings\n \t * performed by the worker threads. That's why we need obj_read_lock()\n \t * here. It should be removed once it's no longer necessary to add the\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 16782320058..8145474cf8d 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -1256,7 +1256,8 @@ int cmd_repack(int argc,\n \tif (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)\n \t\tdie(_(incremental_bitmap_conflict_error));\n \n-\tif (write_bitmaps && po_args.local && has_alt_odb(the_repository)) {\n+\tif (write_bitmaps && po_args.local &&\n+\t    odb_has_alternates(the_repository->objects)) {\n \t\t/*\n \t\t * When asked to do a local repack, but we have\n \t\t * packfiles that are inherited from an alternate, then\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 6ced5b366e7..59265f89385 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -649,7 +649,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,\n \tcount = st->st_size / (the_hash_algo->hexsz + 1);\n \tCALLOC_ARRAY(oids, count);\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (i = 0; i < count; i++) {\n \t\tstruct odb_source *source;\n@@ -778,7 +778,7 @@ static int prepare_commit_graph(struct repository *r)\n \tif (!commit_graph_compatible(r))\n \t\treturn 0;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources;\n \t     !r->objects->commit_graph && source;\n \t     source = source->next)\ndiff --git a/loose.c b/loose.c\nindex fab4041c03d..519f5db7935 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -112,7 +112,7 @@ int repo_read_loose_object_map(struct repository *repo)\n \tif (!should_use_loose_object_map(repo))\n \t\treturn 0;\n \n-\tprepare_alt_odb(repo);\n+\todb_prepare_alternates(repo->objects);\n \n \tfor (source = repo->objects->sources; source; source = source->next) {\n \t\tif (load_one_loose_object_map(repo, source) < 0) {\ndiff --git a/object-file.c b/object-file.c\nindex 2d3af8a77c0..04da19a1a3b 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -106,7 +106,7 @@ static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)\n {\n \tstruct odb_source *source;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (source = the_repository->objects->sources->next; source; source = source->next) {\n \t\tif (check_and_freshen_odb(source, oid, freshen))\n \t\t\treturn 1;\n@@ -205,7 +205,7 @@ static int stat_loose_object(struct repository *r, const struct object_id *oid,\n \tstruct odb_source *source;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources; source; source = source->next) {\n \t\t*path = odb_loose_path(source, &buf, oid);\n \t\tif (!lstat(*path, st))\n@@ -227,7 +227,7 @@ static int open_loose_object(struct repository *r,\n \tint most_interesting_errno = ENOENT;\n \tstatic struct strbuf buf = STRBUF_INIT;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources; source; source = source->next) {\n \t\t*path = odb_loose_path(source, &buf, oid);\n \t\tfd = git_open(*path);\n@@ -246,7 +246,7 @@ static int quick_has_loose(struct repository *r,\n {\n \tstruct odb_source *source;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources; source; source = source->next) {\n \t\tif (oidtree_contains(odb_loose_cache(source, oid), oid))\n \t\t\treturn 1;\n@@ -1439,7 +1439,7 @@ int for_each_loose_object(each_loose_object_fn cb, void *data,\n {\n \tstruct odb_source *source;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (source = the_repository->objects->sources; source; source = source->next) {\n \t\tint r = for_each_loose_file_in_objdir(source->path, cb, NULL,\n \t\t\t\t\t\t      NULL, data);\ndiff --git a/object-name.c b/object-name.c\nindex 544634d0f40..381536e900e 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -376,7 +376,7 @@ static int init_object_disambiguation(struct repository *r,\n \tds->hex_pfx[len] = '\\0';\n \tds->repo = r;\n \tds->bin_pfx.algo = algo ? hash_algo_by_ptr(algo) : GIT_HASH_UNKNOWN;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \treturn 0;\n }\n \ndiff --git a/odb.c b/odb.c\nindex 8967e9fd548..691a8c7c681 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -272,10 +272,11 @@ static void read_info_alternates(struct object_database *odb,\n \tfree(path);\n }\n \n-void add_to_alternates_file(const char *reference)\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *reference)\n {\n \tstruct lock_file lock = LOCK_INIT;\n-\tchar *alts = repo_git_path(the_repository, \"objects/info/alternates\");\n+\tchar *alts = repo_git_path(odb->repo, \"objects/info/alternates\");\n \tFILE *in, *out;\n \tint found = 0;\n \n@@ -308,22 +309,23 @@ void add_to_alternates_file(const char *reference)\n \t\tfprintf_or_die(out, \"%s\\n\", reference);\n \t\tif (commit_lock_file(&lock))\n \t\t\tdie_errno(_(\"unable to move new alternates file into place\"));\n-\t\tif (the_repository->objects->loaded_alternates)\n-\t\t\tlink_alt_odb_entries(the_repository->objects, reference,\n+\t\tif (odb->loaded_alternates)\n+\t\t\tlink_alt_odb_entries(odb, reference,\n \t\t\t\t\t     '\\n', NULL, 0);\n \t}\n \tfree(alts);\n }\n \n-void add_to_alternates_memory(const char *reference)\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *reference)\n {\n \t/*\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(odb);\n \n-\tlink_alt_odb_entries(the_repository->objects, reference,\n+\tlink_alt_odb_entries(odb, reference,\n \t\t\t     '\\n', NULL, 0);\n }\n \n@@ -335,7 +337,7 @@ struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n@@ -379,12 +381,6 @@ void restore_primary_odb(struct odb_source *restore_alt, const char *old_path)\n \tfree_object_directory(cur_alt);\n }\n \n-/*\n- * Compute the exact path an alternate is at and returns it. In case of\n- * error NULL is returned and the human readable error is added to `err`\n- * `path` may be relative and should point to $GIT_DIR.\n- * `err` must not be null.\n- */\n char *compute_alternate_path(const char *path, struct strbuf *err)\n {\n \tchar *ref_git = NULL;\n@@ -455,7 +451,7 @@ struct odb_source *odb_find_source(struct object_database *odb, const char *obj_\n \tchar *obj_dir_real = real_pathdup(obj_dir, 1);\n \tstruct strbuf odb_path_real = STRBUF_INIT;\n \n-\tprepare_alt_odb(odb->repo);\n+\todb_prepare_alternates(odb);\n \tfor (source = odb->sources; source; source = source->next) {\n \t\tstrbuf_realpath(&odb_path_real, source->path, 1);\n \t\tif (!strcmp(obj_dir_real, odb_path_real.buf))\n@@ -573,7 +569,7 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \tstruct odb_source *alternate;\n \tint r = 0;\n \n-\tprepare_alt_odb(the_repository);\n+\todb_prepare_alternates(the_repository->objects);\n \tfor (alternate = the_repository->objects->sources->next; alternate; alternate = alternate->next) {\n \t\tr = fn(alternate, cb);\n \t\tif (r)\n@@ -582,21 +578,21 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)\n \treturn r;\n }\n \n-void prepare_alt_odb(struct repository *r)\n+void odb_prepare_alternates(struct object_database *odb)\n {\n-\tif (r->objects->loaded_alternates)\n+\tif (odb->loaded_alternates)\n \t\treturn;\n \n-\tlink_alt_odb_entries(r->objects, r->objects->alternate_db, PATH_SEP, NULL, 0);\n+\tlink_alt_odb_entries(odb, odb->alternate_db, PATH_SEP, NULL, 0);\n \n-\tread_info_alternates(r->objects, r->objects->sources->path, 0);\n-\tr->objects->loaded_alternates = 1;\n+\tread_info_alternates(odb, odb->sources->path, 0);\n+\todb->loaded_alternates = 1;\n }\n \n-int has_alt_odb(struct repository *r)\n+int odb_has_alternates(struct object_database *odb)\n {\n-\tprepare_alt_odb(r);\n-\treturn !!r->objects->sources->next;\n+\todb_prepare_alternates(odb);\n+\treturn !!odb->sources->next;\n }\n \n int obj_read_use_lock = 0;\ndiff --git a/odb.h b/odb.h\nindex 5de952608f3..eba16929a81 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -13,6 +13,14 @@ struct oidtree;\n struct strbuf;\n struct repository;\n \n+/*\n+ * Compute the exact path an alternate is at and returns it. In case of\n+ * error NULL is returned and the human readable error is added to `err`\n+ * `path` may be relative and should point to $GIT_DIR.\n+ * `err` must not be null.\n+ */\n+char *compute_alternate_path(const char *path, struct strbuf *err);\n+\n /*\n  * The source is the part of the object database that stores the actual\n  * objects. It thus encapsulates the logic to read and write the specific\n@@ -65,27 +73,11 @@ struct odb_source {\n \tchar *path;\n };\n \n-void prepare_alt_odb(struct repository *r);\n-int has_alt_odb(struct repository *r);\n-char *compute_alternate_path(const char *path, struct strbuf *err);\n typedef int alt_odb_fn(struct odb_source *, void *);\n int foreach_alt_odb(alt_odb_fn, void*);\n typedef void alternate_ref_fn(const struct object_id *oid, void *);\n void for_each_alternate_ref(alternate_ref_fn, void *);\n \n-/*\n- * Add the directory to the on-disk alternates file; the new entry will also\n- * take effect in the current process.\n- */\n-void add_to_alternates_file(const char *dir);\n-\n-/*\n- * Add the directory to the in-memory list of alternates (along with any\n- * recursive alternates it points to), but do not modify the on-disk alternates\n- * file.\n- */\n-void add_to_alternates_memory(const char *dir);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -124,7 +116,7 @@ struct object_database {\n \t/*\n \t * A list of alternate object directories loaded from the environment;\n \t * this should not generally need to be accessed directly, but will\n-\t * populate the \"sources\" list when prepare_alt_odb() is run.\n+\t * populate the \"sources\" list when odb_prepare_alternates() is run.\n \t */\n \tchar *alternate_db;\n \n@@ -209,6 +201,33 @@ struct odb_source *odb_find_source(struct object_database *odb, const char *obj_\n int odb_mkstemp(struct object_database *odb,\n \t\tstruct strbuf *temp_filename, const char *pattern);\n \n+/*\n+ * Prepare alternate object sources for the given database by reading\n+ * \"objects/info/alternates\" and opening the respective sources.\n+ */\n+void odb_prepare_alternates(struct object_database *odb);\n+\n+/*\n+ * Check whether the object database has any alternates. The primary object\n+ * source does not count as alternate.\n+ */\n+int odb_has_alternates(struct object_database *odb);\n+\n+/*\n+ * Add the directory to the on-disk alternates file; the new entry will also\n+ * take effect in the current process.\n+ */\n+void odb_add_to_alternates_file(struct object_database *odb,\n+\t\t\t\tconst char *dir);\n+\n+/*\n+ * Add the directory to the in-memory list of alternate sources (along with any\n+ * recursive alternates it points to), but do not modify the on-disk alternates\n+ * file.\n+ */\n+void odb_add_to_alternates_memory(struct object_database *odb,\n+\t\t\t\t  const char *dir);\n+\n void *repo_read_object_file(struct repository *r,\n \t\t\t    const struct object_id *oid,\n \t\t\t    enum object_type *type,\ndiff --git a/packfile.c b/packfile.c\nindex 346c2f9ce90..ac0e29e99b9 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1034,7 +1034,7 @@ static void prepare_packed_git(struct repository *r)\n \tif (r->objects->packed_git_initialized)\n \t\treturn;\n \n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \tfor (source = r->objects->sources; source; source = source->next) {\n \t\tint local = (source == r->objects->sources);\n \t\tprepare_multi_pack_index_one(r, source->path, local);\n@@ -1059,7 +1059,7 @@ void reprepare_packed_git(struct repository *r)\n \t * the lifetime of the process.\n \t */\n \tr->objects->loaded_alternates = 0;\n-\tprepare_alt_odb(r);\n+\todb_prepare_alternates(r->objects);\n \n \tfor (source = r->objects->sources; source; source = source->next)\n \t\todb_clear_loose_cache(source);\ndiff --git a/submodule.c b/submodule.c\nindex 9b1018877df..386be234230 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -189,7 +189,8 @@ int register_all_submodule_odb_as_alternates(void)\n \tint ret = added_submodule_odb_paths.nr;\n \n \tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\tadd_to_alternates_memory(added_submodule_odb_paths.items[i].string);\n+\t\todb_add_to_alternates_memory(the_repository->objects,\n+\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n \tif (ret) {\n \t\tstring_list_clear(&added_submodule_odb_paths, 0);\n \t\ttrace2_data_intmax(\"submodule\", the_repository,\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 2920ca59d72..8d9a271845c 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -79,7 +79,7 @@ static const char **get_store(const char **argv, struct ref_store **refs)\n \t\tif (!repo_submodule_path_append(the_repository,\n \t\t\t\t\t\t&sb, gitdir, \"objects/\"))\n \t\t\tdie(\"computing submodule path failed\");\n-\t\tadd_to_alternates_memory(sb.buf);\n+\t\todb_add_to_alternates_memory(the_repository->objects, sb.buf);\n \t\tstrbuf_release(&sb);\n \n \t\t*refs = repo_get_submodule_ref_store(the_repository, gitdir);\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex bef2f917cd2..4120badf5ce 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -304,7 +304,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)\n \n void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\n {\n-\tadd_to_alternates_memory(t->path.buf);\n+\todb_add_to_alternates_memory(t->repo->objects, t->path.buf);\n }\n \n void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521033","messageId":"20250701-pks-object-store-wo-the-repository-v6-9-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:21Z","receivedAt":"2025-07-01T12:22:52Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"There are a couple of iterator-style functions that execute a callback\nfor each instance of a given set, all of which currently depend on\n`the_repository`. Refactor them to instead take an object database as\nparameter so that we can get rid of this dependency.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/count-objects.c     |  2 +-\n builtin/receive-pack.c      |  3 ++-\n builtin/submodule--helper.c |  3 ++-\n diagnose.c                  |  2 +-\n fetch-pack.c                |  3 ++-\n odb.c                       | 36 +++++++++++++++++++-----------------\n odb.h                       | 23 ++++++++++++++++++-----\n revision.c                  |  3 ++-\n 8 files changed, 47 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex 58e0af433d1..f687647931e 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -159,7 +159,7 @@ int cmd_count_objects(int argc,\n \t\tprintf(\"prune-packable: %lu\\n\", packed_loose);\n \t\tprintf(\"garbage: %lu\\n\", garbage);\n \t\tprintf(\"size-garbage: %s\\n\", garbage_buf.buf);\n-\t\tforeach_alt_odb(print_alternate, NULL);\n+\t\todb_for_each_alternate(the_repository->objects, print_alternate, NULL);\n \t\tstrbuf_release(&loose_buf);\n \t\tstrbuf_release(&pack_buf);\n \t\tstrbuf_release(&garbage_buf);\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 0f5958c4a66..7ea273d93e4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -359,7 +359,8 @@ static void write_head_info(void)\n \n \trefs_for_each_fullref_in(get_main_ref_store(the_repository), \"\",\n \t\t\t\t exclude_patterns, show_ref_cb, &seen);\n-\tfor_each_alternate_ref(show_one_alternate_ref, &seen);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   show_one_alternate_ref, &seen);\n \n \toidset_clear(&seen);\n \tstrvec_clear(&excludes_vector);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 84f7fa53424..7ca483cab52 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1668,7 +1668,8 @@ static void prepare_possible_alternates(const char *sm_name,\n \t\tdie(_(\"Value '%s' for submodule.alternateErrorStrategy is not recognized\"), error_strategy);\n \n \tif (!strcmp(sm_alternate, \"superproject\"))\n-\t\tforeach_alt_odb(add_possible_reference_from_superproject, &sas);\n+\t\todb_for_each_alternate(the_repository->objects,\n+\t\t\t\t       add_possible_reference_from_superproject, &sas);\n \telse if (!strcmp(sm_alternate, \"no\"))\n \t\t; /* do nothing */\n \telse\ndiff --git a/diagnose.c b/diagnose.c\nindex ad0d5c12465..5092bf80d35 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -229,7 +229,7 @@ int create_diagnostics_archive(struct repository *r,\n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n \tdir_file_stats(r->objects->sources, &buf);\n-\tforeach_alt_odb(dir_file_stats, &buf);\n+\todb_for_each_alternate(r->objects, dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \n \tstrbuf_reset(&buf);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex cf157f5d7e5..47fa7fa4c49 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -115,7 +115,8 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,\n \tsize_t i;\n \n \tif (!initialized) {\n-\t\tfor_each_alternate_ref(cache_one_alternate, &cache);\n+\t\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t\t   cache_one_alternate, &cache);\n \t\tinitialized = 1;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex 691a8c7c681..03fb68605c1 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -494,8 +494,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n }\n \n static void read_alternate_refs(const char *path,\n-\t\t\t\talternate_ref_fn *cb,\n-\t\t\t\tvoid *data)\n+\t\t\t\todb_for_each_alternate_ref_fn *cb,\n+\t\t\t\tvoid *payload)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tstruct strbuf line = STRBUF_INIT;\n@@ -517,7 +517,7 @@ static void read_alternate_refs(const char *path,\n \t\t\tbreak;\n \t\t}\n \n-\t\tcb(&oid, data);\n+\t\tcb(&oid, payload);\n \t}\n \n \tfclose(fh);\n@@ -526,16 +526,16 @@ static void read_alternate_refs(const char *path,\n }\n \n struct alternate_refs_data {\n-\talternate_ref_fn *fn;\n-\tvoid *data;\n+\todb_for_each_alternate_ref_fn *fn;\n+\tvoid *payload;\n };\n \n static int refs_from_alternate_cb(struct odb_source *alternate,\n-\t\t\t\t  void *data)\n+\t\t\t\t  void *payload)\n {\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t base_len;\n-\tstruct alternate_refs_data *cb = data;\n+\tstruct alternate_refs_data *cb = payload;\n \n \tif (!strbuf_realpath(&path, alternate->path, 0))\n \t\tgoto out;\n@@ -549,29 +549,31 @@ static int refs_from_alternate_cb(struct odb_source *alternate,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->data);\n+\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n \treturn 0;\n }\n \n-void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload)\n {\n-\tstruct alternate_refs_data cb;\n-\tcb.fn = fn;\n-\tcb.data = data;\n-\tforeach_alt_odb(refs_from_alternate_cb, &cb);\n+\tstruct alternate_refs_data data;\n+\tdata.fn = cb;\n+\tdata.payload = payload;\n+\todb_for_each_alternate(odb, refs_from_alternate_cb, &data);\n }\n \n-int foreach_alt_odb(alt_odb_fn fn, void *cb)\n+int odb_for_each_alternate(struct object_database *odb,\n+\t\t\t odb_for_each_alternate_fn cb, void *payload)\n {\n \tstruct odb_source *alternate;\n \tint r = 0;\n \n-\todb_prepare_alternates(the_repository->objects);\n-\tfor (alternate = the_repository->objects->sources->next; alternate; alternate = alternate->next) {\n-\t\tr = fn(alternate, cb);\n+\todb_prepare_alternates(odb);\n+\tfor (alternate = odb->sources->next; alternate; alternate = alternate->next) {\n+\t\tr = cb(alternate, payload);\n \t\tif (r)\n \t\t\tbreak;\n \t}\ndiff --git a/odb.h b/odb.h\nindex eba16929a81..7e65e9707c1 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -73,11 +73,6 @@ struct odb_source {\n \tchar *path;\n };\n \n-typedef int alt_odb_fn(struct odb_source *, void *);\n-int foreach_alt_odb(alt_odb_fn, void*);\n-typedef void alternate_ref_fn(const struct object_id *oid, void *);\n-void for_each_alternate_ref(alternate_ref_fn, void *);\n-\n /*\n  * Replace the current writable object directory with the specified temporary\n  * object directory; returns the former primary object directory.\n@@ -192,6 +187,24 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Iterate through all alternates of the database and execute the provided\n+ * callback function for each of them. Stop iterating once the callback\n+ * function returns a non-zero value, in which case the value is bubbled up\n+ * from the callback.\n+ */\n+typedef int odb_for_each_alternate_fn(struct odb_source *, void *);\n+int odb_for_each_alternate(struct object_database *odb,\n+\t\t\t   odb_for_each_alternate_fn cb, void *payload);\n+\n+/*\n+ * Iterate through all alternates of the database and yield their respective\n+ * references.\n+ */\n+typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);\n+void odb_for_each_alternate_ref(struct object_database *odb,\n+\t\t\t\todb_for_each_alternate_ref_fn cb, void *payload);\n+\n /*\n  * Create a temporary file rooted in the primary alternate's directory, or die\n  * on failure. The filename is taken from \"pattern\", which should have the\ndiff --git a/revision.c b/revision.c\nindex cdefe7d6e48..b0364f556ee 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1907,7 +1907,8 @@ static void add_alternate_refs_to_pending(struct rev_info *revs,\n \tstruct add_alternate_refs_data data;\n \tdata.revs = revs;\n \tdata.flags = flags;\n-\tfor_each_alternate_ref(add_one_alternate_ref, &data);\n+\todb_for_each_alternate_ref(the_repository->objects,\n+\t\t\t\t   add_one_alternate_ref, &data);\n }\n \n static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521034","messageId":"20250701-pks-object-store-wo-the-repository-v6-10-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 10/17] odb: get rid of `the_repository` when handling the primary source","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:22Z","receivedAt":"2025-07-01T12:22:55Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The functions `set_temporary_primary_odb()` and `restore_primary_odb()`\nare responsible for managing a temporary primary source for the\ndatabase. Both of these functions implicitly rely on `the_repository`.\n\nRefactor them to instead take an explicit object database parameter as\nargument and adjust callers. Rename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c        | 27 +++++++++++++++------------\n odb.h        | 26 +++++++++++++++-----------\n tmp-objdir.c | 10 ++++++----\n 3 files changed, 36 insertions(+), 27 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex 03fb68605c1..4f03be7f770 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -329,7 +329,8 @@ void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t     '\\n', NULL, 0);\n }\n \n-struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n+struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,\n+\t\t\t\t\t\t    const char *dir, int will_destroy)\n {\n \tstruct odb_source *source;\n \n@@ -337,14 +338,14 @@ struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t * Make sure alternates are initialized, or else our entry may be\n \t * overwritten when they are.\n \t */\n-\todb_prepare_alternates(the_repository->objects);\n+\todb_prepare_alternates(odb);\n \n \t/*\n \t * Make a new primary odb and link the old primary ODB in as an\n \t * alternate\n \t */\n \tsource = xcalloc(1, sizeof(*source));\n-\tsource->odb = the_repository->objects;\n+\tsource->odb = odb;\n \tsource->path = xstrdup(dir);\n \n \t/*\n@@ -353,8 +354,8 @@ struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n \t */\n \tsource->disable_ref_updates = 1;\n \tsource->will_destroy = will_destroy;\n-\tsource->next = the_repository->objects->sources;\n-\tthe_repository->objects->sources = source;\n+\tsource->next = odb->sources;\n+\todb->sources = source;\n \treturn source->next;\n }\n \n@@ -366,19 +367,21 @@ static void free_object_directory(struct odb_source *source)\n \tfree(source);\n }\n \n-void restore_primary_odb(struct odb_source *restore_alt, const char *old_path)\n+void odb_restore_primary_source(struct object_database *odb,\n+\t\t\t\tstruct odb_source *restore_source,\n+\t\t\t\tconst char *old_path)\n {\n-\tstruct odb_source *cur_alt = the_repository->objects->sources;\n+\tstruct odb_source *cur_source = odb->sources;\n \n-\tif (strcmp(old_path, cur_alt->path))\n+\tif (strcmp(old_path, cur_source->path))\n \t\tBUG(\"expected %s as primary object store; found %s\",\n-\t\t    old_path, cur_alt->path);\n+\t\t    old_path, cur_source->path);\n \n-\tif (cur_alt->next != restore_alt)\n+\tif (cur_source->next != restore_source)\n \t\tBUG(\"we expect the old primary object store to be the first alternate\");\n \n-\tthe_repository->objects->sources = restore_alt;\n-\tfree_object_directory(cur_alt);\n+\todb->sources = restore_source;\n+\tfree_object_directory(cur_source);\n }\n \n char *compute_alternate_path(const char *path, struct strbuf *err)\ndiff --git a/odb.h b/odb.h\nindex 7e65e9707c1..4e2d1004f8a 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -73,17 +73,6 @@ struct odb_source {\n \tchar *path;\n };\n \n-/*\n- * Replace the current writable object directory with the specified temporary\n- * object directory; returns the former primary object directory.\n- */\n-struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy);\n-\n-/*\n- * Restore a previous ODB replaced by set_temporary_main_odb.\n- */\n-void restore_primary_odb(struct odb_source *restore_alternate, const char *old_path);\n-\n struct packed_git;\n struct multi_pack_index;\n struct cached_object_entry;\n@@ -187,6 +176,21 @@ void odb_clear(struct object_database *o);\n  */\n struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);\n \n+/*\n+ * Replace the current writable object directory with the specified temporary\n+ * object directory; returns the former primary source.\n+ */\n+struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,\n+\t\t\t\t\t\t    const char *dir, int will_destroy);\n+\n+/*\n+ * Restore the primary source that was previously replaced by\n+ * `odb_set_temporary_primary_source()`.\n+ */\n+void odb_restore_primary_source(struct object_database *odb,\n+\t\t\t\tstruct odb_source *restore_source,\n+\t\t\t\tconst char *old_path);\n+\n /*\n  * Iterate through all alternates of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex 4120badf5ce..ae01eae9c41 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -47,7 +47,7 @@ int tmp_objdir_destroy(struct tmp_objdir *t)\n \t\tthe_tmp_objdir = NULL;\n \n \tif (t->prev_source)\n-\t\trestore_primary_odb(t->prev_source, t->path.buf);\n+\t\todb_restore_primary_source(t->repo->objects, t->prev_source, t->path.buf);\n \n \terr = remove_dir_recursively(&t->path, 0);\n \n@@ -279,7 +279,7 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \tif (t->prev_source) {\n \t\tif (t->repo->objects->sources->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n-\t\trestore_primary_odb(t->prev_source, t->path.buf);\n+\t\todb_restore_primary_source(t->repo->objects, t->prev_source, t->path.buf);\n \t\tt->prev_source = NULL;\n \t}\n \n@@ -311,7 +311,8 @@ void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy)\n {\n \tif (t->prev_source)\n \t\tBUG(\"the primary object database is already replaced\");\n-\tt->prev_source = set_temporary_primary_odb(t->path.buf, will_destroy);\n+\tt->prev_source = odb_set_temporary_primary_source(t->repo->objects,\n+\t\t\t\t\t\t\t  t->path.buf, will_destroy);\n \tt->will_destroy = will_destroy;\n }\n \n@@ -320,7 +321,8 @@ struct tmp_objdir *tmp_objdir_unapply_primary_odb(void)\n \tif (!the_tmp_objdir || !the_tmp_objdir->prev_source)\n \t\treturn NULL;\n \n-\trestore_primary_odb(the_tmp_objdir->prev_source, the_tmp_objdir->path.buf);\n+\todb_restore_primary_source(the_tmp_objdir->repo->objects,\n+\t\t\t\t   the_tmp_objdir->prev_source, the_tmp_objdir->path.buf);\n \tthe_tmp_objdir->prev_source = NULL;\n \treturn the_tmp_objdir;\n }\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521035","messageId":"20250701-pks-object-store-wo-the-repository-v6-11-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 11/17] odb: get rid of `the_repository` when handling submodule sources","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:23Z","receivedAt":"2025-07-01T12:22:58Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"--recursive\" flag for git-grep(1) allows users to grep for a string\nacross submodule boundaries. To make this work we add each submodule's\nobject sources to our own object database so that the objects can be\naccessed directly.\n\nThe infrastructure for this depends on a global string list of submodule\npaths. The caller is expected to call `add_submodule_odb_by_path()` for\neach source and the object database will then eventually register all\nsubmodule sources via `do_oid_object_info_extended()` in case it isn't\nable to look up a specific object.\n\nThis reliance on global state is of course suboptimal with regards to\nour libification efforts.\n\nRefactor the logic so that the list of submodule sources is instead\ntracked in the object database itself. This allows us to lose the\ncondition of `r == the_repository` before registering submodule sources\nas we only ever add submodule sources to `the_repository` anyway. As\nsuch, behaviour before and after this refactoring should always be the\nsame.\n\nRename the functions accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/grep.c     |  3 ++-\n odb.c              | 37 +++++++++++++++++++++++++++++++------\n odb.h              | 15 +++++++++++++++\n submodule-config.c |  3 ++-\n submodule.c        | 26 --------------------------\n submodule.h        |  9 ---------\n 6 files changed, 50 insertions(+), 43 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 336cfcab6fb..cfcf916bce1 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -505,7 +505,8 @@ static int grep_submodule(struct grep_opt *opt,\n \t * lazily registered as alternates when needed (and except in an\n \t * unexpected code interaction, it won't be needed).\n \t */\n-\tadd_submodule_odb_by_path(subrepo->objects->sources->path);\n+\todb_add_submodule_source_by_path(the_repository->objects,\n+\t\t\t\t\t subrepo->objects->sources->path);\n \tobj_read_unlock();\n \n \tmemcpy(&subopt, opt, sizeof(subopt));\ndiff --git a/odb.c b/odb.c\nindex 4f03be7f770..f0b27bd936b 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -24,6 +24,7 @@\n #include \"strbuf.h\"\n #include \"strvec.h\"\n #include \"submodule.h\"\n+#include \"trace2.h\"\n #include \"write-or-die.h\"\n \n KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n@@ -469,6 +470,12 @@ struct odb_source *odb_find_source(struct object_database *odb, const char *obj_\n \treturn source;\n }\n \n+void odb_add_submodule_source_by_path(struct object_database *odb,\n+\t\t\t\t      const char *path)\n+{\n+\tstring_list_insert(&odb->submodule_source_paths, path);\n+}\n+\n static void fill_alternate_refs_command(struct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n@@ -623,6 +630,23 @@ void disable_obj_read_lock(void)\n \n int fetch_if_missing = 1;\n \n+static int register_all_submodule_sources(struct object_database *odb)\n+{\n+\tint ret = odb->submodule_source_paths.nr;\n+\n+\tfor (size_t i = 0; i < odb->submodule_source_paths.nr; i++)\n+\t\todb_add_to_alternates_memory(odb,\n+\t\t\t\t\t     odb->submodule_source_paths.items[i].string);\n+\tif (ret) {\n+\t\tstring_list_clear(&odb->submodule_source_paths, 0);\n+\t\ttrace2_data_intmax(\"submodule\", odb->repo,\n+\t\t\t\t   \"register_all_submodule_sources/registered\", ret);\n+\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n+\t\t\tBUG(\"register_all_submodule_sources() called\");\n+\t}\n+\treturn ret;\n+}\n+\n static int do_oid_object_info_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n@@ -676,13 +700,12 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t}\n \n \t\t/*\n-\t\t * If r is the_repository, this might be an attempt at\n-\t\t * accessing a submodule object as if it were in the_repository\n-\t\t * (having called add_submodule_odb() on that submodule's ODB).\n-\t\t * If any such ODBs exist, register them and try again.\n+\t\t * This might be an attempt at accessing a submodule object as\n+\t\t * if it were in main object store (having called\n+\t\t * `odb_add_submodule_source_by_path()` on that submodule's\n+\t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (r == the_repository &&\n-\t\t    register_all_submodule_odb_as_alternates())\n+\t\tif (register_all_submodule_sources(r->objects))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n@@ -968,6 +991,7 @@ struct object_database *odb_new(struct repository *repo)\n \tINIT_LIST_HEAD(&o->packed_git_mru);\n \thashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n+\tstring_list_init_dup(&o->submodule_source_paths);\n \treturn o;\n }\n \n@@ -1017,4 +1041,5 @@ void odb_clear(struct object_database *o)\n \to->packed_git = NULL;\n \n \thashmap_clear(&o->pack_map);\n+\tstring_list_clear(&o->submodule_source_paths, 0);\n }\ndiff --git a/odb.h b/odb.h\nindex 4e2d1004f8a..0ea9d4faa70 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -6,6 +6,7 @@\n #include \"list.h\"\n #include \"oidset.h\"\n #include \"oidmap.h\"\n+#include \"string-list.h\"\n #include \"thread-utils.h\"\n \n struct oidmap;\n@@ -165,6 +166,12 @@ struct object_database {\n \t * packs.\n \t */\n \tunsigned packed_git_initialized : 1;\n+\n+\t/*\n+\t * Submodule source paths that will be added as additional sources to\n+\t * allow lookup of submodule objects via the main object database.\n+\t */\n+\tstruct string_list submodule_source_paths;\n };\n \n struct object_database *odb_new(struct repository *repo);\n@@ -191,6 +198,14 @@ void odb_restore_primary_source(struct object_database *odb,\n \t\t\t\tstruct odb_source *restore_source,\n \t\t\t\tconst char *old_path);\n \n+/*\n+ * Call odb_add_submodule_source_by_path() to add the submodule at the given\n+ * path to a list. The object stores of all submodules in that list will be\n+ * added as additional sources in the object store when looking up objects.\n+ */\n+void odb_add_submodule_source_by_path(struct object_database *odb,\n+\t\t\t\t      const char *path);\n+\n /*\n  * Iterate through all alternates of the database and execute the provided\n  * callback function for each of them. Stop iterating once the callback\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 9c80f9f7b66..a9f72107888 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -810,7 +810,8 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void\n \t\t\t   repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {\n \t\t\tconfig_source.blob = oidstr = xstrdup(oid_to_hex(&oid));\n \t\t\tif (repo != the_repository)\n-\t\t\t\tadd_submodule_odb_by_path(repo->objects->sources->path);\n+\t\t\t\todb_add_submodule_source_by_path(the_repository->objects,\n+\t\t\t\t\t\t\t\t repo->objects->sources->path);\n \t\t} else {\n \t\t\tgoto out;\n \t\t}\ndiff --git a/submodule.c b/submodule.c\nindex 386be234230..788c9e55ed3 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -31,7 +31,6 @@\n #include \"commit-reach.h\"\n #include \"read-cache-ll.h\"\n #include \"setup.h\"\n-#include \"trace2.h\"\n \n static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;\n static int initialized_fetch_ref_tips;\n@@ -176,31 +175,6 @@ void stage_updated_gitmodules(struct index_state *istate)\n \t\tdie(_(\"staging updated .gitmodules failed\"));\n }\n \n-static struct string_list added_submodule_odb_paths = STRING_LIST_INIT_DUP;\n-\n-void add_submodule_odb_by_path(const char *path)\n-{\n-\tstring_list_insert(&added_submodule_odb_paths, path);\n-}\n-\n-int register_all_submodule_odb_as_alternates(void)\n-{\n-\tint i;\n-\tint ret = added_submodule_odb_paths.nr;\n-\n-\tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n-\t\todb_add_to_alternates_memory(the_repository->objects,\n-\t\t\t\t\t     added_submodule_odb_paths.items[i].string);\n-\tif (ret) {\n-\t\tstring_list_clear(&added_submodule_odb_paths, 0);\n-\t\ttrace2_data_intmax(\"submodule\", the_repository,\n-\t\t\t\t   \"register_all_submodule_odb_as_alternates/registered\", ret);\n-\t\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\n-\t\t\tBUG(\"register_all_submodule_odb_as_alternates() called\");\n-\t}\n-\treturn ret;\n-}\n-\n void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\t\t\t\t     const char *path)\n {\ndiff --git a/submodule.h b/submodule.h\nindex db980c1d083..b10e16e6c06 100644\n--- a/submodule.h\n+++ b/submodule.h\n@@ -104,15 +104,6 @@ int submodule_uses_gitfile(const char *path);\n #define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)\n int bad_to_remove_submodule(const char *path, unsigned flags);\n \n-/*\n- * Call add_submodule_odb_by_path() to add the submodule at the given\n- * path to a list. When register_all_submodule_odb_as_alternates() is\n- * called, the object stores of all submodules in that list will be\n- * added as alternates in the_repository.\n- */\n-void add_submodule_odb_by_path(const char *path);\n-int register_all_submodule_odb_as_alternates(void);\n-\n /*\n  * Checks if there are submodule changes in a..b. If a is the null OID,\n  * checks b and all its ancestors instead.\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521036","messageId":"20250701-pks-object-store-wo-the-repository-v6-12-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:24Z","receivedAt":"2025-07-01T12:23:02Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"All of the external functions provided by the object database subsystem\ndon't depend on `the_repository` anymore, but some internal functions\nstill do. Refactor those cases by plumbing through the repository that\nowns the object database.\n\nThis change allows us to get rid of the `USE_THE_REPOSITORY_VARIABLE`\npreprocessor define.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex f0b27bd936b..5a88701550e 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"commit-graph.h\"\n@@ -476,12 +474,13 @@ void odb_add_submodule_source_by_path(struct object_database *odb,\n \tstring_list_insert(&odb->submodule_source_paths, path);\n }\n \n-static void fill_alternate_refs_command(struct child_process *cmd,\n+static void fill_alternate_refs_command(struct repository *repo,\n+\t\t\t\t\tstruct child_process *cmd,\n \t\t\t\t\tconst char *repo_path)\n {\n \tconst char *value;\n \n-\tif (!git_config_get_value(\"core.alternateRefsCommand\", &value)) {\n+\tif (!repo_config_get_value(repo, \"core.alternateRefsCommand\", &value)) {\n \t\tcmd->use_shell = 1;\n \n \t\tstrvec_push(&cmd->args, value);\n@@ -493,7 +492,7 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \t\tstrvec_push(&cmd->args, \"for-each-ref\");\n \t\tstrvec_push(&cmd->args, \"--format=%(objectname)\");\n \n-\t\tif (!git_config_get_value(\"core.alternateRefsPrefixes\", &value)) {\n+\t\tif (!repo_config_get_value(repo, \"core.alternateRefsPrefixes\", &value)) {\n \t\t\tstrvec_push(&cmd->args, \"--\");\n \t\t\tstrvec_split(&cmd->args, value);\n \t\t}\n@@ -503,7 +502,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n \tcmd->out = -1;\n }\n \n-static void read_alternate_refs(const char *path,\n+static void read_alternate_refs(struct repository *repo,\n+\t\t\t\tconst char *path,\n \t\t\t\todb_for_each_alternate_ref_fn *cb,\n \t\t\t\tvoid *payload)\n {\n@@ -511,7 +511,7 @@ static void read_alternate_refs(const char *path,\n \tstruct strbuf line = STRBUF_INIT;\n \tFILE *fh;\n \n-\tfill_alternate_refs_command(&cmd, path);\n+\tfill_alternate_refs_command(repo, &cmd, path);\n \n \tif (start_command(&cmd))\n \t\treturn;\n@@ -521,7 +521,7 @@ static void read_alternate_refs(const char *path,\n \t\tstruct object_id oid;\n \t\tconst char *p;\n \n-\t\tif (parse_oid_hex(line.buf, &oid, &p) || *p) {\n+\t\tif (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) {\n \t\t\twarning(_(\"invalid line while parsing alternate refs: %s\"),\n \t\t\t\tline.buf);\n \t\t\tbreak;\n@@ -559,7 +559,7 @@ static int refs_from_alternate_cb(struct odb_source *alternate,\n \t\tgoto out;\n \tstrbuf_setlen(&path, base_len);\n \n-\tread_alternate_refs(path.buf, cb->fn, cb->payload);\n+\tread_alternate_refs(alternate->odb->repo, path.buf, cb->fn, cb->payload);\n \n out:\n \tstrbuf_release(&path);\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, the_repository->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n \t\tif (oi->contentp)\n \t\t\t*oi->contentp = xmemdupz(co->buf, co->size);\n \t\toi->whence = OI_CACHED;\n@@ -763,10 +763,10 @@ static int oid_object_info_convert(struct repository *r,\n \tvoid *content;\n \tint ret;\n \n-\tif (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) {\n+\tif (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) {\n \t\tif (do_die)\n \t\t\tdie(_(\"missing mapping of %s to %s\"),\n-\t\t\t    oid_to_hex(input_oid), the_hash_algo->name);\n+\t\t\t    oid_to_hex(input_oid), r->hash_algo->name);\n \t\treturn -1;\n \t}\n \n@@ -797,8 +797,8 @@ static int oid_object_info_convert(struct repository *r,\n \t\tstruct strbuf outbuf = STRBUF_INIT;\n \n \t\tif (type != OBJ_BLOB) {\n-\t\t\tret = convert_object_file(the_repository, &outbuf,\n-\t\t\t\t\t\t  the_hash_algo, input_algo,\n+\t\t\tret = convert_object_file(r, &outbuf,\n+\t\t\t\t\t\t  r->hash_algo, input_algo,\n \t\t\t\t\t\t  content, size, type, !do_die);\n \t\t\tfree(content);\n \t\t\tif (ret == -1)\n@@ -944,9 +944,9 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + the_hash_algo->hexsz > isize ||\n+\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex((char *) buffer + ref_length, &actual_oid)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521037","messageId":"20250701-pks-object-store-wo-the-repository-v6-13-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 13/17] odb: rename `oid_object_info()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:25Z","receivedAt":"2025-07-01T12:23:06Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `oid_object_info()` to `odb_read_object_info()` as well as their\n`_extended()` variant to match other functions related to the object\ndatabase and our modern coding guidelines.\n\nIntroduce compatibility wrappers so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n archive.c                     |  2 +-\n blame.c                       |  4 +--\n builtin/blame.c               |  4 +--\n builtin/cat-file.c            | 26 ++++++++++---------\n builtin/describe.c            |  3 ++-\n builtin/fast-export.c         |  2 +-\n builtin/fast-import.c         | 17 ++++++------\n builtin/fsck.c                |  7 ++---\n builtin/gc.c                  |  2 +-\n builtin/grep.c                |  2 +-\n builtin/index-pack.c          | 13 +++++-----\n builtin/ls-files.c            |  2 +-\n builtin/ls-tree.c             |  4 +--\n builtin/mktree.c              |  8 +++---\n builtin/pack-objects.c        | 30 ++++++++++++----------\n builtin/prune.c               |  4 +--\n builtin/repack.c              |  2 +-\n builtin/replace.c             | 10 ++++----\n builtin/rev-list.c            |  6 +++--\n builtin/tag.c                 |  4 +--\n builtin/unpack-objects.c      |  2 +-\n commit-graph.c                |  2 +-\n commit.c                      |  3 ++-\n diff.c                        | 18 ++++++-------\n fetch-pack.c                  |  4 +--\n list-objects-filter.c         |  2 +-\n log-tree.c                    |  2 +-\n merge-ort.c                   |  4 +--\n object-file.c                 |  2 +-\n object-file.h                 |  2 +-\n object-name.c                 | 16 ++++++------\n object.c                      |  6 ++---\n odb.c                         | 60 ++++++++++++++++++++++---------------------\n odb.h                         | 46 +++++++++++++++++++++++++++------\n pack-bitmap-write.c           |  4 +--\n pack-bitmap.c                 |  8 +++---\n packfile.c                    |  5 ++--\n promisor-remote.c             |  4 +--\n protocol-caps.c               |  2 +-\n reachable.c                   |  2 +-\n read-cache.c                  |  6 ++---\n ref-filter.c                  |  4 +--\n remote.c                      |  5 ++--\n sequencer.c                   |  5 ++--\n streaming.c                   |  8 +++---\n submodule.c                   |  5 ++--\n t/helper/test-partial-clone.c |  2 +-\n tag.c                         |  2 +-\n 48 files changed, 213 insertions(+), 170 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 7fa2cc2596a..f2511d530d5 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,\n \n \t/* Stream it? */\n \tif (S_ISREG(mode) && !args->convert &&\n-\t    oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&\n+\t    odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&\n \t    size > repo_settings_get_big_file_threshold(the_repository))\n \t\treturn write_entry(args, oid, path.buf, path.len, mode, NULL, size);\n \ndiff --git a/blame.c b/blame.c\nindex 0ceea080a80..97db3355af4 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,\n \t\tunsigned short mode;\n \n \t\tif (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&\n-\t\t    oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)\n+\t\t    odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n \n@@ -1245,7 +1245,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,\n \t\treturn 0;\n \tif (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))\n \t\tgoto error_out;\n-\tif (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)\n+\tif (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\n \treturn 0;\n  error_out:\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 15eda60af90..91586e6852b 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -837,7 +837,7 @@ static int is_a_rev(const char *name)\n \n \tif (repo_get_oid(the_repository, name, &oid))\n \t\treturn 0;\n-\treturn OBJ_NONE < oid_object_info(the_repository, &oid, NULL);\n+\treturn OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);\n }\n \n static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n@@ -848,7 +848,7 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)\n \toidcpy(&oid, oid_ret);\n \twhile (1) {\n \t\tstruct object *obj;\n-\t\tint kind = oid_object_info(r, &oid, NULL);\n+\t\tint kind = odb_read_object_info(r->objects, &oid, NULL);\n \t\tif (kind == OBJ_COMMIT) {\n \t\t\toidcpy(oid_ret, &oid);\n \t\t\treturn 0;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex f3a925a8183..f7595fdb04e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -132,7 +132,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \tswitch (opt) {\n \tcase 't':\n \t\toi.typep = &type;\n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tprintf(\"%s\\n\", type_name(type));\n \t\tret = 0;\n@@ -146,7 +146,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\toi.contentp = (void**)&buf;\n \t\t}\n \n-\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n+\t\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \n \t\tif (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {\n@@ -180,7 +180,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t/* else fallthrough */\n \n \tcase 'p':\n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Not a valid object name %s\", obj_name);\n \n@@ -217,7 +217,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \n \t\tif (exp_type_id == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n-\t\t\tif (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n \t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n \t\t\t\t\t\t\t\t     &oid,\n \t\t\t\t\t\t\t\t     &type,\n@@ -235,7 +236,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\t} else\n \t\t\t\toidcpy(&blob_oid, &oid);\n \n-\t\t\tif (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {\n+\t\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &blob_oid, NULL) == OBJ_BLOB) {\n \t\t\t\tret = stream_blob(&blob_oid);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n@@ -294,7 +296,7 @@ struct expand_data {\n \n \t/*\n \t * After a mark_query run, this object_info is set up to be\n-\t * passed to oid_object_info_extended. It will point to the data\n+\t * passed to odb_read_object_info_extended. It will point to the data\n \t * elements above, so you can retrieve the response from there.\n \t */\n \tstruct object_info info;\n@@ -484,12 +486,12 @@ static void batch_object_write(const char *obj_name,\n \t\t\tdata->info.sizep = &data->size;\n \n \t\tif (pack)\n-\t\t\tret = packed_object_info(the_repository, pack, offset,\n-\t\t\t\t\t\t &data->info);\n+\t\t\tret = packed_object_info(the_repository, pack,\n+\t\t\t\t\t\t offset, &data->info);\n \t\telse\n-\t\t\tret = oid_object_info_extended(the_repository,\n-\t\t\t\t\t\t       &data->oid, &data->info,\n-\t\t\t\t\t\t       OBJECT_INFO_LOOKUP_REPLACE);\n+\t\t\tret = odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t    &data->oid, &data->info,\n+\t\t\t\t\t\t\t    OBJECT_INFO_LOOKUP_REPLACE);\n \t\tif (ret < 0) {\n \t\t\treport_object_status(opt, obj_name, &data->oid, \"missing\");\n \t\t\treturn;\n@@ -872,7 +874,7 @@ static int batch_objects(struct batch_options *opt)\n \n \t/*\n \t * Expand once with our special mark_query flag, which will prime the\n-\t * object_info to be handed to oid_object_info_extended for each\n+\t * object_info to be handed to odb_read_object_info_extended for each\n \t * object.\n \t */\n \tmemset(&data, 0, sizeof(data));\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 96cb68e5e5d..fbf305d7624 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\n-\telse if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)\n+\telse if (odb_read_object_info(the_repository->objects,\n+\t\t\t\t      &oid, NULL) == OBJ_BLOB)\n \t\tdescribe_blob(oid, &sb);\n \telse\n \t\tdie(_(\"%s is neither a commit nor blob\"), arg);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 0505f289a94..6c93cf0a8aa 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\n \n-\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 413304db9b5..2718376f2c9 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1756,8 +1756,8 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint\n \tstruct object_entry *e;\n \te = find_object(oid);\n \tif (!e) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\toid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\te = insert_object(oid);\n@@ -2416,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)\n \t\tenum object_type expected = S_ISDIR(mode) ?\n \t\t\t\t\t\tOBJ_TREE: OBJ_BLOB;\n \t\tenum object_type type = oe ? oe->type :\n-\t\t\t\t\toid_object_info(the_repository, &oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\t\t\t\todb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"%s not found: %s\",\n \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n@@ -2553,7 +2553,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttype_name(oe->type), command_buf.buf);\n \t} else if (!is_null_oid(&oid)) {\n-\t\tenum object_type type = oid_object_info(the_repository, &oid,\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects, &oid,\n \t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n@@ -2895,7 +2895,8 @@ static void parse_new_tag(const char *arg)\n \t} else if (!repo_get_oid(the_repository, from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n-\t\t\ttype = oid_object_info(the_repository, &oid, NULL);\n+\t\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t    &oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -3085,8 +3086,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tif (!oe) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 014aa1344e2..6e3465b0266 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,\n \tconst char *ret;\n \n \tif (type == OBJ_NONE)\n-\t\ttype = oid_object_info(the_repository, oid, NULL);\n+\t\ttype = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t    oid, NULL);\n \n \tret = type_name(type);\n \tif (!ret)\n@@ -232,8 +233,8 @@ static void mark_unreachable_referents(const struct object_id *oid)\n \t * (and we want to avoid parsing blobs).\n \t */\n \tif (obj->type == OBJ_NONE) {\n-\t\tenum object_type type = oid_object_info(the_repository,\n-\t\t\t\t\t\t\t&obj->oid, NULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     &obj->oid, NULL);\n \t\tif (type > 0)\n \t\t\tobject_as_type(obj, type, 0);\n \t}\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 50a09eb07e3..ff551fab439 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -1080,7 +1080,7 @@ static int dfs_on_ref(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tcommit = lookup_commit(the_repository, oid);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex cfcf916bce1..1435d462cd1 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobj_read_lock();\n-\t\tobject_type = oid_object_info(subrepo, oid, NULL);\n+\t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n \t\tdata = read_object_with_reference(subrepo,\n \t\t\t\t\t\t  oid, OBJ_TREE,\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 4d4d989eb1a..d0b16908122 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -260,7 +260,8 @@ static unsigned check_object(struct object *obj)\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t&obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n \t\t\t      oid_to_hex(&obj->oid));\n@@ -908,7 +909,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\tenum object_type has_type;\n \t\tunsigned long has_size;\n \t\tread_lock();\n-\t\thas_type = oid_object_info(the_repository, oid, &has_size);\n+\t\thas_type = odb_read_object_info(the_repository->objects, oid, &has_size);\n \t\tif (has_type < 0)\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n@@ -1501,9 +1502,9 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \t\tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \t\tfor (i = 0; i < nr_ref_deltas; i++) {\n \t\t\tstruct ref_delta_entry *d = sorted_by_pos[i];\n-\t\t\tif (!oid_object_info_extended(the_repository, &d->oid,\n-\t\t\t\t\t\t      NULL,\n-\t\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t\t   &d->oid, NULL,\n+\t\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\tcontinue;\n \t\t\toid_array_append(&to_fetch, &d->oid);\n \t\t}\n@@ -1829,7 +1830,7 @@ static void repack_local_links(void)\n \toidset_iter_init(&outgoing_links, &iter);\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct object_info info = OBJECT_INFO_INIT;\n-\t\tif (oid_object_info_extended(the_repository, oid, &info, 0))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))\n \t\t\t/* Missing; assume it is a promisor object */\n \t\t\tcontinue;\n \t\tif (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 821339b07d4..ff975e7be06 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -251,7 +251,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(repo, oid, &size) < 0)\n+\t\tif (odb_read_object_info(repo->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 62b6fd58c16..4d616dd5282 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -27,7 +27,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,\n {\n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) < 0)\n \t\t\tdie(_(\"could not get object info about '%s'\"),\n \t\t\t    oid_to_hex(oid));\n \t\tif (padded)\n@@ -217,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,\n \n \tif (type == OBJ_BLOB) {\n \t\tunsigned long size;\n-\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n+\t\tif (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)\n \t\t\txsnprintf(size_text, sizeof(size_text), \"BAD\");\n \t\telse\n \t\t\txsnprintf(size_text, sizeof(size_text),\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 016b0e5b224..81df7f6099f 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -124,10 +124,10 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)\n \n \t/* Check the type of object identified by oid without fetching objects */\n \toi.typep = &obj_type;\n-\tif (oid_object_info_extended(the_repository, &oid, &oi,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t     OBJECT_INFO_QUICK |\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects, &oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t  OBJECT_INFO_QUICK |\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)\n \t\tobj_type = -1;\n \n \tif (obj_type < 0) {\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 99b63cb0980..da35d684081 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2154,10 +2154,10 @@ static void prefetch_to_pack(uint32_t object_index_start) {\n \tfor (i = object_index_start; i < to_pack.nr_objects; i++) {\n \t\tstruct object_entry *entry = to_pack.objects + i;\n \n-\t\tif (!oid_object_info_extended(the_repository,\n-\t\t\t\t\t      &entry->idx.oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &entry->idx.oid,\n+\t\t\t\t\t\t   NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &entry->idx.oid);\n \t}\n@@ -2298,19 +2298,19 @@ static void check_object(struct object_entry *entry, uint32_t object_index)\n \n \t\t/*\n \t\t * No choice but to fall back to the recursive delta walk\n-\t\t * with oid_object_info() to find about the object type\n+\t\t * with odb_read_object_info() to find about the object type\n \t\t * at this point...\n \t\t */\n \t\tgive_up:\n \t\tunuse_pack(&w_curs);\n \t}\n \n-\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n \t\tif (repo_has_promisor_remote(the_repository)) {\n \t\t\tprefetch_to_pack(object_index);\n-\t\t\tif (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,\n-\t\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\t\t\tif (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,\n+\t\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\t\t\ttype = -1;\n \t\t} else {\n \t\t\ttype = -1;\n@@ -2384,12 +2384,13 @@ static void drop_reused_delta(struct object_entry *entry)\n \tif (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {\n \t\t/*\n \t\t * We failed to get the info from this pack for some reason;\n-\t\t * fall back to oid_object_info, which may find another copy.\n+\t\t * fall back to odb_read_object_info, which may find another copy.\n \t\t * And if that fails, the error will be recorded in oe_type(entry)\n \t\t * and dealt with in prepare_pack().\n \t\t */\n \t\toe_set_type(entry,\n-\t\t\t    oid_object_info(the_repository, &entry->idx.oid, &size));\n+\t\t\t    odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t &entry->idx.oid, &size));\n \t} else {\n \t\toe_set_type(entry, type);\n \t}\n@@ -2677,7 +2678,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n \n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tif (oid_object_info(the_repository, &e->idx.oid, &size) < 0)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &e->idx.oid, &size) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"),\n \t\t\t    oid_to_hex(&e->idx.oid));\n \t\tpacking_data_unlock(&to_pack);\n@@ -4063,7 +4065,7 @@ static void add_objects_in_unpacked_packs(void)\n static int add_loose_object(const struct object_id *oid, const char *path,\n \t\t\t    void *data UNUSED)\n {\n-\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n+\tenum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\twarning(_(\"loose object at %s could not be examined\"), path);\n@@ -4449,7 +4451,7 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED,\n static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)\n {\n \tstruct object_info info = OBJECT_INFO_INIT;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &info, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))\n \t\tBUG(\"should_include_obj should only be called on existing objects\");\n \treturn info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;\n }\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 7bbfb14c2be..339017c7ccf 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -99,8 +99,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \tif (st.st_mtime > expire)\n \t\treturn 0;\n \tif (show_only || verbose) {\n-\t\tenum object_type type = oid_object_info(the_repository, oid,\n-\t\t\t\t\t\t\tNULL);\n+\t\tenum object_type type = odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t\t\t     oid, NULL);\n \t\tprintf(\"%s %s\\n\", oid_to_hex(oid),\n \t\t       (type > 0) ? type_name(type) : \"unknown\");\n \t}\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 8145474cf8d..a89c2b704fb 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -707,7 +707,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,\n \tif (oidset_insert(&data->seen, oid))\n \t\treturn 0; /* already seen */\n \n-\tif (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)\n \t\treturn 0;\n \n \tfprintf(data->f->fp, \"%s%s\\n\", data->preferred ? \"+\" : \"\",\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 11c7e2d4c0c..5ff2ab723cb 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -65,8 +65,8 @@ static int show_reference(const char *refname,\n \t\t\tif (repo_get_oid(data->repo, refname, &object))\n \t\t\t\treturn error(_(\"failed to resolve '%s' as a valid ref\"), refname);\n \n-\t\t\tobj_type = oid_object_info(data->repo, &object, NULL);\n-\t\t\trepl_type = oid_object_info(data->repo, oid, NULL);\n+\t\t\tobj_type = odb_read_object_info(data->repo->objects, &object, NULL);\n+\t\t\trepl_type = odb_read_object_info(data->repo->objects, oid, NULL);\n \n \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, type_name(obj_type),\n \t\t\t       oid_to_hex(oid), type_name(repl_type));\n@@ -185,8 +185,8 @@ static int replace_object_oid(const char *object_ref,\n \tstruct strbuf err = STRBUF_INIT;\n \tint res = 0;\n \n-\tobj_type = oid_object_info(the_repository, object, NULL);\n-\trepl_type = oid_object_info(the_repository, repl, NULL);\n+\tobj_type = odb_read_object_info(the_repository->objects, object, NULL);\n+\trepl_type = odb_read_object_info(the_repository->objects, repl, NULL);\n \tif (!force && obj_type != repl_type)\n \t\treturn error(_(\"Objects must be of the same type.\\n\"\n \t\t\t       \"'%s' points to a replaced object of type '%s'\\n\"\n@@ -334,7 +334,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)\n \tif (repo_get_oid(the_repository, object_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), object_ref);\n \n-\ttype = oid_object_info(the_repository, &old_oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &old_oid, NULL);\n \tif (type < 0)\n \t\treturn error(_(\"unable to get object type for %s\"),\n \t\t\t     oid_to_hex(&old_oid));\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 0ee37a32cb2..4d0c460f186 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -110,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)\n \toff_t size;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \toi.disk_sizep = &size;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\tdie(_(\"unable to get disk usage of %s\"), oid_to_hex(&obj->oid));\n \treturn size;\n }\n@@ -346,7 +347,8 @@ static void show_commit(struct commit *commit, void *data)\n static int finish_object(struct object *obj, const char *name, void *cb_data)\n {\n \tstruct rev_list_info *info = cb_data;\n-\tif (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {\n+\tif (odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t  &obj->oid, NULL, 0) < 0) {\n \t\tfinish_object__ma(obj, name);\n \t\treturn 1;\n \t}\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex cf2ea4b4993..e0b27396c6b 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -304,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,\n \tstruct strbuf header = STRBUF_INIT;\n \tint should_edit;\n \n-\ttype = oid_object_info(the_repository, object, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, object, NULL);\n \tif (type <= OBJ_NONE)\n \t\tdie(_(\"bad object type.\"));\n \n@@ -401,7 +401,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 7bf395eec84..405e78bc592 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -232,7 +232,7 @@ static int check_object(struct object *obj, enum object_type type,\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n+\t\tint type = odb_read_object_info(the_repository->objects, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n \t\tobj->flags |= FLAG_WRITTEN;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 59265f89385..5f482d3377f 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1862,7 +1862,7 @@ static int add_ref_to_set(const char *refname UNUSED,\n \n \tif (!peel_iterated_oid(the_repository, oid, &peeled))\n \t\toid = &peeled;\n-\tif (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)\n+\tif (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT)\n \t\toidset_insert(data->commits, oid);\n \n \tdisplay_progress(data->progress, oidset_size(data->commits));\ndiff --git a/commit.c b/commit.c\nindex aa65183d8b6..d4aa9c7a5f8 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -585,7 +585,8 @@ int repo_parse_commit_internal(struct repository *r,\n \t\treturn 0;\n \t}\n \n-\tif (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)\n+\tif (odb_read_object_info_extended(r->objects, &item->object.oid,\n+\t\t\t\t\t  &oi, flags) < 0)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/diff.c b/diff.c\nindex 3af108115b3..dca87e164fb 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4230,14 +4230,14 @@ int diff_populate_filespec(struct repository *r,\n \t\t\tinfo.contentp = &s->data;\n \n \t\tif (options && options->missing_object_cb) {\n-\t\t\tif (!oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE |\n-\t\t\t\t\t\t      OBJECT_INFO_SKIP_FETCH_OBJECT))\n+\t\t\tif (!odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t   OBJECT_INFO_LOOKUP_REPLACE |\n+\t\t\t\t\t\t\t   OBJECT_INFO_SKIP_FETCH_OBJECT))\n \t\t\t\tgoto object_read;\n \t\t\toptions->missing_object_cb(options->missing_object_data);\n \t\t}\n-\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \n object_read:\n@@ -4252,8 +4252,8 @@ int diff_populate_filespec(struct repository *r,\n \t\t}\n \t\tif (!info.contentp) {\n \t\t\tinfo.contentp = &s->data;\n-\t\t\tif (oid_object_info_extended(r, &s->oid, &info,\n-\t\t\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\t\tif (odb_read_object_info_extended(r->objects, &s->oid, &info,\n+\t\t\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \t\t}\n \t\ts->should_free = 1;\n@@ -7019,8 +7019,8 @@ void diff_add_if_missing(struct repository *r,\n {\n \tif (filespec && filespec->oid_valid &&\n \t    !S_ISGITLINK(filespec->mode) &&\n-\t    oid_object_info_extended(r, &filespec->oid, NULL,\n-\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t    odb_read_object_info_extended(r->objects, &filespec->oid, NULL,\n+\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\toid_array_append(to_fetch, &filespec->oid);\n }\n \ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 47fa7fa4c49..0f5de1c94d1 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -149,8 +149,8 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \t}\n \n \twhile (1) {\n-\t\tif (oid_object_info_extended(the_repository, oid, &info,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n+\t\tif (odb_read_object_info_extended(the_repository->objects, oid, &info,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))\n \t\t\treturn NULL;\n \t\tif (type == OBJ_TAG) {\n \t\t\tstruct tag *tag = (struct tag *)\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 80fe48a52c8..7ecd4d9ef50 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -310,7 +310,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \t\tassert(obj->type == OBJ_BLOB);\n \t\tassert((obj->flags & SEEN) == 0);\n \n-\t\tt = oid_object_info(r, &obj->oid, &object_length);\n+\t\tt = odb_read_object_info(r->objects, &obj->oid, &object_length);\n \t\tif (t != OBJ_BLOB) { /* probably OBJ_NONE */\n \t\t\t/*\n \t\t\t * We DO NOT have the blob locally, so we cannot\ndiff --git a/log-tree.c b/log-tree.c\nindex 1d05dc1c701..233bf9f227c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -176,7 +176,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,\n \t\treturn 0;\n \t}\n \n-\tobjtype = oid_object_info(the_repository, oid, NULL);\n+\tobjtype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (objtype < 0)\n \t\treturn 0;\n \tobj = lookup_object_by_type(the_repository, oid, objtype);\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 9f693ab1d36..f29417040c1 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -4385,8 +4385,8 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \n \t\t\tif ((ci->filemask & side_mask) &&\n \t\t\t    S_ISREG(vi->mode) &&\n-\t\t\t    oid_object_info_extended(opt->repo, &vi->oid, NULL,\n-\t\t\t\t\t\t     OBJECT_INFO_FOR_PREFETCH))\n+\t\t\t    odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,\n+\t\t\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH))\n \t\t\t\toid_array_append(&to_fetch, &vi->oid);\n \t\t}\n \t}\ndiff --git a/object-file.c b/object-file.c\nindex 04da19a1a3b..3d674d1093e 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1108,7 +1108,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)\n \toi.typep = &type;\n \toi.sizep = &len;\n \toi.contentp = &buf;\n-\tif (oid_object_info_extended(the_repository, oid, &oi, 0))\n+\tif (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0))\n \t\treturn error(_(\"cannot read object for %s\"), oid_to_hex(oid));\n \tif (compat) {\n \t\tif (repo_oid_to_algop(repo, oid, compat, &compat_oid))\ndiff --git a/object-file.h b/object-file.h\nindex 5066638f8ec..67b4ffc4808 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -8,7 +8,7 @@\n struct index_state;\n \n /*\n- * Set this to 0 to prevent oid_object_info_extended() from fetching missing\n+ * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing\n  * blobs. This has a difference only if extensions.partialClone is set.\n  *\n  * Its default value is 1.\ndiff --git a/object-name.c b/object-name.c\nindex 381536e900e..e225eb602cf 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -251,7 +251,7 @@ static int disambiguate_commit_only(struct repository *r,\n \t\t\t\t    const struct object_id *oid,\n \t\t\t\t    void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_COMMIT;\n }\n \n@@ -262,7 +262,7 @@ static int disambiguate_committish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -279,7 +279,7 @@ static int disambiguate_tree_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_TREE;\n }\n \n@@ -290,7 +290,7 @@ static int disambiguate_treeish_only(struct repository *r,\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(r, oid, NULL);\n+\tkind = odb_read_object_info(r->objects, oid, NULL);\n \tif (kind == OBJ_TREE || kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -307,7 +307,7 @@ static int disambiguate_blob_only(struct repository *r,\n \t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data UNUSED)\n {\n-\tint kind = oid_object_info(r, oid, NULL);\n+\tint kind = odb_read_object_info(r->objects, oid, NULL);\n \treturn kind == OBJ_BLOB;\n }\n \n@@ -399,7 +399,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t\treturn 0;\n \n \thash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);\n-\ttype = oid_object_info(ds->repo, oid, NULL);\n+\ttype = odb_read_object_info(ds->repo->objects, oid, NULL);\n \n \tif (type < 0) {\n \t\t/*\n@@ -514,8 +514,8 @@ static int sort_ambiguous(const void *va, const void *vb, void *ctx)\n {\n \tstruct repository *sort_ambiguous_repo = ctx;\n \tconst struct object_id *a = va, *b = vb;\n-\tint a_type = oid_object_info(sort_ambiguous_repo, a, NULL);\n-\tint b_type = oid_object_info(sort_ambiguous_repo, b, NULL);\n+\tint a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL);\n+\tint b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL);\n \tint a_type_sort;\n \tint b_type_sort;\n \ndiff --git a/object.c b/object.c\nindex 3b15469139d..868d89eed42 100644\n--- a/object.c\n+++ b/object.c\n@@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,\n \tstruct object *o = lookup_unknown_object(r, name);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = oid_object_info(r, name, NULL);\n+\t\tint type = odb_read_object_info(r->objects, name, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\n@@ -315,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t}\n \n \tif ((!obj || obj->type == OBJ_BLOB) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_BLOB) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {\n \t\tif (!skip_hash && stream_object_signature(r, repl) < 0) {\n \t\t\terror(_(\"hash mismatch %s\"), oid_to_hex(oid));\n \t\t\treturn NULL;\n@@ -331,7 +331,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t */\n \tif (skip_hash && discard_tree &&\n \t    (!obj || obj->type == OBJ_TREE) &&\n-\t    oid_object_info(r, oid, NULL) == OBJ_TREE) {\n+\t    odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \ndiff --git a/odb.c b/odb.c\nindex 5a88701550e..40eacdfe2da 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -647,7 +647,7 @@ static int register_all_submodule_sources(struct object_database *odb)\n \treturn ret;\n }\n \n-static int do_oid_object_info_extended(struct repository *r,\n+static int do_oid_object_info_extended(struct object_database *odb,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       struct object_info *oi, unsigned flags)\n {\n@@ -660,7 +660,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \n \n \tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n-\t\treal = lookup_replace_object(r, oid);\n+\t\treal = lookup_replace_object(odb->repo, oid);\n \n \tif (is_null_oid(real))\n \t\treturn -1;\n@@ -668,7 +668,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \tif (!oi)\n \t\toi = &blank_oi;\n \n-\tco = find_cached_object(r->objects, real);\n+\tco = find_cached_object(odb, real);\n \tif (co) {\n \t\tif (oi->typep)\n \t\t\t*(oi->typep) = co->type;\n@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\tif (oi->disk_sizep)\n \t\t\t*(oi->disk_sizep) = 0;\n \t\tif (oi->delta_base_oid)\n-\t\t\toidclr(oi->delta_base_oid, r->hash_algo);\n+\t\t\toidclr(oi->delta_base_oid, odb->repo->hash_algo);\n \t\tif (oi->contentp)\n \t\t\t*oi->contentp = xmemdupz(co->buf, co->size);\n \t\toi->whence = OI_CACHED;\n@@ -685,17 +685,17 @@ static int do_oid_object_info_extended(struct repository *r,\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(r, real, &e))\n+\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\tbreak;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!loose_object_info(r, real, oi, flags))\n+\t\tif (!loose_object_info(odb->repo, real, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\tif (!(flags & OBJECT_INFO_QUICK)) {\n-\t\t\treprepare_packed_git(r);\n-\t\t\tif (find_pack_entry(r, real, &e))\n+\t\t\treprepare_packed_git(odb->repo);\n+\t\t\tif (find_pack_entry(odb->repo, real, &e))\n \t\t\t\tbreak;\n \t\t}\n \n@@ -705,15 +705,15 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * `odb_add_submodule_source_by_path()` on that submodule's\n \t\t * ODB). If any such ODBs exist, register them and try again.\n \t\t */\n-\t\tif (register_all_submodule_sources(r->objects))\n+\t\tif (register_all_submodule_sources(odb))\n \t\t\t/* We added some alternates; retry */\n \t\t\tcontinue;\n \n \t\t/* Check if it is a missing object */\n-\t\tif (fetch_if_missing && repo_has_promisor_remote(r) &&\n+\t\tif (fetch_if_missing && repo_has_promisor_remote(odb->repo) &&\n \t\t    !already_retried &&\n \t\t    !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n-\t\t\tpromisor_remote_get_direct(r, real, 1);\n+\t\t\tpromisor_remote_get_direct(odb->repo, real, 1);\n \t\t\talready_retried = 1;\n \t\t\tcontinue;\n \t\t}\n@@ -723,7 +723,7 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t\tif ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))\n \t\t\t\tdie(_(\"replacement %s not found for %s\"),\n \t\t\t\t    oid_to_hex(real), oid_to_hex(oid));\n-\t\t\tif ((p = has_packed_and_bad(r, real)))\n+\t\t\tif ((p = has_packed_and_bad(odb->repo, real)))\n \t\t\t\tdie(_(\"packed object %s (stored in %s) is corrupt\"),\n \t\t\t\t    oid_to_hex(real), p->pack_name);\n \t\t}\n@@ -736,10 +736,10 @@ static int do_oid_object_info_extended(struct repository *r,\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(r, e.p, e.offset, oi);\n+\trtype = packed_object_info(odb->repo, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real);\n-\t\treturn do_oid_object_info_extended(r, real, oi, 0);\n+\t\treturn do_oid_object_info_extended(odb, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -787,7 +787,7 @@ static int oid_object_info_convert(struct repository *r,\n \t\toi = &new_oi;\n \t}\n \n-\tret = oid_object_info_extended(r, &oid, oi, flags);\n+\tret = odb_read_object_info_extended(r->objects, &oid, oi, flags);\n \tif (ret)\n \t\treturn -1;\n \tif (oi == input_oi)\n@@ -830,33 +830,35 @@ static int oid_object_info_convert(struct repository *r,\n \treturn ret;\n }\n \n-int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n-\t\t\t     struct object_info *oi, unsigned flags)\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags)\n {\n \tint ret;\n \n-\tif (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo))\n-\t\treturn oid_object_info_convert(r, oid, oi, flags);\n+\tif (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo))\n+\t\treturn oid_object_info_convert(odb->repo, oid, oi, flags);\n \n \tobj_read_lock();\n-\tret = do_oid_object_info_extended(r, oid, oi, flags);\n+\tret = do_oid_object_info_extended(odb, oid, oi, flags);\n \tobj_read_unlock();\n \treturn ret;\n }\n \n \n /* returns enum object_type or negative */\n-int oid_object_info(struct repository *r,\n-\t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (odb_read_object_info_extended(odb, oid, &oi,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n@@ -887,7 +889,7 @@ int pretend_object_file(struct repository *repo,\n \n /*\n  * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call oid_object_info_extended() and give\n+ * deal with them should arrange to call odb_read_object_info_extended() and give\n  * error messages themselves.\n  */\n void *repo_read_object_file(struct repository *r,\n@@ -902,7 +904,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (oid_object_info_extended(r, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -968,13 +970,13 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(odb->repo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(odb, oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"%s is not a valid object\"), oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/odb.h b/odb.h\nindex 0ea9d4faa70..b37a9c5d20f 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -265,9 +265,6 @@ void *repo_read_object_file(struct repository *r,\n \t\t\t    enum object_type *type,\n \t\t\t    unsigned long *size);\n \n-/* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n-\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -336,9 +333,24 @@ struct object_info {\n /* Die if object corruption (not just an object being missing) was detected. */\n #define OBJECT_INFO_DIE_IF_CORRUPT 32\n \n-int oid_object_info_extended(struct repository *r,\n-\t\t\t     const struct object_id *,\n-\t\t\t     struct object_info *, unsigned flags);\n+/*\n+ * Read object info from the object database and populate the `object_info`\n+ * structure. Returns 0 on success, a negative error code otherwise.\n+ */\n+int odb_read_object_info_extended(struct object_database *odb,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  struct object_info *oi,\n+\t\t\t\t  unsigned flags);\n+\n+/*\n+ * Read a subset of object info for the given object ID. Returns an `enum\n+ * object_type` on success, a negative error code otherwise. If successful and\n+ * `sizep` is non-NULL, then the size of the object will be written to the\n+ * pointer.\n+ */\n+int odb_read_object_info(struct object_database *odb,\n+\t\t\t const struct object_id *oid,\n+\t\t\t unsigned long *sizep);\n \n enum {\n \t/* Retry packed storage after checking packed and loose storage */\n@@ -360,7 +372,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: repo_read_object_file(),\n- * read_object_with_reference(), oid_object_info() and oid_object_info_extended().\n+ * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -368,7 +380,7 @@ void odb_assert_oid_type(struct object_database *odb,\n  * reading functions. However, beware that in these cases zlib inflation won't\n  * be performed in parallel, losing performance.\n  *\n- * TODO: oid_object_info_extended()'s call stack has a recursive behavior. If\n+ * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If\n  * any of its callees end up calling it, this recursive call won't benefit from\n  * parallel inflation.\n  */\n@@ -416,4 +428,22 @@ void *read_object_with_reference(struct repository *r,\n \t\t\t\t unsigned long *size,\n \t\t\t\t struct object_id *oid_ret);\n \n+/* Compatibility wrappers, to be removed once Git 2.51 has been released. */\n+#include \"repository.h\"\n+\n+static inline int oid_object_info_extended(struct repository *r,\n+\t\t\t\t\t   const struct object_id *oid,\n+\t\t\t\t\t   struct object_info *oi,\n+\t\t\t\t\t   unsigned flags)\n+{\n+\treturn odb_read_object_info_extended(r->objects, oid, oi, flags);\n+}\n+\n+static inline int oid_object_info(struct repository *r,\n+\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t  unsigned long *sizep)\n+{\n+\treturn odb_read_object_info(r->objects, oid, sizep);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex c847369eaaa..c5183b619c1 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -144,8 +144,8 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\treal_type = oid_object_info(writer->to_pack->repo,\n-\t\t\t\t\t\t    &entry->idx.oid, NULL);\n+\t\t\treal_type = odb_read_object_info(writer->to_pack->repo->objects,\n+\t\t\t\t\t\t\t &entry->idx.oid, NULL);\n \t\t\tbreak;\n \t\t}\n \ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex a695a794e9b..bcbb71f7502 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -1868,8 +1868,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,\n \t\tsize_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git);\n \t\tstruct eindex *eindex = &bitmap_git->ext_index;\n \t\tstruct object *obj = eindex->objects[eindex_pos];\n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid,\n+\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get size of %s\"), oid_to_hex(&obj->oid));\n \t}\n \n@@ -3220,8 +3220,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)\n \t\t\t\t       i)))\n \t\t\tcontinue;\n \n-\t\tif (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,\n-\t\t\t\t\t     &oi, 0) < 0)\n+\t\tif (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects,\n+\t\t\t\t\t\t  &obj->oid, &oi, 0) < 0)\n \t\t\tdie(_(\"unable to get disk usage of '%s'\"),\n \t\t\t    oid_to_hex(&obj->oid));\n \ndiff --git a/packfile.c b/packfile.c\nindex ac0e29e99b9..af9ccfdba62 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1321,7 +1321,7 @@ static int retry_bad_packed_offset(struct repository *r,\n \t\treturn OBJ_BAD;\n \tnth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));\n \tmark_bad_packed_object(p, &oid);\n-\ttype = oid_object_info(r, &oid, NULL);\n+\ttype = odb_read_object_info(r->objects, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1849,7 +1849,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\t\t\toi.typep = &type;\n \t\t\t\toi.sizep = &base_size;\n \t\t\t\toi.contentp = &base;\n-\t\t\t\tif (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)\n+\t\t\t\tif (odb_read_object_info_extended(r->objects, &base_oid,\n+\t\t\t\t\t\t\t\t  &oi, 0) < 0)\n \t\t\t\t\tbase = NULL;\n \n \t\t\t\texternal_base = base;\ndiff --git a/promisor-remote.c b/promisor-remote.c\nindex 2baa286bfd0..be6f82d12f8 100644\n--- a/promisor-remote.c\n+++ b/promisor-remote.c\n@@ -245,8 +245,8 @@ static int remove_fetched_oids(struct repository *repo,\n \tstruct object_id *new_oids;\n \n \tfor (i = 0; i < oid_nr; i++)\n-\t\tif (oid_object_info_extended(repo, &old_oids[i], NULL,\n-\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n+\t\tif (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL,\n+\t\t\t\t\t\t  OBJECT_INFO_SKIP_FETCH_OBJECT)) {\n \t\t\tremaining[i] = 1;\n \t\t\tremaining_nr++;\n \t\t}\ndiff --git a/protocol-caps.c b/protocol-caps.c\nindex 3022f69a1bd..ecdd0dc58d5 100644\n--- a/protocol-caps.c\n+++ b/protocol-caps.c\n@@ -64,7 +64,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,\n \t\tstrbuf_addstr(&send_buffer, oid_str);\n \n \t\tif (info->size) {\n-\t\t\tif (oid_object_info(r, &oid, &object_size) < 0) {\n+\t\t\tif (odb_read_object_info(r->objects, &oid, &object_size) < 0) {\n \t\t\t\tstrbuf_addstr(&send_buffer, \" \");\n \t\t\t} else {\n \t\t\t\tstrbuf_addf(&send_buffer, \" %lu\", object_size);\ndiff --git a/reachable.c b/reachable.c\nindex 9dc748f0b9a..e984b68a0c4 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -211,7 +211,7 @@ static void add_recent_object(const struct object_id *oid,\n \t * later processing, and the revision machinery expects\n \t * commits and tags to have been parsed.\n \t */\n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object info for %s\", oid_to_hex(oid));\n \ndiff --git a/read-cache.c b/read-cache.c\nindex c3fa9686766..7d5bccf95dc 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3729,9 +3729,9 @@ void prefetch_cache_entries(const struct index_state *istate,\n \n \t\tif (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))\n \t\t\tcontinue;\n-\t\tif (!oid_object_info_extended(the_repository, &ce->oid,\n-\t\t\t\t\t      NULL,\n-\t\t\t\t\t      OBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_read_object_info_extended(the_repository->objects,\n+\t\t\t\t\t\t   &ce->oid, NULL,\n+\t\t\t\t\t\t   OBJECT_INFO_FOR_PREFETCH))\n \t\t\tcontinue;\n \t\toid_array_append(&to_fetch, &ce->oid);\n \t}\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 4ce45440ad1..f9f2c512a8c 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2302,8 +2302,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj\n \t\toi->info.sizep = &oi->size;\n \t\toi->info.typep = &oi->type;\n \t}\n-\tif (oid_object_info_extended(the_repository, &oi->oid, &oi->info,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\tif (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info,\n+\t\t\t\t\t  OBJECT_INFO_LOOKUP_REPLACE))\n \t\treturn strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n \t\t\t\t       oid_to_hex(&oi->oid), ref->refname);\n \tif (oi->info.disk_sizep && oi->disk_size < 0)\ndiff --git a/remote.c b/remote.c\nindex 17a842f5684..72c36239d31 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1182,7 +1182,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,\n \t\tBUG(\"'%s' is not a valid object, \"\n \t\t    \"match_explicit_lhs() should catch this!\",\n \t\t    matched_src_name);\n-\ttype = oid_object_info(the_repository, &oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, &oid, NULL);\n \tif (type == OBJ_COMMIT) {\n \t\tadvise(_(\"The <src> part of the refspec is a commit object.\\n\"\n \t\t\t \"Did you mean to create a new branch by pushing to\\n\"\n@@ -1412,7 +1412,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)\n+\t\tif (odb_read_object_info(the_repository->objects,\n+\t\t\t\t\t &ref->new_oid, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\ndiff --git a/sequencer.c b/sequencer.c\nindex 2432d0a39ec..193459405f8 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5503,9 +5503,8 @@ int sequencer_pick_revisions(struct repository *r,\n \n \t\tif (!repo_get_oid(r, name, &oid)) {\n \t\t\tif (!lookup_commit_reference_gently(r, &oid, 1)) {\n-\t\t\t\tenum object_type type = oid_object_info(r,\n-\t\t\t\t\t\t\t\t\t&oid,\n-\t\t\t\t\t\t\t\t\tNULL);\n+\t\t\t\tenum object_type type = odb_read_object_info(r->objects,\n+\t\t\t\t\t\t\t\t\t     &oid, NULL);\n \t\t\t\tres = error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\t    name, type_name(type));\n \t\t\t\tgoto out;\ndiff --git a/streaming.c b/streaming.c\nindex 81c42673a23..4b13827668e 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -44,7 +44,7 @@ struct git_istream {\n \n \tunion {\n \t\tstruct {\n-\t\t\tchar *buf; /* from oid_object_info_extended() */\n+\t\t\tchar *buf; /* from odb_read_object_info_extended() */\n \t\t\tunsigned long read_ptr;\n \t\t} incore;\n \n@@ -403,8 +403,8 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,\n \toi.typep = type;\n \toi.sizep = &st->size;\n \toi.contentp = (void **)&st->u.incore.buf;\n-\treturn oid_object_info_extended(r, oid, &oi,\n-\t\t\t\t\tOBJECT_INFO_DIE_IF_CORRUPT);\n+\treturn odb_read_object_info_extended(r->objects, oid, &oi,\n+\t\t\t\t\t     OBJECT_INFO_DIE_IF_CORRUPT);\n }\n \n /*****************************************************************************\n@@ -422,7 +422,7 @@ static int istream_source(struct git_istream *st,\n \n \toi.typep = type;\n \toi.sizep = &size;\n-\tstatus = oid_object_info_extended(r, oid, &oi, 0);\n+\tstatus = odb_read_object_info_extended(r->objects, oid, &oi, 0);\n \tif (status < 0)\n \t\treturn status;\n \ndiff --git a/submodule.c b/submodule.c\nindex 788c9e55ed3..f8373a9ea7d 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -968,7 +968,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n \t\treturn 0;\n \t}\n \n-\ttype = oid_object_info(&subrepo, oid, NULL);\n+\ttype = odb_read_object_info(subrepo.objects, oid, NULL);\n \n \tswitch (type) {\n \tcase OBJ_COMMIT:\n@@ -1752,8 +1752,7 @@ static int fetch_start_failure(struct strbuf *err UNUSED,\n static int commit_missing_in_sub(const struct object_id *oid, void *data)\n {\n \tstruct repository *subrepo = data;\n-\n-\tenum object_type type = oid_object_info(subrepo, oid, NULL);\n+\tenum object_type type = odb_read_object_info(subrepo->objects, oid, NULL);\n \n \treturn type != OBJ_COMMIT;\n }\ndiff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c\nindex dba227259a2..d8488007493 100644\n--- a/t/helper/test-partial-clone.c\n+++ b/t/helper/test-partial-clone.c\n@@ -23,7 +23,7 @@ static void object_info(const char *gitdir, const char *oid_hex)\n \t\tdie(\"could not init repo\");\n \tif (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo))\n \t\tdie(\"could not parse oid\");\n-\tif (oid_object_info_extended(&r, &oid, &oi, 0))\n+\tif (odb_read_object_info_extended(r.objects, &oid, &oi, 0))\n \t\tdie(\"could not obtain object info\");\n \tprintf(\"%d\\n\", (int) size);\n \ndiff --git a/tag.c b/tag.c\nindex 5f6868bf7b1..144048fd5e0 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \tunsigned long size;\n \tint ret;\n \n-\ttype = oid_object_info(the_repository, oid, NULL);\n+\ttype = odb_read_object_info(the_repository->objects, oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521038","messageId":"20250701-pks-object-store-wo-the-repository-v6-14-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 14/17] odb: rename `repo_read_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:26Z","receivedAt":"2025-07-01T12:23:09Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `repo_read_object_file()` to `odb_read_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  | 10 +++++-----\n archive.c                |  2 +-\n attr.c                   |  2 +-\n bisect.c                 |  6 +++---\n blame.c                  | 13 ++++++-------\n builtin/cat-file.c       | 26 +++++++++++---------------\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  6 +++---\n builtin/fast-import.c    |  8 ++++----\n builtin/grep.c           |  8 ++++----\n builtin/index-pack.c     |  8 ++++----\n builtin/log.c            |  2 +-\n builtin/merge-tree.c     | 12 ++++++------\n builtin/mktag.c          |  4 ++--\n builtin/notes.c          |  6 +++---\n builtin/pack-objects.c   | 30 +++++++++++++++---------------\n builtin/tag.c            |  4 ++--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c |  4 ++--\n bundle.c                 |  2 +-\n combine-diff.c           |  2 +-\n commit.c                 |  6 +++---\n config.c                 |  2 +-\n dir.c                    |  2 +-\n entry.c                  |  4 ++--\n fmt-merge-msg.c          |  4 ++--\n fsck.c                   |  2 +-\n grep.c                   |  4 ++--\n http-push.c              |  4 ++--\n mailmap.c                |  2 +-\n match-trees.c            |  4 ++--\n merge-blobs.c            |  8 ++++----\n merge-ort.c              |  2 +-\n notes-cache.c            |  2 +-\n notes-merge.c            |  2 +-\n notes.c                  | 13 +++++++------\n object.c                 |  2 +-\n odb.c                    | 19 +++++++------------\n odb.h                    | 29 +++++++++++++++++++++++------\n read-cache.c             |  6 +++---\n reflog.c                 |  4 ++--\n rerere.c                 |  5 ++---\n submodule-config.c       |  4 ++--\n tag.c                    |  6 +++---\n tree-walk.c              |  6 +++---\n tree.c                   |  4 ++--\n xdiff-interface.c        |  2 +-\n 47 files changed, 157 insertions(+), 150 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex e778b4e911d..a34ced04625 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3210,8 +3210,8 @@ static int apply_binary(struct apply_state *state,\n \t\tunsigned long size;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t       &size);\n+\t\tresult = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t\t &type, &size);\n \t\tif (!result)\n \t\t\treturn error(_(\"the necessary postimage %s for \"\n \t\t\t\t       \"'%s' cannot be read\"),\n@@ -3273,8 +3273,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tunsigned long sz;\n \t\tchar *result;\n \n-\t\tresult = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t       &sz);\n+\t\tresult = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t &type, &sz);\n \t\tif (!result)\n \t\t\treturn -1;\n \t\t/* XXX read_sha1_file NUL-terminates */\n@@ -3503,7 +3503,7 @@ static int resolve_to(struct image *image, const struct object_id *result_id)\n \n \timage_clear(image);\n \n-\tdata = repo_read_object_file(the_repository, result_id, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, result_id, &type, &size);\n \tif (!data || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(result_id));\n \tstrbuf_attach(&image->buf, data, size, size + 1);\ndiff --git a/archive.c b/archive.c\nindex f2511d530d5..f5a9d45c8d3 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -98,7 +98,7 @@ static void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t       (args->tree ? &args->tree->object.oid : NULL), oid);\n \n \tpath += args->baselen;\n-\tbuffer = repo_read_object_file(the_repository, oid, type, sizep);\n+\tbuffer = odb_read_object(the_repository->objects, oid, type, sizep);\n \tif (buffer && S_ISREG(mode)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tsize_t size = 0;\ndiff --git a/attr.c b/attr.c\nindex e5680db7f65..d1daeb0b4d9 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -779,7 +779,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,\n \tif (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))\n \t\treturn NULL;\n \n-\tbuf = repo_read_object_file(istate->repo, &oid, &type, &sz);\n+\tbuf = odb_read_object(istate->repo->objects, &oid, &type, &sz);\n \tif (!buf || type != OBJ_BLOB) {\n \t\tfree(buf);\n \t\treturn NULL;\ndiff --git a/bisect.c b/bisect.c\nindex a7939216d00..f24474542ec 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -155,9 +155,9 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tunsigned commit_flags = commit->object.flags;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &commit->object.oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &commit->object.oid, &type,\n+\t\t\t\t\t    &size);\n \t\tconst char *subject_start;\n \t\tint subject_len;\n \ndiff --git a/blame.c b/blame.c\nindex 97db3355af4..858d2d74df9 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1041,9 +1041,9 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\t\t\t    &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n-\t\t\tfile->ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t  &o->blob_oid, &type,\n-\t\t\t\t\t\t\t  &file_size);\n+\t\t\tfile->ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t    &o->blob_oid, &type,\n+\t\t\t\t\t\t    &file_size);\n \t\tfile->size = file_size;\n \n \t\tif (!file->ptr)\n@@ -2869,10 +2869,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\n \t\telse\n-\t\t\tsb->final_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &o->blob_oid,\n-\t\t\t\t\t\t\t      &type,\n-\t\t\t\t\t\t\t      &sb->final_buf_size);\n+\t\t\tsb->final_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&o->blob_oid, &type,\n+\t\t\t\t\t\t\t&sb->final_buf_size);\n \n \t\tif (!sb->final_buf)\n \t\t\tdie(_(\"cannot read blob %s for path %s\"),\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex f7595fdb04e..90a3e159d11 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -74,7 +74,7 @@ static int filter_object(const char *path, unsigned mode,\n {\n \tenum object_type type;\n \n-\t*buf = repo_read_object_file(the_repository, oid, &type, size);\n+\t*buf = odb_read_object(the_repository->objects, oid, &type, size);\n \tif (!*buf)\n \t\treturn error(_(\"cannot read object %s '%s'\"),\n \t\t\t     oid_to_hex(oid), path);\n@@ -197,8 +197,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\tret = stream_blob(&oid);\n \t\t\tgoto cleanup;\n \t\t}\n-\t\tbuf = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t      &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"Cannot read object %s\", obj_name);\n \n@@ -219,10 +219,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\tstruct object_id blob_oid;\n \t\t\tif (odb_read_object_info(the_repository->objects,\n \t\t\t\t\t\t &oid, NULL) == OBJ_TAG) {\n-\t\t\t\tchar *buffer = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t     &oid,\n-\t\t\t\t\t\t\t\t     &type,\n-\t\t\t\t\t\t\t\t     &size);\n+\t\t\t\tchar *buffer = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t       &oid, &type, &size);\n \t\t\t\tconst char *target;\n \n \t\t\t\tif (!buffer)\n@@ -403,10 +401,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\t\tif (!textconv_object(the_repository,\n \t\t\t\t\t\t     data->rest, 0100644, oid,\n \t\t\t\t\t\t     1, &contents, &size))\n-\t\t\t\t\tcontents = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t\t\t oid,\n-\t\t\t\t\t\t\t\t\t &type,\n-\t\t\t\t\t\t\t\t\t &size);\n+\t\t\t\t\tcontents = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t\t   oid, &type, &size);\n \t\t\t\tif (!contents)\n \t\t\t\t\tdie(\"could not convert '%s' %s\",\n \t\t\t\t\t    oid_to_hex(oid), data->rest);\n@@ -423,8 +419,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\tunsigned long size;\n \t\tvoid *contents;\n \n-\t\tcontents = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t &size);\n+\t\tcontents = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &type, &size);\n \t\tif (!contents)\n \t\t\tdie(\"object %s disappeared\", oid_to_hex(oid));\n \n@@ -533,8 +529,8 @@ static void batch_object_write(const char *obj_name,\n \t\t\tsize_t s = data->size;\n \t\t\tchar *buf = NULL;\n \n-\t\t\tbuf = repo_read_object_file(the_repository, &data->oid, &data->type,\n-\t\t\t\t\t\t    &data->size);\n+\t\t\tbuf = odb_read_object(the_repository->objects, &data->oid,\n+\t\t\t\t\t      &data->type, &data->size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"), oid_to_hex(&data->oid));\n \t\t\tbuf = replace_idents_using_mailmap(buf, &s);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex fac613e3bc3..e4bc1f83169 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -320,7 +320,7 @@ static char *get_symlink(struct repository *repo,\n \t} else {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tdata = repo_read_object_file(repo, oid, &type, &size);\n+\t\tdata = odb_read_object(repo->objects, oid, &type, &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\n \t\t\t\toid_to_hex(oid), path);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 6c93cf0a8aa..33f304dd0ad 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -323,7 +323,7 @@ static void export_blob(const struct object_id *oid)\n \t\tobject = (struct object *)lookup_blob(the_repository, oid);\n \t\teaten = 0;\n \t} else {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"could not read blob %s\", oid_to_hex(oid));\n \t\tif (check_object_signature(the_repository, oid, buf, size,\n@@ -869,8 +869,8 @@ static void handle_tag(const char *name, struct tag *tag)\n \t\treturn;\n \t}\n \n-\tbuf = repo_read_object_file(the_repository, &tag->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(\"could not read tag %s\", oid_to_hex(&tag->object.oid));\n \tmessage = memmem(buf, size, \"\\n\\n\", 2);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 2718376f2c9..1973c504e25 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf || type != OBJ_TREE)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t}\n@@ -3002,7 +3002,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \tchar *buf;\n \n \tif (!oe || oe->pack_id == MAX_PACK_ID) {\n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t} else {\n \t\ttype = oe->type;\n \t\tbuf = gfi_unpack_entry(oe, &size);\n@@ -3110,8 +3110,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \t\tbuf = gfi_unpack_entry(oe, &size);\n \t} else {\n \t\tenum object_type unused;\n-\t\tbuf = repo_read_object_file(the_repository, oid, &unused,\n-\t\t\t\t\t    &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t      &unused, &size);\n \t}\n \tif (!buf)\n \t\tdie(\"Can't load object %s\", oid_to_hex(oid));\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 1435d462cd1..5de61dfffe8 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -573,8 +573,8 @@ static int grep_cache(struct grep_opt *opt,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t     &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t       &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree %s\"), oid_to_hex(&ce->oid));\n \t\t\tinit_tree_desc(&tree, &ce->oid, data, size);\n@@ -666,8 +666,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tvoid *data;\n \t\t\tunsigned long size;\n \n-\t\t\tdata = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry.oid, &type, &size);\n+\t\t\tdata = odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry.oid, &type, &size);\n \t\t\tif (!data)\n \t\t\t\tdie(_(\"unable to read tree (%s)\"),\n \t\t\t\t    oid_to_hex(&entry.oid));\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d0b16908122..180d261f6ce 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -914,8 +914,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), oid_to_hex(oid));\n-\t\thas_data = repo_read_object_file(the_repository, oid,\n-\t\t\t\t\t\t &has_type, &has_size);\n+\t\thas_data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t   &has_type, &has_size);\n \t\tread_unlock();\n \t\tif (!data)\n \t\t\tdata = new_data = get_data_from_pack(obj_entry);\n@@ -1521,8 +1521,8 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \n \t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n-\t\tdata = repo_read_object_file(the_repository, &d->oid, &type,\n-\t\t\t\t\t     &size);\n+\t\tdata = odb_read_object(the_repository->objects, &d->oid,\n+\t\t\t\t       &type, &size);\n \t\tif (!data)\n \t\t\tcontinue;\n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex fe9cc5ebecb..f2040b18159 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -714,7 +714,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tunsigned long offset = 0;\n \n \tif (!buf)\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex b1a17787bcf..cf8b06cadc7 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -75,9 +75,9 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \tconst char *path = entry->path;\n \n \tif (!entry->stage)\n-\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t     &entry->blob->object.oid, &type,\n-\t\t\t\t\t     size);\n+\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t       &entry->blob->object.oid, &type,\n+\t\t\t\t       size);\n \tbase = NULL;\n \tif (entry->stage == 1) {\n \t\tbase = entry->blob;\n@@ -100,9 +100,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)\n \tenum object_type type;\n \twhile (entry) {\n \t\tif (entry->stage == 2)\n-\t\t\treturn repo_read_object_file(the_repository,\n-\t\t\t\t\t\t     &entry->blob->object.oid,\n-\t\t\t\t\t\t     &type, size);\n+\t\t\treturn odb_read_object(the_repository->objects,\n+\t\t\t\t\t       &entry->blob->object.oid,\n+\t\t\t\t\t       &type, size);\n \t\tentry = entry->link;\n \t}\n \treturn NULL;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 1809b38f937..1b391119de8 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -54,8 +54,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)\n \tvoid *buffer;\n \tconst struct object_id *repl;\n \n-\tbuffer = repo_read_object_file(the_repository, tagged_oid, &type,\n-\t\t\t\t       &size);\n+\tbuffer = odb_read_object(the_repository->objects, tagged_oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\tdie(_(\"could not read tagged object '%s'\"),\n \t\t    oid_to_hex(tagged_oid));\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 783d4932ca6..a9529b1696a 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -152,7 +152,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tchar *buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (buf) {\n \t\tif (size)\n \t\t\twrite_or_die(fd, buf, size);\n@@ -319,7 +319,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tstrbuf_init(&msg->buf, 0);\n \tif (repo_get_oid(the_repository, arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(value = repo_read_object_file(the_repository, &object, &type, &len)))\n+\tif (!(value = odb_read_object(the_repository->objects, &object, &type, &len)))\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n \tif (type != OBJ_BLOB) {\n \t\tstrbuf_release(&msg->buf);\n@@ -722,7 +722,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,\n \t\tunsigned long size;\n \t\tenum object_type type;\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tchar *prev_buf = repo_read_object_file(the_repository, note, &type, &size);\n+\t\tchar *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \t\tif (!prev_buf)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(note));\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex da35d684081..580a5c1996b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -337,13 +337,13 @@ static void *get_delta(struct object_entry *entry)\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &entry->idx.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &entry->idx.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\tdie(_(\"unable to read %s\"), oid_to_hex(&entry->idx.oid));\n-\tbase_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t &DELTA(entry)->idx.oid, &type,\n-\t\t\t\t\t &base_size);\n+\tbase_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t   &DELTA(entry)->idx.oid, &type,\n+\t\t\t\t   &base_size);\n \tif (!base_buf)\n \t\tdie(\"unable to read %s\",\n \t\t    oid_to_hex(&DELTA(entry)->idx.oid));\n@@ -506,9 +506,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \t\t\t\t       &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n-\t\t\tbuf = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t    &entry->idx.oid, &type,\n-\t\t\t\t\t\t    &size);\n+\t\t\tbuf = odb_read_object(the_repository->objects,\n+\t\t\t\t\t      &entry->idx.oid, &type,\n+\t\t\t\t\t      &size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&entry->idx.oid));\n@@ -1895,7 +1895,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \t/* Did not find one.  Either we got a bogus request or\n \t * we need to read and perhaps cache.\n \t */\n-\tdata = repo_read_object_file(the_repository, oid, &type, &size);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!data)\n \t\treturn NULL;\n \tif (type != OBJ_TREE) {\n@@ -2762,9 +2762,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t/* Load data if not already done */\n \tif (!trg->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\ttrg->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &trg_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\ttrg->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &trg_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!trg->data)\n \t\t\tdie(_(\"object %s cannot be read\"),\n@@ -2777,9 +2777,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t}\n \tif (!src->data) {\n \t\tpacking_data_lock(&to_pack);\n-\t\tsrc->data = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t  &src_entry->idx.oid, &type,\n-\t\t\t\t\t\t  &sz);\n+\t\tsrc->data = odb_read_object(the_repository->objects,\n+\t\t\t\t\t    &src_entry->idx.oid, &type,\n+\t\t\t\t\t    &sz);\n \t\tpacking_data_unlock(&to_pack);\n \t\tif (!src->data) {\n \t\t\tif (src_entry->preferred_base) {\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex e0b27396c6b..46cbf892e34 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -244,7 +244,7 @@ static void write_tag_body(int fd, const struct object_id *oid)\n \tstruct strbuf payload = STRBUF_INIT;\n \tstruct strbuf signature = STRBUF_INIT;\n \n-\torig = buf = repo_read_object_file(the_repository, oid, &type, &size);\n+\torig = buf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn;\n \tif (parse_signature(buf, size, &payload, &signature)) {\n@@ -407,7 +407,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {\n+\t\tif ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) {\n \t\t\tsubject_len = find_commit_subject(buf, &subject_start);\n \t\t\tstrbuf_insert(sb, sb->len, subject_start, subject_len);\n \t\t} else {\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex b92fd4710a9..4360872ae07 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -14,7 +14,7 @@ static char *create_temp_file(struct object_id *oid)\n \tunsigned long size;\n \tint fd;\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 405e78bc592..4bc6575a574 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -516,8 +516,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \tif (resolve_against_held(nr, &base_oid, delta_data, delta_size))\n \t\treturn;\n \n-\tbase = repo_read_object_file(the_repository, &base_oid, &type,\n-\t\t\t\t     &base_size);\n+\tbase = odb_read_object(the_repository->objects, &base_oid,\n+\t\t\t       &type, &base_size);\n \tif (!base) {\n \t\terror(\"failed to read delta-pack base object %s\",\n \t\t      oid_to_hex(&base_oid));\ndiff --git a/bundle.c b/bundle.c\nindex e09e3c2f58c..717f056a454 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -305,7 +305,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n \tif (revs->max_age == -1 && revs->min_age == -1)\n \t\tgoto out;\n \n-\tbuf = repo_read_object_file(the_repository, &tag->oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &tag->oid, &type, &size);\n \tif (!buf)\n \t\tgoto out;\n \tline = memmem(buf, size, \"\\ntagger \", 8);\ndiff --git a/combine-diff.c b/combine-diff.c\nindex cf23a753407..4ea2dc93c4f 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -325,7 +325,7 @@ static char *grab_blob(struct repository *r,\n \t\t*size = fill_textconv(r, textconv, df, &blob);\n \t\tfree_filespec(df);\n \t} else {\n-\t\tblob = repo_read_object_file(r, oid, &type, size);\n+\t\tblob = odb_read_object(r->objects, oid, &type, size);\n \t\tif (!blob)\n \t\t\tdie(_(\"unable to read %s\"), oid_to_hex(oid));\n \t\tif (type != OBJ_BLOB)\ndiff --git a/commit.c b/commit.c\nindex d4aa9c7a5f8..28ee6b73ae6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -374,7 +374,7 @@ const void *repo_get_commit_buffer(struct repository *r,\n \tif (!ret) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n+\t\tret = odb_read_object(r->objects, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n \t\t\t    oid_to_hex(&commit->object.oid));\n@@ -1275,8 +1275,8 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h\n \tdesc = merge_remote_util(parent);\n \tif (!desc || !desc->obj)\n \t\treturn;\n-\tbuf = repo_read_object_file(the_repository, &desc->obj->oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &desc->obj->oid,\n+\t\t\t      &type, &size);\n \tif (!buf || type != OBJ_TAG)\n \t\tgoto free_return;\n \tif (!parse_signature(buf, size, &payload, &signature))\ndiff --git a/config.c b/config.c\nindex 883dd066827..142c37215a8 100644\n--- a/config.c\n+++ b/config.c\n@@ -1942,7 +1942,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n \tunsigned long size;\n \tint ret;\n \n-\tbuf = repo_read_object_file(repo, oid, &type, &size);\n+\tbuf = odb_read_object(repo->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(_(\"unable to load config blob object '%s'\"), name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/dir.c b/dir.c\nindex a374972b624..cb7bd873b17 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -302,7 +302,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t*size_out = 0;\n \t*data_out = NULL;\n \n-\tdata = repo_read_object_file(the_repository, oid, &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, oid, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn -1;\ndiff --git a/entry.c b/entry.c\nindex 75d55038d7c..cae02eb5039 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -93,8 +93,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tunsigned long ul;\n-\tvoid *blob_data = repo_read_object_file(the_repository, &ce->oid,\n-\t\t\t\t\t\t&type, &ul);\n+\tvoid *blob_data = odb_read_object(the_repository->objects, &ce->oid,\n+\t\t\t\t\t  &type, &ul);\n \n \t*size = ul;\n \tif (blob_data) {\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 1a8c972adf3..40174efa3de 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -526,8 +526,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t  &size);\n+\t\tchar *buf = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t    &type, &size);\n \t\tchar *origbuf = buf;\n \t\tunsigned long len = size;\n \t\tstruct signature_check sigc = { NULL };\ndiff --git a/fsck.c b/fsck.c\nindex e69baab3af7..23965e1880f 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1293,7 +1293,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,\n \t\tif (oidset_contains(blobs_done, oid))\n \t\t\tcontinue;\n \n-\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\t\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \t\tif (!buf) {\n \t\t\tif (is_promisor_object(the_repository, oid))\n \t\t\t\tcontinue;\ndiff --git a/grep.c b/grep.c\nindex dc77e6c4631..932647e4a65 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1931,8 +1931,8 @@ static int grep_source_load_oid(struct grep_source *gs)\n {\n \tenum object_type type;\n \n-\tgs->buf = repo_read_object_file(gs->repo, gs->identifier, &type,\n-\t\t\t\t\t&gs->size);\n+\tgs->buf = odb_read_object(gs->repo->objects, gs->identifier,\n+\t\t\t\t  &type, &gs->size);\n \tif (!gs->buf)\n \t\treturn error(_(\"'%s': unable to read %s\"),\n \t\t\t     gs->name,\ndiff --git a/http-push.c b/http-push.c\nindex d1b1bb23711..9481825abfb 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -369,8 +369,8 @@ static void start_put(struct transfer_request *request)\n \tssize_t size;\n \tgit_zstream stream;\n \n-\tunpacked = repo_read_object_file(the_repository, &request->obj->oid,\n-\t\t\t\t\t &type, &len);\n+\tunpacked = odb_read_object(the_repository->objects, &request->obj->oid,\n+\t\t\t\t   &type, &len);\n \thdrlen = format_object_header(hdr, sizeof(hdr), type, len);\n \n \t/* Set it up */\ndiff --git a/mailmap.c b/mailmap.c\nindex b18e74c2110..56c72102d9e 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -196,7 +196,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \tif (repo_get_oid(the_repository, name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = repo_read_object_file(the_repository, &oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/match-trees.c b/match-trees.c\nindex 4704f95c340..5a8a5c39b04 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -63,7 +63,7 @@ static void *fill_tree_desc_strict(struct repository *r,\n \tenum object_type type;\n \tunsigned long size;\n \n-\tbuffer = repo_read_object_file(r, hash, &type, &size);\n+\tbuffer = odb_read_object(r->objects, hash, &type, &size);\n \tif (!buffer)\n \t\tdie(\"unable to read tree (%s)\", oid_to_hex(hash));\n \tif (type != OBJ_TREE)\n@@ -199,7 +199,7 @@ static int splice_tree(struct repository *r,\n \tif (*subpath)\n \t\tsubpath++;\n \n-\tbuf = repo_read_object_file(r, oid1, &type, &sz);\n+\tbuf = odb_read_object(r->objects, oid1, &type, &sz);\n \tif (!buf)\n \t\tdie(\"cannot read tree %s\", oid_to_hex(oid1));\n \tinit_tree_desc(&desc, oid1, buf, sz);\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex ba8a3fdfd82..6fc27994171 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -12,8 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n \tunsigned long size;\n \tenum object_type type;\n \n-\tbuf = repo_read_object_file(the_repository, &obj->object.oid, &type,\n-\t\t\t\t    &size);\n+\tbuf = odb_read_object(the_repository->objects, &obj->object.oid,\n+\t\t\t      &type, &size);\n \tif (!buf)\n \t\treturn -1;\n \tif (type != OBJ_BLOB) {\n@@ -79,8 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path,\n \t\t\treturn NULL;\n \t\tif (!our)\n \t\t\tour = their;\n-\t\treturn repo_read_object_file(the_repository, &our->object.oid,\n-\t\t\t\t\t     &type, size);\n+\t\treturn odb_read_object(the_repository->objects, &our->object.oid,\n+\t\t\t\t       &type, size);\n \t}\n \n \tif (fill_mmfile_blob(&f1, our) < 0)\ndiff --git a/merge-ort.c b/merge-ort.c\nindex f29417040c1..473ff61e36e 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -3629,7 +3629,7 @@ static int read_oid_strbuf(struct merge_options *opt,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf) {\n \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n \t\t\t path, NULL, NULL, NULL,\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 344f67762b8..dd56feed6e8 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -87,7 +87,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\n \t\treturn NULL;\n-\tvalue = repo_read_object_file(the_repository, value_oid, &type, &size);\n+\tvalue = odb_read_object(the_repository->objects, value_oid, &type, &size);\n \n \t*outsize = size;\n \treturn value;\ndiff --git a/notes-merge.c b/notes-merge.c\nindex de6a52e2e7f..586939939f2 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -340,7 +340,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n {\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buf = repo_read_object_file(the_repository, note, &type, &size);\n+\tvoid *buf = odb_read_object(the_repository->objects, note, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"cannot read note %s for object %s\",\ndiff --git a/notes.c b/notes.c\nindex fc000e501d2..73eb5f00cf5 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -816,15 +816,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \n \t/* read in both note blob objects */\n \tif (!is_null_oid(new_oid))\n-\t\tnew_msg = repo_read_object_file(the_repository, new_oid,\n-\t\t\t\t\t\t&new_type, &new_len);\n+\t\tnew_msg = odb_read_object(the_repository->objects, new_oid,\n+\t\t\t\t\t  &new_type, &new_len);\n \tif (!new_msg || !new_len || new_type != OBJ_BLOB) {\n \t\tfree(new_msg);\n \t\treturn 0;\n \t}\n \tif (!is_null_oid(cur_oid))\n-\t\tcur_msg = repo_read_object_file(the_repository, cur_oid,\n-\t\t\t\t\t\t&cur_type, &cur_len);\n+\t\tcur_msg = odb_read_object(the_repository->objects, cur_oid,\n+\t\t\t\t\t  &cur_type, &cur_len);\n \tif (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {\n \t\tfree(cur_msg);\n \t\tfree(new_msg);\n@@ -880,7 +880,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\treturn 0;\n \n \t/* read_sha1_file NUL-terminates */\n-\tdata = repo_read_object_file(the_repository, oid, &t, &len);\n+\tdata = odb_read_object(the_repository->objects, oid, &t, &len);\n \tif (t != OBJ_BLOB || !data || !len) {\n \t\tfree(data);\n \t\treturn t != OBJ_BLOB || !data;\n@@ -1290,7 +1290,8 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tif (!oid)\n \t\treturn;\n \n-\tif (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {\n+\tif (!(msg = odb_read_object(the_repository->objects, oid, &type, &msglen)) ||\n+\t    type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn;\n \t}\ndiff --git a/object.c b/object.c\nindex 868d89eed42..c1553ee4330 100644\n--- a/object.c\n+++ b/object.c\n@@ -335,7 +335,7 @@ struct object *parse_object_with_flags(struct repository *r,\n \t\treturn &lookup_tree(r, oid)->object;\n \t}\n \n-\tbuffer = repo_read_object_file(r, oid, &type, &size);\n+\tbuffer = odb_read_object(r->objects, oid, &type, &size);\n \tif (buffer) {\n \t\tif (!skip_hash &&\n \t\t    check_object_signature(r, repl, buffer, size, type) < 0) {\ndiff --git a/odb.c b/odb.c\nindex 40eacdfe2da..5419d5dff6d 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -30,7 +30,7 @@ KHASH_INIT(odb_path_map, const char * /* key: odb_path */,\n \n /*\n  * This is meant to hold a *small* number of objects that you would\n- * want repo_read_object_file() to be able to return, but yet you do not want\n+ * want odb_read_object() to be able to return, but yet you do not want\n  * to write them into the object store (e.g. a browse-only\n  * application).\n  */\n@@ -887,15 +887,10 @@ int pretend_object_file(struct repository *repo,\n \treturn 0;\n }\n \n-/*\n- * This function dies on corrupt objects; the callers who want to\n- * deal with them should arrange to call odb_read_object_info_extended() and give\n- * error messages themselves.\n- */\n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size)\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tunsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE;\n@@ -904,7 +899,7 @@ void *repo_read_object_file(struct repository *r,\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &data;\n-\tif (odb_read_object_info_extended(r->objects, oid, &oi, flags))\n+\tif (odb_read_object_info_extended(odb, oid, &oi, flags))\n \t\treturn NULL;\n \n \treturn data;\n@@ -926,7 +921,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = repo_read_object_file(r, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\ndiff --git a/odb.h b/odb.h\nindex b37a9c5d20f..a4a5154fd0f 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -140,7 +140,7 @@ struct object_database {\n \n \t/*\n \t * This is meant to hold a *small* number of objects that you would\n-\t * want repo_read_object_file() to be able to return, but yet you do not want\n+\t * want odb_read_object() to be able to return, but yet you do not want\n \t * to write them into the object store (e.g. a browse-only\n \t * application).\n \t */\n@@ -260,10 +260,19 @@ void odb_add_to_alternates_file(struct object_database *odb,\n void odb_add_to_alternates_memory(struct object_database *odb,\n \t\t\t\t  const char *dir);\n \n-void *repo_read_object_file(struct repository *r,\n-\t\t\t    const struct object_id *oid,\n-\t\t\t    enum object_type *type,\n-\t\t\t    unsigned long *size);\n+/*\n+ * Read an object from the database. Returns the object data and assigns object\n+ * type and size to the `type` and `size` pointers, if these pointers are\n+ * non-NULL. Returns a `NULL` pointer in case the object does not exist.\n+ *\n+ * This function dies on corrupt objects; the callers who want to deal with\n+ * them should arrange to call odb_read_object_info_extended() and give error\n+ * messages themselves.\n+ */\n+void *odb_read_object(struct object_database *odb,\n+\t\t      const struct object_id *oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size);\n \n /*\n  * Add an object file to the in-memory object store, without writing it\n@@ -371,7 +380,7 @@ void odb_assert_oid_type(struct object_database *odb,\n \n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n- * following functions in parallel: repo_read_object_file(),\n+ * following functions in parallel: odb_read_object(),\n  * read_object_with_reference(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n@@ -446,4 +455,12 @@ static inline int oid_object_info(struct repository *r,\n \treturn odb_read_object_info(r->objects, oid, sizep);\n }\n \n+static inline void *repo_read_object_file(struct repository *r,\n+\t\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t\t  enum object_type *type,\n+\t\t\t\t\t  unsigned long *size)\n+{\n+\treturn odb_read_object(r->objects, oid, type, size);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/read-cache.c b/read-cache.c\nindex 7d5bccf95dc..531d87e7905 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -254,7 +254,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n \tif (strbuf_readlink(&sb, ce->name, expected_size))\n \t\treturn -1;\n \n-\tbuffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &ce->oid, &type, &size);\n \tif (buffer) {\n \t\tif (size == sb.len)\n \t\t\tmatch = memcmp(buffer, sb.buf, size);\n@@ -3485,8 +3485,8 @@ void *read_blob_data_from_index(struct index_state *istate,\n \t}\n \tif (pos < 0)\n \t\treturn NULL;\n-\tdata = repo_read_object_file(the_repository, &istate->cache[pos]->oid,\n-\t\t\t\t     &type, &sz);\n+\tdata = odb_read_object(the_repository->objects, &istate->cache[pos]->oid,\n+\t\t\t       &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn NULL;\ndiff --git a/reflog.c b/reflog.c\nindex 4f8a3b717cd..747b82eada8 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -140,8 +140,8 @@ static int tree_is_complete(const struct object_id *oid)\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n-\t\t\t\t\t\t   &size);\n+\t\tvoid *data = odb_read_object(the_repository->objects, oid,\n+\t\t\t\t\t     &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\treturn 0;\ndiff --git a/rerere.c b/rerere.c\nindex 951e4bf8b41..8bb97c98229 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -1000,9 +1000,8 @@ static int handle_cache(struct index_state *istate,\n \t\t\tbreak;\n \t\ti = ce_stage(ce) - 1;\n \t\tif (!mmfile[i].ptr) {\n-\t\t\tmmfile[i].ptr = repo_read_object_file(the_repository,\n-\t\t\t\t\t\t\t      &ce->oid, &type,\n-\t\t\t\t\t\t\t      &size);\n+\t\t\tmmfile[i].ptr = odb_read_object(the_repository->objects,\n+\t\t\t\t\t\t\t&ce->oid, &type, &size);\n \t\t\tif (!mmfile[i].ptr)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&ce->oid));\ndiff --git a/submodule-config.c b/submodule-config.c\nindex a9f72107888..ea3a087a8bb 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -743,8 +743,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \tif (submodule)\n \t\tgoto out;\n \n-\tconfig = repo_read_object_file(the_repository, &oid, &type,\n-\t\t\t\t       &config_size);\n+\tconfig = odb_read_object(the_repository->objects, &oid,\n+\t\t\t\t &type, &config_size);\n \tif (!config || type != OBJ_BLOB)\n \t\tgoto out;\n \ndiff --git a/tag.c b/tag.c\nindex 144048fd5e0..1d52686ee10 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -60,7 +60,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\t\t\trepo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),\n \t\t\t\ttype_name(type));\n \n-\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n+\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n@@ -222,8 +222,8 @@ int parse_tag(struct tag *item)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tdata = repo_read_object_file(the_repository, &item->object.oid, &type,\n-\t\t\t\t     &size);\n+\tdata = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t       &type, &size);\n \tif (!data)\n \t\treturn error(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 34b0fff4873..766af99f466 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -795,9 +795,9 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\t */\n \t\t\tretval = DANGLING_SYMLINK;\n \n-\t\t\tcontents = repo_read_object_file(r,\n-\t\t\t\t\t\t    &current_tree_oid, &type,\n-\t\t\t\t\t\t    &link_len);\n+\t\t\tcontents = odb_read_object(r->objects,\n+\t\t\t\t\t\t   &current_tree_oid, &type,\n+\t\t\t\t\t\t   &link_len);\n \n \t\t\tif (!contents)\n \t\t\t\tgoto done;\ndiff --git a/tree.c b/tree.c\nindex 341b7c2ff3f..1ef743d90f4 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -193,8 +193,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tbuffer = repo_read_object_file(the_repository, &item->object.oid,\n-\t\t\t\t       &type, &size);\n+\tbuffer = odb_read_object(the_repository->objects, &item->object.oid,\n+\t\t\t\t &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 01e6e378ea6..0e5d38c9600 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -187,7 +187,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n \t\treturn;\n \t}\n \n-\tptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);\n+\tptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);\n \tif (!ptr->ptr || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \tptr->size = size;\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521039","messageId":"20250701-pks-object-store-wo-the-repository-v6-15-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 15/17] odb: rename `has_object()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:27Z","receivedAt":"2025-07-01T12:23:12Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `has_object()` to `odb_has_object()` to match other functions\nrelated to the object database and our modern coding guidelines.\n\nIntroduce a compatibility wrapper so that any in-flight topics will\ncontinue to compile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n apply.c                  |  2 +-\n builtin/backfill.c       |  4 ++--\n builtin/cat-file.c       |  4 ++--\n builtin/clone.c          |  2 +-\n builtin/fetch.c          | 17 +++++++++--------\n builtin/fsck.c           |  2 +-\n builtin/index-pack.c     |  4 ++--\n builtin/pack-objects.c   |  4 ++--\n builtin/receive-pack.c   |  4 ++--\n builtin/remote.c         |  4 ++--\n builtin/show-ref.c       |  4 ++--\n builtin/unpack-objects.c |  4 ++--\n bulk-checkin.c           |  4 ++--\n cache-tree.c             | 15 ++++++++-------\n commit-graph.c           |  2 +-\n commit.c                 |  2 +-\n fetch-pack.c             |  8 ++++----\n http-push.c              | 14 ++++++++------\n http-walker.c            |  8 ++++----\n list-objects.c           |  4 ++--\n notes.c                  |  4 ++--\n odb.c                    |  6 +++---\n odb.h                    | 12 ++++++++++--\n reflog.c                 |  2 +-\n refs.c                   |  3 ++-\n remote.c                 |  2 +-\n send-pack.c              |  2 +-\n shallow.c                | 12 ++++++------\n upload-pack.c            |  2 +-\n walker.c                 |  4 ++--\n 30 files changed, 87 insertions(+), 74 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex a34ced04625..a6836692d0c 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3204,7 +3204,7 @@ static int apply_binary(struct apply_state *state,\n \t\treturn 0; /* deletion patch */\n \t}\n \n-\tif (has_object(the_repository, &oid, 0)) {\n+\tif (odb_has_object(the_repository->objects, &oid, 0)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n \t\tunsigned long size;\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex 0b49baa39fa..80056abe473 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -67,8 +67,8 @@ static int fill_missing_blobs(const char *path UNUSED,\n \t\treturn 0;\n \n \tfor (size_t i = 0; i < list->nr; i++) {\n-\t\tif (!has_object(ctx->repo, &list->oid[i],\n-\t\t\t\tOBJECT_INFO_FOR_PREFETCH))\n+\t\tif (!odb_has_object(ctx->repo->objects, &list->oid[i],\n+\t\t\t\t    OBJECT_INFO_FOR_PREFETCH))\n \t\t\toid_array_append(&ctx->current_batch, &list->oid[i]);\n \t}\n \ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 90a3e159d11..01672ec74bd 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -160,8 +160,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\tgoto cleanup;\n \n \tcase 'e':\n-\t\tret = !has_object(the_repository, &oid,\n-\t\t\t\t  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n+\t\tret = !odb_has_object(the_repository->objects, &oid,\n+\t\t\t\t      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n \t\tgoto cleanup;\n \n \tcase 'w':\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 3aabdf6570b..6d08abed37c 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -506,7 +506,7 @@ static void write_followtags(const struct ref *refs, const char *msg)\n \t\t\tcontinue;\n \t\tif (ends_with(ref->name, \"^{}\"))\n \t\t\tcontinue;\n-\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\tcontinue;\n \t\trefs_update_ref(get_main_ref_store(the_repository), msg,\n \t\t\t\tref->name, &ref->old_oid, NULL, 0,\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex b842bc9c51b..65ea6c84368 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -366,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t */\n \t\tif (ends_with(ref->name, \"^{}\")) {\n \t\t\tif (item &&\n-\t\t\t    !has_object(the_repository, &ref->old_oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &ref->old_oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &ref->old_oid) &&\n-\t\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\t\tclear_item(item);\n \t\t\titem = NULL;\n@@ -382,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t * fetch.\n \t\t */\n \t\tif (item &&\n-\t\t    !has_object(the_repository, &item->oid, 0) &&\n+\t\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t\t    !oidset_contains(&fetch_oids, &item->oid))\n \t\t\tclear_item(item);\n \n@@ -403,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t * checked to see if it needs fetching.\n \t */\n \tif (item &&\n-\t    !has_object(the_repository, &item->oid, 0) &&\n+\t    !odb_has_object(the_repository->objects, &item->oid, 0) &&\n \t    !oidset_contains(&fetch_oids, &item->oid))\n \t\tclear_item(item);\n \n@@ -910,8 +910,8 @@ static int update_local_ref(struct ref *ref,\n \tstruct commit *current = NULL, *updated;\n \tint fast_forward = 0;\n \n-\tif (!has_object(the_repository, &ref->new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, &ref->new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \n \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n@@ -1330,7 +1330,8 @@ static int check_exist_and_connected(struct ref *ref_map)\n \t * we need all direct targets to exist.\n \t */\n \tfor (r = rm; r; r = r->next) {\n-\t\tif (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (!odb_has_object(the_repository->objects, &r->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED))\n \t\t\treturn -1;\n \t}\n \n@@ -1485,7 +1486,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)\n \t\t\tstruct object_id oid;\n \t\t\tif (repo_get_oid(the_repository, s, &oid))\n \t\t\t\tdie(_(\"%s is not a valid object\"), s);\n-\t\t\tif (!has_object(the_repository, &oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &oid, 0))\n \t\t\t\tdie(_(\"the object %s does not exist\"), s);\n \t\t\toid_array_append(oids, &oid);\n \t\t\tcontinue;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6e3465b0266..0084cf7400b 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -161,7 +161,7 @@ static int mark_object(struct object *obj, enum object_type type,\n \t\treturn 0;\n \n \tif (!(obj->flags & HAS_OBJ)) {\n-\t\tif (parent && !has_object(the_repository, &obj->oid, 1)) {\n+\t\tif (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {\n \t\t\tprintf_ln(_(\"broken link from %7s %s\\n\"\n \t\t\t\t    \"              to %7s %s\"),\n \t\t\t\t  printable_type(&parent->oid, parent->type),\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 180d261f6ce..19c67a85344 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -893,8 +893,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \n \tif (startup_info->have_repository) {\n \t\tread_lock();\n-\t\tcollision_test_needed = has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_FETCH_PROMISOR);\n+\t\tcollision_test_needed = odb_has_object(the_repository->objects, oid,\n+\t\t\t\t\t\t       HAS_OBJECT_FETCH_PROMISOR);\n \t\tread_unlock();\n \t}\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 580a5c1996b..06bdeb4223b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3968,7 +3968,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void\n \t * Quietly ignore ALL missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0))\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0))\n \t\treturn;\n \n \tshow_object(obj, name, data);\n@@ -3982,7 +3982,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,\n \t * Quietly ignore EXPECTED missing objects.  This avoids problems with\n \t * staging them now and getting an odd error later.\n \t */\n-\tif (!has_object(the_repository, &obj->oid, 0) &&\n+\tif (!odb_has_object(the_repository->objects, &obj->oid, 0) &&\n \t    is_promisor_object(to_pack.repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 7ea273d93e4..26e77d70726 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1509,8 +1509,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \t}\n \n \tif (!is_null_oid(new_oid) &&\n-\t    !has_object(the_repository, new_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, new_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(\"unpack should have generated %s, \"\n \t\t      \"but I can't find it!\", oid_to_hex(new_oid));\n \t\tret = \"bad pack\";\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex ac5b8d2a1a6..7cbda285ebe 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -454,8 +454,8 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \t\t\tinfo->status = PUSH_STATUS_UPTODATE;\n \t\telse if (is_null_oid(&ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_CREATE;\n-\t\telse if (has_object(the_repository, &ref->old_oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t\telse if (odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t\t\t ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_FASTFORWARD;\n \t\telse\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 90ec1de78f9..117709cb076 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -35,8 +35,8 @@ static void show_one(const struct show_one_options *opts,\n \tconst char *hex;\n \tstruct object_id peeled;\n \n-\tif (!has_object(the_repository, oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!odb_has_object(the_repository->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(\"git show-ref: bad ref %s (%s)\", refname,\n \t\t    oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 4bc6575a574..a69d59eb50c 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -449,8 +449,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\tdelta_data = get_data(delta_size);\n \t\tif (!delta_data)\n \t\t\treturn;\n-\t\tif (has_object(the_repository, &base_oid,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, &base_oid,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t; /* Ok we have this one */\n \t\telse if (resolve_against_held(nr, &base_oid,\n \t\t\t\t\t      delta_data, delta_size))\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 55406a539e7..16df86c0ba8 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -130,8 +130,8 @@ static void flush_batch_fsync(void)\n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n \t/* The object may already exist in the repository */\n-\tif (has_object(the_repository, oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 1;\n \n \t/* Might want to keep the list sorted */\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 9786b32b3a1..a4bc14ad15c 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -239,8 +239,8 @@ int cache_tree_fully_valid(struct cache_tree *it)\n \tif (!it)\n \t\treturn 0;\n \tif (it->entry_count < 0 ||\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0;\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tif (!cache_tree_fully_valid(it->down[i]->cache_tree))\n@@ -292,8 +292,8 @@ static int update_one(struct cache_tree *it,\n \t}\n \n \tif (0 <= it->entry_count &&\n-\t    has_object(the_repository, &it->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t    odb_has_object(the_repository->objects, &it->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn it->entry_count;\n \n \t/*\n@@ -399,8 +399,9 @@ static int update_one(struct cache_tree *it,\n \t\tce_missing_ok = mode == S_IFGITLINK || missing_ok ||\n \t\t\t!must_check_existence(ce);\n \t\tif (is_null_oid(oid) ||\n-\t\t    (!ce_missing_ok && !has_object(the_repository, oid,\n-\t\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n+\t\t    (!ce_missing_ok &&\n+\t\t     !odb_has_object(the_repository->objects, oid,\n+\t\t\t\t     HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n \t\t\tstrbuf_release(&buffer);\n \t\t\tif (expected_missing)\n \t\t\t\treturn -1;\n@@ -448,7 +449,7 @@ static int update_one(struct cache_tree *it,\n \t\tstruct object_id oid;\n \t\thash_object_file(the_hash_algo, buffer.buf, buffer.len,\n \t\t\t\t OBJ_TREE, &oid);\n-\t\tif (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\toidcpy(&it->oid, &oid);\n \t\telse\n \t\t\tto_invalidate = 1;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 5f482d3377f..bd7b6f5338b 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1040,7 +1040,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje\n \t\treturn NULL;\n \tif (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos))\n \t\treturn NULL;\n-\tif (commit_graph_paranoia && !has_object(repo, id, 0))\n+\tif (commit_graph_paranoia && !odb_has_object(repo->objects, id, 0))\n \t\treturn NULL;\n \n \tcommit = lookup_commit(repo, id);\ndiff --git a/commit.c b/commit.c\nindex 28ee6b73ae6..15115125c36 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -575,7 +575,7 @@ int repo_parse_commit_internal(struct repository *r,\n \t\tif (commit_graph_paranoia == -1)\n \t\t\tcommit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);\n \n-\t\tif (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {\n+\t\tif (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {\n \t\t\tunparse_commit(r, &item->object.oid);\n \t\t\treturn quiet_on_missing ? -1 :\n \t\t\t\terror(_(\"commit %s exists in commit-graph but not in the object database\"),\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 0f5de1c94d1..5e74235fc06 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -142,7 +142,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \tcommit = lookup_commit_in_graph(the_repository, oid);\n \tif (commit) {\n \t\tif (mark_tags_complete_and_check_obj_db) {\n-\t\t\tif (!has_object(the_repository, oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\t\t\tdie_in_commit_graph_only(oid);\n \t\t}\n \t\treturn commit;\n@@ -770,7 +770,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,\n \t\tif (!commit) {\n \t\t\tstruct object *o;\n \n-\t\t\tif (!has_object(the_repository, &ref->old_oid, 0))\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid, 0))\n \t\t\t\tcontinue;\n \t\t\to = parse_object(the_repository, &ref->old_oid);\n \t\t\tif (!o || o->type != OBJ_COMMIT)\n@@ -1984,8 +1984,8 @@ static void update_shallow(struct fetch_pack_args *args,\n \t\tstruct oid_array extra = OID_ARRAY_INIT;\n \t\tstruct object_id *oid = si->shallow->oid;\n \t\tfor (i = 0; i < si->shallow->nr; i++)\n-\t\t\tif (has_object(the_repository, &oid[i],\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &oid[i],\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\toid_array_append(&extra, &oid[i]);\n \t\tif (extra.nr) {\n \t\t\tsetup_alternate_shallow(&shallow_lock,\ndiff --git a/http-push.c b/http-push.c\nindex 9481825abfb..beb41732fb6 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1447,8 +1447,8 @@ static void one_remote_ref(const char *refname)\n \t * may be required for updating server info later.\n \t */\n \tif (repo->can_update_info_refs &&\n-\t    !has_object(the_repository, &ref->old_oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t    !odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tobj = lookup_unknown_object(the_repository, &ref->old_oid);\n \t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n \t\t\toid_to_hex(&ref->old_oid), refname);\n@@ -1653,14 +1653,16 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t\treturn error(\"Remote HEAD symrefs too deep\");\n \t\tif (is_null_oid(&head_oid))\n \t\t\treturn error(\"Unable to resolve remote HEAD\");\n-\t\tif (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &head_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", oid_to_hex(&head_oid));\n \n \t\t/* Remote branch must resolve to a known object */\n \t\tif (is_null_oid(&remote_ref->old_oid))\n \t\t\treturn error(\"Unable to resolve remote branch %s\",\n \t\t\t\t     remote_ref->name);\n-\t\tif (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &remote_ref->old_oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, oid_to_hex(&remote_ref->old_oid));\n \n \t\t/* Remote branch must be an ancestor of remote HEAD */\n@@ -1881,8 +1883,8 @@ int cmd_main(int argc, const char **argv)\n \t\tif (!force_all &&\n \t\t    !is_null_oid(&ref->old_oid) &&\n \t\t    !ref->force) {\n-\t\t\tif (!has_object(the_repository, &ref->old_oid,\n-\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n+\t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid,\n+\t\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t\t    !ref_newer(&ref->peer_ref->new_oid,\n \t\t\t\t       &ref->old_oid)) {\n \t\t\t\t/*\ndiff --git a/http-walker.c b/http-walker.c\nindex 05fb9ce714a..0f7ae46d7f1 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -138,8 +138,8 @@ static int fill_active_slot(void *data UNUSED)\n \tlist_for_each_safe(pos, tmp, head) {\n \t\tobj_req = list_entry(pos, struct object_request, node);\n \t\tif (obj_req->state == WAITING) {\n-\t\t\tif (has_object(the_repository, &obj_req->oid,\n-\t\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\tobj_req->state = COMPLETE;\n \t\t\telse {\n \t\t\t\tstart_object_request(obj_req);\n@@ -497,8 +497,8 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \tif (!obj_req)\n \t\treturn error(\"Couldn't find request for %s in the queue\", hex);\n \n-\tif (has_object(the_repository, &obj_req->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tif (obj_req->req)\n \t\t\tabort_http_object_request(&obj_req->req);\n \t\tabort_object_request(obj_req);\ndiff --git a/list-objects.c b/list-objects.c\nindex c50b9578584..42c17d95739 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -74,8 +74,8 @@ static void process_blob(struct traversal_context *ctx,\n \t * of missing objects.\n \t */\n \tif (ctx->revs->exclude_promisor_objects &&\n-\t    !has_object(the_repository, &obj->oid,\n-\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t    !odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n \t    is_promisor_object(ctx->revs->repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/notes.c b/notes.c\nindex 73eb5f00cf5..97b995f3f2d 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -794,8 +794,8 @@ static int prune_notes_helper(const struct object_id *object_oid,\n \tstruct note_delete_list **l = (struct note_delete_list **) cb_data;\n \tstruct note_delete_list *n;\n \n-\tif (has_object(the_repository, object_oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\tif (odb_has_object(the_repository->objects, object_oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0; /* nothing to do for this note */\n \n \t/* failed to find object => prune this note */\ndiff --git a/odb.c b/odb.c\nindex 5419d5dff6d..ecb6711a27b 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -871,7 +871,7 @@ int pretend_object_file(struct repository *repo,\n \tchar *co_buf;\n \n \thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (has_object(repo, oid, 0) ||\n+\tif (odb_has_object(repo->objects, oid, 0) ||\n \t    find_cached_object(repo->objects, oid))\n \t\treturn 0;\n \n@@ -953,7 +953,7 @@ void *read_object_with_reference(struct repository *r,\n \t}\n }\n \n-int has_object(struct repository *r, const struct object_id *oid,\n+int odb_has_object(struct object_database *odb, const struct object_id *oid,\n \t       unsigned flags)\n {\n \tunsigned object_info_flags = 0;\n@@ -965,7 +965,7 @@ int has_object(struct repository *r, const struct object_id *oid,\n \tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n-\treturn odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;\n+\treturn odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;\n }\n \n void odb_assert_oid_type(struct object_database *odb,\ndiff --git a/odb.h b/odb.h\nindex a4a5154fd0f..2532c490461 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -372,8 +372,9 @@ enum {\n  * Returns 1 if the object exists. This function will not lazily fetch objects\n  * in a partial clone by default.\n  */\n-int has_object(struct repository *r, const struct object_id *oid,\n-\t       unsigned flags);\n+int odb_has_object(struct object_database *odb,\n+\t\t   const struct object_id *oid,\n+\t\t   unsigned flags);\n \n void odb_assert_oid_type(struct object_database *odb,\n \t\t\t const struct object_id *oid, enum object_type expect);\n@@ -463,4 +464,11 @@ static inline void *repo_read_object_file(struct repository *r,\n \treturn odb_read_object(r->objects, oid, type, size);\n }\n \n+static inline int has_object(struct repository *r,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     unsigned flags)\n+{\n+\treturn odb_has_object(r->objects, oid, flags);\n+}\n+\n #endif /* ODB_H */\ndiff --git a/reflog.c b/reflog.c\nindex 747b82eada8..39c205fd26e 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -152,7 +152,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tinit_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size);\n \tcomplete = 1;\n \twhile (tree_entry(&desc, &entry)) {\n-\t\tif (!has_object(the_repository, &entry.oid,\n+\t\tif (!odb_has_object(the_repository->objects, &entry.oid,\n \t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/refs.c b/refs.c\nindex 0ff0e582a6b..26e5c2a7d9c 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -376,7 +376,8 @@ int ref_resolves_to_object(const char *refname,\n {\n \tif (flags & REF_ISBROKEN)\n \t\treturn 0;\n-\tif (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (!odb_has_object(repo->objects, oid,\n+\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(_(\"%s does not point to a valid object!\"), refname);\n \t\treturn 0;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 72c36239d31..5edf2a9f4b2 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1703,7 +1703,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\tif (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {\n \t\t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n-\t\t\telse if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\t\telse if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n \t\t\telse if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||\n \t\t\t\t !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))\ndiff --git a/send-pack.c b/send-pack.c\nindex abca2dd38a7..d029f748232 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -45,7 +45,7 @@ int option_parse_push_signed(const struct option *opt,\n static void feed_object(struct repository *r,\n \t\t\tconst struct object_id *oid, FILE *fh, int negative)\n {\n-\tif (negative && !has_object(r, oid, 0))\n+\tif (negative && !odb_has_object(r->objects, oid, 0))\n \t\treturn;\n \n \tif (negative)\ndiff --git a/shallow.c b/shallow.c\nindex d379756e39a..ef3adb635fd 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -310,8 +310,8 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n \tif (graft->nr_parent != -1)\n \t\treturn 0;\n \tif (data->flags & QUICK) {\n-\t\tif (!has_object(the_repository, &graft->oid,\n-\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (!odb_has_object(the_repository->objects, &graft->oid,\n+\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn 0;\n \t} else if (data->flags & SEEN_ONLY) {\n \t\tstruct commit *c = lookup_commit(the_repository, &graft->oid);\n@@ -477,8 +477,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)\n \tALLOC_ARRAY(info->ours, sa->nr);\n \tALLOC_ARRAY(info->theirs, sa->nr);\n \tfor (size_t i = 0; i < sa->nr; i++) {\n-\t\tif (has_object(the_repository, sa->oid + i,\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\tif (odb_has_object(the_repository->objects, sa->oid + i,\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t\tstruct commit_graft *graft;\n \t\t\tgraft = lookup_commit_graft(the_repository,\n \t\t\t\t\t\t    &sa->oid[i]);\n@@ -515,8 +515,8 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)\n \tfor (i = dst = 0; i < info->nr_theirs; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->theirs[dst] = info->theirs[i];\n-\t\tif (has_object(the_repository, oid + info->theirs[i],\n-\t\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\tif (odb_has_object(the_repository->objects, oid + info->theirs[i],\n+\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n \t\t\tdst++;\n \t}\n \tinfo->nr_theirs = dst;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex e994d6a901b..4f26f6afc77 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -509,7 +509,7 @@ static int got_oid(struct upload_pack_data *data,\n {\n \tif (get_oid_hex(hex, oid))\n \t\tdie(\"git upload-pack: expected SHA1 object, got '%s'\", hex);\n-\tif (!has_object(the_repository, oid, 0))\n+\tif (!odb_has_object(the_repository->objects, oid, 0))\n \t\treturn -1;\n \treturn do_got_oid(data, oid);\n }\ndiff --git a/walker.c b/walker.c\nindex a8abe8a2e78..d131af04c7b 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -150,8 +150,8 @@ static int process(struct walker *walker, struct object *obj)\n \t\treturn 0;\n \tobj->flags |= SEEN;\n \n-\tif (has_object(the_repository, &obj->oid,\n-\t\t       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\tif (odb_has_object(the_repository->objects, &obj->oid,\n+\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t/* We already have it, so we should scan it now. */\n \t\tobj->flags |= TO_SCAN;\n \t}\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521040","messageId":"20250701-pks-object-store-wo-the-repository-v6-16-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 16/17] odb: rename `pretend_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:28Z","receivedAt":"2025-07-01T12:23:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `pretend_object_file()` to `odb_pretend_object()` to match other\nfunctions related to the object database and our modern coding\nguidelines.\n\nNo compatibility wrapper is introduced as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n blame.c |  3 ++-\n odb.c   | 18 +++++++++---------\n odb.h   |  6 +++---\n 3 files changed, 14 insertions(+), 13 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 858d2d74df9..dce5c8d855c 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -277,7 +277,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \tconvert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);\n \torigin->file.ptr = buf.buf;\n \torigin->file.size = buf.len;\n-\tpretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);\n+\todb_pretend_object(the_repository->objects, buf.buf, buf.len,\n+\t\t\t   OBJ_BLOB, &origin->blob_oid);\n \n \t/*\n \t * Read the current index, replace the path entry with\ndiff --git a/odb.c b/odb.c\nindex ecb6711a27b..217903d7b14 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -863,21 +863,21 @@ int odb_read_object_info(struct object_database *odb,\n \treturn type;\n }\n \n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid)\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid)\n {\n \tstruct cached_object_entry *co;\n \tchar *co_buf;\n \n-\thash_object_file(repo->hash_algo, buf, len, type, oid);\n-\tif (odb_has_object(repo->objects, oid, 0) ||\n-\t    find_cached_object(repo->objects, oid))\n+\thash_object_file(odb->repo->hash_algo, buf, len, type, oid);\n+\tif (odb_has_object(odb, oid, 0) ||\n+\t    find_cached_object(odb, oid))\n \t\treturn 0;\n \n-\tALLOC_GROW(repo->objects->cached_objects,\n-\t\t   repo->objects->cached_object_nr + 1, repo->objects->cached_object_alloc);\n-\tco = &repo->objects->cached_objects[repo->objects->cached_object_nr++];\n+\tALLOC_GROW(odb->cached_objects,\n+\t\t   odb->cached_object_nr + 1, odb->cached_object_alloc);\n+\tco = &odb->cached_objects[odb->cached_object_nr++];\n \tco->value.size = len;\n \tco->value.type = type;\n \tco_buf = xmalloc(len);\ndiff --git a/odb.h b/odb.h\nindex 2532c490461..e4c51f8c38e 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -282,9 +282,9 @@ void *odb_read_object(struct object_database *odb,\n  * object in persistent storage before writing any other new objects\n  * that reference it.\n  */\n-int pretend_object_file(struct repository *repo,\n-\t\t\tvoid *buf, unsigned long len, enum object_type type,\n-\t\t\tstruct object_id *oid);\n+int odb_pretend_object(struct object_database *odb,\n+\t\t       void *buf, unsigned long len, enum object_type type,\n+\t\t       struct object_id *oid);\n \n struct object_info {\n \t/* Request */\n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521041","messageId":"20250701-pks-object-store-wo-the-repository-v6-17-dbf3894ab4e2@pks.im","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"[PATCH v6 17/17] odb: rename `read_object_with_reference()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-01T12:22:29Z","receivedAt":"2025-07-01T12:23:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename `read_object_with_reference()` to `odb_read_object_peeled()` to\nmatch other functions related to the object database and our modern\ncoding guidelines. Furthermore though, the old name didn't really\ndescribe very well what this function actually does, which is to walk\ndown any commit and tag objects until an object of the required type has\nbeen found. This is generally referred to as \"peeling\", so the new name\nshould be way more descriptive.\n\nNo compatibility wrapper is introduced as the function is not used a lot\nthroughout our codebase.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/user-manual.adoc |  4 ++--\n builtin/cat-file.c             |  4 ++--\n builtin/fast-import.c          | 19 ++++++++-----------\n builtin/grep.c                 |  9 +++------\n builtin/pack-objects.c         |  4 ++--\n odb.c                          | 17 +++++++++--------\n odb.h                          | 15 +++++++--------\n tree-walk.c                    | 10 ++++------\n 8 files changed, 37 insertions(+), 45 deletions(-)\n\ndiff --git a/Documentation/user-manual.adoc b/Documentation/user-manual.adoc\nindex d2b478ad232..e86b2ad9f8a 100644\n--- a/Documentation/user-manual.adoc\n+++ b/Documentation/user-manual.adoc\n@@ -4301,11 +4301,11 @@ Now, for the meat:\n \n -----------------------------------------------------------------------------\n         case 0:\n-                buf = read_object_with_reference(sha1, argv[1], &size, NULL);\n+                buf = odb_read_object_peeled(r->objects, sha1, argv[1], &size, NULL);\n -----------------------------------------------------------------------------\n \n This is how you read a blob (actually, not only a blob, but any type of\n-object).  To know how the function `read_object_with_reference()` actually\n+object).  To know how the function `odb_read_object_peeled()` actually\n works, find the source code for it (something like `git grep\n read_object_with | grep \":[a-z]\"` in the Git repository), and read\n the source.\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 01672ec74bd..08afecbf57c 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -246,8 +246,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\t\t * fall-back to the usual case.\n \t\t\t */\n \t\t}\n-\t\tbuf = read_object_with_reference(the_repository, &oid,\n-\t\t\t\t\t\t exp_type_id, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &oid,\n+\t\t\t\t\t     exp_type_id, &size, NULL);\n \n \t\tif (use_mailmap) {\n \t\t\tsize_t s = size;\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 1973c504e25..b1389c59211 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -2535,10 +2535,9 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!repo_get_oid(the_repository, p, &commit_oid)) {\n \t\tunsigned long size;\n-\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t       &commit_oid,\n-\t\t\t\t\t\t       OBJ_COMMIT, &size,\n-\t\t\t\t\t\t       &commit_oid);\n+\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t   &commit_oid, OBJ_COMMIT, &size,\n+\t\t\t\t\t\t   &commit_oid);\n \t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\tdie(\"Not a valid commit: %s\", p);\n \t\tfree(buf);\n@@ -2604,9 +2603,8 @@ static void parse_from_existing(struct branch *b)\n \t\tunsigned long size;\n \t\tchar *buf;\n \n-\t\tbuf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t &b->oid, OBJ_COMMIT, &size,\n-\t\t\t\t\t\t &b->oid);\n+\t\tbuf = odb_read_object_peeled(the_repository->objects, &b->oid,\n+\t\t\t\t\t     OBJ_COMMIT, &size, &b->oid);\n \t\tparse_from_commit(b, buf, size);\n \t\tfree(buf);\n \t}\n@@ -2699,10 +2697,9 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!repo_get_oid(the_repository, from, &n->oid)) {\n \t\t\tunsigned long size;\n-\t\t\tchar *buf = read_object_with_reference(the_repository,\n-\t\t\t\t\t\t\t       &n->oid,\n-\t\t\t\t\t\t\t       OBJ_COMMIT,\n-\t\t\t\t\t\t\t       &size, &n->oid);\n+\t\t\tchar *buf = odb_read_object_peeled(the_repository->objects,\n+\t\t\t\t\t\t\t   &n->oid, OBJ_COMMIT,\n+\t\t\t\t\t\t\t   &size, &n->oid);\n \t\t\tif (!buf || size < the_hash_algo->hexsz + 6)\n \t\t\t\tdie(\"Not a valid commit: %s\", from);\n \t\t\tfree(buf);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 5de61dfffe8..39273d9c0fd 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -522,9 +522,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tobj_read_lock();\n \t\tobject_type = odb_read_object_info(subrepo->objects, oid, NULL);\n \t\tobj_read_unlock();\n-\t\tdata = read_object_with_reference(subrepo,\n-\t\t\t\t\t\t  oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(subrepo->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \n@@ -705,9 +703,8 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \n-\t\tdata = read_object_with_reference(opt->repo,\n-\t\t\t\t\t\t  &obj->oid, OBJ_TREE,\n-\t\t\t\t\t\t  &size, NULL);\n+\t\tdata = odb_read_object_peeled(opt->repo->objects, &obj->oid,\n+\t\t\t\t\t      OBJ_TREE, &size, NULL);\n \t\tif (!data)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(&obj->oid));\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 06bdeb4223b..e88a13dbb9f 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2055,8 +2055,8 @@ static void add_preferred_base(struct object_id *oid)\n \tif (window <= num_preferred_base++)\n \t\treturn;\n \n-\tdata = read_object_with_reference(the_repository, oid,\n-\t\t\t\t\t  OBJ_TREE, &size, &tree_oid);\n+\tdata = odb_read_object_peeled(the_repository->objects, oid,\n+\t\t\t\t      OBJ_TREE, &size, &tree_oid);\n \tif (!data)\n \t\treturn;\n \ndiff --git a/odb.c b/odb.c\nindex 217903d7b14..1f48a0448e3 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -905,11 +905,11 @@ void *odb_read_object(struct object_database *odb,\n \treturn data;\n }\n \n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *actual_oid_return)\n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *actual_oid_return)\n {\n \tenum object_type type;\n \tvoid *buffer;\n@@ -921,7 +921,7 @@ void *read_object_with_reference(struct repository *r,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = odb_read_object(r->objects, &actual_oid, &type, &isize);\n+\t\tbuffer = odb_read_object(odb, &actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\n@@ -941,9 +941,10 @@ void *read_object_with_reference(struct repository *r,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + r->hash_algo->hexsz > isize ||\n+\t\tif (ref_length + odb->repo->hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {\n+\t\t    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid,\n+\t\t\t\t      odb->repo->hash_algo)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\ndiff --git a/odb.h b/odb.h\nindex e4c51f8c38e..e922f256802 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -274,6 +274,12 @@ void *odb_read_object(struct object_database *odb,\n \t\t      enum object_type *type,\n \t\t      unsigned long *size);\n \n+void *odb_read_object_peeled(struct object_database *odb,\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     enum object_type required_type,\n+\t\t\t     unsigned long *size,\n+\t\t\t     struct object_id *oid_ret);\n+\n /*\n  * Add an object file to the in-memory object store, without writing it\n  * to disk.\n@@ -382,7 +388,7 @@ void odb_assert_oid_type(struct object_database *odb,\n /*\n  * Enabling the object read lock allows multiple threads to safely call the\n  * following functions in parallel: odb_read_object(),\n- * read_object_with_reference(), odb_read_object_info() and odb().\n+ * odb_read_object_peeled(), odb_read_object_info() and odb().\n  *\n  * obj_read_lock() and obj_read_unlock() may also be used to protect other\n  * section which cannot execute in parallel with object reading. Since the used\n@@ -431,13 +437,6 @@ enum for_each_object_flags {\n \tFOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),\n };\n \n-\n-void *read_object_with_reference(struct repository *r,\n-\t\t\t\t const struct object_id *oid,\n-\t\t\t\t enum object_type required_type,\n-\t\t\t\t unsigned long *size,\n-\t\t\t\t struct object_id *oid_ret);\n-\n /* Compatibility wrappers, to be removed once Git 2.51 has been released. */\n #include \"repository.h\"\n \ndiff --git a/tree-walk.c b/tree-walk.c\nindex 766af99f466..e449a1320e5 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -90,7 +90,7 @@ void *fill_tree_descriptor(struct repository *r,\n \tvoid *buf = NULL;\n \n \tif (oid) {\n-\t\tbuf = read_object_with_reference(r, oid, OBJ_TREE, &size, NULL);\n+\t\tbuf = odb_read_object_peeled(r->objects, oid, OBJ_TREE, &size, NULL);\n \t\tif (!buf)\n \t\t\tdie(_(\"unable to read tree (%s)\"), oid_to_hex(oid));\n \t}\n@@ -611,7 +611,7 @@ int get_tree_entry(struct repository *r,\n \tunsigned long size;\n \tstruct object_id root;\n \n-\ttree = read_object_with_reference(r, tree_oid, OBJ_TREE, &size, &root);\n+\ttree = odb_read_object_peeled(r->objects, tree_oid, OBJ_TREE, &size, &root);\n \tif (!tree)\n \t\treturn -1;\n \n@@ -681,10 +681,8 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n \t\t\tunsigned long size;\n-\t\t\ttree = read_object_with_reference(r,\n-\t\t\t\t\t\t\t  &current_tree_oid,\n-\t\t\t\t\t\t\t  OBJ_TREE, &size,\n-\t\t\t\t\t\t\t  &root);\n+\t\t\ttree = odb_read_object_peeled(r->objects, &current_tree_oid,\n+\t\t\t\t\t\t      OBJ_TREE, &size, &root);\n \t\t\tif (!tree)\n \t\t\t\tgoto done;\n \n\n-- \n2.50.0.195.g74e6fc65d0.dirty\n\n"},{"id":"521050","messageId":"o6aswfyrrfgp3xytnnko6hmxiqowiwqbfmpto6nx4pvuvrzw66@ihcwxe4ek2ek","threadId":"63403","inReplyTo":"20250701-pks-object-store-wo-the-repository-v6-0-dbf3894ab4e2@pks.im","subject":"Re: [PATCH v6 00/17] object-store: carve out the object database subsystem","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-07-01T14:26:30Z","receivedAt":"2025-07-01T14:32:00Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/07/01 02:22PM, Patrick Steinhardt wrote:\n> Hi,\n> \n> this patch series refactors the object store subsystem to become more\n> self-contained by getting rid of `the_repository`. Instead of passing in\n> the repository explicitly, we start to pass in the object store itself,\n> which is in contrast to many other refactorings we did, but in line with\n> what we did for the ref store, as well.\n>\n> This series also starts to properly scope functions to the carved out\n> object database subsystem, which requires a bit of shuffling. This\n> allows us to have a short-and-sweet `odb_` prefix for functions and\n> prepares us for a future with pluggable object backends.\n\nNice to see the odb subsystem take shape and become more self-contained.\n\n> The series is structured as follows:\n> \n>   - Patches 1 to 3 rename `struct object_store` and `struct\n>     object_directory` as well as the code files.\n> \n>   - Patches 4 to 12 refactor \"odb.c\" to get rid of `the_repository`.\n> \n>   - Patches 13 to 17 adjust the name of remaining functions so that they\n>     can be clearly attributed to the ODB. I'm happy to kick these\n>     patches out of this series and resend them at a later point in case\n>     they create too much turmoil.\n> \n> This series is built on top of 6f84262c44a (The eleventh batch,\n> 2025-05-05) with ps/object-store-cleanup at 8a9e27be821 (object-store:\n> drop `repo_has_object_file()`, 2025-04-29) merged into it. There are a\n> couple of trivial conflicts when merged with \"seen\", I have appended the\n> merge conflict resolution as a patch at the end of this mail.\n\n[snip]\n \n> Changes in v6:\n>   - Fix a mis-merged comment.\n>   - A couple of commit message improvements.\n>   - Link to v5: https://lore.kernel.org/r/20250605-pks-object-store-wo-the-repository-v5-0-779d1c28774b@pks.im\n\nThe changes in the range-diff are good. This version looks good to me.\n\n-Justin\n"}]}