{"thread":{"id":"63561","subject":"[PATCH v4 01/17] object-store: rename `raw_object_store` to `object_database`","startedAt":"2025-06-02T10:27:21Z","lastAt":"2025-06-04T13:56:02Z","messageCount":23,"participants":["Patrick Steinhardt","Junio C Hamano","Toon Claes"],"isPatch":true,"patchVersion":4,"patchTotal":17},"messages":[{"id":"519409","messageId":"20250602-pks-object-store-wo-the-repository-v4-1-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:02Z","receivedAt":"2025-06-02T10:27: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 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519414","messageId":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250506-pks-object-store-wo-the-repository-v1-0-c05b82e7b126@pks.im","subject":"[PATCH v4 00/17] object-store: carve out the object database subsystem","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:01Z","receivedAt":"2025-06-02T10:27:21Z","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\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                                   | 472 ++++++++++++++++++++++++++++++++\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, 1452 insertions(+), 1298 deletions(-)\n\nRange-diff versus v3:\n\n 1:  043ce74ca7c =  1:  159c8dbbe70 object-store: rename `raw_object_store` to `object_database`\n 2:  9a723eebf54 !  2:  6b9fea59a10 object-store: rename `object_directory` to `odb_alternate`\n    @@ Metadata\n     Author: Patrick Steinhardt <ps@pks.im>\n     \n      ## Commit message ##\n    -    object-store: rename `object_directory` to `odb_alternate`\n    +    object-store: rename `object_directory` to `odb_source`\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    @@ Commit message\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    +    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     \n         In the future, this change allows us to easily introduce for example a\n    -    `odb_files_alternate` and other format-specific implementations.\n    +    `odb_files_source` and other format-specific implementations.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n     \n    @@ builtin/commit-graph.c: static int graph_verify(int argc, const char **argv, con\n      {\n      \tstruct commit_graph *graph = NULL;\n     -\tstruct object_directory *odb = NULL;\n    -+\tstruct odb_alternate *alternate = 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    @@ builtin/commit-graph.c: static int graph_verify(int argc, const char **argv, con\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    ++\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    @@ builtin/commit-graph.c: static int graph_verify(int argc, const char **argv, con\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    ++\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    @@ builtin/commit-graph.c: static int graph_write(int argc, const char **argv, cons\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    ++\tstruct odb_source *source = NULL;\n      \tint result = 0;\n      \tenum commit_graph_write_flags flags = 0;\n      \tstruct progress *progress = NULL;\n    @@ builtin/commit-graph.c: static int graph_write(int argc, const char **argv, cons\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    ++\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(alternate, 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    @@ builtin/commit-graph.c: static int graph_write(int argc, const char **argv, cons\n      \t}\n      \n     -\tif (write_commit_graph(odb,\n    -+\tif (write_commit_graph(alternate,\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,\n    @@ builtin/count-objects.c: static int count_cruft(const char *basename UNUSED, con\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    ++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    @@ builtin/fetch.c: int cmd_fetch(int argc,\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\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);\n    @@ builtin/fsck.c: int cmd_fsck(int argc,\n      {\n      \tint i;\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *source;\n      \n      \t/* fsck knows how to handle missing promisor objects */\n      \tfetch_if_missing = 0;\n    @@ builtin/fsck.c: int cmd_fsck(int argc,\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    ++\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    @@ builtin/fsck.c: int cmd_fsck(int argc,\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\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\", alternate->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    @@ builtin/fsck.c: int cmd_fsck(int argc,\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\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\", alternate->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\n     \n      ## builtin/gc.c ##\n    -@@ builtin/gc.c: struct repository *repo UNUSED)\n    +@@ builtin/gc.c: 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->alternates,\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    @@ builtin/gc.c: static int loose_object_auto_condition(struct gc_config *cfg UNUSE\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    ++\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    @@ builtin/gc.c: static int pack_loose(struct maintenance_run_opts *opts)\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    ++\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    @@ builtin/gc.c: static int pack_loose(struct maintenance_run_opts *opts)\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    ++\tstrvec_pushf(&pack_proc.args, \"%s/pack/loose\", r->objects->sources->path);\n      \n      \tpack_proc.in = -1;\n      \n    @@ builtin/gc.c: static int pack_loose(struct maintenance_run_opts *opts)\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    ++\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    @@ builtin/gc.c: static int maintenance_run_tasks(struct maintenance_run_opts *opts\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    ++\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    @@ builtin/gc.c: static int update_background_schedule(const struct maintenance_sta\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    ++\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)\n    @@ builtin/grep.c: static int grep_submodule(struct grep_opt *opt,\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    ++\tadd_submodule_odb_by_path(subrepo->objects->sources->path);\n      \tobj_read_unlock();\n      \n      \tmemcpy(&subopt, opt, sizeof(subopt));\n    @@ builtin/multi-pack-index.c: int cmd_multi_pack_index(int argc,\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    ++\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);\n    @@ builtin/submodule--helper.c: static const char alternate_error_advice[] = 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    ++\t\tstruct odb_source *alt_odb, void *sas_cb)\n      {\n      \tstruct submodule_alternate_setup *sas = sas_cb;\n      \tsize_t len;\n    @@ bundle.c: int verify_bundle(struct repository *r,\n      \t};\n      \n     -\tif (!r || !r->objects || !r->objects->odb)\n    -+\tif (!r || !r->objects || !r->objects->alternates)\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++) {\n    @@ commit-graph.c: void git_test_write_commit_graph_or_die(void)\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    ++\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    @@ commit-graph.c: static int commit_gen_cmp(const void *va, const void *vb)\n      }\n      \n     -char *get_commit_graph_filename(struct object_directory *obj_dir)\n    -+char *get_commit_graph_filename(struct odb_alternate *alternate)\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\", alternate->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_alternate *alternate,\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\", alternate->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_alternate *alternate)\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\", alternate->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    @@ commit-graph.c: int open_commit_graph(const char *graph_file, int *fd, struct st\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    ++\t\t\t\t\t\t struct odb_source *source)\n      {\n      \tvoid *graph_map;\n      \tsize_t graph_size;\n    @@ commit-graph.c: struct commit_graph *load_commit_graph_one_fd_st(struct reposito\n      \n      \tif (ret)\n     -\t\tret->odb = odb;\n    -+\t\tret->alternate = alternate;\n    ++\t\tret->odb_source = source;\n      \telse\n      \t\tmunmap(graph_map, graph_size);\n      \n    @@ commit-graph.c: struct commit_graph *parse_commit_graph(struct repo_settings *s,\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    ++\t\t\t\t\t\t  struct odb_source *source)\n      {\n      \n      \tstruct stat st;\n    @@ commit-graph.c: static struct commit_graph *load_commit_graph_one(struct reposit\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    ++\tg = load_commit_graph_one_fd_st(r, fd, &st, source);\n      \n      \tif (g)\n      \t\tg->filename = xstrdup(graph_file);\n    @@ commit-graph.c: static struct commit_graph *load_commit_graph_one(struct reposit\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    ++\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(alternate);\n    -+\tstruct commit_graph *g = load_commit_graph_one(r, graph_name, alternate);\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    @@ commit-graph.c: struct commit_graph *load_commit_graph_chain_fd_st(struct reposi\n      \n      \tfor (i = 0; i < count; i++) {\n     -\t\tstruct object_directory *odb;\n    -+\t\tstruct odb_alternate *alternate;\n    ++\t\tstruct odb_source *source;\n      \n      \t\tif (strbuf_getline_lf(&line, fp) == EOF)\n      \t\t\tbreak;\n    @@ commit-graph.c: struct commit_graph *load_commit_graph_chain_fd_st(struct reposi\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    ++\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    @@ commit-graph.c: struct commit_graph *load_commit_graph_chain_fd_st(struct reposi\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    ++\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(alternate);\n    ++\tchar *chain_file = get_commit_graph_chain_filename(source);\n      \tstruct stat st;\n      \tint fd;\n      \tstruct commit_graph *g = NULL;\n    @@ commit-graph.c: static struct commit_graph *load_commit_graph_chain(struct repos\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    ++\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, alternate);\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, alternate);\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_alternate *alternate)\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, alternate);\n    ++\tr->objects->commit_graph = read_commit_graph_one(r, source);\n      }\n      \n      /*\n    @@ commit-graph.c: static void prepare_commit_graph_one(struct repository *r,\n      static int prepare_commit_graph(struct repository *r)\n      {\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\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    @@ commit-graph.c: static int prepare_commit_graph(struct repository *r)\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    ++\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    @@ commit-graph.c: struct packed_commit_list {\n      struct write_commit_graph_context {\n      \tstruct repository *r;\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *odb_source;\n      \tchar *graph_name;\n      \tstruct oid_array oids;\n      \tstruct packed_commit_list commits;\n    @@ commit-graph.c: static int add_ref_to_set(const char *refname UNUSED,\n      }\n      \n     -int write_commit_graph_reachable(struct object_directory *odb,\n    -+int write_commit_graph_reachable(struct odb_alternate *alternate,\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    @@ commit-graph.c: int write_commit_graph_reachable(struct object_directory *odb,\n      \tstop_progress(&data.progress);\n      \n     -\tresult = write_commit_graph(odb, NULL, &commits,\n    -+\tresult = write_commit_graph(alternate, NULL, &commits,\n    ++\tresult = write_commit_graph(source, NULL, &commits,\n      \t\t\t\t    flags, opts);\n      \n      \toidset_clear(&commits);\n    @@ commit-graph.c: static int fill_oids_from_packs(struct write_commit_graph_contex\n      \tint ret = 0;\n      \n     -\tstrbuf_addf(&packname, \"%s/pack/\", ctx->odb->path);\n    -+\tstrbuf_addf(&packname, \"%s/pack/\", ctx->alternate->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    @@ commit-graph.c: static int write_commit_graph_file(struct write_commit_graph_con\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\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->alternate);\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    @@ commit-graph.c: static int write_commit_graph_file(struct write_commit_graph_con\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    ++\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    @@ commit-graph.c: static int write_commit_graph_file(struct write_commit_graph_con\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    ++\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    @@ commit-graph.c: static int write_commit_graph_file(struct write_commit_graph_con\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\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    @@ commit-graph.c: static int write_commit_graph_file(struct write_commit_graph_con\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\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    @@ commit-graph.c: static void split_graph_merge_strategy(struct write_commit_graph\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\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    @@ commit-graph.c: static void split_graph_merge_strategy(struct write_commit_graph\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    ++\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->alternate != ctx->alternate) {\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    @@ commit-graph.c: static void expire_commit_graphs(struct write_commit_graph_conte\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\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->alternate->path);\n    ++\tstrbuf_addstr(&path, ctx->odb_source->path);\n      \tstrbuf_addstr(&path, \"/info/commit-graphs\");\n      \tdir = opendir(path.buf);\n      \n    @@ commit-graph.c: static void expire_commit_graphs(struct write_commit_graph_conte\n      }\n      \n     -int write_commit_graph(struct object_directory *odb,\n    -+int write_commit_graph(struct odb_alternate *alternate,\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     @@ commit-graph.c: 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;\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,\n     \n      ## commit-graph.h ##\n     @@ commit-graph.h: struct repository;\n    @@ commit-graph.h: struct repository;\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    ++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    @@ commit-graph.h: struct commit_graph {\n      \tstruct object_id oid;\n      \tchar *filename;\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *odb_source;\n      \n      \tuint32_t num_commits_in_base;\n      \tunsigned int read_generation_data;\n    @@ commit-graph.h: struct commit_graph {\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    ++\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_alternate *alternate);\n    ++\t\t\t\t\t   struct odb_source *source);\n      \n      struct repo_settings;\n      \n    @@ commit-graph.h: struct commit_graph_opts {\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    ++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_alternate *alternate,\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,\n    @@ diagnose.c: static void dir_file_stats_objects(const char *full_path,\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    ++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\", alternate->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(alternate->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    @@ 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->odb, &buf);\n    -+\tdir_file_stats(r->objects->alternates, &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      \n    @@ http-walker.c: static int fetch_object(struct walker *walker, const struct objec\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\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}\n    @@ http.c: struct http_object_request *new_http_object_request(const char *base_url\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    ++\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    @@ http.c: int finish_http_object_request(struct http_object_request *freq)\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    ++\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      \n    @@ loose.c: static int insert_oid_pair(kh_oid_map_t *map, const struct object_id *k\n      }\n      \n     -static int insert_loose_map(struct object_directory *odb,\n    -+static int insert_loose_map(struct odb_alternate *alternate,\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 = alternate->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(alternate->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_alternate *alternate)\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    @@ loose.c: static int insert_oid_pair(kh_oid_map_t *map, const struct object_id *k\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    ++\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(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    ++\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    @@ loose.c: static int load_one_loose_object_map(struct repository *repo, struct ob\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\tinsert_loose_map(source, &oid, &compat_oid);\n      \t}\n      \n      \tstrbuf_release(&buf);\n    @@ loose.c: static int load_one_loose_object_map(struct repository *repo, struct ob\n      int repo_read_loose_object_map(struct repository *repo)\n      {\n     -\tstruct object_directory *dir;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *source;\n      \n      \tif (!should_use_loose_object_map(repo))\n      \t\treturn 0;\n    @@ loose.c: static int load_one_loose_object_map(struct repository *repo, struct ob\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    ++\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    @@ loose.c: int repo_read_loose_object_map(struct repository *repo)\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    ++\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    @@ loose.c: int repo_add_loose_object_map(struct repository *repo, const struct obj\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    ++\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    @@ loose.c: int repo_loose_object_map_oid(struct repository *repo,\n      \t\t\t      struct object_id *dest)\n      {\n     -\tstruct object_directory *dir;\n    -+\tstruct odb_alternate *alternate;\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 (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n    -+\t\tstruct loose_object_map *loose_map = alternate->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) ?\n    @@ midx.c: void clear_midx_file(struct repository *r)\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    ++\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    @@ midx.c: void clear_midx_file(struct repository *r)\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    ++\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      }\n    @@ object-file.c: static void fill_loose_path(struct strbuf *buf, const struct obje\n      }\n      \n     -const char *odb_loose_path(struct object_directory *odb,\n    -+const char *odb_loose_path(struct odb_alternate *alternate,\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, alternate->path);\n    ++\tstrbuf_addstr(buf, source->path);\n      \tstrbuf_addch(buf, '/');\n      \tfill_loose_path(buf, oid);\n      \treturn buf->buf;\n    @@ object-file.c: int check_and_freshen_file(const char *fn, int freshen)\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    ++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(alternate, &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->alternates, 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_alternate *alternate;\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 (alternate = the_repository->objects->alternates->next; alternate; alternate = alternate->next) {\n    -+\t\tif (check_and_freshen_odb(alternate, 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    @@ object-file.c: int stream_object_signature(struct repository *r, const struct ob\n      \t\t\t     struct stat *st, const char **path)\n      {\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\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 (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    -+\t\t*path = odb_loose_path(alternate, &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    @@ object-file.c: static int open_loose_object(struct repository *r,\n      {\n      \tint fd;\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\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 (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    -+\t\t*path = odb_loose_path(alternate, &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    @@ object-file.c: static int open_loose_object(struct repository *r,\n      \t\t\t   const struct object_id *oid)\n      {\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\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 (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    -+\t\tif (oidtree_contains(odb_loose_cache(alternate, 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    @@ object-file.c: void hash_object_file(const struct git_hash_algo *algo, const voi\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    ++\tif (the_repository->objects->sources->will_destroy)\n      \t\tgoto out;\n      \n      \tif (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))\n    @@ object-file.c: static int write_loose_object(const struct object_id *oid, char *\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    ++\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    @@ object-file.c: int stream_loose_object(struct input_stream *in_stream, size_t le\n      \t}\n      \n     -\todb_loose_path(the_repository->objects->odb, &filename, oid);\n    -+\todb_loose_path(the_repository->objects->alternates, &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    @@ object-file.c: int for_each_loose_file_in_objdir(const char *path,\n      \t\t\t  enum for_each_object_flags flags)\n      {\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\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 (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next) {\n    -+\t\tint r = for_each_loose_file_in_objdir(alternate->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    @@ object-file.c: static int append_loose_object(const struct object_id *oid,\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    ++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(alternate->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(alternate->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 = &alternate->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 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\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, alternate->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    alternate->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 alternate->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_alternate *alternate)\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(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    ++\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,\n    @@ object-file.h: enum {\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    ++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_alternate *alternate,\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_alternate *alternate);\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_alternate *alternate,\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    @@ object-name.c: static enum cb_next match_prefix(const struct object_id *oid, voi\n      static void find_short_object_filename(struct disambiguate_state *ds)\n      {\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\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 (alternate = ds->repo->objects->alternates; alternate && !ds->ambiguous; alternate = alternate->next)\n    -+\t\toidtree_each(odb_loose_cache(alternate, &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      \n    @@ object-store.c\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    ++\tstruct odb_source *, 1, fspathhash, fspatheq)\n      \n      /*\n       * This is meant to hold a *small* number of objects that you would\n    @@ object-store.c: static int alt_odb_usable(struct object_database *o,\n      \t * thing twice, or object directory itself.\n      \t */\n     -\tif (!o->odb_by_path) {\n    -+\tif (!o->alternate_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->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\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->alternate_by_path, p) = o->alternates;\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->alternate_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    @@ object-store.c: static int alt_odb_usable(struct object_database *o,\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    ++ * 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    @@ object-store.c: static void read_info_alternates(struct repository *r,\n      \tconst char *relative_base, int depth, const char *normalized_objdir)\n      {\n     -\tstruct object_directory *ent;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *alternate;\n      \tstruct strbuf pathbuf = STRBUF_INIT;\n      \tstruct strbuf tmp = STRBUF_INIT;\n      \tkhiter_t pos;\n    @@ object-store.c: static int link_alt_odb_entry(struct repository *r, const struct\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    ++\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    @@ object-store.c: static int link_alt_odb_entry(struct repository *r, const struct\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    ++\t*r->objects->sources_tail = alternate;\n    ++\tr->objects->sources_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(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    @@ object-store.c: static void link_alt_odb_entries(struct repository *r, const cha\n      \t}\n      \n     -\tstrbuf_realpath(&objdirbuf, r->objects->odb->path, 1);\n    -+\tstrbuf_realpath(&objdirbuf, r->objects->alternates->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    @@ object-store.c: void add_to_alternates_memory(const char *reference)\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    ++struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n      {\n     -\tstruct object_directory *new_odb;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *source;\n      \n      \t/*\n      \t * Make sure alternates are initialized, or else our entry may be\n    @@ object-store.c: struct object_directory *set_temporary_primary_odb(const char *d\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    ++\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    @@ object-store.c: struct object_directory *set_temporary_primary_odb(const char *d\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    ++\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_alternate *alternate)\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(alternate->path);\n    -+\todb_clear_loose_cache(alternate);\n    -+\tloose_object_map_clear(&alternate->loose_map);\n    -+\tfree(alternate);\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_alternate *restore_alt, 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_alternate *cur_alt = the_repository->objects->alternates;\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    @@ object-store.c: struct object_directory *set_temporary_primary_odb(const char *d\n      \n     -\tthe_repository->objects->odb = restore_odb;\n     -\tfree_object_directory(cur_odb);\n    -+\tthe_repository->objects->alternates = restore_alt;\n    ++\tthe_repository->objects->sources = restore_alt;\n     +\tfree_object_directory(cur_alt);\n      }\n      \n    @@ object-store.c: char *compute_alternate_path(const char *path, struct strbuf *er\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    ++struct odb_source *find_odb(struct repository *r, const char *obj_dir)\n      {\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\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 (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    -+\t\tstrbuf_realpath(&odb_path_real, alternate->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    @@ object-store.c: struct object_directory *find_odb(struct repository *r, const ch\n      \tstrbuf_release(&odb_path_real);\n      \n     -\tif (!odb)\n    -+\tif (!alternate)\n    ++\tif (!source)\n      \t\tdie(_(\"could not find object directory matching %s\"), obj_dir);\n     -\treturn odb;\n    -+\treturn alternate;\n    ++\treturn source;\n      }\n      \n      static void fill_alternate_refs_command(struct child_process *cmd,\n    @@ object-store.c: struct alternate_refs_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    ++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    @@ object-store.c: void for_each_alternate_ref(alternate_ref_fn fn, void *data)\n      int foreach_alt_odb(alt_odb_fn fn, void *cb)\n      {\n     -\tstruct object_directory *ent;\n    -+\tstruct odb_alternate *alternate;\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->alternates->next; alternate; alternate = alternate->next) {\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    @@ object-store.c: void prepare_alt_odb(struct repository *r)\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    ++\tread_info_alternates(r, r->objects->sources->path, 0);\n      \tr->objects->loaded_alternates = 1;\n      }\n      \n    @@ object-store.c: void prepare_alt_odb(struct repository *r)\n      {\n      \tprepare_alt_odb(r);\n     -\treturn !!r->objects->odb->next;\n    -+\treturn !!r->objects->alternates->next;\n    ++\treturn !!r->objects->sources->next;\n      }\n      \n      int obj_read_use_lock = 0;\n    @@ object-store.c: struct object_database *odb_new(void)\n      {\n     -\twhile (o->odb) {\n     -\t\tstruct object_directory *next;\n    -+\twhile (o->alternates) {\n    -+\t\tstruct odb_alternate *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->alternates->next;\n    -+\t\tfree_object_directory(o->alternates);\n    -+\t\to->alternates = 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->alternate_by_path);\n    -+\to->alternate_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    @@ object-store.c: void odb_clear(struct object_database *o)\n      \n      \tfree_object_directories(o);\n     -\to->odb_tail = NULL;\n    -+\to->alternates_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++)\n    @@ object-store.h: struct oidtree;\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    ++ * 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 alternates, and\n    -+ * exactly one primary alternate that is used when writing new objects.\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_alternate {\n    -+\tstruct odb_alternate *next;\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    +@@ object-store.h: 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     @@ object-store.h: 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    ++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    @@ object-store.h: void add_to_alternates_memory(const char *dir);\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    ++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_alternate *restore_alternate, 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    @@ object-store.h: struct object_database {\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    ++\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    @@ object-store.h: struct object_database {\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 * populate the \"sources\" list when prepare_alt_odb() is run.\n      \t */\n      \tchar *alternate_db;\n      \n    @@ packfile.c: static void prepare_packed_git_mru(struct repository *r)\n      static void prepare_packed_git(struct repository *r)\n      {\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *source;\n      \n      \tif (r->objects->packed_git_initialized)\n      \t\treturn;\n    @@ packfile.c: static void prepare_packed_git_mru(struct repository *r)\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    ++\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    @@ packfile.c: static void prepare_packed_git(struct repository *r)\n      void reprepare_packed_git(struct repository *r)\n      {\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *source;\n      \n      \tobj_read_lock();\n      \n    @@ packfile.c: void reprepare_packed_git(struct repository *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    ++\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;\n    @@ path.c: static void adjust_git_path(struct repository *repo,\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    ++\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)\n    @@ refs.c: int ref_transaction_prepare(struct ref_transaction *transaction,\n      \t}\n      \n     -\tif (refs->repo->objects->odb->disable_ref_updates) {\n    -+\tif (refs->repo->objects->alternates->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;\n    @@ repository.c: const char *repo_get_common_dir(struct repository *repo)\n      const char *repo_get_object_directory(struct repository *repo)\n      {\n     -\tif (!repo->objects->odb)\n    -+\tif (!repo->objects->alternates)\n    ++\tif (!repo->objects->sources)\n      \t\tBUG(\"repository hasn't been set up\");\n     -\treturn repo->objects->odb->path;\n    -+\treturn repo->objects->alternates->path;\n    ++\treturn repo->objects->sources->path;\n      }\n      \n      const char *repo_get_index_file(struct repository *repo)\n    @@ repository.c: void repo_set_gitdir(struct repository *repo,\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    ++\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->alternates->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->alternates->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);\n    @@ submodule-config.c: static void config_from_gitmodules(config_fn_t fn, struct re\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\t\tadd_submodule_odb_by_path(repo->objects->sources->path);\n      \t\t} else {\n      \t\t\tgoto out;\n      \t\t}\n    @@ t/helper/test-read-graph.c: static void dump_graph_bloom_filters(struct commit_g\n      {\n      \tstruct commit_graph *graph = NULL;\n     -\tstruct object_directory *odb;\n    -+\tstruct odb_alternate *alternate;\n    ++\tstruct odb_source *source;\n      \tint ret = 0;\n      \n      \tsetup_git_directory();\n     -\todb = the_repository->objects->odb;\n    -+\talternate = the_repository->objects->alternates;\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, alternate);\n    ++\tgraph = read_commit_graph_one(the_repository, source);\n      \tif (!graph) {\n      \t\tret = 1;\n      \t\tgoto done;\n    @@ tmp-objdir.c: struct tmp_objdir {\n      \tstruct strbuf path;\n      \tstruct strvec env;\n     -\tstruct object_directory *prev_odb;\n    -+\tstruct odb_alternate *prev_alt;\n    ++\tstruct odb_source *prev_source;\n      \tint will_destroy;\n      };\n      \n    @@ tmp-objdir.c: int tmp_objdir_destroy(struct tmp_objdir *t)\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    ++\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    @@ tmp-objdir.c: int tmp_objdir_migrate(struct tmp_objdir *t)\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    ++\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_alt, t->path.buf);\n    -+\t\tt->prev_alt = 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    @@ tmp-objdir.c: void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)\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    ++\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_alt = 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_alt)\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_alt, the_tmp_objdir->path.buf);\n    -+\tthe_tmp_objdir->prev_alt = 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 3:  c9fe7a702f2 =  3:  f294d140f35 object-store: rename files to \"odb.{c,h}\"\n 4:  2d35bc630b1 !  4:  b9cd65d68e3 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_alternate`. In some cases though we'll need access to the\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_alternate` to its owning object\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     \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    -    alternate there. The callchain is adapted to pass through the object\n    +    source there. The callchain is adapted to pass through the object\n         database accordingly.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\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_alternate *alternate;\n    + \tstruct odb_source *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      \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->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    +-\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->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    +-\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    @@ 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->alternates->path, 1);\n    -+\tstrbuf_realpath(&objdirbuf, odb->alternates->path, 1);\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    @@ odb.c: void add_to_alternates_memory(const char *reference)\n      \t\t\t     '\\n', NULL, 0);\n      }\n      \n    -@@ odb.c: struct odb_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n    +@@ odb.c: struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy)\n      \t * alternate\n      \t */\n    - \talternate = xcalloc(1, sizeof(*alternate));\n    -+\talternate->odb = the_repository->objects;\n    - \talternate->path = xstrdup(dir);\n    + \tsource = xcalloc(1, sizeof(*source));\n    ++\tsource->odb = the_repository->objects;\n    + \tsource->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->alternates->path, 0);\n    -+\tread_info_alternates(r->objects, r->objects->alternates->path, 0);\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    @@ odb.c: void assert_oid_type(const struct object_id *oid, enum object_type expect\n     \n      ## odb.h ##\n     @@ odb.h: struct repository;\n    - struct odb_alternate {\n    - \tstruct odb_alternate *next;\n    + struct odb_source {\n    + \tstruct odb_source *next;\n      \n    -+\t/* Object database that owns this alternate. */\n    ++\t/* Object database that owns this object source. */\n     +\tstruct object_database *odb;\n     +\n      \t/*\n    @@ repository.c: static void set_default_hash_algo(struct repository *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    + \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->alternates->path, o->object_dir,\n    + \texpand_base_dir(&repo->objects->sources->path, o->object_dir,\n 5:  7ed8aaa8e94 <  -:  ----------- odb: get rid of `the_repository` in `find_odb()`\n -:  ----------- >  5:  ca3b9e62e03 odb: get rid of `the_repository` in `find_odb()`\n 6:  3cad18408a7 =  6:  36c9802f66c odb: get rid of `the_repository` in `assert_oid_type()`\n 7:  2b69ee1249b !  7:  7dcf630c701 odb: get rid of `the_repository` in `odb_mkstemp()`\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_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\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 8:  cd36a4906a9 !  8:  2d3a4a958d7 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 (alternate = the_repository->objects->alternates; alternate; alternate = alternate->next)\n    - \t\t\tfsck_object_dir(alternate->path);\n    + \t\tfor (source = the_repository->objects->sources; source; source = source->next)\n    + \t\t\tfsck_object_dir(source->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 (alternate = the_repository->objects->alternates; alternate; alternate = alternate->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     @@ 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 (alternate = the_repository->objects->alternates; alternate; alternate = alternate->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     \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_alternate *alternate;\n    + \t\tstruct odb_source *source;\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 (alternate = r->objects->alternates;\n    - \t     !r->objects->commit_graph && alternate;\n    - \t     alternate = alternate->next)\n    + \tfor (source = r->objects->sources;\n    + \t     !r->objects->commit_graph && source;\n    + \t     source = source->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 (alternate = repo->objects->alternates; alternate; alternate = alternate->next) {\n    - \t\tif (load_one_loose_object_map(repo, alternate) < 0) {\n    + \tfor (source = repo->objects->sources; source; source = source->next) {\n    + \t\tif (load_one_loose_object_map(repo, source) < 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_alternate *alternate;\n    + \tstruct odb_source *source;\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    + \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     @@ object-file.c: static int stat_loose_object(struct repository *r, const struct object_id *oid,\n    - \tstruct odb_alternate *alternate;\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 (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    - \t\t*path = odb_loose_path(alternate, &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     @@ 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 (alternate = r->objects->alternates; alternate; alternate = alternate->next) {\n    - \t\t*path = odb_loose_path(alternate, &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     @@ object-file.c: static int quick_has_loose(struct repository *r,\n      {\n    - \tstruct odb_alternate *alternate;\n    + \tstruct odb_source *source;\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    + \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     @@ object-file.c: int for_each_loose_object(each_loose_object_fn cb, void *data,\n      {\n    - \tstruct odb_alternate *alternate;\n    + \tstruct odb_source *source;\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    + \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     \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_alternate *set_temporary_primary_odb(const char *dir, int will_destro\n    +@@ odb.c: 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    @@ odb.c: struct odb_alternate *set_temporary_primary_odb(const char *dir, int will\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_alternate *restore_alt, const char *old_path\n    +@@ odb.c: void restore_primary_odb(struct odb_source *restore_alt, const char *old_path)\n      \tfree_object_directory(cur_alt);\n      }\n      \n    @@ odb.c: void restore_primary_odb(struct odb_alternate *restore_alt, const char *o\n      char *compute_alternate_path(const char *path, struct strbuf *err)\n      {\n      \tchar *ref_git = NULL;\n    -@@ odb.c: struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n    +@@ odb.c: 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 (alternate = odb->alternates; alternate; alternate = alternate->next) {\n    - \t\tstrbuf_realpath(&odb_path_real, alternate->path, 1);\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     @@ odb.c: int foreach_alt_odb(alt_odb_fn fn, void *cb)\n    - \tstruct odb_alternate *alternate;\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->alternates->next; alternate; alternate = alternate->next) {\n    + \tfor (alternate = the_repository->objects->sources->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    @@ 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->alternates->path, 0);\n    +-\tread_info_alternates(r->objects, r->objects->sources->path, 0);\n     -\tr->objects->loaded_alternates = 1;\n    -+\tread_info_alternates(odb, odb->alternates->path, 0);\n    ++\tread_info_alternates(odb, odb->sources->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->alternates->next;\n    +-\treturn !!r->objects->sources->next;\n     +\todb_prepare_alternates(odb);\n    -+\treturn !!odb->alternates->next;\n    ++\treturn !!odb->sources->next;\n      }\n      \n      int obj_read_use_lock = 0;\n    @@ odb.h: struct oidtree;\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    +  * 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    -@@ odb.h: struct odb_alternate {\n    +@@ odb.h: 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_alternate *, void *);\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    @@ 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 \"alternates\" list when prepare_alt_odb() is run.\n    -+\t * populate the \"alternates\" list when odb_prepare_alternates() is run.\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    -@@ odb.h: struct odb_alternate *odb_find_alternate(struct object_database *odb, const char\n    +@@ odb.h: 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 backends for the given database by reading\n    -+ * \"objects/info/alternates\" and opening the respective alternates.\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    -+ * backend does not count as alternate.\n    ++ * source does not count as alternate.\n     + */\n     +int odb_has_alternates(struct object_database *odb);\n     +\n    @@ odb.h: struct odb_alternate *odb_find_alternate(struct object_database *odb, con\n     +\t\t\t\tconst char *dir);\n     +\n     +/*\n    -+ * Add the directory to the in-memory list of alternates (along with any\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    @@ packfile.c: static void prepare_packed_git(struct repository *r)\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    + \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     @@ 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 (alternate = r->objects->alternates; alternate; alternate = alternate->next)\n    - \t\todb_clear_loose_cache(alternate);\n    + \tfor (source = r->objects->sources; source; source = source->next)\n    + \t\todb_clear_loose_cache(source);\n     \n      ## submodule.c ##\n     @@ submodule.c: int register_all_submodule_odb_as_alternates(void)\n 9:  e69ccfe7434 !  9:  320f73f70e0 odb: get rid of `the_repository`  in `for_each()` functions\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->alternates, &buf);\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    @@ odb.c: static void read_alternate_refs(const char *path,\n     +\tvoid *payload;\n      };\n      \n    - static int refs_from_alternate_cb(struct odb_alternate *alternate,\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    @@ odb.c: static void read_alternate_refs(const char *path,\n      \n      \tif (!strbuf_realpath(&path, alternate->path, 0))\n      \t\tgoto out;\n    -@@ odb.c: static int refs_from_alternate_cb(struct odb_alternate *alternate,\n    +@@ odb.c: static int refs_from_alternate_cb(struct odb_source *alternate,\n      \t\tgoto out;\n      \tstrbuf_setlen(&path, base_len);\n      \n    @@ odb.c: static int refs_from_alternate_cb(struct odb_alternate *alternate,\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    + \tstruct odb_source *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    +-\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->alternates->next; alternate; alternate = alternate->next) {\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}\n     \n      ## odb.h ##\n    -@@ odb.h: struct odb_alternate {\n    +@@ odb.h: struct odb_source {\n      \tchar *path;\n      };\n      \n    --typedef int alt_odb_fn(struct odb_alternate *, void *);\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    @@ odb.h: struct odb_alternate {\n       * object directory; returns the former primary object directory.\n     @@ odb.h: void odb_clear(struct object_database *o);\n       */\n    - struct odb_alternate *odb_find_alternate(struct object_database *odb, const char *obj_dir);\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    @@ odb.h: void odb_clear(struct object_database *o);\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    ++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     +\n10:  271ab001cd6 <  -:  ----------- odb: get rid of `the_repository` when handling the primary alternate\n -:  ----------- > 10:  6a5991f3c90 odb: get rid of `the_repository` when handling the primary source\n11:  cfa2d832fd6 ! 11:  aa502131265 odb: get rid of `the_repository` when handling submodule alternates\n    @@ Metadata\n     Author: Patrick Steinhardt <ps@pks.im>\n     \n      ## Commit message ##\n    -    odb: get rid of `the_repository` when handling submodule alternates\n    +    odb: get rid of `the_repository` when handling submodule sources\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 alternate to our own object database so that the objects can be\n    +    object sources 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 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    +    each source and the object database will then eventually register all\n    +    submodule sources via `do_oid_object_info_extended()` in case it isn't\n    +    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 alternates is instead\n    +    Refactor the logic so that the list of submodule sources is instead\n         tracked in the object database itself. This allows us to lose the\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    +    condition of `r == the_repository` before registering submodule sources\n    +    as we only ever add submodule sources to `the_repository` anyway. As\n    +    such, behaviour before and after this refactoring should always be the\n    +    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->alternates->path);\n    -+\todb_add_submodule_alternate_by_path(the_repository->objects,\n    -+\t\t\t\t\t    subrepo->objects->alternates->path);\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));\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_alternate *odb_find_alternate(struct object_database *odb, const char\n    - \treturn alternate;\n    +@@ odb.c: struct odb_source *odb_find_source(struct object_database *odb, const char *obj_\n    + \treturn source;\n      }\n      \n    -+void odb_add_submodule_alternate_by_path(struct object_database *odb,\n    -+\t\t\t\t\t const char *path)\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_alternate_paths, path);\n    ++\tstring_list_insert(&odb->submodule_source_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     +static int register_all_submodule_alternates(struct object_database *odb)\n     +{\n    -+\tint ret = odb->submodule_alternate_paths.nr;\n    ++\tint ret = odb->submodule_source_paths.nr;\n     +\n    -+\tfor (size_t i = 0; i < odb->submodule_alternate_paths.nr; i++)\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_alternate_paths.items[i].string);\n    ++\t\t\t\t\t     odb->submodule_source_paths.items[i].string);\n     +\tif (ret) {\n    -+\t\tstring_list_clear(&odb->submodule_alternate_paths, 0);\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\tif (git_env_bool(\"GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB\", 0))\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_alternate_by_path()` on that submodule's\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    @@ 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_alternate_paths);\n    ++\tstring_list_init_dup(&o->submodule_source_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_alternate_paths, 0);\n    ++\tstring_list_clear(&o->submodule_source_paths, 0);\n      }\n     \n      ## odb.h ##\n     @@\n    - #include \"object.h\"\n      #include \"list.h\"\n      #include \"oidset.h\"\n    + #include \"oidmap.h\"\n     +#include \"string-list.h\"\n      #include \"thread-utils.h\"\n      \n    @@ odb.h: struct object_database {\n      \tunsigned packed_git_initialized : 1;\n     +\n     +\t/*\n    -+\t * Submodule alternate paths that will be added as alternatives to\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_alternate_paths;\n    ++\tstruct string_list submodule_source_paths;\n      };\n      \n      struct object_database *odb_new(struct repository *repo);\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    +@@ odb.h: 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_alternate_by_path() to add the submodule at the given\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 alternates in the object store when looking up objects.\n    ++ * added as additional sources 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    ++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    @@ 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->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\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}\n12:  9541cc16ed7 ! 12:  a9fdf3fbb8b 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_alternate_by_path(struct object_database *odb,\n    - \tstring_list_insert(&odb->submodule_alternate_paths, path);\n    +@@ odb.c: 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    @@ 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_alternate *alternate,\n    +@@ odb.c: static int refs_from_alternate_cb(struct odb_source *alternate,\n      \t\tgoto out;\n      \tstrbuf_setlen(&path, base_len);\n      \n    @@ odb.c: static int do_oid_object_info_extended(struct repository *r,\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    + \t\t\t*oi->contentp = xmemdupz(co->buf, co->size);\n    + \t\toi->whence = OI_CACHED;\n     @@ odb.c: static int oid_object_info_convert(struct repository *r,\n      \tvoid *content;\n      \tint ret;\n    @@ odb.c: static int oid_object_info_convert(struct repository *r,\n      \t}\n      \n     @@ odb.c: static int oid_object_info_convert(struct repository *r,\n    - \t\tif (type == -1)\n    - \t\t\treturn -1;\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,\n13:  c4b1c12476e ! 13:  3f0bdecc039 odb: rename `oid_object_info()`\n    @@ builtin/blame.c: static int peel_to_commit_oid(struct object_id *oid_ret, void *\n      \t\t\treturn 0;\n     \n      ## builtin/cat-file.c ##\n    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    +@@ builtin/cat-file.c: 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\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\tif (sb.len) {\n    - \t\t\tprintf(\"%s\\n\", sb.buf);\n    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    + \t\tprintf(\"%s\\n\", type_name(type));\n    + \t\tret = 0;\n    +@@ builtin/cat-file.c: 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    @@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const\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    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    +@@ builtin/cat-file.c: 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    @@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const\n      \t\tif (type < 0)\n      \t\t\tdie(\"Not a valid object name %s\", obj_name);\n      \n    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    +@@ builtin/cat-file.c: 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    @@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const\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    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    +@@ builtin/cat-file.c: 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    @@ odb.c: static int do_oid_object_info_extended(struct repository *r,\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    + \t\t\t*oi->contentp = xmemdupz(co->buf, co->size);\n    + \t\toi->whence = OI_CACHED;\n     @@ odb.c: static int do_oid_object_info_extended(struct repository *r,\n      \t}\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_alternate_by_path()` on that submodule's\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    @@ odb.h: 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    ++/* 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,\n14:  eeb31a420b0 ! 14:  644cd847670 odb: rename `repo_read_object_file()`\n    @@ builtin/cat-file.c: static int filter_object(const char *path, unsigned mode,\n      \tif (!*buf)\n      \t\treturn error(_(\"cannot read object %s '%s'\"),\n      \t\t\t     oid_to_hex(oid), path);\n    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    +@@ builtin/cat-file.c: 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    @@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const\n      \t\tif (!buf)\n      \t\t\tdie(\"Cannot read object %s\", obj_name);\n      \n    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    +@@ builtin/cat-file.c: 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) {\n15:  ab652070bc6 ! 15:  53812350b40 odb: rename `has_object()`\n    @@ builtin/backfill.c: static int fill_missing_blobs(const char *path UNUSED,\n      \n     \n      ## builtin/cat-file.c ##\n    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    +@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n      \t\tgoto cleanup;\n      \n      \tcase 'e':\n16:  580bfe7bc24 = 16:  bcbfd390398 odb: rename `pretend_object_file()`\n17:  b23d48d216a ! 17:  77f7e41f83f odb: rename `read_object_with_reference()`\n    @@ Documentation/user-manual.adoc: Now, for the meat:\n      the source.\n     \n      ## builtin/cat-file.c ##\n    -@@ builtin/cat-file.c: static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n    +@@ builtin/cat-file.c: 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    @@ odb.h: enum for_each_object_flags {\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    + /* Compatibility wrappers, to be removed once Git 2.51 has been released. */\n      #include \"repository.h\"\n      \n     \n\n---\nbase-commit: 7014b55638da979331baf8dc31c4e1d697cf2d67\nchange-id: 20250505-pks-object-store-wo-the-repository-9c6cbdf8d4b1\n\n"},{"id":"519410","messageId":"20250602-pks-object-store-wo-the-repository-v4-3-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 03/17] object-store: rename files to \"odb.{c,h}\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:04Z","receivedAt":"2025-06-02T10:27: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 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 a034a8f39e2..111584a0a09 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519412","messageId":"20250602-pks-object-store-wo-the-repository-v4-2-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 02/17] object-store: rename `object_directory` to `odb_source`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:03Z","receivedAt":"2025-06-02T10:27:23Z","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..a034a8f39e2 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 alternates 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519411","messageId":"20250602-pks-object-store-wo-the-repository-v4-4-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 04/17] odb: introduce parent pointers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:05Z","receivedAt":"2025-06-02T10:27:25Z","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 111584a0a09..f1c903d103c 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519413","messageId":"20250602-pks-object-store-wo-the-repository-v4-5-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 05/17] odb: get rid of `the_repository` in `find_odb()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:06Z","receivedAt":"2025-06-02T10:27: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 `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 f1c903d103c..a9e802f5831 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519415","messageId":"20250602-pks-object-store-wo-the-repository-v4-7-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 07/17] odb: get rid of `the_repository` in `odb_mkstemp()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:08Z","receivedAt":"2025-06-02T10:27: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 `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 7b64358d678..418a57a5487 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519416","messageId":"20250602-pks-object-store-wo-the-repository-v4-6-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 06/17] odb: get rid of `the_repository` in `assert_oid_type()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:07Z","receivedAt":"2025-06-02T10:27: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/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 a9e802f5831..7b64358d678 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519417","messageId":"20250602-pks-object-store-wo-the-repository-v4-9-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 09/17] odb: get rid of `the_repository` in `for_each()` functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:10Z","receivedAt":"2025-06-02T10:27:28Z","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 abe3d2c7a80..82ddbb71e46 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519418","messageId":"20250602-pks-object-store-wo-the-repository-v4-8-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 08/17] odb: get rid of `the_repository` when handling alternates","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:09Z","receivedAt":"2025-06-02T10:27:28Z","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 418a57a5487..abe3d2c7a80 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519419","messageId":"20250602-pks-object-store-wo-the-repository-v4-11-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 11/17] odb: get rid of `the_repository` when handling submodule sources","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:12Z","receivedAt":"2025-06-02T10:27: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 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..793903cb046 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_alternates(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_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@@ -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_alternates(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 5acfda88fa7..4e6029ec542 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@@ -190,6 +197,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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519420","messageId":"20250602-pks-object-store-wo-the-repository-v4-10-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 10/17] odb: get rid of `the_repository` when handling the primary source","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:11Z","receivedAt":"2025-06-02T10:27:29Z","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        | 25 ++++++++++++++-----------\n tmp-objdir.c | 10 ++++++----\n 3 files changed, 35 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 82ddbb71e46..5acfda88fa7 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,20 @@ 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 a previous backend replaced by `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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519421","messageId":"20250602-pks-object-store-wo-the-repository-v4-12-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 12/17] odb: trivial refactorings to get rid of `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:13Z","receivedAt":"2025-06-02T10:27:31Z","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 793903cb046..a13b9ecbbc9 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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519422","messageId":"20250602-pks-object-store-wo-the-repository-v4-13-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 13/17] odb: rename `oid_object_info()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:14Z","receivedAt":"2025-06-02T10:27: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 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 a13b9ecbbc9..cc1cc727346 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->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_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@@ -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 4e6029ec542..fd99bd593f7 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -264,9 +264,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@@ -335,9 +332,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@@ -359,7 +371,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@@ -367,7 +379,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@@ -415,4 +427,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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519423","messageId":"20250602-pks-object-store-wo-the-repository-v4-15-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 15/17] odb: rename `has_object()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:16Z","receivedAt":"2025-06-02T10:27:33Z","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 15f81401c9a..ad2a621698c 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 4a5c9eaf0a9..09cfd9e01f9 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -371,8 +371,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@@ -462,4 +463,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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519424","messageId":"20250602-pks-object-store-wo-the-repository-v4-14-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 14/17] odb: rename `repo_read_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:15Z","receivedAt":"2025-06-02T10:27:33Z","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 cc1cc727346..15f81401c9a 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 fd99bd593f7..4a5c9eaf0a9 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@@ -259,10 +259,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@@ -370,7 +379,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@@ -445,4 +454,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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519425","messageId":"20250602-pks-object-store-wo-the-repository-v4-17-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 17/17] odb: rename `read_object_with_reference()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:18Z","receivedAt":"2025-06-02T10:27:34Z","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 dd6b37eaa92..b6c087c1fe0 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 8eaa4ba7ba9..f629380f79f 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -273,6 +273,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@@ -381,7 +387,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@@ -430,13 +436,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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519426","messageId":"20250602-pks-object-store-wo-the-repository-v4-16-e986804a7c62@pks.im","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"[PATCH v4 16/17] odb: rename `pretend_object_file()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-02T10:27:17Z","receivedAt":"2025-06-02T10:27:34Z","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 ad2a621698c..dd6b37eaa92 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 09cfd9e01f9..8eaa4ba7ba9 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -281,9 +281,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.rc0.629.g846fc57c9e.dirty\n\n"},{"id":"519475","messageId":"xmqqy0uataqk.fsf@gitster.g","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-0-e986804a7c62@pks.im","subject":"Re: [PATCH v4 00/17] object-store: carve out the object database subsystem","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-06-02T15:38:11Z","receivedAt":"2025-06-02T15:38: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> 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 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\nAh, the original cover letter material that was more prominent is\nstill left before the changes per iteration lissted here, so I was\nscratching my head wondering why the series fails to apply at 02/17.\n\nWill try to read it through before queuing.\n\nThanks.\n"},{"id":"519645","messageId":"87a56n3myb.fsf@iotcl.com","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-1-e986804a7c62@pks.im","subject":"Re: [PATCH v4 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-06-04T08:55:40Z","receivedAt":"2025-06-04T08:55:55Z","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 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>\n> Signed-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>\n> diff --git a/commit-graph.c b/commit-graph.c\n> index 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;\n> diff --git a/commit-graph.h b/commit-graph.h\n> index 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>  /*\n> diff --git a/object-store.c b/object-store.c\n> index 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>  \n> diff --git a/object-store.h b/object-store.h\n> index 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\nThis still uses /old/ terminology. I think the \"backend\" should be\ncalled \"source\", and we can keep the \"alternates\"?\n\n-- \nCheers,\nToon\n"},{"id":"519655","messageId":"aEAzZLgPWCGwdpiE@pks.im","threadId":"63561","inReplyTo":"87a56n3myb.fsf@iotcl.com","subject":"Re: [PATCH v4 01/17] object-store: rename `raw_object_store` to `object_database`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-04T11:52:04Z","receivedAt":"2025-06-04T11:52:10Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Jun 04, 2025 at 10:55:40AM +0200, Toon Claes wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > diff --git a/object-store.h b/object-store.h\n> > index 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> This still uses /old/ terminology. I think the \"backend\" should be\n> called \"source\", and we can keep the \"alternates\"?\n\nThe term \"source\" doesn't yet exist in this commit. The next commit\ntouches the comment, but _that_ commit still uses the old \"alternate\"\nterm to talk about the sources. It's correct to say that those are\nconfigured via alternates, but the alternates do configure sources in\nthe ODB indeed.\n\nPatrick\n"},{"id":"519663","messageId":"875xhb3ahw.fsf@iotcl.com","threadId":"63561","inReplyTo":"20250602-pks-object-store-wo-the-repository-v4-2-e986804a7c62@pks.im","subject":"Re: [PATCH v4 02/17] object-store: rename `object_directory` to `odb_source`","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-06-04T13:24:43Z","receivedAt":"2025-06-04T13:24:55Z","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. 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>\n> In the future, this change allows us to easily introduce for example a\n> `odb_files_source` and other format-specific implementations.\n\nSorry for being pedantic (but I guess this series is all about naming\nanyway, so better get it right), but wouldn't this be\n`odb_files_backend`?\n\n-- \nCheers,\nToon\n"},{"id":"519666","messageId":"aEBQbWre85PSrWqt@pks.im","threadId":"63561","inReplyTo":"875xhb3ahw.fsf@iotcl.com","subject":"Re: [PATCH v4 02/17] object-store: rename `object_directory` to `odb_source`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-06-04T13:55:57Z","receivedAt":"2025-06-04T13:56:02Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Jun 04, 2025 at 03:24:43PM +0200, Toon Claes wrote:\n> 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. 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> >\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> Sorry for being pedantic (but I guess this series is all about naming\n> anyway, so better get it right), but wouldn't this be\n> `odb_files_backend`?\n\nMaybe, maybe not. In any case, we can still decide that at a later point\nin time -- it's only part of the commit message, so this part is not set\nin stone and can be discussed once we introduce such backends.\n\nPatrick\n"}]}