{"thread":{"id":"66584","subject":"[PATCH 0/7] odb: introduce object storage extension","startedAt":"2026-10-19T08:55:55Z","lastAt":"2026-10-28T11:31:01Z","messageCount":59,"participants":["Patrick Steinhardt","Karthik Nayak","Junio C Hamano","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"555398","messageId":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","threadId":"66584","inReplyTo":null,"subject":"[PATCH 0/7] odb: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-19T08:55:55Z","receivedAt":"2026-10-19T08:55:55Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series introduces the object storage extension. The extension\nis of course similar in spirit and design to the ref storage extension:\nit can be configured via \"extensions.objectStorage\", has the same syntax\nwith \"<schema>[://<payload>]\", and we have the same mechanisms to\nconfigure it (\"--object-storage-format=\", GIT_OBJECT_STORAGE_FORMAT,\nGIT_DEFAULT_OBJECT_STORAGE_FORMAT, \"init.defaultObjetcStorageFormat\").\n\nFor now, we only support the \"files\" object storage format, so not a lot\nof stuff really changes. That being said, its optional payload allows\nyou to configure a different location for the \".git/objects\" directory.\nSo if you specify \"extensions.objectStorage=files://objs\", objects would\nbe stored in \".git/objs\" instead.\n\nThe series is built on top of c51408889c (The 6th batch, 2026-10-16)\nwith the following dependencies merged into it:\n\n  - ps/odb-files-alternates at 0ba59c8453 (odb/source: drop\n    `read_alternates` callback, 2026-10-08) merged into it.\n\n  - ps/setup-enforce-repo-passed-to-create-repository-has-no-state\n    (phew, what a mouthful) at 0ba59c8453 (odb/source: drop\n    `read_alternates` callback, 2026-10-08).\n\nNote that these two series conflict with one another. The conflict can\neasily be resolved by just deleting the whole conflicting sections.\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (7):\n      loose: drop unused `repo_write_loose_object_map()`\n      setup: introduce object storage extension\n      setup: allow overriding object storage format via environment\n      builtin: expose the object storage format\n      builtin/init: introduce handling of object storage format\n      builtin/clone: introduce \"--object-storage-format=\"\n      builtin/submodule: propagate \"--object-storage-format=\"\n\n Documentation/config/extensions.adoc       |  23 +++\n Documentation/config/init.adoc             |   5 +\n Documentation/git-clone.adoc               |  11 ++\n Documentation/git-init.adoc                |  10 +-\n Documentation/git-repo.adoc                |   6 +\n Documentation/git-rev-parse.adoc           |   5 +\n Documentation/git-submodule.adoc           |  10 +-\n Documentation/git.adoc                     |  10 ++\n Documentation/object-storage-format.adoc   |   6 +\n builtin/clone.c                            |  58 +++++++-\n builtin/init-db.c                          |   7 +-\n builtin/repo.c                             |  10 ++\n builtin/rev-parse.c                        |   7 +\n builtin/submodule--helper.c                |  28 ++++\n environment.h                              |   1 +\n git-submodule.sh                           |  18 +++\n loose.c                                    |  46 ------\n loose.h                                    |   1 -\n odb.c                                      |   2 +-\n odb/source-files.c                         |   7 +\n odb/source-files.h                         |   1 +\n odb/source.c                               |  48 ++++++-\n odb/source.h                               |  12 +-\n repository.c                               |   8 ++\n repository.h                               |   8 ++\n setup.c                                    | 116 ++++++++++++++-\n setup.h                                    |   2 +\n t/meson.build                              |   1 +\n t/t0001-init.sh                            | 221 +++++++++++++++++++++++++++++\n t/t1900-repo-info.sh                       |   3 +\n t/t5601-clone.sh                           |  68 +++++++++\n t/t7427-submodule-object-storage-format.sh |  91 ++++++++++++\n 32 files changed, 788 insertions(+), 62 deletions(-)\n\n\n---\nbase-commit: 0d31382da9336683214372ba328fe9ecbc8bcb9a\nchange-id: 20261006-b4-pks-odb-extension-36de693bb943\n\n\n"},{"id":"555399","messageId":"20261019-b4-pks-odb-extension-v1-1-143a5963b77f@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH 1/7] loose: drop unused `repo_write_loose_object_map()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-19T08:55:56Z","receivedAt":"2026-10-19T08:55:56Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The function `repo_write_loose_object_map()` was introduced in\n23b2c7e95b (loose: add a mapping between SHA-1 and SHA-256 for loose\nobjects, 2023-10-01), but it never had any callers as loose object maps\nare instead written incrementally via `repo_add_loose_object_map()`\nwhenever a new loose object is created.\n\nBesides being dead code, the function also hardcodes the location of the\n\"loose-object-idx\" file as \"$GIT_COMMON_DIR/objects\", whereas both the\nreader and `repo_add_loose_object_map()` derive the location from the\nloose source's path. The function would thus disagree with everyone else\nwhere the loose object map is supposed to be located when the object\ndirectory is using a non-default location.\n\nRemove the function.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n loose.c | 46 ----------------------------------------------\n loose.h |  1 -\n 2 files changed, 47 deletions(-)\n\ndiff --git a/loose.c b/loose.c\nindex d6a2bb5ba3..7e26a04ec0 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -123,52 +123,6 @@ int repo_read_loose_object_map(struct repository *repo)\n \treturn 0;\n }\n \n-int repo_write_loose_object_map(struct repository *repo)\n-{\n-\tstruct odb_source_files *files = odb_source_files_downcast(repo->objects->source);\n-\tkh_oid_map_t *map = files->dirs->loose->map->to_compat;\n-\tstruct lock_file lock;\n-\tint fd;\n-\tkhiter_t iter;\n-\tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n-\n-\tif (!should_use_loose_object_map(repo))\n-\t\treturn 0;\n-\n-\trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n-\tfd = repo_hold_lock_file_for_update_timeout(repo, &lock, path.buf,\n-\t\t\t\t\t\t    LOCK_DIE_ON_ERROR, -1);\n-\titer = kh_begin(map);\n-\tif (write_in_full(fd, loose_object_header, strlen(loose_object_header)) < 0)\n-\t\tgoto errout;\n-\n-\tfor (; iter != kh_end(map); iter++) {\n-\t\tif (kh_exist(map, iter)) {\n-\t\t\tif (oideq(&kh_key(map, iter), repo->hash_algo->empty_tree) ||\n-\t\t\t    oideq(&kh_key(map, iter), repo->hash_algo->empty_blob))\n-\t\t\t\tcontinue;\n-\t\t\tstrbuf_addf(&buf, \"%s %s\\n\", oid_to_hex(&kh_key(map, iter)), oid_to_hex(kh_value(map, iter)));\n-\t\t\tif (write_in_full(fd, buf.buf, buf.len) < 0)\n-\t\t\t\tgoto errout;\n-\t\t\tstrbuf_reset(&buf);\n-\t\t}\n-\t}\n-\tstrbuf_release(&buf);\n-\tif (commit_lock_file(&lock) < 0) {\n-\t\terror_errno(_(\"could not write loose object index %s\"), path.buf);\n-\t\tstrbuf_release(&path);\n-\t\treturn -1;\n-\t}\n-\tstrbuf_release(&path);\n-\treturn 0;\n-errout:\n-\trollback_lock_file(&lock);\n-\tstrbuf_release(&buf);\n-\terror_errno(_(\"failed to write loose object index %s\"), path.buf);\n-\tstrbuf_release(&path);\n-\treturn -1;\n-}\n-\n static int write_one_object(struct odb_source_loose *loose,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\ndiff --git a/loose.h b/loose.h\nindex ed663ac550..41c4b46818 100644\n--- a/loose.h\n+++ b/loose.h\n@@ -22,6 +22,5 @@ int repo_add_loose_object_map(struct odb_source_loose *loose,\n \t\t\t      const struct object_id *oid,\n \t\t\t      const struct object_id *compat_oid);\n int repo_read_loose_object_map(struct repository *repo);\n-int repo_write_loose_object_map(struct repository *repo);\n \n #endif\n\n-- \n2.56.0.269.g68944adf51.dirty\n\n\n"},{"id":"555400","messageId":"20261019-b4-pks-odb-extension-v1-2-143a5963b77f@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH 2/7] setup: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-19T08:55:57Z","receivedAt":"2026-10-19T08:55:57Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Introduce a new \"extensions.objectStorage\" extension that allows the\nuser to configure the primary object database source of a repository.\nThe value is a URI in the format \"<schema>[://<payload>]\", mirroring\nthe format used by \"extensions.refStorage\":\n\n  - The schema identifies the backend that shall be used. For now the\n    only supported schema is \"files\", which is the existing object\n    database backed by loose objects and packfiles.\n\n  - The payload can be passed to configure the backend, and its\n    interpretation is backend-specific. For the \"files\" backend, it\n    allows you to configure a different location for the \".git/objects\"\n    directory.\n\nEventually, this mechanism will be used to support alternative backends.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/config/extensions.adoc     | 23 +++++++++++++++\n Documentation/object-storage-format.adoc |  6 ++++\n odb.c                                    |  2 +-\n odb/source-files.c                       |  7 +++++\n odb/source-files.h                       |  1 +\n odb/source.c                             | 48 +++++++++++++++++++++++++++++++-\n odb/source.h                             | 12 +++++++-\n repository.c                             |  8 ++++++\n repository.h                             |  8 ++++++\n setup.c                                  | 13 +++++++++\n setup.h                                  |  1 +\n t/t0001-init.sh                          | 30 ++++++++++++++++++++\n 12 files changed, 156 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config/extensions.adoc b/Documentation/config/extensions.adoc\nindex be6678bb5b..4f3a66a454 100644\n--- a/Documentation/config/extensions.adoc\n+++ b/Documentation/config/extensions.adoc\n@@ -56,6 +56,29 @@ preciousObjects:::\n For historical reasons, this extension is respected regardless of the\n `core.repositoryFormatVersion` setting.\n \n+objectStorage:::\n+\tSpecify the object storage format and a corresponding payload. The\n+\tvalue can be either a format name or a URI:\n++\n+--\n+* A format name alone (e.g., `files`).\n+\n+* A URI format `<format>://<payload>` explicitly specifies both the\n+  format and payload (e.g., `files:///foo/bar`).\n+\n+Supported formats are:\n+\n+include::../object-storage-format.adoc[]\n+\n+--\n++\n+Note that this setting should only be set by linkgit:git-init[1] or\n+linkgit:git-clone[1]. Trying to change it after initialization will make\n+preexisting objects inaccessible.\n++\n+NOTE: This extension is still considered EXPERIMENTAL and may be subject to\n+change.\n+\n refStorage:::\n \tSpecify the ref storage format and a corresponding payload. The value\n \tcan be either a format name or a URI:\ndiff --git a/Documentation/object-storage-format.adoc b/Documentation/object-storage-format.adoc\nnew file mode 100644\nindex 0000000000..4c4aef6dda\n--- /dev/null\n+++ b/Documentation/object-storage-format.adoc\n@@ -0,0 +1,6 @@\n+`files[://<path>]`;; for loose objects and packfiles. This is the default.\n++\n+The optional payload can be passed to specify an alternative filesystem path\n+where the objects will be stored. Relative paths are resolved relative to the\n+`$GIT_COMMON_DIR`. Defaults to `$GIT_COMMON_DIR/objects` when no payload is\n+provided. The payload is ignored when `GIT_OBJECT_DIRECTORY` is set.\ndiff --git a/odb.c b/odb.c\nindex 98c5c862f5..6c07b3b671 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -757,7 +757,7 @@ struct object_database *odb_new(struct repository *repo,\n \to->repo = repo;\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n \n-\to->source = odb_source_new(o, flags);\n+\to->source = odb_source_new(o, repo->object_storage_format, flags);\n \to->inmemory_objects = &odb_source_inmemory_new(o)->base;\n \n \treturn o;\ndiff --git a/odb/source-files.c b/odb/source-files.c\nindex 455f409db0..4a7cbbfd9b 100644\n--- a/odb/source-files.c\n+++ b/odb/source-files.c\n@@ -1235,6 +1235,7 @@ struct odb_files_dir *odb_source_files_find_dir(struct object_database *odb, con\n }\n \n struct odb_source_files *odb_source_files_new(struct object_database *odb,\n+\t\t\t\t\t      const char *payload,\n \t\t\t\t\t      enum odb_new_flags flags)\n {\n \tstruct odb_source_files *files;\n@@ -1245,6 +1246,12 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,\n \t\tobject_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));\n \t\talternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));\n \t}\n+\tif (!object_dir && payload) {\n+\t\tif (is_absolute_path(payload))\n+\t\t\tobject_dir = xstrdup(payload);\n+\t\telse\n+\t\t\tobject_dir = xstrfmt(\"%s/%s\", odb->repo->commondir, payload);\n+\t}\n \tif (!object_dir)\n \t\tobject_dir = xstrfmt(\"%s/objects\", odb->repo->commondir);\n \ndiff --git a/odb/source-files.h b/odb/source-files.h\nindex 837e890304..71e8db84ff 100644\n--- a/odb/source-files.h\n+++ b/odb/source-files.h\n@@ -70,6 +70,7 @@ struct odb_source_files {\n \n /* Allocate and initialize a new object source. */\n struct odb_source_files *odb_source_files_new(struct object_database *odb,\n+\t\t\t\t\t      const char *payload,\n \t\t\t\t\t      enum odb_new_flags flags);\n \n /*\ndiff --git a/odb/source.c b/odb/source.c\nindex b25ef14df8..10abe33a26 100644\n--- a/odb/source.c\n+++ b/odb/source.c\n@@ -1,4 +1,5 @@\n #include \"git-compat-util.h\"\n+#include \"gettext.h\"\n #include \"object-file.h\"\n #include \"odb/source-files.h\"\n #include \"odb/source.h\"\n@@ -23,10 +24,55 @@ const char *odb_source_type_to_name(enum odb_source_type type)\n \treturn name;\n }\n \n+static enum odb_source_type odb_source_type_by_name(const char *name)\n+{\n+\tif (!strcmp(name, \"files\"))\n+\t\treturn ODB_SOURCE_FILES;\n+\treturn ODB_SOURCE_UNKNOWN;\n+}\n+\n+enum odb_source_type odb_source_type_by_uri(const char *uri, char **payload)\n+{\n+\tenum odb_source_type type;\n+\tconst char *schema_end;\n+\tchar *name;\n+\n+\tschema_end = strstr(uri, \"://\");\n+\tif (!schema_end) {\n+\t\tname = xstrdup(uri);\n+\t\tif (payload)\n+\t\t\t*payload = NULL;\n+\t} else {\n+\t\tname = xstrndup(uri, schema_end - uri);\n+\t\tif (payload)\n+\t\t\t*payload = *(schema_end + 3) ? xstrdup(schema_end + 3) : NULL;\n+\t}\n+\n+\ttype = odb_source_type_by_name(name);\n+\tfree(name);\n+\treturn type;\n+}\n+\n struct odb_source *odb_source_new(struct object_database *odb,\n+\t\t\t\t  const char *object_storage_format,\n \t\t\t\t  enum odb_new_flags flags)\n {\n-\treturn &odb_source_files_new(odb, flags)->base;\n+\tstruct odb_source *source;\n+\tchar *payload = NULL;\n+\n+\tif (!object_storage_format)\n+\t\treturn &odb_source_files_new(odb, NULL, flags)->base;\n+\n+\tswitch (odb_source_type_by_uri(object_storage_format, &payload)) {\n+\tcase ODB_SOURCE_FILES:\n+\t\tsource = &odb_source_files_new(odb, payload, flags)->base;\n+\t\tbreak;\n+\tdefault:\n+\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n+\t}\n+\n+\tfree(payload);\n+\treturn source;\n }\n \n void odb_source_init(struct odb_source *source,\ndiff --git a/odb/source.h b/odb/source.h\nindex 1867347dfc..c194b3254b 100644\n--- a/odb/source.h\n+++ b/odb/source.h\n@@ -32,6 +32,14 @@ enum odb_source_type {\n  */\n const char *odb_source_type_to_name(enum odb_source_type type);\n \n+/*\n+ * Parse the given URI in the format \"<schema>[://<payload>]\" and return the\n+ * source type identified by the schema. If `payload` is non-NULL it will be\n+ * set to a newly allocated copy of the payload, or NULL if the URI has no or\n+ * an empty payload. Returns `ODB_SOURCE_UNKNOWN` for unknown schemas.\n+ */\n+enum odb_source_type odb_source_type_by_uri(const char *uri, char **payload);\n+\n struct object_id;\n struct odb_stream;\n struct strbuf;\n@@ -304,9 +312,11 @@ struct odb_source {\n \n /*\n  * Allocate and initialize a new source for the given object database. The path\n- * of the source is derived from repository paths.\n+ * of the source is derived from repository paths or from the object storage\n+ * format.\n  */\n struct odb_source *odb_source_new(struct object_database *odb,\n+\t\t\t\t  const char *object_storage_format,\n \t\t\t\t  enum odb_new_flags flags);\n \n /*\ndiff --git a/repository.c b/repository.c\nindex 970d181828..bb01fe5dd6 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -217,6 +217,13 @@ void repo_set_ref_storage_format(struct repository *repo,\n \trepo->ref_storage_payload = xstrdup_or_null(payload);\n }\n \n+void repo_set_object_storage_format(struct repository *repo,\n+\t\t\t\t    const char *uri)\n+{\n+\tfree(repo->object_storage_format);\n+\trepo->object_storage_format = xstrdup_or_null(uri);\n+}\n+\n /*\n  * Attempt to resolve and set the provided 'gitdir' for repository 'repo'.\n  * Return 0 upon success and a non-zero value upon failure.\n@@ -382,6 +389,7 @@ void repo_clear(struct repository *repo)\n \tfree(repo->worktree);\n \tfree(repo->submodule_prefix);\n \tfree(repo->ref_storage_payload);\n+\tfree(repo->object_storage_format);\n \n \todb_free(repo->objects);\n \ndiff --git a/repository.h b/repository.h\nindex 2a348012e8..e9a3a7f18b 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -178,6 +178,12 @@ struct repository {\n \t */\n \tchar *ref_storage_payload;\n \n+\t/*\n+\t * The object storage URI in the format \"<schema>[://<payload>]\", as\n+\t * configured via \"extensions.objectStorage\".\n+\t */\n+\tchar *object_storage_format;\n+\n \t/* A unique-id for tracing purposes. */\n \tint trace2_repo_id;\n \n@@ -255,6 +261,8 @@ void repo_set_compat_hash_algo(struct repository *repo, uint32_t compat_algo);\n void repo_set_ref_storage_format(struct repository *repo,\n \t\t\t\t enum ref_storage_format format,\n \t\t\t\t const char *payload);\n+void repo_set_object_storage_format(struct repository *repo,\n+\t\t\t\t    const char *uri);\n void initialize_repository(struct repository *repo);\n RESULT_MUST_BE_USED\n int repo_init(struct repository *r, const char *gitdir, const char *worktree);\ndiff --git a/setup.c b/setup.c\nindex 3ee19f3e3c..499b5bbe3c 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -9,6 +9,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n+#include \"odb/source.h\"\n #include \"refs.h\"\n #include \"repository.h\"\n #include \"config.h\"\n@@ -687,6 +688,15 @@ static enum extension_result handle_extension(const char *var,\n \t\t\t\t     \"extensions.refstorage\", value);\n \t\tdata->ref_storage_format = format;\n \t\treturn EXTENSION_OK;\n+\t} else if (!strcmp(ext, \"objectstorage\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tif (odb_source_type_by_uri(value, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\treturn error(_(\"invalid value for '%s': '%s'\"),\n+\t\t\t\t     \"extensions.objectstorage\", value);\n+\t\tfree(data->object_storage);\n+\t\tdata->object_storage = xstrdup(value);\n+\t\treturn EXTENSION_OK;\n \t} else if (!strcmp(ext, \"relativeworktrees\")) {\n \t\tdata->relative_worktrees = git_config_bool(var, value);\n \t\treturn EXTENSION_OK;\n@@ -694,6 +704,7 @@ static enum extension_result handle_extension(const char *var,\n \t\tdata->submodule_path_cfg = git_config_bool(var, value);\n \t\treturn EXTENSION_OK;\n \t}\n+\n \treturn EXTENSION_UNKNOWN;\n }\n \n@@ -864,6 +875,7 @@ void clear_repository_format(struct repository_format *format)\n \tfree(format->work_tree);\n \tfree(format->partial_clone);\n \tfree(format->ref_storage_payload);\n+\tfree(format->object_storage);\n \tinit_repository_format(format);\n }\n \n@@ -1786,6 +1798,7 @@ int apply_repository_format(struct repository *repo,\n \trepo_set_ref_storage_format(repo,\n \t\t\t\t    format->ref_storage_format,\n \t\t\t\t    format->ref_storage_payload);\n+\trepo_set_object_storage_format(repo, format->object_storage);\n \trepo->repository_format_worktree_config =\n \t\tformat->worktree_config;\n \trepo->repository_format_submodule_path_cfg =\ndiff --git a/setup.h b/setup.h\nindex 7a3efe5e48..9145aacc5f 100644\n--- a/setup.h\n+++ b/setup.h\n@@ -192,6 +192,7 @@ struct repository_format {\n \tchar *ref_storage_payload;\n \tint sparse_index;\n \tchar *work_tree;\n+\tchar *object_storage;\n \tstruct string_list unknown_extensions;\n \tstruct string_list v1_only_extensions;\n };\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex f1d227f271..c7c464d3a2 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -839,6 +839,36 @@ test_expect_success 'init with --ref-storage-format=garbage' '\n \ttest_cmp expect err\n '\n \n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage is not allowed with repo version 0' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set extensions.objectStorage files &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"repo version is 0, but v1-only extension found\" err\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files backend' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set core.repositoryformatversion 1 &&\n+\tgit -C objstorage config set extensions.objectStorage files &&\n+\ttest_commit -C objstorage A &&\n+\tgit -C objstorage rev-parse --verify HEAD\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set core.repositoryformatversion 1 &&\n+\tgit -C objstorage config set extensions.objectStorage garbage &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage${SQ}\" err &&\n+\n+\tgit config --file objstorage/.git/config extensions.objectStorage garbage://payload &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.269.g68944adf51.dirty\n\n\n"},{"id":"555401","messageId":"20261019-b4-pks-odb-extension-v1-3-143a5963b77f@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH 3/7] setup: allow overriding object storage format via environment","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-19T08:55:58Z","receivedAt":"2026-10-19T08:55:58Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format configured via \"extensions.refStorage\" can be\noverridden with the GIT_REF_STORAGE_FORMAT environment variable.\nIntroduce the GIT_OBJECT_STORAGE_FORMAT environment variable that\noverrides \"extensions.objectStorage\" in the same way.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git.adoc |  5 +++++\n environment.h          |  1 +\n setup.c                | 14 ++++++++++++++\n t/t0001-init.sh        | 26 ++++++++++++++++++++++++++\n 4 files changed, 46 insertions(+)\n\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 3abb4701c3..34812131bb 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -609,6 +609,11 @@ double-quotes and respecting backslash escapes. E.g., the value\n `GIT_REFERENCE_BACKEND`::\n \tDeprecated alias of `GIT_REF_STORAGE_FORMAT`.\n \n+`GIT_OBJECT_STORAGE_FORMAT`::\n+\tSpecify which object storage format to use along with its URI.\n+\tSee `extensions.objectStorage` option in linkgit:git-config[1] for more\n+\tdetails. Overrides the config variable when used.\n+\n Git Commits\n ~~~~~~~~~~~\n `GIT_AUTHOR_NAME`::\ndiff --git a/environment.h b/environment.h\nindex b336459e90..c26ef92b52 100644\n--- a/environment.h\n+++ b/environment.h\n@@ -45,6 +45,7 @@\n #define GIT_ATTR_SOURCE_ENVIRONMENT \"GIT_ATTR_SOURCE\"\n #define GIT_REFERENCE_BACKEND_ENVIRONMENT \"GIT_REFERENCE_BACKEND\"\n #define GIT_REF_STORAGE_FORMAT_ENVIRONMENT \"GIT_REF_STORAGE_FORMAT\"\n+#define GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT \"GIT_OBJECT_STORAGE_FORMAT\"\n \n /*\n  * Environment variable used to propagate the --no-advice global option to the\ndiff --git a/setup.c b/setup.c\nindex 499b5bbe3c..98140a7641 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2073,6 +2073,7 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \n \t\tif (startup_info->have_repository) {\n \t\t\tstruct strbuf err = STRBUF_INIT;\n+\t\t\tconst char *object_storage_uri;\n \t\t\tconst char *ref_backend_uri;\n \n \t\t\t/*\n@@ -2091,6 +2092,19 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \t\t\t\t\tdie(_(\"unknown ref storage format: '%s'\"), ref_backend_uri);\n \t\t\t}\n \n+\t\t\t/*\n+\t\t\t * Likewise, the GIT_OBJECT_STORAGE_FORMAT environment\n+\t\t\t * variable should override the repository config for\n+\t\t\t * 'extensions.objectStorage'.\n+\t\t\t */\n+\t\t\tobject_storage_uri = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT);\n+\t\t\tif (object_storage_uri) {\n+\t\t\t\tif (odb_source_type_by_uri(object_storage_uri, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\t\t\tdie(_(\"unknown object storage format: '%s'\"), object_storage_uri);\n+\t\t\t\tfree(discovery.format.object_storage);\n+\t\t\t\tdiscovery.format.object_storage = xstrdup(object_storage_uri);\n+\t\t\t}\n+\n \t\t\tif (apply_repository_format(repo, &discovery.format,\n \t\t\t\t\t\t    APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n \t\t\t\tdie(\"%s\", err.buf);\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex c7c464d3a2..5e7c25e42c 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -869,6 +869,32 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown b\n \ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n '\n \n+test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides extensions.objectStorage' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\t(\n+\t\tcd objstorage &&\n+\t\tgit config set core.repositoryformatversion 1 &&\n+\t\tgit config set extensions.objectStorage files://objs &&\n+\t\tmkdir .git/objs .git/other &&\n+\n+\t\techo content >file &&\n+\t\toid=$(git hash-object -w file) &&\n+\t\ttest_path_is_file .git/objs/$(test_oid_to_path \"$oid\") &&\n+\t\tgit cat-file -e \"$oid\" &&\n+\n+\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://other git cat-file -e \"$oid\" &&\n+\t\tGIT_OBJECT_STORAGE_FORMAT=files://other git hash-object -w file &&\n+\t\ttest_path_is_file .git/other/$(test_oid_to_path \"$oid\") &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\tfatal: unknown object storage format: ${SQ}garbage${SQ}\n+\t\tEOF\n+\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git rev-parse 2>err &&\n+\t\ttest_cmp expect err\n+\t)\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.269.g68944adf51.dirty\n\n\n"},{"id":"555402","messageId":"20261019-b4-pks-odb-extension-v1-4-143a5963b77f@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH 4/7] builtin: expose the object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-19T08:55:59Z","receivedAt":"2026-10-19T08:55:59Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format of a repository can be inspected via both\ngit-rev-parse(1)'s \"--show-ref-storage-format\" and git-repo(1)'s\n\"references.storageFormat\" field. Introduce the equivalent options for\nthe object storage format, as well.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-repo.adoc      |  6 ++++++\n Documentation/git-rev-parse.adoc |  5 +++++\n builtin/repo.c                   | 10 ++++++++++\n builtin/rev-parse.c              |  7 +++++++\n t/t0001-init.sh                  |  5 ++++-\n t/t1900-repo-info.sh             |  3 +++\n 6 files changed, 35 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex cb8c1e7292..d2dc9b7a69 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -105,6 +105,12 @@ values that they return:\n `object.format`::\n \tThe object format (hash algorithm) used in the repository.\n \n+`objects.storageFormat`::\n+\tThe object storage format used in the repository, as configured via\n+\t`extensions.objectStorage`. The valid values are:\n++\n+include::object-storage-format.adoc[]\n+\n `path.commondir.absolute`::\n \tThe canonical absolute path to the Git repository's common\n \tdirectory (the shared `.git` directory containing objects,\ndiff --git a/Documentation/git-rev-parse.adoc b/Documentation/git-rev-parse.adoc\nindex 5b866af66a..9103d54d53 100644\n--- a/Documentation/git-rev-parse.adoc\n+++ b/Documentation/git-rev-parse.adoc\n@@ -338,6 +338,11 @@ The following options are unaffected by `--path-format`:\n --show-ref-format::\n \tDeprecated alias of `--show-ref-storage-format`.\n \n+--show-object-storage-format::\n+\tShow the object storage format used for the repository. Prints the\n+\tvalue of `extensions.objectStorage`, or `files` when the extension is\n+\tnot set.\n+\n \n Other Options\n ~~~~~~~~~~~~~\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 84e012f83f..da11a56ede 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -6,6 +6,7 @@\n #include \"hash.h\"\n #include \"hex.h\"\n #include \"odb.h\"\n+#include \"odb/source.h\"\n #include \"parse-options.h\"\n #include \"path.h\"\n #include \"path-walk.h\"\n@@ -128,11 +129,20 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_object_storage_format(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf, repo->object_storage_format ?\n+\t\t      repo->object_storage_format :\n+\t\t      odb_source_type_to_name(ODB_SOURCE_FILES));\n+\treturn 0;\n+}\n+\n /* repo_info_field keys must be in lexicographical order */\n static const struct repo_info_field repo_info_field[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n \t{ \"object.format\", get_object_format },\n+\t{ \"objects.storageFormat\", get_object_storage_format },\n \t{ \"path.commondir.absolute\", get_path_commondir_absolute },\n \t{ \"path.commondir.relative\", get_path_commondir_relative },\n \t{ \"path.gitdir.absolute\", get_path_gitdir_absolute },\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex ec33c19bdf..b206944ad9 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -17,6 +17,7 @@\n #include \"gettext.h\"\n #include \"hash.h\"\n #include \"hex.h\"\n+#include \"odb/source.h\"\n #include \"refs.h\"\n #include \"quote.h\"\n #include \"object-name.h\"\n@@ -1138,6 +1139,12 @@ int cmd_rev_parse(int argc,\n \t\t\t\tputs(ref_storage_format_to_name(the_repository->ref_storage_format));\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--show-object-storage-format\")) {\n+\t\t\t\tputs(the_repository->object_storage_format ?\n+\t\t\t\t     the_repository->object_storage_format :\n+\t\t\t\t     odb_source_type_to_name(ODB_SOURCE_FILES));\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--end-of-options\")) {\n \t\t\t\tseen_end_of_options = 1;\n \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 5e7c25e42c..d080ab04a8 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -853,7 +853,10 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files bac\n \tgit -C objstorage config set core.repositoryformatversion 1 &&\n \tgit -C objstorage config set extensions.objectStorage files &&\n \ttest_commit -C objstorage A &&\n-\tgit -C objstorage rev-parse --verify HEAD\n+\tgit -C objstorage rev-parse --verify HEAD &&\n+\techo files >expect &&\n+\tgit -C objstorage rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\ndiff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh\nindex d115d2d9f9..493a78f230 100755\n--- a/t/t1900-repo-info.sh\n+++ b/t/t1900-repo-info.sh\n@@ -69,6 +69,9 @@ test_repo_info 'object.format = sha1 is retrieved correctly' \\\n test_repo_info 'object.format = sha256 is retrieved correctly' \\\n \t'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'\n \n+test_repo_info 'objects.storageFormat = files is retrieved correctly' \\\n+\t'git init' 'objects-files' 'objects.storageFormat' 'files'\n+\n test_expect_success 'values returned in order requested' '\n \tcat >expect <<-\\EOF &&\n \tlayout.bare=false\n\n-- \n2.56.0.269.g68944adf51.dirty\n\n\n"},{"id":"555403","messageId":"20261019-b4-pks-odb-extension-v1-5-143a5963b77f@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH 5/7] builtin/init: introduce handling of object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-19T08:56:00Z","receivedAt":"2026-10-19T08:56:00Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"While the object storage format extension can already be configured\nmanually via git-config(1), this isn't exactly an ergonomic way of doing\nso. For the reference storage format extension, users have a host of\noptions available to them.\n\nIntroduce the equivalent options for the object storage format.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/config/init.adoc |   5 ++\n Documentation/git-init.adoc    |  10 ++-\n Documentation/git.adoc         |   5 ++\n builtin/clone.c                |   2 +-\n builtin/init-db.c              |   7 +-\n setup.c                        |  89 +++++++++++++++++++++-\n setup.h                        |   1 +\n t/t0001-init.sh                | 162 +++++++++++++++++++++++++++++++++++++++++\n 8 files changed, 273 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/config/init.adoc b/Documentation/config/init.adoc\nindex e45bd692db..dbd9c663ee 100644\n--- a/Documentation/config/init.adoc\n+++ b/Documentation/config/init.adoc\n@@ -20,6 +20,11 @@ endif::[]\n \tprecedence over this config.\n `init.defaultRefFormat`::\n \tDeprecated alias of `init.defaultRefStorageFormat`.\n+`init.defaultObjectStorageFormat`::\n+\tAllows overriding the default object storage format for new\n+\trepositories. See `--object-storage-format=` in linkgit:git-init[1].\n+\tBoth the command line option and the `GIT_DEFAULT_OBJECT_STORAGE_FORMAT`\n+\tenvironment variable take precedence over this config.\n \n init.defaultSubmodulePathConfig::\n \tA boolean that specifies if `git init` and `git clone` should\ndiff --git a/Documentation/git-init.adoc b/Documentation/git-init.adoc\nindex b02af22ad1..9e022a7ba8 100644\n--- a/Documentation/git-init.adoc\n+++ b/Documentation/git-init.adoc\n@@ -11,7 +11,7 @@ SYNOPSIS\n [synopsis]\n git init [-q | --quiet] [--bare] [--template=<template-directory>]\n \t [--separate-git-dir <git-dir>] [--object-format=<format>]\n-\t [--ref-storage-format=<format>]\n+\t [--ref-storage-format=<format>] [--object-storage-format=<format>]\n \t [-b <branch-name> | --initial-branch=<branch-name>]\n \t [--shared[=<permissions>]] [<directory>]\n \n@@ -68,6 +68,14 @@ include::ref-storage-format.adoc[]\n `--ref-format=<format>`::\n Deprecated alias of `--ref-storage-format=<format>`.\n \n+`--object-storage-format=<format>`::\n+Specify the given object storage _<format>_ for the repository. Backends that\n+require additional configuration accept a payload in the form\n+`<format>://<payload>`, for example a path or a connection string identifying\n+the database that shall store the objects. The valid values are:\n++\n+include::object-storage-format.adoc[]\n+\n `--template=<template-directory>`::\n Specify the directory from which templates will be used.  (See the \"TEMPLATE\n DIRECTORY\" section below.)\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 34812131bb..67de5646f0 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -609,6 +609,11 @@ double-quotes and respecting backslash escapes. E.g., the value\n `GIT_REFERENCE_BACKEND`::\n \tDeprecated alias of `GIT_REF_STORAGE_FORMAT`.\n \n+`GIT_DEFAULT_OBJECT_STORAGE_FORMAT`::\n+\tIf this variable is set, the default object storage format for new\n+\trepositories will be set to this value. The default is \"files\".\n+\tSee `--object-storage-format` in linkgit:git-init[1].\n+\n `GIT_OBJECT_STORAGE_FORMAT`::\n \tSpecify which object storage format to use along with its URI.\n \tSee `extensions.objectStorage` option in linkgit:git-config[1] for more\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 6047501dfc..ba4fc16def 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -1214,7 +1214,7 @@ int cmd_clone(int argc,\n \t */\n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n \t\t\t  option_template, GIT_HASH_UNKNOWN, ref_storage_format_uri,\n-\t\t\t  do_not_override_repo_unix_permissions, NULL);\n+\t\t\t  NULL, do_not_override_repo_unix_permissions, NULL);\n \n \tif (real_git_dir) {\n \t\tfree((char *)git_dir);\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 0abdbca8e9..71b748f2f2 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -57,7 +57,7 @@ static int shared_callback(const struct option *opt, const char *arg, int unset)\n static const char *const init_db_usage[] = {\n \tN_(\"git init [-q | --quiet] [--bare] [--template=<template-directory>]\\n\"\n \t   \"         [--separate-git-dir <git-dir>] [--object-format=<format>]\\n\"\n-\t   \"         [--ref-storage-format=<format>]\\n\"\n+\t   \"         [--ref-storage-format=<format>] [--object-storage-format=<format>]\\n\"\n \t   \"         [-b <branch-name> | --initial-branch=<branch-name>]\\n\"\n \t   \"         [--shared[=<permissions>]] [<directory>]\"),\n \tNULL\n@@ -84,6 +84,7 @@ int cmd_init_db(int argc,\n \tint bare = startup_info->force_bare_repository ? 1 : -1;\n \tconst char *object_format = NULL;\n \tconst char *ref_storage_format_uri = NULL;\n+\tconst char *object_storage_format_uri = NULL;\n \tconst char *initial_branch = NULL;\n \tint hash_algo = GIT_HASH_UNKNOWN;\n \tint init_shared_repository = -1;\n@@ -111,6 +112,8 @@ int cmd_init_db(int argc,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format_uri, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format_uri, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_END()\n \t};\n \tint reinit;\n@@ -232,7 +235,7 @@ int cmd_init_db(int argc,\n \n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n \t\t\t  template_dir, hash_algo, ref_storage_format_uri,\n-\t\t\t  init_shared_repository, &reinit);\n+\t\t\t  object_storage_format_uri, init_shared_repository, &reinit);\n \tcreate_reference_database(the_repository, initial_branch, quiet);\n \tcreate_object_database(the_repository, NULL);\n \ndiff --git a/setup.c b/setup.c\nindex 98140a7641..7117336b13 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2466,7 +2466,8 @@ void initialize_repository_version(struct repository *repo,\n \t */\n \tif (hash_algo != GIT_HASH_SHA1_LEGACY ||\n \t    ref_storage_format != REF_STORAGE_FORMAT_FILES ||\n-\t    repo->ref_storage_payload)\n+\t    repo->ref_storage_payload ||\n+\t    repo->object_storage_format)\n \t\ttarget_version = GIT_REPO_VERSION_READ;\n \n \tif (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)\n@@ -2490,6 +2491,12 @@ void initialize_repository_version(struct repository *repo,\n \t\trepo_config_set_gently(repo, \"extensions.refstorage\", NULL);\n \t}\n \n+\tif (repo->object_storage_format)\n+\t\trepo_config_set(repo, \"extensions.objectstorage\",\n+\t\t\t\trepo->object_storage_format);\n+\telse if (reinit)\n+\t\trepo_config_set_gently(repo, \"extensions.objectstorage\", NULL);\n+\n \tif (reinit) {\n \t\tstruct strbuf config = STRBUF_INIT;\n \t\tstruct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;\n@@ -2726,6 +2733,7 @@ static void separate_git_dir(struct repository *repo,\n struct default_format_config {\n \tint hash;\n \tenum ref_storage_format ref_storage_format;\n+\tchar *object_storage_format;\n };\n \n static int read_default_format_config(const char *key, const char *value,\n@@ -2757,6 +2765,20 @@ static int read_default_format_config(const char *key, const char *value,\n \t\tgoto out;\n \t}\n \n+\tif (!strcmp(key, \"init.defaultobjectstorageformat\")) {\n+\t\tret = git_config_string(&str, key, value);\n+\t\tif (ret)\n+\t\t\tgoto out;\n+\t\tif (odb_source_type_by_uri(str, NULL) == ODB_SOURCE_UNKNOWN) {\n+\t\t\twarning(_(\"unknown object storage format '%s'\"), str);\n+\t\t\tgoto out;\n+\t\t}\n+\t\tfree(cfg->object_storage_format);\n+\t\tcfg->object_storage_format = str;\n+\t\tstr = NULL;\n+\t\tgoto out;\n+\t}\n+\n \t/*\n \t * Enable the reftable format when \"features.experimental\" is enabled.\n \t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n@@ -2777,7 +2799,8 @@ static int read_default_format_config(const char *key, const char *value,\n \n static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t\t\t\tint hash,\n-\t\t\t\t\tconst char *ref_storage_format_uri)\n+\t\t\t\t\tconst char *ref_storage_format_uri,\n+\t\t\t\t\tconst char *object_storage_uri)\n {\n \tstruct default_format_config cfg = {\n \t\t.hash = GIT_HASH_UNKNOWN,\n@@ -2790,6 +2813,7 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t};\n \tenum ref_storage_format ref_storage_format;\n \tchar *ref_storage_payload = NULL;\n+\tchar *object_storage = NULL;\n \tconst char *env;\n \n \tconfig_with_options(read_default_format_config, &cfg, NULL, NULL, &opts);\n@@ -2877,9 +2901,58 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\tref_storage_format = REF_STORAGE_FORMAT_DEFAULT;\n \t}\n \n+\t/*\n+\t * Determine the object storage format, with the same precedence as\n+\t * for the ref storage format:\n+\t *\n+\t *   1. The format specified via the command line.\n+\t *\n+\t *   2. The format specified via \"GIT_OBJECT_STORAGE_FORMAT\".\n+\t *\n+\t *   3. The format of a preexisting repository when reinitializing.\n+\t *\n+\t *   4. The default format for new repositories as configured via\n+\t *      \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\".\n+\t *\n+\t *   5. The default format for new repositories as configured via\n+\t *      \"init.defaultObjectStorageFormat\".\n+\t *\n+\t *   6. The \"files\" format.\n+\t */\n+\tif (object_storage_uri) {\n+\t\tif (odb_source_type_by_uri(object_storage_uri, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_uri);\n+\t\tobject_storage = xstrdup(object_storage_uri);\n+\t} else if ((env = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT))) {\n+\t\tif (odb_source_type_by_uri(env, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n+\t\t\t    GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT, env);\n+\t\tobject_storage = xstrdup(env);\n+\t} else if (repo_fmt->version >= 0) {\n+\t\tobject_storage = xstrdup_or_null(repo_fmt->object_storage);\n+\t} else if ((env = getenv(\"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\"))) {\n+\t\tif (odb_source_type_by_uri(env, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n+\t\t\t    \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\", env);\n+\t\tobject_storage = xstrdup(env);\n+\t} else {\n+\t\tobject_storage = xstrdup_or_null(cfg.object_storage_format);\n+\t}\n+\n+\t/*\n+\t * The \"files\" format without a payload is the default and thus doesn't\n+\t * need to be recorded as an extension.\n+\t */\n+\tif (object_storage) {\n+\t\tchar *payload = NULL;\n+\t\tif (odb_source_type_by_uri(object_storage, &payload) == ODB_SOURCE_FILES && !payload)\n+\t\t\tFREE_AND_NULL(object_storage);\n+\t\tfree(payload);\n+\t}\n+\n \t/*\n \t * If we have a preexisting repository we need to verify that its\n-\t * current ref storage format does not change.\n+\t * current storage formats do not change.\n \t */\n \tif (repo_fmt->version >= 0) {\n \t\tif (ref_storage_format != repo_fmt->ref_storage_format)\n@@ -2888,11 +2961,18 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t    strcmp(ref_storage_payload ? ref_storage_payload : \"\",\n \t\t\t   repo_fmt->ref_storage_payload ? repo_fmt->ref_storage_payload : \"\"))\n \t\t\tdie(_(\"attempt to reinitialize repository with different reference storage payload\"));\n+\t\tif (strcmp(object_storage ? object_storage : \"\",\n+\t\t\t   repo_fmt->object_storage ? repo_fmt->object_storage : \"\"))\n+\t\t\tdie(_(\"attempt to reinitialize repository with different object storage format\"));\n \t}\n \n \tfree(repo_fmt->ref_storage_payload);\n \trepo_fmt->ref_storage_format = ref_storage_format;\n \trepo_fmt->ref_storage_payload = ref_storage_payload;\n+\n+\tfree(repo_fmt->object_storage);\n+\trepo_fmt->object_storage = object_storage;\n+\tfree(cfg.object_storage_format);\n }\n \n void create_repository(struct repository *repo,\n@@ -2902,6 +2982,7 @@ void create_repository(struct repository *repo,\n \t\t       const char *template_dir,\n \t\t       int hash,\n \t\t       const char *ref_storage_format_uri,\n+\t\t       const char *object_storage_format_uri,\n \t\t       int init_shared_repository,\n \t\t       int *reinit_ok)\n {\n@@ -2940,7 +3021,7 @@ void create_repository(struct repository *repo,\n \t * is an attempt to reinitialize new repository with an old tool.\n \t */\n \tread_and_verify_repository_format(&repo_fmt, repo_get_git_dir(repo), NULL);\n-\trepository_format_configure(&repo_fmt, hash, ref_storage_format_uri);\n+\trepository_format_configure(&repo_fmt, hash, ref_storage_format_uri, object_storage_format_uri);\n \tif (apply_repository_format(repo, &repo_fmt, APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n \t\tdie(\"%s\", err.buf);\n \ndiff --git a/setup.h b/setup.h\nindex 9145aacc5f..4e1737ade9 100644\n--- a/setup.h\n+++ b/setup.h\n@@ -275,6 +275,7 @@ void create_repository(struct repository *repo,\n \t\t       const char *template_dir,\n \t\t       int hash_algo,\n \t\t       const char *ref_storage_format_uri,\n+\t\t       const char *object_storage_format_uri,\n \t\t       int init_shared_repository,\n \t\t       int *reinit_ok);\n \ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex d080ab04a8..0da14e8f70 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -898,6 +898,168 @@ test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides ext\n \t)\n '\n \n+test_expect_success 'init with --object-storage-format=files does not set extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files objformat &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\tif test_have_prereq DEFAULT_REPO_FORMAT\n+\tthen\n+\t\techo 0 >expect &&\n+\t\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\t\ttest_cmp expect actual\n+\tfi\n+'\n+\n+test_expect_success 'init with --object-storage-format=files:// does not set extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files:// objformat &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with --object-storage-format=files://<relative-path>' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat config get extensions.objectstorage >actual &&\n+\ttest_cmp expect actual &&\n+\techo 1 >expect &&\n+\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\ttest_cmp expect actual &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual &&\n+\ttest_path_is_dir objformat/.git/objects &&\n+\ttest_path_is_dir objformat/.git/objs &&\n+\ttest_commit -C objformat A &&\n+\tgit -C objformat rev-parse --verify HEAD &&\n+\ttest_path_is_missing objformat/.git/objects/pack &&\n+\ttest_path_is_dir objformat/.git/objs/pack\n+'\n+\n+test_expect_success 'init with --object-storage-format=files://<absolute-path>' '\n+\ttest_when_finished \"rm -rf objformat objdir\" &&\n+\tgit init --object-storage-format=files://\"$(pwd)/objdir\" objformat &&\n+\techo \"files://$(pwd)/objdir\" >expect &&\n+\tgit -C objformat config get extensions.objectstorage >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_commit -C objformat A &&\n+\tgit -C objformat rev-parse --verify HEAD &&\n+\ttest_path_is_dir objdir/pack\n+'\n+\n+test_expect_success 'GIT_OBJECT_DIRECTORY takes precedence over extensions.objectStorage payload' '\n+\ttest_when_finished \"rm -rf objformat objdir\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\ttest_commit -C objformat A &&\n+\tmkdir objdir &&\n+\ttest_must_fail env GIT_DIR=\"$PWD/objformat/.git\" GIT_OBJECT_DIRECTORY=\"$PWD/objdir\" \\\n+\t\tgit cat-file -e HEAD &&\n+\tGIT_DIR=\"$PWD/objformat/.git\" GIT_OBJECT_DIRECTORY=\"$PWD/objdir\" \\\n+\t\tgit hash-object -w objformat/A.t >oid &&\n+\ttest_path_is_file objdir/$(test_oid_to_path \"$(cat oid)\")\n+'\n+\n+test_expect_success 'init with --object-storage-format=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git init --object-storage-format=garbage objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'init with GIT_DEFAULT_OBJECT_STORAGE_FORMAT=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via GIT_DEFAULT_OBJECT_STORAGE_FORMAT: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail env GIT_DEFAULT_OBJECT_STORAGE_FORMAT=garbage git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'init with GIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://objs' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://objs git init objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with GIT_OBJECT_STORAGE_FORMAT=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via GIT_OBJECT_STORAGE_FORMAT: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'GIT_OBJECT_STORAGE_FORMAT takes precedence over default' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://default \\\n+\tGIT_OBJECT_STORAGE_FORMAT=files://explicit git init objformat &&\n+\techo files://explicit >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '--object-storage-format= takes precedence over environment' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_OBJECT_STORAGE_FORMAT=files://explicit \\\n+\tgit init --object-storage-format=files://cmdline objformat &&\n+\techo files://cmdline >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 're-init refuses with different storage format' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files objformat &&\n+\tcat >expect <<-EOF &&\n+\tfatal: attempt to reinitialize repository with different object storage format\n+\tEOF\n+\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://objs git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 're-init with same object storage format' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\tgit init objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init warns about invalid init.defaultObjectStorageFormat' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\ttest_config_global init.defaultObjectStorageFormat garbage &&\n+\techo \"warning: unknown object storage format ${SQ}garbage${SQ}\" >expect &&\n+\tgit init objformat 2>err &&\n+\ttest_cmp expect err &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with init.defaultObjectStorageFormat' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\ttest_config_global init.defaultObjectStorageFormat files://objs &&\n+\tgit init objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_commit -C objformat A &&\n+\ttest_path_is_dir objformat/.git/objs/pack\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.269.g68944adf51.dirty\n\n\n"},{"id":"555404","messageId":"20261019-b4-pks-odb-extension-v1-6-143a5963b77f@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH 6/7] builtin/clone: introduce \"--object-storage-format=\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-19T08:56:01Z","receivedAt":"2026-10-19T08:56:01Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Wire up the new object storage format in git-clone(1) via a new\n`--object-storage-format=` option, same as we have introduced in the\npreceding commit for git-init(1).\n\nNote that \"--local\" clones will not work if either of the object\ndatabases is not using the \"files\" format. This is because we hardlink\nloose objects and packfiles into the new repository, and that is\nsomething that simply won't work with alternative backends.\nConsequently, we either downgrade to a non-local clone with a warning,\nor we die in case the user has explicitly asked for a local clone.\n\nWe _could_ in theory handle the case where the \"files\" backend has been\nconfigured with an alternative object directory path (that is, with\n\"files:///path/to/dir\"). But that's left for a future patch series to\nimplement for the sake of simplicity.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-clone.adoc | 11 +++++++\n builtin/clone.c              | 50 ++++++++++++++++++++++++++++++--\n t/t5601-clone.sh             | 68 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 127 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-clone.adoc b/Documentation/git-clone.adoc\nindex 07f7cf1a98..dd3b44817a 100644\n--- a/Documentation/git-clone.adoc\n+++ b/Documentation/git-clone.adoc\n@@ -360,6 +360,17 @@ include::ref-storage-format.adoc[]\n `--ref-format=<format>`::\n Deprecated alias of `--ref-storage-format=<format>`.\n \n+`--object-storage-format=<format>`::\n+Specify the given object storage _<format>_ for the repository. Backends that\n+require additional configuration accept a payload in the form\n+`<format>://<payload>`, for example a path or a connection string identifying\n+the database that shall store the objects. The valid values are:\n++\n+include::object-storage-format.adoc[]\n++\n+Local clones (see `--local`) fall back to the regular transport when either\n+repository uses a non-default object storage.\n+\n `-j<n>`::\n `--jobs=<n>`::\n \tThe number of submodules fetched at the same time.\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex ba4fc16def..85c124dc37 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -26,6 +26,7 @@\n #include \"refspec.h\"\n #include \"object-file.h\"\n #include \"odb.h\"\n+#include \"odb/source.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\n@@ -378,6 +379,28 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,\n \tdir_iterator_free(iter);\n }\n \n+static bool is_using_default_object_storage_format(const char *repo_path)\n+{\n+\tstruct repository_format format = REPOSITORY_FORMAT_INIT;\n+\tstruct strbuf config = STRBUF_INIT;\n+\tbool uses_default_format = true;\n+\tchar *payload = NULL;\n+\n+\tget_common_dir(&config, repo_path);\n+\tstrbuf_addstr(&config, \"/config\");\n+\tread_repository_format(&format, config.buf);\n+\n+\tif (format.version >= 1 &&\n+\t    format.object_storage &&\n+\t    (odb_source_type_by_uri(format.object_storage, &payload) != ODB_SOURCE_FILES || payload))\n+\t\tuses_default_format = false;\n+\n+\tclear_repository_format(&format);\n+\tstrbuf_release(&config);\n+\tfree(payload);\n+\treturn uses_default_format;\n+}\n+\n static void clone_local(const char *src_repo, const char *dest_repo)\n {\n \tif (!option_shared) {\n@@ -927,6 +950,7 @@ int cmd_clone(int argc,\n \tstruct string_list option_not = STRING_LIST_INIT_NODUP;\n \tconst char *real_git_dir = NULL;\n \tconst char *ref_storage_format_uri = NULL;\n+\tconst char *object_storage_format_uri = NULL;\n \tconst char *option_upload_pack = \"git-upload-pack\";\n \tint option_progress = -1;\n \tint option_sparse_checkout = 0;\n@@ -1008,6 +1032,8 @@ int cmd_clone(int argc,\n \t\t\t   N_(\"separate git dir from working tree\")),\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format_uri, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format_uri, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n \t\tOPT_STRING_LIST('c', \"config\", &option_config, N_(\"key=value\"),\n \t\t\t\tN_(\"set config inside the new repository\")),\n@@ -1060,6 +1086,10 @@ int cmd_clone(int argc,\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format_uri);\n \t}\n \n+\tif (object_storage_format_uri &&\n+\t    odb_source_type_by_uri(object_storage_format_uri, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n+\n \tif (option_mirror) {\n \t\toption_bare = 1;\n \t\toption_tags = 0;\n@@ -1213,8 +1243,9 @@ int cmd_clone(int argc,\n \t * their on-disk data structures.\n \t */\n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n-\t\t\t  option_template, GIT_HASH_UNKNOWN, ref_storage_format_uri,\n-\t\t\t  NULL, do_not_override_repo_unix_permissions, NULL);\n+\t\t\t  option_template, GIT_HASH_UNKNOWN,\n+\t\t\t  ref_storage_format_uri, object_storage_format_uri,\n+\t\t\t  do_not_override_repo_unix_permissions, NULL);\n \n \tif (real_git_dir) {\n \t\tfree((char *)git_dir);\n@@ -1362,6 +1393,21 @@ int cmd_clone(int argc,\n \t\t\tis_local = 0;\n \t\t}\n \t}\n+\n+\t/*\n+\t * Local clones copy or hardlink the object directory of the source repository\n+\t * into the destination. This only works when both repositories use the \"files\"\n+\t * object storage format.\n+\t */\n+\tif (is_local &&\n+\t    (!is_using_default_object_storage_format(path) || !is_using_default_object_storage_format(git_dir))) {\n+\t\tif (option_local > 0)\n+\t\t\tdie(_(\"cannot perform local clone with non-default object storage format\"));\n+\t\telse\n+\t\t\twarning(_(\"falling back to non-local clone because of non-default object storage format\"));\n+\t\tis_local = 0;\n+\t}\n+\n \tif (option_local > 0 && !is_local)\n \t\twarning(_(\"--local is ignored\"));\n \ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 06f6121f82..85f439d6b6 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -181,6 +181,74 @@ test_expect_success 'clone with garbage ref format' '\n \ttest_path_is_missing ref-storage\n '\n \n+test_expect_success 'clone with files object storage format' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\tgit clone --object-storage-format=files --bare src object-storage &&\n+\ttest_must_fail git -C object-storage config get extensions.objectstorage &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\techo files >expect &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'clone with object storage payload' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\tgit clone --object-storage-format=files://objs --bare src object-storage &&\n+\tgit -C object-storage config get extensions.objectstorage >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_path_is_dir object-storage/objs/pack &&\n+\ttest_path_is_missing object-storage/objects/pack\n+'\n+\n+test_expect_success 'clone with object storage payload and bundle URI' '\n+\ttest_when_finished \"rm -rf object-storage src.bundle\" &&\n+\tgit -C src bundle create ../src.bundle --all &&\n+\tgit clone --object-storage-format=files://objs --bundle-uri=\"$PWD/src.bundle\" \\\n+\t\tsrc object-storage &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'clone with garbage object storage format' '\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git clone --object-storage-format=garbage --bare src object-storage 2>err &&\n+\ttest_cmp expect err &&\n+\ttest_path_is_missing object-storage\n+'\n+\n+test_expect_success 'local clone into non-default object storage bails' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\ttest_must_fail git clone --local --object-storage-format=files://objs src object-storage 2>err &&\n+\ttest_grep \"cannot perform local clone with non-default object storage format\" err\n+'\n+\n+test_expect_success 'local clone from explicit files object storage succeeds' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone src object-storage &&\n+\tgit -C object-storage config set core.repositoryformatversion 1 &&\n+\tgit -C object-storage config set extensions.objectstorage files &&\n+\tgit clone --local object-storage object-storage-dest\n+'\n+\n+test_expect_success 'local clone from non-default object storage bails' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone --object-storage-format=files://objs src object-storage &&\n+\ttest_must_fail git clone --local object-storage object-storage-dest 2>err &&\n+\ttest_grep \"cannot perform local clone with non-default object storage format\" err\n+'\n+\n+test_expect_success 'local clone from non-default object storage without --local warns' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone --object-storage-format=files://objs src object-storage &&\n+\tgit clone object-storage object-storage-dest 2>err &&\n+\ttest_grep \"falling back to non-local clone\" err\n+'\n+\n test_expect_success 'clone to destination with trailing /' '\n \n \tgit clone src target-1/ &&\n\n-- \n2.56.0.269.g68944adf51.dirty\n\n\n"},{"id":"555405","messageId":"20261019-b4-pks-odb-extension-v1-7-143a5963b77f@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH 7/7] builtin/submodule: propagate \"--object-storage-format=\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-19T08:56:02Z","receivedAt":"2026-10-19T08:56:02Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format passed to git-clone(1) propagates to recursively\ncloned submodules, and git-submodule(1)'s \"add\" and \"update\" subcommands\naccept `--ref-storage-format=` so that newly cloned submodules can be\nset up with a specific format.\n\nTeach git-submodule(1) to also propagate the object storage format.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-submodule.adoc           | 10 +++-\n builtin/clone.c                            | 10 +++-\n builtin/submodule--helper.c                | 28 +++++++++\n git-submodule.sh                           | 18 ++++++\n t/meson.build                              |  1 +\n t/t7427-submodule-object-storage-format.sh | 91 ++++++++++++++++++++++++++++++\n 6 files changed, 154 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-submodule.adoc b/Documentation/git-submodule.adoc\nindex e9c81a7170..57a21bc8d9 100644\n--- a/Documentation/git-submodule.adoc\n+++ b/Documentation/git-submodule.adoc\n@@ -34,7 +34,7 @@ COMMANDS\n With no arguments, shows the status of existing submodules.  Several\n subcommands are available to perform operations on the submodules.\n \n-`add [-b <branch>] [-f | --force] [--name <name>] [--reference <repository>] [--ref-storage-format <format>] [--depth <depth>] [--] <repository> [<path>]`::\n+`add [-b <branch>] [-f | --force] [--name <name>] [--reference <repository>] [--ref-storage-format <format>] [--object-storage-format <format>] [--depth <depth>] [--] <repository> [<path>]`::\n \tAdd the given repository as a submodule at the given path\n \tto the changeset to be committed next to the current\n \tproject: the current project is termed the \"superproject\".\n@@ -75,6 +75,9 @@ URL in `.gitmodules`.\n If `--ref-storage-format <format>` or its deprecated alias `--ref-format\n <format>` is specified, the ref storage format of the newly cloned submodules\n will be set accordingly.\n++\n+If `--object-storage-format <format>` is specified, the object storage format\n+of the newly cloned submodules will be set accordingly.\n \n `status [--cached] [--recursive] [--] [<path>...]`::\n \tShow the status of the submodules. This will print the SHA-1 of the\n@@ -140,7 +143,7 @@ If you really want to remove a submodule from the repository and commit\n that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal\n options.\n \n-`update [--init] [--remote] [-N | --no-fetch] [--[no-]recommend-shallow] [-f | --force] [--checkout | --rebase | --merge] [--reference=<repository>] [--ref-storage-format=<format>] [--depth=<depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter=<filter-spec>] [--] [<path>...]`::\n+`update [--init] [--remote] [-N | --no-fetch] [--[no-]recommend-shallow] [-f | --force] [--checkout | --rebase | --merge] [--reference=<repository>] [--ref-storage-format=<format>] [--object-storage-format=<format>] [--depth=<depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter=<filter-spec>] [--] [<path>...]`::\n +\n --\n Update the registered submodules to match what the superproject\n@@ -193,6 +196,9 @@ If `--ref-storage-format <format>` or its deprecated alias `--ref-format\n <format>` is specified, the ref storage format of the newly cloned submodules\n will be set accordingly.\n \n+If `--object-storage-format <format>` is specified, the object storage format\n+of the newly cloned submodules will be set accordingly.\n+\n If `--filter <filter-spec>` is specified, the given partial clone filter will be\n applied to the submodule. See linkgit:git-rev-list[1] for details on filter\n specifications.\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 85c124dc37..63348c3f34 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -686,7 +686,8 @@ static int git_sparse_checkout_init(const char *repo)\n static int checkout(int submodule_progress,\n \t\t    struct list_objects_filter_options *filter_options,\n \t\t    int filter_submodules,\n-\t\t    enum ref_storage_format ref_storage_format)\n+\t\t    enum ref_storage_format ref_storage_format,\n+\t\t    const char *object_storage_format_uri)\n {\n \tstruct object_id oid;\n \tchar *head;\n@@ -776,6 +777,10 @@ static int checkout(int submodule_progress,\n \t\t\tstrvec_pushf(&cmd.args, \"--ref-storage-format=%s\",\n \t\t\t\t     ref_storage_format_to_name(ref_storage_format));\n \n+\t\tif (object_storage_format_uri)\n+\t\t\tstrvec_pushf(&cmd.args, \"--object-storage-format=%s\",\n+\t\t\t\t     object_storage_format_uri);\n+\n \t\tif (filter_submodules && filter_options->choice)\n \t\t\tstrvec_pushf(&cmd.args, \"--filter=%s\",\n \t\t\t\t     expand_list_objects_filter_spec(filter_options));\n@@ -1703,7 +1708,8 @@ int cmd_clone(int argc,\n \terr = checkout(submodule_progress,\n \t\t       &filter_options,\n \t\t       filter_submodules,\n-\t\t       ref_storage_format);\n+\t\t       ref_storage_format,\n+\t\t       object_storage_format_uri);\n \n \tlist_objects_filter_release(&filter_options);\n \ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 64412adf9f..8a9c9e17b6 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1739,6 +1739,7 @@ struct module_clone_data {\n \tint depth;\n \tstruct list_objects_filter_options *filter_options;\n \tenum ref_storage_format ref_storage_format;\n+\tconst char *object_storage_format;\n \tunsigned int quiet: 1;\n \tunsigned int progress: 1;\n \tunsigned int dissociate: 1;\n@@ -1948,6 +1949,9 @@ static int clone_submodule(const struct module_clone_data *clone_data,\n \t\tif (clone_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tstrvec_pushf(&cp.args, \"--ref-storage-format=%s\",\n \t\t\t\t     ref_storage_format_to_name(clone_data->ref_storage_format));\n+\t\tif (clone_data->object_storage_format)\n+\t\t\tstrvec_pushf(&cp.args, \"--object-storage-format=%s\",\n+\t\t\t\t     clone_data->object_storage_format);\n \t\tif (clone_data->dissociate)\n \t\t\tstrvec_push(&cp.args, \"--dissociate\");\n \t\tif (sm_gitdir && *sm_gitdir)\n@@ -2065,6 +2069,8 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &clone_data.object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &dissociate,\n \t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_INTEGER(0, \"depth\", &clone_data.depth,\n@@ -2095,6 +2101,9 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \t\tif (clone_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (clone_data.object_storage_format &&\n+\t    odb_source_type_by_uri(clone_data.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), clone_data.object_storage_format);\n \tclone_data.dissociate = !!dissociate;\n \tclone_data.quiet = !!quiet;\n \tclone_data.progress = !!progress;\n@@ -2202,6 +2211,7 @@ struct update_data {\n \tstruct list_objects_filter_options *filter_options;\n \tstruct module_list list;\n \tenum ref_storage_format ref_storage_format;\n+\tconst char *object_storage_format;\n \tint depth;\n \tint max_jobs;\n \tint single_branch;\n@@ -2365,6 +2375,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n \tif (suc->update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\tstrvec_pushf(&child->args, \"--ref-storage-format=%s\",\n \t\t\t     ref_storage_format_to_name(suc->update_data->ref_storage_format));\n+\tif (suc->update_data->object_storage_format)\n+\t\tstrvec_pushf(&child->args, \"--object-storage-format=%s\",\n+\t\t\t     suc->update_data->object_storage_format);\n \tstrvec_pushl(&child->args, \"--path\", sub->path, NULL);\n \tstrvec_pushl(&child->args, \"--name\", sub->name, NULL);\n \tstrvec_pushl(&child->args, \"--url\", url, NULL);\n@@ -2809,6 +2822,9 @@ static void update_data_to_args(const struct update_data *update_data,\n \tif (update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\tstrvec_pushf(args, \"--ref-storage-format=%s\",\n \t\t\t     ref_storage_format_to_name(update_data->ref_storage_format));\n+\tif (update_data->object_storage_format)\n+\t\tstrvec_pushf(args, \"--object-storage-format=%s\",\n+\t\t\t     update_data->object_storage_format);\n \tif (update_data->filter_options && update_data->filter_options->choice)\n \t\tstrvec_pushf(args, \"--filter=%s\",\n \t\t\t\texpand_list_objects_filter_spec(\n@@ -3019,6 +3035,8 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &opt.object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n \t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_INTEGER(0, \"depth\", &opt.depth,\n@@ -3067,6 +3085,9 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \t\tif (opt.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (opt.object_storage_format &&\n+\t    odb_source_type_by_uri(opt.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), opt.object_storage_format);\n \n \topt.filter_options = &filter_options;\n \topt.prefix = prefix;\n@@ -3372,6 +3393,7 @@ struct add_data {\n \tconst char *repo;\n \tconst char *realrepo;\n \tenum ref_storage_format ref_storage_format;\n+\tconst char *object_storage_format;\n \tint depth;\n \tunsigned int force: 1;\n \tunsigned int quiet: 1;\n@@ -3477,6 +3499,7 @@ static int add_submodule(const struct add_data *add_data)\n \t\t\tstring_list_append(&reference, p)->util = p;\n \t\t}\n \t\tclone_data.ref_storage_format = add_data->ref_storage_format;\n+\t\tclone_data.object_storage_format = add_data->object_storage_format;\n \t\tclone_data.dissociate = add_data->dissociate;\n \t\tif (add_data->depth >= 0)\n \t\t\tclone_data.depth = add_data->depth;\n@@ -3669,6 +3692,8 @@ static int module_add(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &add_data.object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &dissociate, N_(\"borrow the objects from reference repositories\")),\n \t\tOPT_STRING(0, \"name\", &add_data.sm_name, N_(\"name\"),\n \t\t\t   N_(\"sets the submodule's name to the given string \"\n@@ -3700,6 +3725,9 @@ static int module_add(int argc, const char **argv, const char *prefix,\n \t\tif (add_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (add_data.object_storage_format &&\n+\t    odb_source_type_by_uri(add_data.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), add_data.object_storage_format);\n \n \tadd_data.repo = argv[0];\n \tif (argc == 1)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 8632194138..4de5ffba04 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -103,6 +103,14 @@ cmd_add()\n \t\t--ref-format=*|--ref-storage-format=*)\n \t\t\tref_storage_format=\"$1\"\n \t\t\t;;\n+\t\t--object-storage-format)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tobject_storage_format=\"--object-storage-format=$2\"\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--object-storage-format=*)\n+\t\t\tobject_storage_format=\"$1\"\n+\t\t\t;;\n \t\t--dissociate)\n \t\t\tdissociate=$1\n \t\t\t;;\n@@ -148,6 +156,7 @@ cmd_add()\n \t\t${branch:+\"$branch\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${ref_storage_format:+\"$ref_storage_format\"} \\\n+\t\t${object_storage_format:+\"$object_storage_format\"} \\\n \t\t$dissociate \\\n \t\t${name:+\"$name\"} \\\n \t\t${depth:+\"$depth\"} \\\n@@ -310,6 +319,14 @@ cmd_update()\n \t\t--ref-format=*|--ref-storage-format=*)\n \t\t\tref_storage_format=\"$1\"\n \t\t\t;;\n+\t\t--object-storage-format)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tobject_storage_format=\"--object-storage-format=$2\"\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--object-storage-format=*)\n+\t\t\tobject_storage_format=\"$1\"\n+\t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n \t\t\treference=\"--reference=$2\"\n@@ -386,6 +403,7 @@ cmd_update()\n \t\t$merge \\\n \t\t$checkout \\\n \t\t${ref_storage_format:+\"$ref_storage_format\"} \\\n+\t\t${object_storage_format:+\"$object_storage_format\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t$dissociate \\\n \t\t${depth:+\"$depth\"} \\\ndiff --git a/t/meson.build b/t/meson.build\nindex 11b3752f00..8542035b6f 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -926,6 +926,7 @@ integration_tests = [\n   't7424-submodule-mixed-ref-formats.sh',\n   't7425-submodule-gitdir-path-extension.sh',\n   't7426-submodule-get-default-remote.sh',\n+  't7427-submodule-object-storage-format.sh',\n   't7450-bad-git-dotfiles.sh',\n   't7500-commit-template-squash-signoff.sh',\n   't7501-commit-basic-functionality.sh',\ndiff --git a/t/t7427-submodule-object-storage-format.sh b/t/t7427-submodule-object-storage-format.sh\nnew file mode 100755\nindex 0000000000..a2c9a5e753\n--- /dev/null\n+++ b/t/t7427-submodule-object-storage-format.sh\n@@ -0,0 +1,91 @@\n+#!/bin/sh\n+\n+test_description='submodules handle the object storage format'\n+\n+. ./test-lib.sh\n+\n+test_object_storage_format () {\n+\techo \"$2\" >expect &&\n+\tgit -C \"$1\" rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+}\n+\n+test_expect_success 'setup' '\n+\tgit config set --global protocol.file.allow always\n+'\n+\n+test_expect_success 'add existing repository with different object storage format' '\n+\ttest_when_finished \"rm -rf parent\" &&\n+\n+\tgit init parent &&\n+\t(\n+\t\tcd parent &&\n+\t\ttest_commit parent &&\n+\t\tgit init --object-storage-format=files://objs submodule &&\n+\t\ttest_commit -C submodule submodule &&\n+\t\tgit submodule add ./submodule &&\n+\t\ttest_object_storage_format submodule files://objs\n+\t)\n+'\n+\n+test_expect_success 'add submodules with different object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\ttest_object_storage_format upstream files &&\n+\tgit -C upstream submodule add --object-storage-format=files://objs \"file://$(pwd)/submodule\" &&\n+\ttest_object_storage_format upstream/submodule files://objs &&\n+\ttest_path_is_dir upstream/.git/modules/submodule/objs/pack\n+'\n+\n+test_expect_success 'add submodules with garbage object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git -C upstream submodule add --object-storage-format=garbage \"file://$(pwd)/submodule\" 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'recursive clone propagates object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tgit -C upstream submodule add \"file://$(pwd)/submodule\" &&\n+\tgit -C upstream commit -am \"add submodule\" &&\n+\n+\ttest_object_storage_format upstream files &&\n+\ttest_object_storage_format upstream/submodule files &&\n+\n+\tgit clone --object-storage-format=files://objs --recurse-submodules \\\n+\t\tupstream downstream &&\n+\ttest_object_storage_format downstream files://objs &&\n+\ttest_object_storage_format downstream/submodule files://objs &&\n+\ttest_path_is_dir downstream/.git/objs/pack &&\n+\ttest_path_is_dir downstream/.git/modules/submodule/objs/pack\n+'\n+\n+test_expect_success 'clone submodules with different object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tgit -C upstream submodule add \"file://$(pwd)/submodule\" &&\n+\tgit -C upstream commit -m \"upstream submodule\" &&\n+\n+\tgit clone --no-recurse-submodules \"file://$(pwd)/upstream\" downstream &&\n+\tgit -C downstream submodule update --init --object-storage-format=files://objs &&\n+\ttest_object_storage_format downstream files &&\n+\ttest_object_storage_format downstream/submodule files://objs\n+'\n+\n+test_done\n\n-- \n2.56.0.269.g68944adf51.dirty\n\n\n"},{"id":"555460","messageId":"CAOLa=ZT91C0OZE=h7B0j6mgPhfrGjkRN4bCT9gVEXdXx+bSi1A@mail.gmail.com","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-1-143a5963b77f@pks.im","subject":"Re: [PATCH 1/7] loose: drop unused `repo_write_loose_object_map()`","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-19T20:21:08Z","receivedAt":"2026-10-19T20:21:08Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> The function `repo_write_loose_object_map()` was introduced in\n> 23b2c7e95b (loose: add a mapping between SHA-1 and SHA-256 for loose\n> objects, 2023-10-01), but it never had any callers as loose object maps\n> are instead written incrementally via `repo_add_loose_object_map()`\n> whenever a new loose object is created.\n>\n> Besides being dead code, the function also hardcodes the location of the\n> \"loose-object-idx\" file as \"$GIT_COMMON_DIR/objects\", whereas both the\n> reader and `repo_add_loose_object_map()` derive the location from the\n> loose source's path. The function would thus disagree with everyone else\n> where the loose object map is supposed to be located when the object\n> directory is using a non-default location.\n>\n> Remove the function.\n>\n\nIt's like the function being unused is an insufficient argument by\nitself, so we also talk about why its incorrect. Made me chuckle.\n\nThe patch obviously makes sense.\n\n[snip]\n"},{"id":"555470","messageId":"CAOLa=ZQj0sZu7WRzmvgZx23ZeO1KBtOm6yWOLCzeVP_86zkTPQ@mail.gmail.com","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-2-143a5963b77f@pks.im","subject":"Re: [PATCH 2/7] setup: introduce object storage extension","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-19T21:29:20Z","receivedAt":"2026-10-19T21:29:20Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n[snip]\n\n> diff --git a/odb/source-files.c b/odb/source-files.c\n> index 455f409db0..4a7cbbfd9b 100644\n> --- a/odb/source-files.c\n> +++ b/odb/source-files.c\n> @@ -1235,6 +1235,7 @@ struct odb_files_dir *odb_source_files_find_dir(struct object_database *odb, con\n>  }\n>\n>  struct odb_source_files *odb_source_files_new(struct object_database *odb,\n> +\t\t\t\t\t      const char *payload,\n>  \t\t\t\t\t      enum odb_new_flags flags)\n>  {\n>  \tstruct odb_source_files *files;\n> @@ -1245,6 +1246,12 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,\n>  \t\tobject_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));\n>  \t\talternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));\n>  \t}\n> +\tif (!object_dir && payload) {\n> +\t\tif (is_absolute_path(payload))\n> +\t\t\tobject_dir = xstrdup(payload);\n> +\t\telse\n> +\t\t\tobject_dir = xstrfmt(\"%s/%s\", odb->repo->commondir, payload);\n> +\t}\n\nOn the reference side, we use `strbuf_realpath()` to convert the\nrelative paths to absolute paths, should we be doing that here too?\n\n>  \tif (!object_dir)\n>  \t\tobject_dir = xstrfmt(\"%s/objects\", odb->repo->commondir);\n>\n\n[snip]\n\n> diff --git a/odb/source.c b/odb/source.c\n> index b25ef14df8..10abe33a26 100644\n> --- a/odb/source.c\n> +++ b/odb/source.c\n> @@ -1,4 +1,5 @@\n>  #include \"git-compat-util.h\"\n> +#include \"gettext.h\"\n>  #include \"object-file.h\"\n>  #include \"odb/source-files.h\"\n>  #include \"odb/source.h\"\n\nDo we need this import? This commit seems to compile without it.\n\n[snip]\n\n> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> index f1d227f271..c7c464d3a2 100755\n> --- a/t/t0001-init.sh\n> +++ b/t/t0001-init.sh\n> @@ -839,6 +839,36 @@ test_expect_success 'init with --ref-storage-format=garbage' '\n>  \ttest_cmp expect err\n>  '\n>\n> +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage is not allowed with repo version 0' '\n> +\ttest_when_finished \"rm -rf objstorage\" &&\n> +\tgit init objstorage &&\n> +\tgit -C objstorage config set extensions.objectStorage files &&\n> +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n> +\ttest_grep \"repo version is 0, but v1-only extension found\" err\n> +'\n> +\n> +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files backend' '\n> +\ttest_when_finished \"rm -rf objstorage\" &&\n> +\tgit init objstorage &&\n> +\tgit -C objstorage config set core.repositoryformatversion 1 &&\n\nIf we're doing this, do we still need DEFAULT_REPO_FORMAT?\n\n> +\tgit -C objstorage config set extensions.objectStorage files &&\n> +\ttest_commit -C objstorage A &&\n> +\tgit -C objstorage rev-parse --verify HEAD\n> +'\n> +\n> +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\n> +\ttest_when_finished \"rm -rf objstorage\" &&\n> +\tgit init objstorage &&\n> +\tgit -C objstorage config set core.repositoryformatversion 1 &&\n\nSame question here.\n\n> +\tgit -C objstorage config set extensions.objectStorage garbage &&\n> +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n> +\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage${SQ}\" err &&\n> +\n> +\tgit config --file objstorage/.git/config extensions.objectStorage garbage://payload &&\n> +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n> +\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n> +'\n> +\n\nWe should add  tests for the files ODB with {valid, invalid} payload. We\nshould probably also test absolute and relative paths in the valid flow.\n\n>  test_expect_success MINGW 'core.hidedotfiles = false' '\n>  \tgit config --global core.hidedotfiles false &&\n>  \trm -rf newdir &&\n>\n> --\n> 2.56.0.269.g68944adf51.dirty\n"},{"id":"555472","messageId":"CAOLa=ZTbYQvnKBodYm4Bmk7Veb=tt6oDJwWqb+AfXdiuLxcdrA@mail.gmail.com","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-3-143a5963b77f@pks.im","subject":"Re: [PATCH 3/7] setup: allow overriding object storage format via environment","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-19T21:34:39Z","receivedAt":"2026-10-19T21:34:39Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> The ref storage format configured via \"extensions.refStorage\" can be\n> overridden with the GIT_REF_STORAGE_FORMAT environment variable.\n> Introduce the GIT_OBJECT_STORAGE_FORMAT environment variable that\n> overrides \"extensions.objectStorage\" in the same way.\n\n[snip]\n\n> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> index c7c464d3a2..5e7c25e42c 100755\n> --- a/t/t0001-init.sh\n> +++ b/t/t0001-init.sh\n> @@ -869,6 +869,32 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown b\n>  \ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n>  '\n>\n> +test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides extensions.objectStorage' '\n> +\ttest_when_finished \"rm -rf objstorage\" &&\n> +\tgit init objstorage &&\n> +\t(\n> +\t\tcd objstorage &&\n> +\t\tgit config set core.repositoryformatversion 1 &&\n> +\t\tgit config set extensions.objectStorage files://objs &&\n\nThis commit does test the payload for the files backend. I do wonder if\nwe can make a matrix for tests\n\n   {config, env} x\n   {valid backend, invalid backend} x\n   {valid relative path, valid absolute path, invalid path}\n\n> +\t\tmkdir .git/objs .git/other &&\n> +\n> +\t\techo content >file &&\n> +\t\toid=$(git hash-object -w file) &&\n> +\t\ttest_path_is_file .git/objs/$(test_oid_to_path \"$oid\") &&\n> +\t\tgit cat-file -e \"$oid\" &&\n> +\n> +\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://other git cat-file -e \"$oid\" &&\n> +\t\tGIT_OBJECT_STORAGE_FORMAT=files://other git hash-object -w file &&\n> +\t\ttest_path_is_file .git/other/$(test_oid_to_path \"$oid\") &&\n> +\n> +\t\tcat >expect <<-EOF &&\n> +\t\tfatal: unknown object storage format: ${SQ}garbage${SQ}\n> +\t\tEOF\n> +\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git rev-parse 2>err &&\n> +\t\ttest_cmp expect err\n> +\t)\n> +'\n> +\n>  test_expect_success MINGW 'core.hidedotfiles = false' '\n>  \tgit config --global core.hidedotfiles false &&\n>  \trm -rf newdir &&\n>\n> --\n> 2.56.0.269.g68944adf51.dirty\n"},{"id":"555473","messageId":"CAOLa=ZQ1E5sg05++KCXgbM9+=4=vFeCHU-5iMbNEGRuS-8+aPg@mail.gmail.com","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-4-143a5963b77f@pks.im","subject":"Re: [PATCH 4/7] builtin: expose the object storage format","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-19T21:40:31Z","receivedAt":"2026-10-19T21:40:31Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> The ref storage format of a repository can be inspected via both\n> git-rev-parse(1)'s \"--show-ref-storage-format\" and git-repo(1)'s\n> \"references.storageFormat\" field. Introduce the equivalent options for\n> the object storage format, as well.\n\n[snip]\n\n> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n> index cb8c1e7292..d2dc9b7a69 100644\n> --- a/Documentation/git-repo.adoc\n> +++ b/Documentation/git-repo.adoc\n> @@ -105,6 +105,12 @@ values that they return:\n>  `object.format`::\n>  \tThe object format (hash algorithm) used in the repository.\n>\n> +`objects.storageFormat`::\n> +\tThe object storage format used in the repository, as configured via\n> +\t`extensions.objectStorage`. The valid values are:\n> ++\n\nThe nuance between `object` above and `objects` here is too little and\ncan be confusing. But there's nothing we can really do here.\n\n[snip]\n\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index 84e012f83f..da11a56ede 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -128,11 +129,20 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n>  \treturn 0;\n>  }\n>\n> +static int get_object_storage_format(struct repository *repo, struct strbuf *buf)\n> +{\n> +\tstrbuf_addstr(buf, repo->object_storage_format ?\n> +\t\t      repo->object_storage_format :\n> +\t\t      odb_source_type_to_name(ODB_SOURCE_FILES));\n> +\treturn 0;\n> +}\n\nIs there a reason why `repo->object_storage_format` won't be set, I\ndon't like the fact that we have to expose the default object storage\nformat outside the repository and odb subsystem.\n\n> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\n> index ec33c19bdf..b206944ad9 100644\n> @@ -1138,6 +1139,12 @@ int cmd_rev_parse(int argc,\n>  \t\t\t\tputs(ref_storage_format_to_name(the_repository->ref_storage_format));\n>  \t\t\t\tcontinue;\n>  \t\t\t}\n> +\t\t\tif (!strcmp(arg, \"--show-object-storage-format\")) {\n> +\t\t\t\tputs(the_repository->object_storage_format ?\n> +\t\t\t\t     the_repository->object_storage_format :\n> +\t\t\t\t     odb_source_type_to_name(ODB_SOURCE_FILES));\n\nSame question here.\n\n> +\t\t\t\tcontinue;\n> +\t\t\t}\n>  \t\t\tif (!strcmp(arg, \"--end-of-options\")) {\n>  \t\t\t\tseen_end_of_options = 1;\n>  \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\n\n[snip]\n"},{"id":"555488","messageId":"xmqqh5ihyxd2.fsf@gitster.g","threadId":"66584","inReplyTo":"CAOLa=ZQj0sZu7WRzmvgZx23ZeO1KBtOm6yWOLCzeVP_86zkTPQ@mail.gmail.com","subject":"Re: [PATCH 2/7] setup: introduce object storage extension","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-20T01:27:53Z","receivedAt":"2026-10-20T01:27:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n>> diff --git a/odb/source.c b/odb/source.c\n>> index b25ef14df8..10abe33a26 100644\n>> --- a/odb/source.c\n>> +++ b/odb/source.c\n>> @@ -1,4 +1,5 @@\n>>  #include \"git-compat-util.h\"\n>> +#include \"gettext.h\"\n>>  #include \"object-file.h\"\n>>  #include \"odb/source-files.h\"\n>>  #include \"odb/source.h\"\n>\n> Do we need this import? This commit seems to compile without it.\n\nIt is better to be explicit, rather than relying on an indirect\ninclusion from an unrelated header.  Since odb/source.c is more\nor less a library-like part of the system, however, the presence\nof translatable messages meant for human users is a bit of a\ncuriosity.\n\n"},{"id":"555506","messageId":"atcrJ2u9F_9M9wTl@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZT91C0OZE=h7B0j6mgPhfrGjkRN4bCT9gVEXdXx+bSi1A@mail.gmail.com","subject":"Re: [PATCH 1/7] loose: drop unused `repo_write_loose_object_map()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-20T08:49:54Z","receivedAt":"2026-10-20T08:49:54Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Oct 19, 2026 at 01:21:08PM -0700, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > The function `repo_write_loose_object_map()` was introduced in\n> > 23b2c7e95b (loose: add a mapping between SHA-1 and SHA-256 for loose\n> > objects, 2023-10-01), but it never had any callers as loose object maps\n> > are instead written incrementally via `repo_add_loose_object_map()`\n> > whenever a new loose object is created.\n> >\n> > Besides being dead code, the function also hardcodes the location of the\n> > \"loose-object-idx\" file as \"$GIT_COMMON_DIR/objects\", whereas both the\n> > reader and `repo_add_loose_object_map()` derive the location from the\n> > loose source's path. The function would thus disagree with everyone else\n> > where the loose object map is supposed to be located when the object\n> > directory is using a non-default location.\n> >\n> > Remove the function.\n> >\n> \n> It's like the function being unused is an insufficient argument by\n> itself, so we also talk about why its incorrect. Made me chuckle.\n\nYeah. The only reason that I even stumbled over this function is that\nit'll break with the object storage format extension, because it would\nput files into the wrong location. I only realized later on that the\nfunction isn't even used at all. But that probably explains why this\nmessage is a bit on the excessive side.\n\nShould I trim it?\n\nPatrick\n\n"},{"id":"555507","messageId":"atcrO3y0o-2G8Dpu@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZQj0sZu7WRzmvgZx23ZeO1KBtOm6yWOLCzeVP_86zkTPQ@mail.gmail.com","subject":"Re: [PATCH 2/7] setup: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-20T08:50:03Z","receivedAt":"2026-10-20T08:50:03Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Oct 19, 2026 at 02:29:20PM -0700, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > diff --git a/odb/source-files.c b/odb/source-files.c\n> > index 455f409db0..4a7cbbfd9b 100644\n> > --- a/odb/source-files.c\n> > +++ b/odb/source-files.c\n> > @@ -1245,6 +1246,12 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,\n> >  \t\tobject_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));\n> >  \t\talternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));\n> >  \t}\n> > +\tif (!object_dir && payload) {\n> > +\t\tif (is_absolute_path(payload))\n> > +\t\t\tobject_dir = xstrdup(payload);\n> > +\t\telse\n> > +\t\t\tobject_dir = xstrfmt(\"%s/%s\", odb->repo->commondir, payload);\n> > +\t}\n> \n> On the reference side, we use `strbuf_realpath()` to convert the\n> relative paths to absolute paths, should we be doing that here too?\n\nOverall I'd love for the \"files\" source to only ever use absolute paths,\nbut historically that wasn't the case. We sometimes expose those paths\nto users, and changing the \"files\" source thus breaks a bunch of tests.\n\nSo I'm retaining that behaviour for now, also with the extension. It may\nbe something to explore going forward though.\n\n> > diff --git a/odb/source.c b/odb/source.c\n> > index b25ef14df8..10abe33a26 100644\n> > --- a/odb/source.c\n> > +++ b/odb/source.c\n> > @@ -1,4 +1,5 @@\n> >  #include \"git-compat-util.h\"\n> > +#include \"gettext.h\"\n> >  #include \"object-file.h\"\n> >  #include \"odb/source-files.h\"\n> >  #include \"odb/source.h\"\n> \n> Do we need this import? This commit seems to compile without it.\n\nYeah, we add some translatable strings to `odb_source_new()`. The header\nis also implicitly included, but as Junio pointed out we should include\nheaders explicitly regardless when we require their declarations.\n\n> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> > index f1d227f271..c7c464d3a2 100755\n> > --- a/t/t0001-init.sh\n> > +++ b/t/t0001-init.sh\n> > @@ -839,6 +839,36 @@ test_expect_success 'init with --ref-storage-format=garbage' '\n> >  \ttest_cmp expect err\n> >  '\n> >\n> > +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage is not allowed with repo version 0' '\n> > +\ttest_when_finished \"rm -rf objstorage\" &&\n> > +\tgit init objstorage &&\n> > +\tgit -C objstorage config set extensions.objectStorage files &&\n> > +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n> > +\ttest_grep \"repo version is 0, but v1-only extension found\" err\n> > +'\n> > +\n> > +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files backend' '\n> > +\ttest_when_finished \"rm -rf objstorage\" &&\n> > +\tgit init objstorage &&\n> > +\tgit -C objstorage config set core.repositoryformatversion 1 &&\n> \n> If we're doing this, do we still need DEFAULT_REPO_FORMAT?\n\nWe could indeed get away with not having the prerequisite right now. But\nonce we have a second backend we'd need this, because in that case we'd\npotentially initialize the repository with a different backend here. And\nthen just switching over to the \"files\" backend would probably not\nresult in anything good.\n\nSo this is more of a protective measure for the future.\n\n> > +\tgit -C objstorage config set extensions.objectStorage garbage &&\n> > +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n> > +\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage${SQ}\" err &&\n> > +\n> > +\tgit config --file objstorage/.git/config extensions.objectStorage garbage://payload &&\n> > +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n> > +\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n> > +'\n> > +\n> \n> We should add  tests for the files ODB with {valid, invalid} payload. We\n> should probably also test absolute and relative paths in the valid flow.\n\nI add tests for both absolute and relative paths in a later commit. Here\nI'm basically just verifying whether the object storage extension even\nkicks in at all, without yet verifying its semantics properly.\n\nPatrick\n\n"},{"id":"555508","messageId":"atcrRWX2-S9374Sy@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZQ1E5sg05++KCXgbM9+=4=vFeCHU-5iMbNEGRuS-8+aPg@mail.gmail.com","subject":"Re: [PATCH 4/7] builtin: expose the object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-20T08:50:13Z","receivedAt":"2026-10-20T08:50:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Oct 19, 2026 at 02:40:31PM -0700, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n> > index cb8c1e7292..d2dc9b7a69 100644\n> > --- a/Documentation/git-repo.adoc\n> > +++ b/Documentation/git-repo.adoc\n> > @@ -105,6 +105,12 @@ values that they return:\n> >  `object.format`::\n> >  \tThe object format (hash algorithm) used in the repository.\n> >\n> > +`objects.storageFormat`::\n> > +\tThe object storage format used in the repository, as configured via\n> > +\t`extensions.objectStorage`. The valid values are:\n> > ++\n> \n> The nuance between `object` above and `objects` here is too little and\n> can be confusing. But there's nothing we can really do here.\n\nYeah, I'm not a fan of this, either. It used to be even worse than that,\nbecause we had \"references.format\" which was giving us information about\nthe backend that our refs use. And that's why I recently sent the patch\nseries to rename \"ref format\" to \"ref storage format\", so that we can\navoid this conflict here.\n\nIt's still not perfect to have both \"object.format\" and\n\"objects.storageFormat\". I was wondering whether we also want to rename\n\"object.format\" to \"objects.format\" to at least have the prefix match.\nBut I shied away from that.\n\n> > diff --git a/builtin/repo.c b/builtin/repo.c\n> > index 84e012f83f..da11a56ede 100644\n> > --- a/builtin/repo.c\n> > +++ b/builtin/repo.c\n> > @@ -128,11 +129,20 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n> >  \treturn 0;\n> >  }\n> >\n> > +static int get_object_storage_format(struct repository *repo, struct strbuf *buf)\n> > +{\n> > +\tstrbuf_addstr(buf, repo->object_storage_format ?\n> > +\t\t      repo->object_storage_format :\n> > +\t\t      odb_source_type_to_name(ODB_SOURCE_FILES));\n> > +\treturn 0;\n> > +}\n> \n> Is there a reason why `repo->object_storage_format` won't be set, I\n> don't like the fact that we have to expose the default object storage\n> format outside the repository and odb subsystem.\n\nHmm, not really, and I agree that this creates some awkwardness. I'll\nhave a look at whether I can fix that.\n\nPatrick\n\n"},{"id":"555509","messageId":"atcrZHZkvitoFJMR@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZTbYQvnKBodYm4Bmk7Veb=tt6oDJwWqb+AfXdiuLxcdrA@mail.gmail.com","subject":"Re: [PATCH 3/7] setup: allow overriding object storage format via environment","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-20T08:50:44Z","receivedAt":"2026-10-20T08:50:44Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Oct 19, 2026 at 05:34:39PM -0400, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> > index c7c464d3a2..5e7c25e42c 100755\n> > --- a/t/t0001-init.sh\n> > +++ b/t/t0001-init.sh\n> > @@ -869,6 +869,32 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown b\n> >  \ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n> >  '\n> >\n> > +test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides extensions.objectStorage' '\n> > +\ttest_when_finished \"rm -rf objstorage\" &&\n> > +\tgit init objstorage &&\n> > +\t(\n> > +\t\tcd objstorage &&\n> > +\t\tgit config set core.repositoryformatversion 1 &&\n> > +\t\tgit config set extensions.objectStorage files://objs &&\n> \n> This commit does test the payload for the files backend. I do wonder if\n> we can make a matrix for tests\n> \n>    {config, env} x\n>    {valid backend, invalid backend} x\n>    {valid relative path, valid absolute path, invalid path}\n\nThere's more to this test matrix: GIT_DEFAULT_OBJECT_STORAGE_FORMAT,\n\"init.defaultObjectStorageFormat\", \"git init --object-storage-format=\".\nSo that would result in a matrix that covers 30 different combinations,\nwhich I feel might be a bit excessive.\n\nThat being said I do add lots of tests especially in the patch that\nextends git-init(1), even though they're not layed out in a matrix. I'd\npropose that we go from there and extend these tests in case there's\nanything missing there?\n\nI think the one thing that's missing is exercising invalid paths. The\nquestion though is what an invalid path even is. Right now for example\nwe use `safe_create_dir()`, so we won't create leading directories. I'm\nnot sure whether that restriction is a sensible one, and because of this\nI shy away from seemingly casting it into stone via a test. But if we\neventually start to create leading directories, then there isn't really\nany path that I would consider invalid, right?\n\nPatrick\n\n"},{"id":"555596","messageId":"CAOLa=ZQLbB5R1sc9M7Odkp7gpHAFCy9Wa+OYOJoEpUXGS2X3=A@mail.gmail.com","threadId":"66584","inReplyTo":"atcrJ2u9F_9M9wTl@pks.im","subject":"Re: [PATCH 1/7] loose: drop unused `repo_write_loose_object_map()`","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-20T18:30:30Z","receivedAt":"2026-10-20T18:30:30Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Mon, Oct 19, 2026 at 01:21:08PM -0700, Karthik Nayak wrote:\n>> Patrick Steinhardt <ps@pks.im> writes:\n>>\n>> > The function `repo_write_loose_object_map()` was introduced in\n>> > 23b2c7e95b (loose: add a mapping between SHA-1 and SHA-256 for loose\n>> > objects, 2023-10-01), but it never had any callers as loose object maps\n>> > are instead written incrementally via `repo_add_loose_object_map()`\n>> > whenever a new loose object is created.\n>> >\n>> > Besides being dead code, the function also hardcodes the location of the\n>> > \"loose-object-idx\" file as \"$GIT_COMMON_DIR/objects\", whereas both the\n>> > reader and `repo_add_loose_object_map()` derive the location from the\n>> > loose source's path. The function would thus disagree with everyone else\n>> > where the loose object map is supposed to be located when the object\n>> > directory is using a non-default location.\n>> >\n>> > Remove the function.\n>> >\n>>\n>> It's like the function being unused is an insufficient argument by\n>> itself, so we also talk about why its incorrect. Made me chuckle.\n>\n> Yeah. The only reason that I even stumbled over this function is that\n> it'll break with the object storage format extension, because it would\n> put files into the wrong location. I only realized later on that the\n> function isn't even used at all. But that probably explains why this\n> message is a bit on the excessive side.\n>\n> Should I trim it?\n>\n\nI think its good, I just was amused by it.\n\n> Patrick\n"},{"id":"555597","messageId":"CAOLa=ZTqy4WQv4vwJJAsyBo0n0-Pj5gXCtbwO1Ctz-E5TGE1Fw@mail.gmail.com","threadId":"66584","inReplyTo":"xmqqh5ihyxd2.fsf@gitster.g","subject":"Re: [PATCH 2/7] setup: introduce object storage extension","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-20T18:32:07Z","receivedAt":"2026-10-20T18:32:07Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n>>> diff --git a/odb/source.c b/odb/source.c\n>>> index b25ef14df8..10abe33a26 100644\n>>> --- a/odb/source.c\n>>> +++ b/odb/source.c\n>>> @@ -1,4 +1,5 @@\n>>>  #include \"git-compat-util.h\"\n>>> +#include \"gettext.h\"\n>>>  #include \"object-file.h\"\n>>>  #include \"odb/source-files.h\"\n>>>  #include \"odb/source.h\"\n>>\n>> Do we need this import? This commit seems to compile without it.\n>\n> It is better to be explicit, rather than relying on an indirect\n> inclusion from an unrelated header.  Since odb/source.c is more\n> or less a library-like part of the system, however, the presence\n> of translatable messages meant for human users is a bit of a\n> curiosity.\n\nAh! it's for the '_()' translation, I missed that. Makes sense. Thanks\n"},{"id":"555609","messageId":"CAOLa=ZQ9YH43igSivrCTy9ruDsRnTDPu0xipp3XdpNXU2zmtCA@mail.gmail.com","threadId":"66584","inReplyTo":"atcrO3y0o-2G8Dpu@pks.im","subject":"Re: [PATCH 2/7] setup: introduce object storage extension","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-20T19:06:00Z","receivedAt":"2026-10-20T19:06:00Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Mon, Oct 19, 2026 at 02:29:20PM -0700, Karthik Nayak wrote:\n>> Patrick Steinhardt <ps@pks.im> writes:\n>> > diff --git a/odb/source-files.c b/odb/source-files.c\n>> > index 455f409db0..4a7cbbfd9b 100644\n>> > --- a/odb/source-files.c\n>> > +++ b/odb/source-files.c\n>> > @@ -1245,6 +1246,12 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,\n>> >  \t\tobject_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));\n>> >  \t\talternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));\n>> >  \t}\n>> > +\tif (!object_dir && payload) {\n>> > +\t\tif (is_absolute_path(payload))\n>> > +\t\t\tobject_dir = xstrdup(payload);\n>> > +\t\telse\n>> > +\t\t\tobject_dir = xstrfmt(\"%s/%s\", odb->repo->commondir, payload);\n>> > +\t}\n>>\n>> On the reference side, we use `strbuf_realpath()` to convert the\n>> relative paths to absolute paths, should we be doing that here too?\n>\n> Overall I'd love for the \"files\" source to only ever use absolute paths,\n> but historically that wasn't the case. We sometimes expose those paths\n> to users, and changing the \"files\" source thus breaks a bunch of tests.\n>\n> So I'm retaining that behaviour for now, also with the extension. It may\n> be something to explore going forward though.\n>\n>> > diff --git a/odb/source.c b/odb/source.c\n>> > index b25ef14df8..10abe33a26 100644\n>> > --- a/odb/source.c\n>> > +++ b/odb/source.c\n>> > @@ -1,4 +1,5 @@\n>> >  #include \"git-compat-util.h\"\n>> > +#include \"gettext.h\"\n>> >  #include \"object-file.h\"\n>> >  #include \"odb/source-files.h\"\n>> >  #include \"odb/source.h\"\n>>\n>> Do we need this import? This commit seems to compile without it.\n>\n> Yeah, we add some translatable strings to `odb_source_new()`. The header\n> is also implicitly included, but as Junio pointed out we should include\n> headers explicitly regardless when we require their declarations.\n>\n>> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n>> > index f1d227f271..c7c464d3a2 100755\n>> > --- a/t/t0001-init.sh\n>> > +++ b/t/t0001-init.sh\n>> > @@ -839,6 +839,36 @@ test_expect_success 'init with --ref-storage-format=garbage' '\n>> >  \ttest_cmp expect err\n>> >  '\n>> >\n>> > +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage is not allowed with repo version 0' '\n>> > +\ttest_when_finished \"rm -rf objstorage\" &&\n>> > +\tgit init objstorage &&\n>> > +\tgit -C objstorage config set extensions.objectStorage files &&\n>> > +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n>> > +\ttest_grep \"repo version is 0, but v1-only extension found\" err\n>> > +'\n>> > +\n>> > +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files backend' '\n>> > +\ttest_when_finished \"rm -rf objstorage\" &&\n>> > +\tgit init objstorage &&\n>> > +\tgit -C objstorage config set core.repositoryformatversion 1 &&\n>>\n>> If we're doing this, do we still need DEFAULT_REPO_FORMAT?\n>\n> We could indeed get away with not having the prerequisite right now. But\n> once we have a second backend we'd need this, because in that case we'd\n> potentially initialize the repository with a different backend here. And\n> then just switching over to the \"files\" backend would probably not\n> result in anything good.\n>\n> So this is more of a protective measure for the future.\n>\n\nYeah but this also means that this doesn't run with refs reftable, no?\nIt should be okay, I'll leave it to you.\n\n>> > +\tgit -C objstorage config set extensions.objectStorage garbage &&\n>> > +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n>> > +\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage${SQ}\" err &&\n>> > +\n>> > +\tgit config --file objstorage/.git/config extensions.objectStorage garbage://payload &&\n>> > +\ttest_must_fail git -C objstorage rev-parse 2>err &&\n>> > +\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n>> > +'\n>> > +\n>>\n>> We should add  tests for the files ODB with {valid, invalid} payload. We\n>> should probably also test absolute and relative paths in the valid flow.\n>\n> I add tests for both absolute and relative paths in a later commit. Here\n> I'm basically just verifying whether the object storage extension even\n> kicks in at all, without yet verifying its semantics properly.\n>\n> Patrick\n\nYeah, I think I saw those after this email.\n"},{"id":"555610","messageId":"CAOLa=ZT=prBjyG3aOcnZJiqJ_2x4n8hcE1P3-UkJa7ynLpvVYA@mail.gmail.com","threadId":"66584","inReplyTo":"atcrZHZkvitoFJMR@pks.im","subject":"Re: [PATCH 3/7] setup: allow overriding object storage format via environment","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-20T19:08:36Z","receivedAt":"2026-10-20T19:08:36Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Mon, Oct 19, 2026 at 05:34:39PM -0400, Karthik Nayak wrote:\n>> Patrick Steinhardt <ps@pks.im> writes:\n>> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n>> > index c7c464d3a2..5e7c25e42c 100755\n>> > --- a/t/t0001-init.sh\n>> > +++ b/t/t0001-init.sh\n>> > @@ -869,6 +869,32 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown b\n>> >  \ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n>> >  '\n>> >\n>> > +test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides extensions.objectStorage' '\n>> > +\ttest_when_finished \"rm -rf objstorage\" &&\n>> > +\tgit init objstorage &&\n>> > +\t(\n>> > +\t\tcd objstorage &&\n>> > +\t\tgit config set core.repositoryformatversion 1 &&\n>> > +\t\tgit config set extensions.objectStorage files://objs &&\n>>\n>> This commit does test the payload for the files backend. I do wonder if\n>> we can make a matrix for tests\n>>\n>>    {config, env} x\n>>    {valid backend, invalid backend} x\n>>    {valid relative path, valid absolute path, invalid path}\n>\n> There's more to this test matrix: GIT_DEFAULT_OBJECT_STORAGE_FORMAT,\n> \"init.defaultObjectStorageFormat\", \"git init --object-storage-format=\".\n> So that would result in a matrix that covers 30 different combinations,\n> which I feel might be a bit excessive.\n>\n> That being said I do add lots of tests especially in the patch that\n> extends git-init(1), even though they're not layed out in a matrix. I'd\n> propose that we go from there and extend these tests in case there's\n> anything missing there?\n>\n\nThat's okay, I only was curious if we'd miss anything. The matrix is\neasier to think about.\n\n> I think the one thing that's missing is exercising invalid paths. The\n> question though is what an invalid path even is. Right now for example\n> we use `safe_create_dir()`, so we won't create leading directories. I'm\n> not sure whether that restriction is a sensible one, and because of this\n> I shy away from seemingly casting it into stone via a test. But if we\n> eventually start to create leading directories, then there isn't really\n> any path that I would consider invalid, right?\n>\n> Patrick\n\nYeah that's fair. It's all good then.\n"},{"id":"555612","messageId":"CAOLa=ZSTt1vcqOtKAfRJMvpkXsJgHbDP-jedOLPkTZGY+HFeMA@mail.gmail.com","threadId":"66584","inReplyTo":"atcrRWX2-S9374Sy@pks.im","subject":"Re: [PATCH 4/7] builtin: expose the object storage format","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-20T19:10:04Z","receivedAt":"2026-10-20T19:10:04Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Mon, Oct 19, 2026 at 02:40:31PM -0700, Karthik Nayak wrote:\n>> Patrick Steinhardt <ps@pks.im> writes:\n>> > diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n>> > index cb8c1e7292..d2dc9b7a69 100644\n>> > --- a/Documentation/git-repo.adoc\n>> > +++ b/Documentation/git-repo.adoc\n>> > @@ -105,6 +105,12 @@ values that they return:\n>> >  `object.format`::\n>> >  \tThe object format (hash algorithm) used in the repository.\n>> >\n>> > +`objects.storageFormat`::\n>> > +\tThe object storage format used in the repository, as configured via\n>> > +\t`extensions.objectStorage`. The valid values are:\n>> > ++\n>>\n>> The nuance between `object` above and `objects` here is too little and\n>> can be confusing. But there's nothing we can really do here.\n>\n> Yeah, I'm not a fan of this, either. It used to be even worse than that,\n> because we had \"references.format\" which was giving us information about\n> the backend that our refs use. And that's why I recently sent the patch\n> series to rename \"ref format\" to \"ref storage format\", so that we can\n> avoid this conflict here.\n>\n> It's still not perfect to have both \"object.format\" and\n> \"objects.storageFormat\". I was wondering whether we also want to rename\n> \"object.format\" to \"objects.format\" to at least have the prefix match.\n> But I shied away from that.\n>\n\nBut then you'd have to also rename the config options for the same no?\nI'd leave that out of this series.\n\n[snip]\n"},{"id":"555651","messageId":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH v2 0/7] odb: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-21T05:39:13Z","receivedAt":"2026-10-21T05:39:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series introduces the object storage extension. The extension\nis of course similar in spirit and design to the ref storage extension:\nit can be configured via \"extensions.objectStorage\", has the same syntax\nwith \"<schema>[://<payload>]\", and we have the same mechanisms to\nconfigure it (\"--object-storage-format=\", GIT_OBJECT_STORAGE_FORMAT,\nGIT_DEFAULT_OBJECT_STORAGE_FORMAT, \"init.defaultObjetcStorageFormat\").\n\nFor now, we only support the \"files\" object storage format, so not a lot\nof stuff really changes. That being said, its optional payload allows\nyou to configure a different location for the \".git/objects\" directory.\nSo if you specify \"extensions.objectStorage=files://objs\", objects would\nbe stored in \".git/objs\" instead.\n\nThe series is built on top of c51408889c (The 6th batch, 2026-10-16)\nwith the following dependencies merged into it:\n\n  - ps/odb-files-alternates at 0ba59c8453 (odb/source: drop\n    `read_alternates` callback, 2026-10-08) merged into it.\n\n  - ps/setup-enforce-repo-passed-to-create-repository-has-no-state\n    (phew, what a mouthful) at 0ba59c8453 (odb/source: drop\n    `read_alternates` callback, 2026-10-08).\n\nNote that these two series conflict with one another. The conflict can\neasily be resolved by just deleting the whole conflicting sections.\n\nChanges in v2:\n  - Ensure that `repo->object_storage_format` is always populated.\n  - Link to v1: https://patch.msgid.link/20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (7):\n      loose: drop unused `repo_write_loose_object_map()`\n      setup: introduce object storage extension\n      setup: allow overriding object storage format via environment\n      builtin: expose the object storage format\n      builtin/init: introduce handling of object storage format\n      builtin/clone: introduce \"--object-storage-format=\"\n      builtin/submodule: propagate \"--object-storage-format=\"\n\n Documentation/config/extensions.adoc       |  23 +++\n Documentation/config/init.adoc             |   5 +\n Documentation/git-clone.adoc               |  11 ++\n Documentation/git-init.adoc                |  10 +-\n Documentation/git-repo.adoc                |   6 +\n Documentation/git-rev-parse.adoc           |   5 +\n Documentation/git-submodule.adoc           |  10 +-\n Documentation/git.adoc                     |  10 ++\n Documentation/object-storage-format.adoc   |   6 +\n builtin/clone.c                            |  58 +++++++-\n builtin/init-db.c                          |   7 +-\n builtin/repo.c                             |   8 ++\n builtin/rev-parse.c                        |   5 +\n builtin/submodule--helper.c                |  28 ++++\n environment.h                              |   1 +\n git-submodule.sh                           |  18 +++\n loose.c                                    |  46 ------\n loose.h                                    |   1 -\n odb.c                                      |   2 +-\n odb/source-files.c                         |   7 +\n odb/source-files.h                         |   1 +\n odb/source.c                               |  45 +++++-\n odb/source.h                               |  12 +-\n repository.c                               |  11 ++\n repository.h                               |   8 ++\n setup.c                                    | 116 ++++++++++++++-\n setup.h                                    |   2 +\n t/meson.build                              |   1 +\n t/t0001-init.sh                            | 221 +++++++++++++++++++++++++++++\n t/t1900-repo-info.sh                       |   3 +\n t/t5601-clone.sh                           |  68 +++++++++\n t/t7427-submodule-object-storage-format.sh |  91 ++++++++++++\n t/unit-tests/u-odb-inmemory.c              |   1 +\n 33 files changed, 785 insertions(+), 62 deletions(-)\n\nRange-diff versus v1:\n\n1:  c9d303a0a4 = 1:  49f964eeec loose: drop unused `repo_write_loose_object_map()`\n2:  1090634b33 ! 2:  82849d866a setup: introduce object storage extension\n    @@ odb/source.c: const char *odb_source_type_to_name(enum odb_source_type type)\n     +\tstruct odb_source *source;\n     +\tchar *payload = NULL;\n     +\n    -+\tif (!object_storage_format)\n    -+\t\treturn &odb_source_files_new(odb, NULL, flags)->base;\n    -+\n     +\tswitch (odb_source_type_by_uri(object_storage_format, &payload)) {\n     +\tcase ODB_SOURCE_FILES:\n     +\t\tsource = &odb_source_files_new(odb, payload, flags)->base;\n    @@ repository.c: void repo_set_ref_storage_format(struct repository *repo,\n     +\t\t\t\t    const char *uri)\n     +{\n     +\tfree(repo->object_storage_format);\n    -+\trepo->object_storage_format = xstrdup_or_null(uri);\n    ++\tif (uri)\n    ++\t\trepo->object_storage_format = xstrdup(uri);\n    ++\telse\n    ++\t\trepo->object_storage_format = xstrdup(\"files\");\n     +}\n     +\n      /*\n    @@ t/t0001-init.sh: test_expect_success 'init with --ref-storage-format=garbage' '\n      test_expect_success MINGW 'core.hidedotfiles = false' '\n      \tgit config --global core.hidedotfiles false &&\n      \trm -rf newdir &&\n    +\n    + ## t/unit-tests/u-odb-inmemory.c ##\n    +@@\n    + \n    + static struct repository repo = {\n    + \t.hash_algo = &hash_algos[GIT_HASH_SHA1],\n    ++\t.object_storage_format = (char *) \"files\",\n    + };\n    + static struct object_database *odb;\n    + \n3:  afbd06d834 = 3:  5d5728f5a3 setup: allow overriding object storage format via environment\n4:  aba2dd3339 ! 4:  9b408ae68e builtin: expose the object storage format\n    @@ builtin/repo.c: static int get_references_format(struct repository *repo, struct\n      \n     +static int get_object_storage_format(struct repository *repo, struct strbuf *buf)\n     +{\n    -+\tstrbuf_addstr(buf, repo->object_storage_format ?\n    -+\t\t      repo->object_storage_format :\n    -+\t\t      odb_source_type_to_name(ODB_SOURCE_FILES));\n    ++\tstrbuf_addstr(buf, repo->object_storage_format);\n     +\treturn 0;\n     +}\n     +\n    @@ builtin/rev-parse.c: int cmd_rev_parse(int argc,\n      \t\t\t\tcontinue;\n      \t\t\t}\n     +\t\t\tif (!strcmp(arg, \"--show-object-storage-format\")) {\n    -+\t\t\t\tputs(the_repository->object_storage_format ?\n    -+\t\t\t\t     the_repository->object_storage_format :\n    -+\t\t\t\t     odb_source_type_to_name(ODB_SOURCE_FILES));\n    ++\t\t\t\tputs(the_repository->object_storage_format);\n     +\t\t\t\tcontinue;\n     +\t\t\t}\n      \t\t\tif (!strcmp(arg, \"--end-of-options\")) {\n5:  a61a7f674d ! 5:  ca8be36980 builtin/init: introduce handling of object storage format\n    @@ setup.c: void initialize_repository_version(struct repository *repo,\n      \t    ref_storage_format != REF_STORAGE_FORMAT_FILES ||\n     -\t    repo->ref_storage_payload)\n     +\t    repo->ref_storage_payload ||\n    -+\t    repo->object_storage_format)\n    ++\t    strcmp(repo->object_storage_format, \"files\"))\n      \t\ttarget_version = GIT_REPO_VERSION_READ;\n      \n      \tif (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)\n    @@ setup.c: void initialize_repository_version(struct repository *repo,\n      \t\trepo_config_set_gently(repo, \"extensions.refstorage\", NULL);\n      \t}\n      \n    -+\tif (repo->object_storage_format)\n    ++\tif (strcmp(repo->object_storage_format, \"files\"))\n     +\t\trepo_config_set(repo, \"extensions.objectstorage\",\n     +\t\t\t\trepo->object_storage_format);\n     +\telse if (reinit)\n6:  a61c708bc9 = 6:  34c9345892 builtin/clone: introduce \"--object-storage-format=\"\n7:  1d2c6a3cd0 = 7:  95c9be6418 builtin/submodule: propagate \"--object-storage-format=\"\n\n---\nbase-commit: 0d31382da9336683214372ba328fe9ecbc8bcb9a\nchange-id: 20261006-b4-pks-odb-extension-36de693bb943\n\n\n"},{"id":"555652","messageId":"20261021-b4-pks-odb-extension-v2-1-8cf11b65eda8@pks.im","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","subject":"[PATCH v2 1/7] loose: drop unused `repo_write_loose_object_map()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-21T05:39:14Z","receivedAt":"2026-10-21T05:39:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The function `repo_write_loose_object_map()` was introduced in\n23b2c7e95b (loose: add a mapping between SHA-1 and SHA-256 for loose\nobjects, 2023-10-01), but it never had any callers as loose object maps\nare instead written incrementally via `repo_add_loose_object_map()`\nwhenever a new loose object is created.\n\nBesides being dead code, the function also hardcodes the location of the\n\"loose-object-idx\" file as \"$GIT_COMMON_DIR/objects\", whereas both the\nreader and `repo_add_loose_object_map()` derive the location from the\nloose source's path. The function would thus disagree with everyone else\nwhere the loose object map is supposed to be located when the object\ndirectory is using a non-default location.\n\nRemove the function.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n loose.c | 46 ----------------------------------------------\n loose.h |  1 -\n 2 files changed, 47 deletions(-)\n\ndiff --git a/loose.c b/loose.c\nindex d6a2bb5ba3..7e26a04ec0 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -123,52 +123,6 @@ int repo_read_loose_object_map(struct repository *repo)\n \treturn 0;\n }\n \n-int repo_write_loose_object_map(struct repository *repo)\n-{\n-\tstruct odb_source_files *files = odb_source_files_downcast(repo->objects->source);\n-\tkh_oid_map_t *map = files->dirs->loose->map->to_compat;\n-\tstruct lock_file lock;\n-\tint fd;\n-\tkhiter_t iter;\n-\tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n-\n-\tif (!should_use_loose_object_map(repo))\n-\t\treturn 0;\n-\n-\trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n-\tfd = repo_hold_lock_file_for_update_timeout(repo, &lock, path.buf,\n-\t\t\t\t\t\t    LOCK_DIE_ON_ERROR, -1);\n-\titer = kh_begin(map);\n-\tif (write_in_full(fd, loose_object_header, strlen(loose_object_header)) < 0)\n-\t\tgoto errout;\n-\n-\tfor (; iter != kh_end(map); iter++) {\n-\t\tif (kh_exist(map, iter)) {\n-\t\t\tif (oideq(&kh_key(map, iter), repo->hash_algo->empty_tree) ||\n-\t\t\t    oideq(&kh_key(map, iter), repo->hash_algo->empty_blob))\n-\t\t\t\tcontinue;\n-\t\t\tstrbuf_addf(&buf, \"%s %s\\n\", oid_to_hex(&kh_key(map, iter)), oid_to_hex(kh_value(map, iter)));\n-\t\t\tif (write_in_full(fd, buf.buf, buf.len) < 0)\n-\t\t\t\tgoto errout;\n-\t\t\tstrbuf_reset(&buf);\n-\t\t}\n-\t}\n-\tstrbuf_release(&buf);\n-\tif (commit_lock_file(&lock) < 0) {\n-\t\terror_errno(_(\"could not write loose object index %s\"), path.buf);\n-\t\tstrbuf_release(&path);\n-\t\treturn -1;\n-\t}\n-\tstrbuf_release(&path);\n-\treturn 0;\n-errout:\n-\trollback_lock_file(&lock);\n-\tstrbuf_release(&buf);\n-\terror_errno(_(\"failed to write loose object index %s\"), path.buf);\n-\tstrbuf_release(&path);\n-\treturn -1;\n-}\n-\n static int write_one_object(struct odb_source_loose *loose,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\ndiff --git a/loose.h b/loose.h\nindex ed663ac550..41c4b46818 100644\n--- a/loose.h\n+++ b/loose.h\n@@ -22,6 +22,5 @@ int repo_add_loose_object_map(struct odb_source_loose *loose,\n \t\t\t      const struct object_id *oid,\n \t\t\t      const struct object_id *compat_oid);\n int repo_read_loose_object_map(struct repository *repo);\n-int repo_write_loose_object_map(struct repository *repo);\n \n #endif\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555653","messageId":"20261021-b4-pks-odb-extension-v2-2-8cf11b65eda8@pks.im","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","subject":"[PATCH v2 2/7] setup: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-21T05:39:15Z","receivedAt":"2026-10-21T05:39:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Introduce a new \"extensions.objectStorage\" extension that allows the\nuser to configure the primary object database source of a repository.\nThe value is a URI in the format \"<schema>[://<payload>]\", mirroring\nthe format used by \"extensions.refStorage\":\n\n  - The schema identifies the backend that shall be used. For now the\n    only supported schema is \"files\", which is the existing object\n    database backed by loose objects and packfiles.\n\n  - The payload can be passed to configure the backend, and its\n    interpretation is backend-specific. For the \"files\" backend, it\n    allows you to configure a different location for the \".git/objects\"\n    directory.\n\nEventually, this mechanism will be used to support alternative backends.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/config/extensions.adoc     | 23 ++++++++++++++++\n Documentation/object-storage-format.adoc |  6 +++++\n odb.c                                    |  2 +-\n odb/source-files.c                       |  7 +++++\n odb/source-files.h                       |  1 +\n odb/source.c                             | 45 +++++++++++++++++++++++++++++++-\n odb/source.h                             | 12 ++++++++-\n repository.c                             | 11 ++++++++\n repository.h                             |  8 ++++++\n setup.c                                  | 13 +++++++++\n setup.h                                  |  1 +\n t/t0001-init.sh                          | 30 +++++++++++++++++++++\n t/unit-tests/u-odb-inmemory.c            |  1 +\n 13 files changed, 157 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config/extensions.adoc b/Documentation/config/extensions.adoc\nindex be6678bb5b..4f3a66a454 100644\n--- a/Documentation/config/extensions.adoc\n+++ b/Documentation/config/extensions.adoc\n@@ -56,6 +56,29 @@ preciousObjects:::\n For historical reasons, this extension is respected regardless of the\n `core.repositoryFormatVersion` setting.\n \n+objectStorage:::\n+\tSpecify the object storage format and a corresponding payload. The\n+\tvalue can be either a format name or a URI:\n++\n+--\n+* A format name alone (e.g., `files`).\n+\n+* A URI format `<format>://<payload>` explicitly specifies both the\n+  format and payload (e.g., `files:///foo/bar`).\n+\n+Supported formats are:\n+\n+include::../object-storage-format.adoc[]\n+\n+--\n++\n+Note that this setting should only be set by linkgit:git-init[1] or\n+linkgit:git-clone[1]. Trying to change it after initialization will make\n+preexisting objects inaccessible.\n++\n+NOTE: This extension is still considered EXPERIMENTAL and may be subject to\n+change.\n+\n refStorage:::\n \tSpecify the ref storage format and a corresponding payload. The value\n \tcan be either a format name or a URI:\ndiff --git a/Documentation/object-storage-format.adoc b/Documentation/object-storage-format.adoc\nnew file mode 100644\nindex 0000000000..4c4aef6dda\n--- /dev/null\n+++ b/Documentation/object-storage-format.adoc\n@@ -0,0 +1,6 @@\n+`files[://<path>]`;; for loose objects and packfiles. This is the default.\n++\n+The optional payload can be passed to specify an alternative filesystem path\n+where the objects will be stored. Relative paths are resolved relative to the\n+`$GIT_COMMON_DIR`. Defaults to `$GIT_COMMON_DIR/objects` when no payload is\n+provided. The payload is ignored when `GIT_OBJECT_DIRECTORY` is set.\ndiff --git a/odb.c b/odb.c\nindex 98c5c862f5..6c07b3b671 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -757,7 +757,7 @@ struct object_database *odb_new(struct repository *repo,\n \to->repo = repo;\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n \n-\to->source = odb_source_new(o, flags);\n+\to->source = odb_source_new(o, repo->object_storage_format, flags);\n \to->inmemory_objects = &odb_source_inmemory_new(o)->base;\n \n \treturn o;\ndiff --git a/odb/source-files.c b/odb/source-files.c\nindex 455f409db0..4a7cbbfd9b 100644\n--- a/odb/source-files.c\n+++ b/odb/source-files.c\n@@ -1235,6 +1235,7 @@ struct odb_files_dir *odb_source_files_find_dir(struct object_database *odb, con\n }\n \n struct odb_source_files *odb_source_files_new(struct object_database *odb,\n+\t\t\t\t\t      const char *payload,\n \t\t\t\t\t      enum odb_new_flags flags)\n {\n \tstruct odb_source_files *files;\n@@ -1245,6 +1246,12 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,\n \t\tobject_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));\n \t\talternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));\n \t}\n+\tif (!object_dir && payload) {\n+\t\tif (is_absolute_path(payload))\n+\t\t\tobject_dir = xstrdup(payload);\n+\t\telse\n+\t\t\tobject_dir = xstrfmt(\"%s/%s\", odb->repo->commondir, payload);\n+\t}\n \tif (!object_dir)\n \t\tobject_dir = xstrfmt(\"%s/objects\", odb->repo->commondir);\n \ndiff --git a/odb/source-files.h b/odb/source-files.h\nindex 837e890304..71e8db84ff 100644\n--- a/odb/source-files.h\n+++ b/odb/source-files.h\n@@ -70,6 +70,7 @@ struct odb_source_files {\n \n /* Allocate and initialize a new object source. */\n struct odb_source_files *odb_source_files_new(struct object_database *odb,\n+\t\t\t\t\t      const char *payload,\n \t\t\t\t\t      enum odb_new_flags flags);\n \n /*\ndiff --git a/odb/source.c b/odb/source.c\nindex b25ef14df8..7917ecc990 100644\n--- a/odb/source.c\n+++ b/odb/source.c\n@@ -1,4 +1,5 @@\n #include \"git-compat-util.h\"\n+#include \"gettext.h\"\n #include \"object-file.h\"\n #include \"odb/source-files.h\"\n #include \"odb/source.h\"\n@@ -23,10 +24,52 @@ const char *odb_source_type_to_name(enum odb_source_type type)\n \treturn name;\n }\n \n+static enum odb_source_type odb_source_type_by_name(const char *name)\n+{\n+\tif (!strcmp(name, \"files\"))\n+\t\treturn ODB_SOURCE_FILES;\n+\treturn ODB_SOURCE_UNKNOWN;\n+}\n+\n+enum odb_source_type odb_source_type_by_uri(const char *uri, char **payload)\n+{\n+\tenum odb_source_type type;\n+\tconst char *schema_end;\n+\tchar *name;\n+\n+\tschema_end = strstr(uri, \"://\");\n+\tif (!schema_end) {\n+\t\tname = xstrdup(uri);\n+\t\tif (payload)\n+\t\t\t*payload = NULL;\n+\t} else {\n+\t\tname = xstrndup(uri, schema_end - uri);\n+\t\tif (payload)\n+\t\t\t*payload = *(schema_end + 3) ? xstrdup(schema_end + 3) : NULL;\n+\t}\n+\n+\ttype = odb_source_type_by_name(name);\n+\tfree(name);\n+\treturn type;\n+}\n+\n struct odb_source *odb_source_new(struct object_database *odb,\n+\t\t\t\t  const char *object_storage_format,\n \t\t\t\t  enum odb_new_flags flags)\n {\n-\treturn &odb_source_files_new(odb, flags)->base;\n+\tstruct odb_source *source;\n+\tchar *payload = NULL;\n+\n+\tswitch (odb_source_type_by_uri(object_storage_format, &payload)) {\n+\tcase ODB_SOURCE_FILES:\n+\t\tsource = &odb_source_files_new(odb, payload, flags)->base;\n+\t\tbreak;\n+\tdefault:\n+\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n+\t}\n+\n+\tfree(payload);\n+\treturn source;\n }\n \n void odb_source_init(struct odb_source *source,\ndiff --git a/odb/source.h b/odb/source.h\nindex 1867347dfc..c194b3254b 100644\n--- a/odb/source.h\n+++ b/odb/source.h\n@@ -32,6 +32,14 @@ enum odb_source_type {\n  */\n const char *odb_source_type_to_name(enum odb_source_type type);\n \n+/*\n+ * Parse the given URI in the format \"<schema>[://<payload>]\" and return the\n+ * source type identified by the schema. If `payload` is non-NULL it will be\n+ * set to a newly allocated copy of the payload, or NULL if the URI has no or\n+ * an empty payload. Returns `ODB_SOURCE_UNKNOWN` for unknown schemas.\n+ */\n+enum odb_source_type odb_source_type_by_uri(const char *uri, char **payload);\n+\n struct object_id;\n struct odb_stream;\n struct strbuf;\n@@ -304,9 +312,11 @@ struct odb_source {\n \n /*\n  * Allocate and initialize a new source for the given object database. The path\n- * of the source is derived from repository paths.\n+ * of the source is derived from repository paths or from the object storage\n+ * format.\n  */\n struct odb_source *odb_source_new(struct object_database *odb,\n+\t\t\t\t  const char *object_storage_format,\n \t\t\t\t  enum odb_new_flags flags);\n \n /*\ndiff --git a/repository.c b/repository.c\nindex 970d181828..5b1f1460e0 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -217,6 +217,16 @@ void repo_set_ref_storage_format(struct repository *repo,\n \trepo->ref_storage_payload = xstrdup_or_null(payload);\n }\n \n+void repo_set_object_storage_format(struct repository *repo,\n+\t\t\t\t    const char *uri)\n+{\n+\tfree(repo->object_storage_format);\n+\tif (uri)\n+\t\trepo->object_storage_format = xstrdup(uri);\n+\telse\n+\t\trepo->object_storage_format = xstrdup(\"files\");\n+}\n+\n /*\n  * Attempt to resolve and set the provided 'gitdir' for repository 'repo'.\n  * Return 0 upon success and a non-zero value upon failure.\n@@ -382,6 +392,7 @@ void repo_clear(struct repository *repo)\n \tfree(repo->worktree);\n \tfree(repo->submodule_prefix);\n \tfree(repo->ref_storage_payload);\n+\tfree(repo->object_storage_format);\n \n \todb_free(repo->objects);\n \ndiff --git a/repository.h b/repository.h\nindex 2a348012e8..e9a3a7f18b 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -178,6 +178,12 @@ struct repository {\n \t */\n \tchar *ref_storage_payload;\n \n+\t/*\n+\t * The object storage URI in the format \"<schema>[://<payload>]\", as\n+\t * configured via \"extensions.objectStorage\".\n+\t */\n+\tchar *object_storage_format;\n+\n \t/* A unique-id for tracing purposes. */\n \tint trace2_repo_id;\n \n@@ -255,6 +261,8 @@ void repo_set_compat_hash_algo(struct repository *repo, uint32_t compat_algo);\n void repo_set_ref_storage_format(struct repository *repo,\n \t\t\t\t enum ref_storage_format format,\n \t\t\t\t const char *payload);\n+void repo_set_object_storage_format(struct repository *repo,\n+\t\t\t\t    const char *uri);\n void initialize_repository(struct repository *repo);\n RESULT_MUST_BE_USED\n int repo_init(struct repository *r, const char *gitdir, const char *worktree);\ndiff --git a/setup.c b/setup.c\nindex 3ee19f3e3c..499b5bbe3c 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -9,6 +9,7 @@\n #include \"hex.h\"\n #include \"object-file.h\"\n #include \"object-name.h\"\n+#include \"odb/source.h\"\n #include \"refs.h\"\n #include \"repository.h\"\n #include \"config.h\"\n@@ -687,6 +688,15 @@ static enum extension_result handle_extension(const char *var,\n \t\t\t\t     \"extensions.refstorage\", value);\n \t\tdata->ref_storage_format = format;\n \t\treturn EXTENSION_OK;\n+\t} else if (!strcmp(ext, \"objectstorage\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tif (odb_source_type_by_uri(value, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\treturn error(_(\"invalid value for '%s': '%s'\"),\n+\t\t\t\t     \"extensions.objectstorage\", value);\n+\t\tfree(data->object_storage);\n+\t\tdata->object_storage = xstrdup(value);\n+\t\treturn EXTENSION_OK;\n \t} else if (!strcmp(ext, \"relativeworktrees\")) {\n \t\tdata->relative_worktrees = git_config_bool(var, value);\n \t\treturn EXTENSION_OK;\n@@ -694,6 +704,7 @@ static enum extension_result handle_extension(const char *var,\n \t\tdata->submodule_path_cfg = git_config_bool(var, value);\n \t\treturn EXTENSION_OK;\n \t}\n+\n \treturn EXTENSION_UNKNOWN;\n }\n \n@@ -864,6 +875,7 @@ void clear_repository_format(struct repository_format *format)\n \tfree(format->work_tree);\n \tfree(format->partial_clone);\n \tfree(format->ref_storage_payload);\n+\tfree(format->object_storage);\n \tinit_repository_format(format);\n }\n \n@@ -1786,6 +1798,7 @@ int apply_repository_format(struct repository *repo,\n \trepo_set_ref_storage_format(repo,\n \t\t\t\t    format->ref_storage_format,\n \t\t\t\t    format->ref_storage_payload);\n+\trepo_set_object_storage_format(repo, format->object_storage);\n \trepo->repository_format_worktree_config =\n \t\tformat->worktree_config;\n \trepo->repository_format_submodule_path_cfg =\ndiff --git a/setup.h b/setup.h\nindex 7a3efe5e48..9145aacc5f 100644\n--- a/setup.h\n+++ b/setup.h\n@@ -192,6 +192,7 @@ struct repository_format {\n \tchar *ref_storage_payload;\n \tint sparse_index;\n \tchar *work_tree;\n+\tchar *object_storage;\n \tstruct string_list unknown_extensions;\n \tstruct string_list v1_only_extensions;\n };\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex f1d227f271..c7c464d3a2 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -839,6 +839,36 @@ test_expect_success 'init with --ref-storage-format=garbage' '\n \ttest_cmp expect err\n '\n \n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage is not allowed with repo version 0' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set extensions.objectStorage files &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"repo version is 0, but v1-only extension found\" err\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files backend' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set core.repositoryformatversion 1 &&\n+\tgit -C objstorage config set extensions.objectStorage files &&\n+\ttest_commit -C objstorage A &&\n+\tgit -C objstorage rev-parse --verify HEAD\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set core.repositoryformatversion 1 &&\n+\tgit -C objstorage config set extensions.objectStorage garbage &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage${SQ}\" err &&\n+\n+\tgit config --file objstorage/.git/config extensions.objectStorage garbage://payload &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\ndiff --git a/t/unit-tests/u-odb-inmemory.c b/t/unit-tests/u-odb-inmemory.c\nindex a8da278c68..d7261b9e0c 100644\n--- a/t/unit-tests/u-odb-inmemory.c\n+++ b/t/unit-tests/u-odb-inmemory.c\n@@ -12,6 +12,7 @@\n \n static struct repository repo = {\n \t.hash_algo = &hash_algos[GIT_HASH_SHA1],\n+\t.object_storage_format = (char *) \"files\",\n };\n static struct object_database *odb;\n \n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555654","messageId":"20261021-b4-pks-odb-extension-v2-3-8cf11b65eda8@pks.im","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","subject":"[PATCH v2 3/7] setup: allow overriding object storage format via environment","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-21T05:39:16Z","receivedAt":"2026-10-21T05:39:16Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format configured via \"extensions.refStorage\" can be\noverridden with the GIT_REF_STORAGE_FORMAT environment variable.\nIntroduce the GIT_OBJECT_STORAGE_FORMAT environment variable that\noverrides \"extensions.objectStorage\" in the same way.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git.adoc |  5 +++++\n environment.h          |  1 +\n setup.c                | 14 ++++++++++++++\n t/t0001-init.sh        | 26 ++++++++++++++++++++++++++\n 4 files changed, 46 insertions(+)\n\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 3abb4701c3..34812131bb 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -609,6 +609,11 @@ double-quotes and respecting backslash escapes. E.g., the value\n `GIT_REFERENCE_BACKEND`::\n \tDeprecated alias of `GIT_REF_STORAGE_FORMAT`.\n \n+`GIT_OBJECT_STORAGE_FORMAT`::\n+\tSpecify which object storage format to use along with its URI.\n+\tSee `extensions.objectStorage` option in linkgit:git-config[1] for more\n+\tdetails. Overrides the config variable when used.\n+\n Git Commits\n ~~~~~~~~~~~\n `GIT_AUTHOR_NAME`::\ndiff --git a/environment.h b/environment.h\nindex b336459e90..c26ef92b52 100644\n--- a/environment.h\n+++ b/environment.h\n@@ -45,6 +45,7 @@\n #define GIT_ATTR_SOURCE_ENVIRONMENT \"GIT_ATTR_SOURCE\"\n #define GIT_REFERENCE_BACKEND_ENVIRONMENT \"GIT_REFERENCE_BACKEND\"\n #define GIT_REF_STORAGE_FORMAT_ENVIRONMENT \"GIT_REF_STORAGE_FORMAT\"\n+#define GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT \"GIT_OBJECT_STORAGE_FORMAT\"\n \n /*\n  * Environment variable used to propagate the --no-advice global option to the\ndiff --git a/setup.c b/setup.c\nindex 499b5bbe3c..98140a7641 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2073,6 +2073,7 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \n \t\tif (startup_info->have_repository) {\n \t\t\tstruct strbuf err = STRBUF_INIT;\n+\t\t\tconst char *object_storage_uri;\n \t\t\tconst char *ref_backend_uri;\n \n \t\t\t/*\n@@ -2091,6 +2092,19 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \t\t\t\t\tdie(_(\"unknown ref storage format: '%s'\"), ref_backend_uri);\n \t\t\t}\n \n+\t\t\t/*\n+\t\t\t * Likewise, the GIT_OBJECT_STORAGE_FORMAT environment\n+\t\t\t * variable should override the repository config for\n+\t\t\t * 'extensions.objectStorage'.\n+\t\t\t */\n+\t\t\tobject_storage_uri = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT);\n+\t\t\tif (object_storage_uri) {\n+\t\t\t\tif (odb_source_type_by_uri(object_storage_uri, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\t\t\tdie(_(\"unknown object storage format: '%s'\"), object_storage_uri);\n+\t\t\t\tfree(discovery.format.object_storage);\n+\t\t\t\tdiscovery.format.object_storage = xstrdup(object_storage_uri);\n+\t\t\t}\n+\n \t\t\tif (apply_repository_format(repo, &discovery.format,\n \t\t\t\t\t\t    APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n \t\t\t\tdie(\"%s\", err.buf);\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex c7c464d3a2..5e7c25e42c 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -869,6 +869,32 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown b\n \ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n '\n \n+test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides extensions.objectStorage' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\t(\n+\t\tcd objstorage &&\n+\t\tgit config set core.repositoryformatversion 1 &&\n+\t\tgit config set extensions.objectStorage files://objs &&\n+\t\tmkdir .git/objs .git/other &&\n+\n+\t\techo content >file &&\n+\t\toid=$(git hash-object -w file) &&\n+\t\ttest_path_is_file .git/objs/$(test_oid_to_path \"$oid\") &&\n+\t\tgit cat-file -e \"$oid\" &&\n+\n+\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://other git cat-file -e \"$oid\" &&\n+\t\tGIT_OBJECT_STORAGE_FORMAT=files://other git hash-object -w file &&\n+\t\ttest_path_is_file .git/other/$(test_oid_to_path \"$oid\") &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\tfatal: unknown object storage format: ${SQ}garbage${SQ}\n+\t\tEOF\n+\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git rev-parse 2>err &&\n+\t\ttest_cmp expect err\n+\t)\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555655","messageId":"20261021-b4-pks-odb-extension-v2-4-8cf11b65eda8@pks.im","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","subject":"[PATCH v2 4/7] builtin: expose the object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-21T05:39:17Z","receivedAt":"2026-10-21T05:39:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format of a repository can be inspected via both\ngit-rev-parse(1)'s \"--show-ref-storage-format\" and git-repo(1)'s\n\"references.storageFormat\" field. Introduce the equivalent options for\nthe object storage format, as well.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-repo.adoc      | 6 ++++++\n Documentation/git-rev-parse.adoc | 5 +++++\n builtin/repo.c                   | 8 ++++++++\n builtin/rev-parse.c              | 5 +++++\n t/t0001-init.sh                  | 5 ++++-\n t/t1900-repo-info.sh             | 3 +++\n 6 files changed, 31 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex cb8c1e7292..d2dc9b7a69 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -105,6 +105,12 @@ values that they return:\n `object.format`::\n \tThe object format (hash algorithm) used in the repository.\n \n+`objects.storageFormat`::\n+\tThe object storage format used in the repository, as configured via\n+\t`extensions.objectStorage`. The valid values are:\n++\n+include::object-storage-format.adoc[]\n+\n `path.commondir.absolute`::\n \tThe canonical absolute path to the Git repository's common\n \tdirectory (the shared `.git` directory containing objects,\ndiff --git a/Documentation/git-rev-parse.adoc b/Documentation/git-rev-parse.adoc\nindex 5b866af66a..9103d54d53 100644\n--- a/Documentation/git-rev-parse.adoc\n+++ b/Documentation/git-rev-parse.adoc\n@@ -338,6 +338,11 @@ The following options are unaffected by `--path-format`:\n --show-ref-format::\n \tDeprecated alias of `--show-ref-storage-format`.\n \n+--show-object-storage-format::\n+\tShow the object storage format used for the repository. Prints the\n+\tvalue of `extensions.objectStorage`, or `files` when the extension is\n+\tnot set.\n+\n \n Other Options\n ~~~~~~~~~~~~~\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 84e012f83f..451c940140 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -6,6 +6,7 @@\n #include \"hash.h\"\n #include \"hex.h\"\n #include \"odb.h\"\n+#include \"odb/source.h\"\n #include \"parse-options.h\"\n #include \"path.h\"\n #include \"path-walk.h\"\n@@ -128,11 +129,18 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_object_storage_format(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf, repo->object_storage_format);\n+\treturn 0;\n+}\n+\n /* repo_info_field keys must be in lexicographical order */\n static const struct repo_info_field repo_info_field[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n \t{ \"object.format\", get_object_format },\n+\t{ \"objects.storageFormat\", get_object_storage_format },\n \t{ \"path.commondir.absolute\", get_path_commondir_absolute },\n \t{ \"path.commondir.relative\", get_path_commondir_relative },\n \t{ \"path.gitdir.absolute\", get_path_gitdir_absolute },\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex ec33c19bdf..9dd692dcb6 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -17,6 +17,7 @@\n #include \"gettext.h\"\n #include \"hash.h\"\n #include \"hex.h\"\n+#include \"odb/source.h\"\n #include \"refs.h\"\n #include \"quote.h\"\n #include \"object-name.h\"\n@@ -1138,6 +1139,10 @@ int cmd_rev_parse(int argc,\n \t\t\t\tputs(ref_storage_format_to_name(the_repository->ref_storage_format));\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--show-object-storage-format\")) {\n+\t\t\t\tputs(the_repository->object_storage_format);\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--end-of-options\")) {\n \t\t\t\tseen_end_of_options = 1;\n \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 5e7c25e42c..d080ab04a8 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -853,7 +853,10 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files bac\n \tgit -C objstorage config set core.repositoryformatversion 1 &&\n \tgit -C objstorage config set extensions.objectStorage files &&\n \ttest_commit -C objstorage A &&\n-\tgit -C objstorage rev-parse --verify HEAD\n+\tgit -C objstorage rev-parse --verify HEAD &&\n+\techo files >expect &&\n+\tgit -C objstorage rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\ndiff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh\nindex d115d2d9f9..493a78f230 100755\n--- a/t/t1900-repo-info.sh\n+++ b/t/t1900-repo-info.sh\n@@ -69,6 +69,9 @@ test_repo_info 'object.format = sha1 is retrieved correctly' \\\n test_repo_info 'object.format = sha256 is retrieved correctly' \\\n \t'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'\n \n+test_repo_info 'objects.storageFormat = files is retrieved correctly' \\\n+\t'git init' 'objects-files' 'objects.storageFormat' 'files'\n+\n test_expect_success 'values returned in order requested' '\n \tcat >expect <<-\\EOF &&\n \tlayout.bare=false\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555656","messageId":"20261021-b4-pks-odb-extension-v2-5-8cf11b65eda8@pks.im","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","subject":"[PATCH v2 5/7] builtin/init: introduce handling of object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-21T05:39:18Z","receivedAt":"2026-10-21T05:39:18Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"While the object storage format extension can already be configured\nmanually via git-config(1), this isn't exactly an ergonomic way of doing\nso. For the reference storage format extension, users have a host of\noptions available to them.\n\nIntroduce the equivalent options for the object storage format.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/config/init.adoc |   5 ++\n Documentation/git-init.adoc    |  10 ++-\n Documentation/git.adoc         |   5 ++\n builtin/clone.c                |   2 +-\n builtin/init-db.c              |   7 +-\n setup.c                        |  89 +++++++++++++++++++++-\n setup.h                        |   1 +\n t/t0001-init.sh                | 162 +++++++++++++++++++++++++++++++++++++++++\n 8 files changed, 273 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/config/init.adoc b/Documentation/config/init.adoc\nindex e45bd692db..dbd9c663ee 100644\n--- a/Documentation/config/init.adoc\n+++ b/Documentation/config/init.adoc\n@@ -20,6 +20,11 @@ endif::[]\n \tprecedence over this config.\n `init.defaultRefFormat`::\n \tDeprecated alias of `init.defaultRefStorageFormat`.\n+`init.defaultObjectStorageFormat`::\n+\tAllows overriding the default object storage format for new\n+\trepositories. See `--object-storage-format=` in linkgit:git-init[1].\n+\tBoth the command line option and the `GIT_DEFAULT_OBJECT_STORAGE_FORMAT`\n+\tenvironment variable take precedence over this config.\n \n init.defaultSubmodulePathConfig::\n \tA boolean that specifies if `git init` and `git clone` should\ndiff --git a/Documentation/git-init.adoc b/Documentation/git-init.adoc\nindex b02af22ad1..9e022a7ba8 100644\n--- a/Documentation/git-init.adoc\n+++ b/Documentation/git-init.adoc\n@@ -11,7 +11,7 @@ SYNOPSIS\n [synopsis]\n git init [-q | --quiet] [--bare] [--template=<template-directory>]\n \t [--separate-git-dir <git-dir>] [--object-format=<format>]\n-\t [--ref-storage-format=<format>]\n+\t [--ref-storage-format=<format>] [--object-storage-format=<format>]\n \t [-b <branch-name> | --initial-branch=<branch-name>]\n \t [--shared[=<permissions>]] [<directory>]\n \n@@ -68,6 +68,14 @@ include::ref-storage-format.adoc[]\n `--ref-format=<format>`::\n Deprecated alias of `--ref-storage-format=<format>`.\n \n+`--object-storage-format=<format>`::\n+Specify the given object storage _<format>_ for the repository. Backends that\n+require additional configuration accept a payload in the form\n+`<format>://<payload>`, for example a path or a connection string identifying\n+the database that shall store the objects. The valid values are:\n++\n+include::object-storage-format.adoc[]\n+\n `--template=<template-directory>`::\n Specify the directory from which templates will be used.  (See the \"TEMPLATE\n DIRECTORY\" section below.)\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 34812131bb..67de5646f0 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -609,6 +609,11 @@ double-quotes and respecting backslash escapes. E.g., the value\n `GIT_REFERENCE_BACKEND`::\n \tDeprecated alias of `GIT_REF_STORAGE_FORMAT`.\n \n+`GIT_DEFAULT_OBJECT_STORAGE_FORMAT`::\n+\tIf this variable is set, the default object storage format for new\n+\trepositories will be set to this value. The default is \"files\".\n+\tSee `--object-storage-format` in linkgit:git-init[1].\n+\n `GIT_OBJECT_STORAGE_FORMAT`::\n \tSpecify which object storage format to use along with its URI.\n \tSee `extensions.objectStorage` option in linkgit:git-config[1] for more\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 6047501dfc..ba4fc16def 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -1214,7 +1214,7 @@ int cmd_clone(int argc,\n \t */\n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n \t\t\t  option_template, GIT_HASH_UNKNOWN, ref_storage_format_uri,\n-\t\t\t  do_not_override_repo_unix_permissions, NULL);\n+\t\t\t  NULL, do_not_override_repo_unix_permissions, NULL);\n \n \tif (real_git_dir) {\n \t\tfree((char *)git_dir);\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 0abdbca8e9..71b748f2f2 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -57,7 +57,7 @@ static int shared_callback(const struct option *opt, const char *arg, int unset)\n static const char *const init_db_usage[] = {\n \tN_(\"git init [-q | --quiet] [--bare] [--template=<template-directory>]\\n\"\n \t   \"         [--separate-git-dir <git-dir>] [--object-format=<format>]\\n\"\n-\t   \"         [--ref-storage-format=<format>]\\n\"\n+\t   \"         [--ref-storage-format=<format>] [--object-storage-format=<format>]\\n\"\n \t   \"         [-b <branch-name> | --initial-branch=<branch-name>]\\n\"\n \t   \"         [--shared[=<permissions>]] [<directory>]\"),\n \tNULL\n@@ -84,6 +84,7 @@ int cmd_init_db(int argc,\n \tint bare = startup_info->force_bare_repository ? 1 : -1;\n \tconst char *object_format = NULL;\n \tconst char *ref_storage_format_uri = NULL;\n+\tconst char *object_storage_format_uri = NULL;\n \tconst char *initial_branch = NULL;\n \tint hash_algo = GIT_HASH_UNKNOWN;\n \tint init_shared_repository = -1;\n@@ -111,6 +112,8 @@ int cmd_init_db(int argc,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format_uri, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format_uri, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_END()\n \t};\n \tint reinit;\n@@ -232,7 +235,7 @@ int cmd_init_db(int argc,\n \n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n \t\t\t  template_dir, hash_algo, ref_storage_format_uri,\n-\t\t\t  init_shared_repository, &reinit);\n+\t\t\t  object_storage_format_uri, init_shared_repository, &reinit);\n \tcreate_reference_database(the_repository, initial_branch, quiet);\n \tcreate_object_database(the_repository, NULL);\n \ndiff --git a/setup.c b/setup.c\nindex 98140a7641..3d74f8eeed 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2466,7 +2466,8 @@ void initialize_repository_version(struct repository *repo,\n \t */\n \tif (hash_algo != GIT_HASH_SHA1_LEGACY ||\n \t    ref_storage_format != REF_STORAGE_FORMAT_FILES ||\n-\t    repo->ref_storage_payload)\n+\t    repo->ref_storage_payload ||\n+\t    strcmp(repo->object_storage_format, \"files\"))\n \t\ttarget_version = GIT_REPO_VERSION_READ;\n \n \tif (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)\n@@ -2490,6 +2491,12 @@ void initialize_repository_version(struct repository *repo,\n \t\trepo_config_set_gently(repo, \"extensions.refstorage\", NULL);\n \t}\n \n+\tif (strcmp(repo->object_storage_format, \"files\"))\n+\t\trepo_config_set(repo, \"extensions.objectstorage\",\n+\t\t\t\trepo->object_storage_format);\n+\telse if (reinit)\n+\t\trepo_config_set_gently(repo, \"extensions.objectstorage\", NULL);\n+\n \tif (reinit) {\n \t\tstruct strbuf config = STRBUF_INIT;\n \t\tstruct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;\n@@ -2726,6 +2733,7 @@ static void separate_git_dir(struct repository *repo,\n struct default_format_config {\n \tint hash;\n \tenum ref_storage_format ref_storage_format;\n+\tchar *object_storage_format;\n };\n \n static int read_default_format_config(const char *key, const char *value,\n@@ -2757,6 +2765,20 @@ static int read_default_format_config(const char *key, const char *value,\n \t\tgoto out;\n \t}\n \n+\tif (!strcmp(key, \"init.defaultobjectstorageformat\")) {\n+\t\tret = git_config_string(&str, key, value);\n+\t\tif (ret)\n+\t\t\tgoto out;\n+\t\tif (odb_source_type_by_uri(str, NULL) == ODB_SOURCE_UNKNOWN) {\n+\t\t\twarning(_(\"unknown object storage format '%s'\"), str);\n+\t\t\tgoto out;\n+\t\t}\n+\t\tfree(cfg->object_storage_format);\n+\t\tcfg->object_storage_format = str;\n+\t\tstr = NULL;\n+\t\tgoto out;\n+\t}\n+\n \t/*\n \t * Enable the reftable format when \"features.experimental\" is enabled.\n \t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n@@ -2777,7 +2799,8 @@ static int read_default_format_config(const char *key, const char *value,\n \n static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t\t\t\tint hash,\n-\t\t\t\t\tconst char *ref_storage_format_uri)\n+\t\t\t\t\tconst char *ref_storage_format_uri,\n+\t\t\t\t\tconst char *object_storage_uri)\n {\n \tstruct default_format_config cfg = {\n \t\t.hash = GIT_HASH_UNKNOWN,\n@@ -2790,6 +2813,7 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t};\n \tenum ref_storage_format ref_storage_format;\n \tchar *ref_storage_payload = NULL;\n+\tchar *object_storage = NULL;\n \tconst char *env;\n \n \tconfig_with_options(read_default_format_config, &cfg, NULL, NULL, &opts);\n@@ -2877,9 +2901,58 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\tref_storage_format = REF_STORAGE_FORMAT_DEFAULT;\n \t}\n \n+\t/*\n+\t * Determine the object storage format, with the same precedence as\n+\t * for the ref storage format:\n+\t *\n+\t *   1. The format specified via the command line.\n+\t *\n+\t *   2. The format specified via \"GIT_OBJECT_STORAGE_FORMAT\".\n+\t *\n+\t *   3. The format of a preexisting repository when reinitializing.\n+\t *\n+\t *   4. The default format for new repositories as configured via\n+\t *      \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\".\n+\t *\n+\t *   5. The default format for new repositories as configured via\n+\t *      \"init.defaultObjectStorageFormat\".\n+\t *\n+\t *   6. The \"files\" format.\n+\t */\n+\tif (object_storage_uri) {\n+\t\tif (odb_source_type_by_uri(object_storage_uri, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_uri);\n+\t\tobject_storage = xstrdup(object_storage_uri);\n+\t} else if ((env = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT))) {\n+\t\tif (odb_source_type_by_uri(env, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n+\t\t\t    GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT, env);\n+\t\tobject_storage = xstrdup(env);\n+\t} else if (repo_fmt->version >= 0) {\n+\t\tobject_storage = xstrdup_or_null(repo_fmt->object_storage);\n+\t} else if ((env = getenv(\"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\"))) {\n+\t\tif (odb_source_type_by_uri(env, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n+\t\t\t    \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\", env);\n+\t\tobject_storage = xstrdup(env);\n+\t} else {\n+\t\tobject_storage = xstrdup_or_null(cfg.object_storage_format);\n+\t}\n+\n+\t/*\n+\t * The \"files\" format without a payload is the default and thus doesn't\n+\t * need to be recorded as an extension.\n+\t */\n+\tif (object_storage) {\n+\t\tchar *payload = NULL;\n+\t\tif (odb_source_type_by_uri(object_storage, &payload) == ODB_SOURCE_FILES && !payload)\n+\t\t\tFREE_AND_NULL(object_storage);\n+\t\tfree(payload);\n+\t}\n+\n \t/*\n \t * If we have a preexisting repository we need to verify that its\n-\t * current ref storage format does not change.\n+\t * current storage formats do not change.\n \t */\n \tif (repo_fmt->version >= 0) {\n \t\tif (ref_storage_format != repo_fmt->ref_storage_format)\n@@ -2888,11 +2961,18 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t    strcmp(ref_storage_payload ? ref_storage_payload : \"\",\n \t\t\t   repo_fmt->ref_storage_payload ? repo_fmt->ref_storage_payload : \"\"))\n \t\t\tdie(_(\"attempt to reinitialize repository with different reference storage payload\"));\n+\t\tif (strcmp(object_storage ? object_storage : \"\",\n+\t\t\t   repo_fmt->object_storage ? repo_fmt->object_storage : \"\"))\n+\t\t\tdie(_(\"attempt to reinitialize repository with different object storage format\"));\n \t}\n \n \tfree(repo_fmt->ref_storage_payload);\n \trepo_fmt->ref_storage_format = ref_storage_format;\n \trepo_fmt->ref_storage_payload = ref_storage_payload;\n+\n+\tfree(repo_fmt->object_storage);\n+\trepo_fmt->object_storage = object_storage;\n+\tfree(cfg.object_storage_format);\n }\n \n void create_repository(struct repository *repo,\n@@ -2902,6 +2982,7 @@ void create_repository(struct repository *repo,\n \t\t       const char *template_dir,\n \t\t       int hash,\n \t\t       const char *ref_storage_format_uri,\n+\t\t       const char *object_storage_format_uri,\n \t\t       int init_shared_repository,\n \t\t       int *reinit_ok)\n {\n@@ -2940,7 +3021,7 @@ void create_repository(struct repository *repo,\n \t * is an attempt to reinitialize new repository with an old tool.\n \t */\n \tread_and_verify_repository_format(&repo_fmt, repo_get_git_dir(repo), NULL);\n-\trepository_format_configure(&repo_fmt, hash, ref_storage_format_uri);\n+\trepository_format_configure(&repo_fmt, hash, ref_storage_format_uri, object_storage_format_uri);\n \tif (apply_repository_format(repo, &repo_fmt, APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n \t\tdie(\"%s\", err.buf);\n \ndiff --git a/setup.h b/setup.h\nindex 9145aacc5f..4e1737ade9 100644\n--- a/setup.h\n+++ b/setup.h\n@@ -275,6 +275,7 @@ void create_repository(struct repository *repo,\n \t\t       const char *template_dir,\n \t\t       int hash_algo,\n \t\t       const char *ref_storage_format_uri,\n+\t\t       const char *object_storage_format_uri,\n \t\t       int init_shared_repository,\n \t\t       int *reinit_ok);\n \ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex d080ab04a8..0da14e8f70 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -898,6 +898,168 @@ test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides ext\n \t)\n '\n \n+test_expect_success 'init with --object-storage-format=files does not set extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files objformat &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\tif test_have_prereq DEFAULT_REPO_FORMAT\n+\tthen\n+\t\techo 0 >expect &&\n+\t\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\t\ttest_cmp expect actual\n+\tfi\n+'\n+\n+test_expect_success 'init with --object-storage-format=files:// does not set extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files:// objformat &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with --object-storage-format=files://<relative-path>' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat config get extensions.objectstorage >actual &&\n+\ttest_cmp expect actual &&\n+\techo 1 >expect &&\n+\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\ttest_cmp expect actual &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual &&\n+\ttest_path_is_dir objformat/.git/objects &&\n+\ttest_path_is_dir objformat/.git/objs &&\n+\ttest_commit -C objformat A &&\n+\tgit -C objformat rev-parse --verify HEAD &&\n+\ttest_path_is_missing objformat/.git/objects/pack &&\n+\ttest_path_is_dir objformat/.git/objs/pack\n+'\n+\n+test_expect_success 'init with --object-storage-format=files://<absolute-path>' '\n+\ttest_when_finished \"rm -rf objformat objdir\" &&\n+\tgit init --object-storage-format=files://\"$(pwd)/objdir\" objformat &&\n+\techo \"files://$(pwd)/objdir\" >expect &&\n+\tgit -C objformat config get extensions.objectstorage >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_commit -C objformat A &&\n+\tgit -C objformat rev-parse --verify HEAD &&\n+\ttest_path_is_dir objdir/pack\n+'\n+\n+test_expect_success 'GIT_OBJECT_DIRECTORY takes precedence over extensions.objectStorage payload' '\n+\ttest_when_finished \"rm -rf objformat objdir\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\ttest_commit -C objformat A &&\n+\tmkdir objdir &&\n+\ttest_must_fail env GIT_DIR=\"$PWD/objformat/.git\" GIT_OBJECT_DIRECTORY=\"$PWD/objdir\" \\\n+\t\tgit cat-file -e HEAD &&\n+\tGIT_DIR=\"$PWD/objformat/.git\" GIT_OBJECT_DIRECTORY=\"$PWD/objdir\" \\\n+\t\tgit hash-object -w objformat/A.t >oid &&\n+\ttest_path_is_file objdir/$(test_oid_to_path \"$(cat oid)\")\n+'\n+\n+test_expect_success 'init with --object-storage-format=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git init --object-storage-format=garbage objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'init with GIT_DEFAULT_OBJECT_STORAGE_FORMAT=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via GIT_DEFAULT_OBJECT_STORAGE_FORMAT: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail env GIT_DEFAULT_OBJECT_STORAGE_FORMAT=garbage git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'init with GIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://objs' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://objs git init objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with GIT_OBJECT_STORAGE_FORMAT=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via GIT_OBJECT_STORAGE_FORMAT: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'GIT_OBJECT_STORAGE_FORMAT takes precedence over default' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://default \\\n+\tGIT_OBJECT_STORAGE_FORMAT=files://explicit git init objformat &&\n+\techo files://explicit >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '--object-storage-format= takes precedence over environment' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_OBJECT_STORAGE_FORMAT=files://explicit \\\n+\tgit init --object-storage-format=files://cmdline objformat &&\n+\techo files://cmdline >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 're-init refuses with different storage format' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files objformat &&\n+\tcat >expect <<-EOF &&\n+\tfatal: attempt to reinitialize repository with different object storage format\n+\tEOF\n+\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://objs git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 're-init with same object storage format' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\tgit init objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init warns about invalid init.defaultObjectStorageFormat' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\ttest_config_global init.defaultObjectStorageFormat garbage &&\n+\techo \"warning: unknown object storage format ${SQ}garbage${SQ}\" >expect &&\n+\tgit init objformat 2>err &&\n+\ttest_cmp expect err &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with init.defaultObjectStorageFormat' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\ttest_config_global init.defaultObjectStorageFormat files://objs &&\n+\tgit init objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_commit -C objformat A &&\n+\ttest_path_is_dir objformat/.git/objs/pack\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555657","messageId":"20261021-b4-pks-odb-extension-v2-6-8cf11b65eda8@pks.im","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","subject":"[PATCH v2 6/7] builtin/clone: introduce \"--object-storage-format=\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-21T05:39:19Z","receivedAt":"2026-10-21T05:39:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Wire up the new object storage format in git-clone(1) via a new\n`--object-storage-format=` option, same as we have introduced in the\npreceding commit for git-init(1).\n\nNote that \"--local\" clones will not work if either of the object\ndatabases is not using the \"files\" format. This is because we hardlink\nloose objects and packfiles into the new repository, and that is\nsomething that simply won't work with alternative backends.\nConsequently, we either downgrade to a non-local clone with a warning,\nor we die in case the user has explicitly asked for a local clone.\n\nWe _could_ in theory handle the case where the \"files\" backend has been\nconfigured with an alternative object directory path (that is, with\n\"files:///path/to/dir\"). But that's left for a future patch series to\nimplement for the sake of simplicity.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-clone.adoc | 11 +++++++\n builtin/clone.c              | 50 ++++++++++++++++++++++++++++++--\n t/t5601-clone.sh             | 68 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 127 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-clone.adoc b/Documentation/git-clone.adoc\nindex 07f7cf1a98..dd3b44817a 100644\n--- a/Documentation/git-clone.adoc\n+++ b/Documentation/git-clone.adoc\n@@ -360,6 +360,17 @@ include::ref-storage-format.adoc[]\n `--ref-format=<format>`::\n Deprecated alias of `--ref-storage-format=<format>`.\n \n+`--object-storage-format=<format>`::\n+Specify the given object storage _<format>_ for the repository. Backends that\n+require additional configuration accept a payload in the form\n+`<format>://<payload>`, for example a path or a connection string identifying\n+the database that shall store the objects. The valid values are:\n++\n+include::object-storage-format.adoc[]\n++\n+Local clones (see `--local`) fall back to the regular transport when either\n+repository uses a non-default object storage.\n+\n `-j<n>`::\n `--jobs=<n>`::\n \tThe number of submodules fetched at the same time.\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex ba4fc16def..85c124dc37 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -26,6 +26,7 @@\n #include \"refspec.h\"\n #include \"object-file.h\"\n #include \"odb.h\"\n+#include \"odb/source.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\n@@ -378,6 +379,28 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,\n \tdir_iterator_free(iter);\n }\n \n+static bool is_using_default_object_storage_format(const char *repo_path)\n+{\n+\tstruct repository_format format = REPOSITORY_FORMAT_INIT;\n+\tstruct strbuf config = STRBUF_INIT;\n+\tbool uses_default_format = true;\n+\tchar *payload = NULL;\n+\n+\tget_common_dir(&config, repo_path);\n+\tstrbuf_addstr(&config, \"/config\");\n+\tread_repository_format(&format, config.buf);\n+\n+\tif (format.version >= 1 &&\n+\t    format.object_storage &&\n+\t    (odb_source_type_by_uri(format.object_storage, &payload) != ODB_SOURCE_FILES || payload))\n+\t\tuses_default_format = false;\n+\n+\tclear_repository_format(&format);\n+\tstrbuf_release(&config);\n+\tfree(payload);\n+\treturn uses_default_format;\n+}\n+\n static void clone_local(const char *src_repo, const char *dest_repo)\n {\n \tif (!option_shared) {\n@@ -927,6 +950,7 @@ int cmd_clone(int argc,\n \tstruct string_list option_not = STRING_LIST_INIT_NODUP;\n \tconst char *real_git_dir = NULL;\n \tconst char *ref_storage_format_uri = NULL;\n+\tconst char *object_storage_format_uri = NULL;\n \tconst char *option_upload_pack = \"git-upload-pack\";\n \tint option_progress = -1;\n \tint option_sparse_checkout = 0;\n@@ -1008,6 +1032,8 @@ int cmd_clone(int argc,\n \t\t\t   N_(\"separate git dir from working tree\")),\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format_uri, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format_uri, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n \t\tOPT_STRING_LIST('c', \"config\", &option_config, N_(\"key=value\"),\n \t\t\t\tN_(\"set config inside the new repository\")),\n@@ -1060,6 +1086,10 @@ int cmd_clone(int argc,\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format_uri);\n \t}\n \n+\tif (object_storage_format_uri &&\n+\t    odb_source_type_by_uri(object_storage_format_uri, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n+\n \tif (option_mirror) {\n \t\toption_bare = 1;\n \t\toption_tags = 0;\n@@ -1213,8 +1243,9 @@ int cmd_clone(int argc,\n \t * their on-disk data structures.\n \t */\n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n-\t\t\t  option_template, GIT_HASH_UNKNOWN, ref_storage_format_uri,\n-\t\t\t  NULL, do_not_override_repo_unix_permissions, NULL);\n+\t\t\t  option_template, GIT_HASH_UNKNOWN,\n+\t\t\t  ref_storage_format_uri, object_storage_format_uri,\n+\t\t\t  do_not_override_repo_unix_permissions, NULL);\n \n \tif (real_git_dir) {\n \t\tfree((char *)git_dir);\n@@ -1362,6 +1393,21 @@ int cmd_clone(int argc,\n \t\t\tis_local = 0;\n \t\t}\n \t}\n+\n+\t/*\n+\t * Local clones copy or hardlink the object directory of the source repository\n+\t * into the destination. This only works when both repositories use the \"files\"\n+\t * object storage format.\n+\t */\n+\tif (is_local &&\n+\t    (!is_using_default_object_storage_format(path) || !is_using_default_object_storage_format(git_dir))) {\n+\t\tif (option_local > 0)\n+\t\t\tdie(_(\"cannot perform local clone with non-default object storage format\"));\n+\t\telse\n+\t\t\twarning(_(\"falling back to non-local clone because of non-default object storage format\"));\n+\t\tis_local = 0;\n+\t}\n+\n \tif (option_local > 0 && !is_local)\n \t\twarning(_(\"--local is ignored\"));\n \ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 06f6121f82..85f439d6b6 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -181,6 +181,74 @@ test_expect_success 'clone with garbage ref format' '\n \ttest_path_is_missing ref-storage\n '\n \n+test_expect_success 'clone with files object storage format' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\tgit clone --object-storage-format=files --bare src object-storage &&\n+\ttest_must_fail git -C object-storage config get extensions.objectstorage &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\techo files >expect &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'clone with object storage payload' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\tgit clone --object-storage-format=files://objs --bare src object-storage &&\n+\tgit -C object-storage config get extensions.objectstorage >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_path_is_dir object-storage/objs/pack &&\n+\ttest_path_is_missing object-storage/objects/pack\n+'\n+\n+test_expect_success 'clone with object storage payload and bundle URI' '\n+\ttest_when_finished \"rm -rf object-storage src.bundle\" &&\n+\tgit -C src bundle create ../src.bundle --all &&\n+\tgit clone --object-storage-format=files://objs --bundle-uri=\"$PWD/src.bundle\" \\\n+\t\tsrc object-storage &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'clone with garbage object storage format' '\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git clone --object-storage-format=garbage --bare src object-storage 2>err &&\n+\ttest_cmp expect err &&\n+\ttest_path_is_missing object-storage\n+'\n+\n+test_expect_success 'local clone into non-default object storage bails' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\ttest_must_fail git clone --local --object-storage-format=files://objs src object-storage 2>err &&\n+\ttest_grep \"cannot perform local clone with non-default object storage format\" err\n+'\n+\n+test_expect_success 'local clone from explicit files object storage succeeds' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone src object-storage &&\n+\tgit -C object-storage config set core.repositoryformatversion 1 &&\n+\tgit -C object-storage config set extensions.objectstorage files &&\n+\tgit clone --local object-storage object-storage-dest\n+'\n+\n+test_expect_success 'local clone from non-default object storage bails' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone --object-storage-format=files://objs src object-storage &&\n+\ttest_must_fail git clone --local object-storage object-storage-dest 2>err &&\n+\ttest_grep \"cannot perform local clone with non-default object storage format\" err\n+'\n+\n+test_expect_success 'local clone from non-default object storage without --local warns' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone --object-storage-format=files://objs src object-storage &&\n+\tgit clone object-storage object-storage-dest 2>err &&\n+\ttest_grep \"falling back to non-local clone\" err\n+'\n+\n test_expect_success 'clone to destination with trailing /' '\n \n \tgit clone src target-1/ &&\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555658","messageId":"20261021-b4-pks-odb-extension-v2-7-8cf11b65eda8@pks.im","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","subject":"[PATCH v2 7/7] builtin/submodule: propagate \"--object-storage-format=\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-21T05:39:20Z","receivedAt":"2026-10-21T05:39:20Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format passed to git-clone(1) propagates to recursively\ncloned submodules, and git-submodule(1)'s \"add\" and \"update\" subcommands\naccept `--ref-storage-format=` so that newly cloned submodules can be\nset up with a specific format.\n\nTeach git-submodule(1) to also propagate the object storage format.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-submodule.adoc           | 10 +++-\n builtin/clone.c                            | 10 +++-\n builtin/submodule--helper.c                | 28 +++++++++\n git-submodule.sh                           | 18 ++++++\n t/meson.build                              |  1 +\n t/t7427-submodule-object-storage-format.sh | 91 ++++++++++++++++++++++++++++++\n 6 files changed, 154 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-submodule.adoc b/Documentation/git-submodule.adoc\nindex e9c81a7170..57a21bc8d9 100644\n--- a/Documentation/git-submodule.adoc\n+++ b/Documentation/git-submodule.adoc\n@@ -34,7 +34,7 @@ COMMANDS\n With no arguments, shows the status of existing submodules.  Several\n subcommands are available to perform operations on the submodules.\n \n-`add [-b <branch>] [-f | --force] [--name <name>] [--reference <repository>] [--ref-storage-format <format>] [--depth <depth>] [--] <repository> [<path>]`::\n+`add [-b <branch>] [-f | --force] [--name <name>] [--reference <repository>] [--ref-storage-format <format>] [--object-storage-format <format>] [--depth <depth>] [--] <repository> [<path>]`::\n \tAdd the given repository as a submodule at the given path\n \tto the changeset to be committed next to the current\n \tproject: the current project is termed the \"superproject\".\n@@ -75,6 +75,9 @@ URL in `.gitmodules`.\n If `--ref-storage-format <format>` or its deprecated alias `--ref-format\n <format>` is specified, the ref storage format of the newly cloned submodules\n will be set accordingly.\n++\n+If `--object-storage-format <format>` is specified, the object storage format\n+of the newly cloned submodules will be set accordingly.\n \n `status [--cached] [--recursive] [--] [<path>...]`::\n \tShow the status of the submodules. This will print the SHA-1 of the\n@@ -140,7 +143,7 @@ If you really want to remove a submodule from the repository and commit\n that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal\n options.\n \n-`update [--init] [--remote] [-N | --no-fetch] [--[no-]recommend-shallow] [-f | --force] [--checkout | --rebase | --merge] [--reference=<repository>] [--ref-storage-format=<format>] [--depth=<depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter=<filter-spec>] [--] [<path>...]`::\n+`update [--init] [--remote] [-N | --no-fetch] [--[no-]recommend-shallow] [-f | --force] [--checkout | --rebase | --merge] [--reference=<repository>] [--ref-storage-format=<format>] [--object-storage-format=<format>] [--depth=<depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter=<filter-spec>] [--] [<path>...]`::\n +\n --\n Update the registered submodules to match what the superproject\n@@ -193,6 +196,9 @@ If `--ref-storage-format <format>` or its deprecated alias `--ref-format\n <format>` is specified, the ref storage format of the newly cloned submodules\n will be set accordingly.\n \n+If `--object-storage-format <format>` is specified, the object storage format\n+of the newly cloned submodules will be set accordingly.\n+\n If `--filter <filter-spec>` is specified, the given partial clone filter will be\n applied to the submodule. See linkgit:git-rev-list[1] for details on filter\n specifications.\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 85c124dc37..63348c3f34 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -686,7 +686,8 @@ static int git_sparse_checkout_init(const char *repo)\n static int checkout(int submodule_progress,\n \t\t    struct list_objects_filter_options *filter_options,\n \t\t    int filter_submodules,\n-\t\t    enum ref_storage_format ref_storage_format)\n+\t\t    enum ref_storage_format ref_storage_format,\n+\t\t    const char *object_storage_format_uri)\n {\n \tstruct object_id oid;\n \tchar *head;\n@@ -776,6 +777,10 @@ static int checkout(int submodule_progress,\n \t\t\tstrvec_pushf(&cmd.args, \"--ref-storage-format=%s\",\n \t\t\t\t     ref_storage_format_to_name(ref_storage_format));\n \n+\t\tif (object_storage_format_uri)\n+\t\t\tstrvec_pushf(&cmd.args, \"--object-storage-format=%s\",\n+\t\t\t\t     object_storage_format_uri);\n+\n \t\tif (filter_submodules && filter_options->choice)\n \t\t\tstrvec_pushf(&cmd.args, \"--filter=%s\",\n \t\t\t\t     expand_list_objects_filter_spec(filter_options));\n@@ -1703,7 +1708,8 @@ int cmd_clone(int argc,\n \terr = checkout(submodule_progress,\n \t\t       &filter_options,\n \t\t       filter_submodules,\n-\t\t       ref_storage_format);\n+\t\t       ref_storage_format,\n+\t\t       object_storage_format_uri);\n \n \tlist_objects_filter_release(&filter_options);\n \ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 64412adf9f..8a9c9e17b6 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1739,6 +1739,7 @@ struct module_clone_data {\n \tint depth;\n \tstruct list_objects_filter_options *filter_options;\n \tenum ref_storage_format ref_storage_format;\n+\tconst char *object_storage_format;\n \tunsigned int quiet: 1;\n \tunsigned int progress: 1;\n \tunsigned int dissociate: 1;\n@@ -1948,6 +1949,9 @@ static int clone_submodule(const struct module_clone_data *clone_data,\n \t\tif (clone_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tstrvec_pushf(&cp.args, \"--ref-storage-format=%s\",\n \t\t\t\t     ref_storage_format_to_name(clone_data->ref_storage_format));\n+\t\tif (clone_data->object_storage_format)\n+\t\t\tstrvec_pushf(&cp.args, \"--object-storage-format=%s\",\n+\t\t\t\t     clone_data->object_storage_format);\n \t\tif (clone_data->dissociate)\n \t\t\tstrvec_push(&cp.args, \"--dissociate\");\n \t\tif (sm_gitdir && *sm_gitdir)\n@@ -2065,6 +2069,8 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &clone_data.object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &dissociate,\n \t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_INTEGER(0, \"depth\", &clone_data.depth,\n@@ -2095,6 +2101,9 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \t\tif (clone_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (clone_data.object_storage_format &&\n+\t    odb_source_type_by_uri(clone_data.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), clone_data.object_storage_format);\n \tclone_data.dissociate = !!dissociate;\n \tclone_data.quiet = !!quiet;\n \tclone_data.progress = !!progress;\n@@ -2202,6 +2211,7 @@ struct update_data {\n \tstruct list_objects_filter_options *filter_options;\n \tstruct module_list list;\n \tenum ref_storage_format ref_storage_format;\n+\tconst char *object_storage_format;\n \tint depth;\n \tint max_jobs;\n \tint single_branch;\n@@ -2365,6 +2375,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n \tif (suc->update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\tstrvec_pushf(&child->args, \"--ref-storage-format=%s\",\n \t\t\t     ref_storage_format_to_name(suc->update_data->ref_storage_format));\n+\tif (suc->update_data->object_storage_format)\n+\t\tstrvec_pushf(&child->args, \"--object-storage-format=%s\",\n+\t\t\t     suc->update_data->object_storage_format);\n \tstrvec_pushl(&child->args, \"--path\", sub->path, NULL);\n \tstrvec_pushl(&child->args, \"--name\", sub->name, NULL);\n \tstrvec_pushl(&child->args, \"--url\", url, NULL);\n@@ -2809,6 +2822,9 @@ static void update_data_to_args(const struct update_data *update_data,\n \tif (update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\tstrvec_pushf(args, \"--ref-storage-format=%s\",\n \t\t\t     ref_storage_format_to_name(update_data->ref_storage_format));\n+\tif (update_data->object_storage_format)\n+\t\tstrvec_pushf(args, \"--object-storage-format=%s\",\n+\t\t\t     update_data->object_storage_format);\n \tif (update_data->filter_options && update_data->filter_options->choice)\n \t\tstrvec_pushf(args, \"--filter=%s\",\n \t\t\t\texpand_list_objects_filter_spec(\n@@ -3019,6 +3035,8 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &opt.object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n \t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_INTEGER(0, \"depth\", &opt.depth,\n@@ -3067,6 +3085,9 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \t\tif (opt.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (opt.object_storage_format &&\n+\t    odb_source_type_by_uri(opt.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), opt.object_storage_format);\n \n \topt.filter_options = &filter_options;\n \topt.prefix = prefix;\n@@ -3372,6 +3393,7 @@ struct add_data {\n \tconst char *repo;\n \tconst char *realrepo;\n \tenum ref_storage_format ref_storage_format;\n+\tconst char *object_storage_format;\n \tint depth;\n \tunsigned int force: 1;\n \tunsigned int quiet: 1;\n@@ -3477,6 +3499,7 @@ static int add_submodule(const struct add_data *add_data)\n \t\t\tstring_list_append(&reference, p)->util = p;\n \t\t}\n \t\tclone_data.ref_storage_format = add_data->ref_storage_format;\n+\t\tclone_data.object_storage_format = add_data->object_storage_format;\n \t\tclone_data.dissociate = add_data->dissociate;\n \t\tif (add_data->depth >= 0)\n \t\t\tclone_data.depth = add_data->depth;\n@@ -3669,6 +3692,8 @@ static int module_add(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &add_data.object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &dissociate, N_(\"borrow the objects from reference repositories\")),\n \t\tOPT_STRING(0, \"name\", &add_data.sm_name, N_(\"name\"),\n \t\t\t   N_(\"sets the submodule's name to the given string \"\n@@ -3700,6 +3725,9 @@ static int module_add(int argc, const char **argv, const char *prefix,\n \t\tif (add_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (add_data.object_storage_format &&\n+\t    odb_source_type_by_uri(add_data.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), add_data.object_storage_format);\n \n \tadd_data.repo = argv[0];\n \tif (argc == 1)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 8632194138..4de5ffba04 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -103,6 +103,14 @@ cmd_add()\n \t\t--ref-format=*|--ref-storage-format=*)\n \t\t\tref_storage_format=\"$1\"\n \t\t\t;;\n+\t\t--object-storage-format)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tobject_storage_format=\"--object-storage-format=$2\"\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--object-storage-format=*)\n+\t\t\tobject_storage_format=\"$1\"\n+\t\t\t;;\n \t\t--dissociate)\n \t\t\tdissociate=$1\n \t\t\t;;\n@@ -148,6 +156,7 @@ cmd_add()\n \t\t${branch:+\"$branch\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${ref_storage_format:+\"$ref_storage_format\"} \\\n+\t\t${object_storage_format:+\"$object_storage_format\"} \\\n \t\t$dissociate \\\n \t\t${name:+\"$name\"} \\\n \t\t${depth:+\"$depth\"} \\\n@@ -310,6 +319,14 @@ cmd_update()\n \t\t--ref-format=*|--ref-storage-format=*)\n \t\t\tref_storage_format=\"$1\"\n \t\t\t;;\n+\t\t--object-storage-format)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tobject_storage_format=\"--object-storage-format=$2\"\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--object-storage-format=*)\n+\t\t\tobject_storage_format=\"$1\"\n+\t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n \t\t\treference=\"--reference=$2\"\n@@ -386,6 +403,7 @@ cmd_update()\n \t\t$merge \\\n \t\t$checkout \\\n \t\t${ref_storage_format:+\"$ref_storage_format\"} \\\n+\t\t${object_storage_format:+\"$object_storage_format\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t$dissociate \\\n \t\t${depth:+\"$depth\"} \\\ndiff --git a/t/meson.build b/t/meson.build\nindex 11b3752f00..8542035b6f 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -926,6 +926,7 @@ integration_tests = [\n   't7424-submodule-mixed-ref-formats.sh',\n   't7425-submodule-gitdir-path-extension.sh',\n   't7426-submodule-get-default-remote.sh',\n+  't7427-submodule-object-storage-format.sh',\n   't7450-bad-git-dotfiles.sh',\n   't7500-commit-template-squash-signoff.sh',\n   't7501-commit-basic-functionality.sh',\ndiff --git a/t/t7427-submodule-object-storage-format.sh b/t/t7427-submodule-object-storage-format.sh\nnew file mode 100755\nindex 0000000000..a2c9a5e753\n--- /dev/null\n+++ b/t/t7427-submodule-object-storage-format.sh\n@@ -0,0 +1,91 @@\n+#!/bin/sh\n+\n+test_description='submodules handle the object storage format'\n+\n+. ./test-lib.sh\n+\n+test_object_storage_format () {\n+\techo \"$2\" >expect &&\n+\tgit -C \"$1\" rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+}\n+\n+test_expect_success 'setup' '\n+\tgit config set --global protocol.file.allow always\n+'\n+\n+test_expect_success 'add existing repository with different object storage format' '\n+\ttest_when_finished \"rm -rf parent\" &&\n+\n+\tgit init parent &&\n+\t(\n+\t\tcd parent &&\n+\t\ttest_commit parent &&\n+\t\tgit init --object-storage-format=files://objs submodule &&\n+\t\ttest_commit -C submodule submodule &&\n+\t\tgit submodule add ./submodule &&\n+\t\ttest_object_storage_format submodule files://objs\n+\t)\n+'\n+\n+test_expect_success 'add submodules with different object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\ttest_object_storage_format upstream files &&\n+\tgit -C upstream submodule add --object-storage-format=files://objs \"file://$(pwd)/submodule\" &&\n+\ttest_object_storage_format upstream/submodule files://objs &&\n+\ttest_path_is_dir upstream/.git/modules/submodule/objs/pack\n+'\n+\n+test_expect_success 'add submodules with garbage object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git -C upstream submodule add --object-storage-format=garbage \"file://$(pwd)/submodule\" 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'recursive clone propagates object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tgit -C upstream submodule add \"file://$(pwd)/submodule\" &&\n+\tgit -C upstream commit -am \"add submodule\" &&\n+\n+\ttest_object_storage_format upstream files &&\n+\ttest_object_storage_format upstream/submodule files &&\n+\n+\tgit clone --object-storage-format=files://objs --recurse-submodules \\\n+\t\tupstream downstream &&\n+\ttest_object_storage_format downstream files://objs &&\n+\ttest_object_storage_format downstream/submodule files://objs &&\n+\ttest_path_is_dir downstream/.git/objs/pack &&\n+\ttest_path_is_dir downstream/.git/modules/submodule/objs/pack\n+'\n+\n+test_expect_success 'clone submodules with different object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tgit -C upstream submodule add \"file://$(pwd)/submodule\" &&\n+\tgit -C upstream commit -m \"upstream submodule\" &&\n+\n+\tgit clone --no-recurse-submodules \"file://$(pwd)/upstream\" downstream &&\n+\tgit -C downstream submodule update --init --object-storage-format=files://objs &&\n+\ttest_object_storage_format downstream files &&\n+\ttest_object_storage_format downstream/submodule files://objs\n+'\n+\n+test_done\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555740","messageId":"CAOLa=ZRzu_7No085hEHnULo0L50y=ntx3MSkb-VbcywChdOPZA@mail.gmail.com","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-5-8cf11b65eda8@pks.im","subject":"Re: [PATCH v2 5/7] builtin/init: introduce handling of object storage format","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-21T14:23:17Z","receivedAt":"2026-10-21T14:23:17Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> While the object storage format extension can already be configured\n> manually via git-config(1), this isn't exactly an ergonomic way of doing\n> so. For the reference storage format extension, users have a host of\n> options available to them.\n>\n> Introduce the equivalent options for the object storage format.\n\n[snip]\n\n> diff --git a/setup.c b/setup.c\n> index 98140a7641..3d74f8eeed 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -2466,7 +2466,8 @@ void initialize_repository_version(struct repository *repo,\n>  \t */\n>  \tif (hash_algo != GIT_HASH_SHA1_LEGACY ||\n>  \t    ref_storage_format != REF_STORAGE_FORMAT_FILES ||\n> -\t    repo->ref_storage_payload)\n> +\t    repo->ref_storage_payload ||\n> +\t    strcmp(repo->object_storage_format, \"files\"))\n>  \t\ttarget_version = GIT_REPO_VERSION_READ;\n>\n\nOkay so this is what also sets the 'core.repositoryformatversion'\nconfig. I was specifically looking for that.\n\nDoes this mean that even for the files odb with a payload we need v1 of\n'core.repositoryformatversion'?\n\n>  \tif (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)\n> @@ -2490,6 +2491,12 @@ void initialize_repository_version(struct repository *repo,\n>  \t\trepo_config_set_gently(repo, \"extensions.refstorage\", NULL);\n>  \t}\n>\n> +\tif (strcmp(repo->object_storage_format, \"files\"))\n> +\t\trepo_config_set(repo, \"extensions.objectstorage\",\n> +\t\t\t\trepo->object_storage_format);\n> +\telse if (reinit)\n> +\t\trepo_config_set_gently(repo, \"extensions.objectstorage\", NULL);\n> +\n\nSo this handled reinitializing the same repo. If there was a previously\nset object storage format, we unset it gently.\n\nBut, we already catch and error out if the extension before and after\nreinit differ, so this `else` block is not needed, no? Removing it\npasses all the tests in this patch.\n\n>  \tif (reinit) {\n>  \t\tstruct strbuf config = STRBUF_INIT;\n>  \t\tstruct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;\n> @@ -2726,6 +2733,7 @@ static void separate_git_dir(struct repository *repo,\n>  struct default_format_config {\n>  \tint hash;\n>  \tenum ref_storage_format ref_storage_format;\n> +\tchar *object_storage_format;\n>  };\n>\n>  static int read_default_format_config(const char *key, const char *value,\n\n[snip]\n\n> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> index d080ab04a8..0da14e8f70 100755\n> --- a/t/t0001-init.sh\n> +++ b/t/t0001-init.sh\n> @@ -898,6 +898,168 @@ test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides ext\n\n[snip]\n\n> +\n> +test_expect_success 'init with --object-storage-format=files://<relative-path>' '\n> +\ttest_when_finished \"rm -rf objformat\" &&\n> +\tgit init --object-storage-format=files://objs objformat &&\n> +\techo files://objs >expect &&\n> +\tgit -C objformat config get extensions.objectstorage >actual &&\n> +\ttest_cmp expect actual &&\n> +\techo 1 >expect &&\n>\n\nOkay what I asked before is expected, files with payload is v1. Makes\nsense.\n\n> +\tgit -C objformat config get core.repositoryformatversion >actual &&\n> +\ttest_cmp expect actual &&\n> +\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n> +\techo files://objs >expect &&\n> +\ttest_cmp expect actual &&\n> +\ttest_path_is_dir objformat/.git/objects &&\n> +\ttest_path_is_dir objformat/.git/objs &&\n> +\ttest_commit -C objformat A &&\n> +\tgit -C objformat rev-parse --verify HEAD &&\n> +\ttest_path_is_missing objformat/.git/objects/pack &&\n> +\ttest_path_is_dir objformat/.git/objs/pack\n\nSuper nit: some newlines in between would help improve readability of a\nfew of these denser tests.\n\n> +'\n> +\n\n[snip]\n\nNice. I like the extensive testing done here.\n"},{"id":"555741","messageId":"CAOLa=ZS3vbjY9yxx1TCaAtUp5D5KeQ+qiB805SPqhZT7NX+uFg@mail.gmail.com","threadId":"66584","inReplyTo":"20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im","subject":"Re: [PATCH v2 0/7] odb: introduce object storage extension","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-21T14:31:59Z","receivedAt":"2026-10-21T14:31:59Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Hi,\n>\n> this patch series introduces the object storage extension. The extension\n> is of course similar in spirit and design to the ref storage extension:\n> it can be configured via \"extensions.objectStorage\", has the same syntax\n> with \"<schema>[://<payload>]\", and we have the same mechanisms to\n> configure it (\"--object-storage-format=\", GIT_OBJECT_STORAGE_FORMAT,\n> GIT_DEFAULT_OBJECT_STORAGE_FORMAT, \"init.defaultObjetcStorageFormat\").\n>\n> For now, we only support the \"files\" object storage format, so not a lot\n> of stuff really changes. That being said, its optional payload allows\n> you to configure a different location for the \".git/objects\" directory.\n> So if you specify \"extensions.objectStorage=files://objs\", objects would\n> be stored in \".git/objs\" instead.\n>\n> The series is built on top of c51408889c (The 6th batch, 2026-10-16)\n> with the following dependencies merged into it:\n>\n>   - ps/odb-files-alternates at 0ba59c8453 (odb/source: drop\n>     `read_alternates` callback, 2026-10-08) merged into it.\n>\n>   - ps/setup-enforce-repo-passed-to-create-repository-has-no-state\n>     (phew, what a mouthful) at 0ba59c8453 (odb/source: drop\n>     `read_alternates` callback, 2026-10-08).\n>\n> Note that these two series conflict with one another. The conflict can\n> easily be resolved by just deleting the whole conflicting sections.\n>\n> Changes in v2:\n>   - Ensure that `repo->object_storage_format` is always populated.\n>   - Link to v1: https://patch.msgid.link/20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im\n>\n\nI had a look at the range diff and it looks as expected, I had one small\ncleanup comment in 5/7, but its harmless so I'd be okay with it as is.\nThanks!\n"},{"id":"555948","messageId":"atrxjqESUSunxsqU@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZRzu_7No085hEHnULo0L50y=ntx3MSkb-VbcywChdOPZA@mail.gmail.com","subject":"Re: [PATCH v2 5/7] builtin/init: introduce handling of object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T05:33:15Z","receivedAt":"2026-10-23T05:33:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Oct 21, 2026 at 10:23:17AM -0400, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > diff --git a/setup.c b/setup.c\n> > index 98140a7641..3d74f8eeed 100644\n> > --- a/setup.c\n> > +++ b/setup.c\n> > @@ -2466,7 +2466,8 @@ void initialize_repository_version(struct repository *repo,\n> >  \t */\n> >  \tif (hash_algo != GIT_HASH_SHA1_LEGACY ||\n> >  \t    ref_storage_format != REF_STORAGE_FORMAT_FILES ||\n> > -\t    repo->ref_storage_payload)\n> > +\t    repo->ref_storage_payload ||\n> > +\t    strcmp(repo->object_storage_format, \"files\"))\n> >  \t\ttarget_version = GIT_REPO_VERSION_READ;\n> >\n> \n> Okay so this is what also sets the 'core.repositoryformatversion'\n> config. I was specifically looking for that.\n> \n> Does this mean that even for the files odb with a payload we need v1 of\n> 'core.repositoryformatversion'?\n\nYes. Repository extensions aren't read in the case where we have a v0\nrepository, so we cannot make use of any non-default object storage\nformat there.\n\n> > @@ -2490,6 +2491,12 @@ void initialize_repository_version(struct repository *repo,\n> >  \t\trepo_config_set_gently(repo, \"extensions.refstorage\", NULL);\n> >  \t}\n> >\n> > +\tif (strcmp(repo->object_storage_format, \"files\"))\n> > +\t\trepo_config_set(repo, \"extensions.objectstorage\",\n> > +\t\t\t\trepo->object_storage_format);\n> > +\telse if (reinit)\n> > +\t\trepo_config_set_gently(repo, \"extensions.objectstorage\", NULL);\n> > +\n> \n> So this handled reinitializing the same repo. If there was a previously\n> set object storage format, we unset it gently.\n> \n> But, we already catch and error out if the extension before and after\n> reinit differ, so this `else` block is not needed, no? Removing it\n> passes all the tests in this patch.\n\nThis is a slightly different case: if you have a repository that uses\nthe default storage format, but that explicitly configures the \"files\"\nformat, then we downgrade the repository format version to 0 and unset\nthe extension again. This logic basically matches what we do with the\nref backend, too.\n\nI noticed there's no test for this though. And that then led me down the\nrabbit hole, because I'm not particularly happy with some of the logic\nhere. For example, I was doing normalization of \"files\" vs \"files://\"\nsomewhat inconsistently.\n\nSo I've redone some of the infrastructure here to be much closer to what\nwe do with the ref backend. Currently we track the object storage format\nas a single URI that we pass around, whereas for the ref storage format\nwe pass around a backend type and payload. And that makes normalization\na lot easier, and we don't have to re-parse the URI in a lot of places.\n\nSo I've adapted the series now to use the same approach. It also makes\nstuff easier to reason about, as we basically have the exact same logic\nfor both storage types in most places.\n\nI'll send that later today.\n\nPatrick\n\n"},{"id":"555984","messageId":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH v3 0/7] odb: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T11:49:09Z","receivedAt":"2026-10-23T11:49:09Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series introduces the object storage extension. The extension\nis of course similar in spirit and design to the ref storage extension:\nit can be configured via \"extensions.objectStorage\", has the same syntax\nwith \"<schema>[://<payload>]\", and we have the same mechanisms to\nconfigure it (\"--object-storage-format=\", GIT_OBJECT_STORAGE_FORMAT,\nGIT_DEFAULT_OBJECT_STORAGE_FORMAT, \"init.defaultObjetcStorageFormat\").\n\nFor now, we only support the \"files\" object storage format, so not a lot\nof stuff really changes. That being said, its optional payload allows\nyou to configure a different location for the \".git/objects\" directory.\nSo if you specify \"extensions.objectStorage=files://objs\", objects would\nbe stored in \".git/objs\" instead.\n\nThe series is built on top of c51408889c (The 6th batch, 2026-10-16)\nwith the following dependencies merged into it:\n\n  - ps/odb-files-alternates at 0ba59c8453 (odb/source: drop\n    `read_alternates` callback, 2026-10-08) merged into it.\n\n  - ps/setup-enforce-repo-passed-to-create-repository-has-no-state\n    (phew, what a mouthful) at 0ba59c8453 (odb/source: drop\n    `read_alternates` callback, 2026-10-08).\n\nNote that these two series conflict with one another. The conflict can\neasily be resolved by just deleting the whole conflicting sections.\n\nChanges in v3:\n  - Split up object storage format URI into object storage format and\n    payload. This matches how we do it for the ref storage format and\n    thus brings us much closer to it, where we mostly use the exact same\n    logic. For now though this restricts a couple cases, like for\n    example submodule clones do not pass down payloads to the submodules\n    anymore. This is intentional so that object and ref storage format\n    have the same behaviour.\n  - There's an en explicit `enum object_storage_format` now, matching\n    how we handle this for the ref storage format.\n  - Link to v2: https://patch.msgid.link/20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im\n\nChanges in v2:\n  - Ensure that `repo->object_storage_format` is always populated.\n  - Link to v1: https://patch.msgid.link/20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (7):\n      loose: drop unused `repo_write_loose_object_map()`\n      setup: introduce object storage extension\n      setup: allow overriding object storage format via environment\n      builtin: expose the object storage format\n      builtin/init: introduce handling of object storage format\n      builtin/clone: introduce \"--object-storage-format=\"\n      builtin/submodule: propagate \"--object-storage-format=\"\n\n Documentation/config/extensions.adoc       |  23 +++\n Documentation/config/init.adoc             |   5 +\n Documentation/git-clone.adoc               |  11 ++\n Documentation/git-init.adoc                |  10 +-\n Documentation/git-repo.adoc                |   6 +\n Documentation/git-rev-parse.adoc           |   5 +\n Documentation/git-submodule.adoc           |  10 +-\n Documentation/git.adoc                     |  10 ++\n Documentation/object-storage-format.adoc   |   6 +\n builtin/clone.c                            |  63 +++++++-\n builtin/init-db.c                          |   7 +-\n builtin/repo.c                             |  10 ++\n builtin/rev-parse.c                        |   9 ++\n builtin/submodule--helper.c                |  40 +++++\n environment.h                              |   1 +\n git-submodule.sh                           |  18 +++\n loose.c                                    |  46 ------\n loose.h                                    |   1 -\n odb.c                                      |  46 +++++-\n odb.h                                      |  13 ++\n odb/source-files.c                         |   7 +\n odb/source-files.h                         |   1 +\n odb/source.c                               |  14 +-\n odb/source.h                               |   5 +-\n refs.c                                     |   3 +-\n repository.c                               |  10 ++\n repository.h                               |  18 +++\n setup.c                                    | 133 ++++++++++++++++-\n setup.h                                    |   5 +\n t/meson.build                              |   1 +\n t/t0001-init.sh                            | 225 +++++++++++++++++++++++++++++\n t/t1900-repo-info.sh                       |   3 +\n t/t5601-clone.sh                           |  68 +++++++++\n t/t7427-submodule-object-storage-format.sh | 104 +++++++++++++\n t/unit-tests/u-odb-inmemory.c              |   1 +\n 35 files changed, 872 insertions(+), 66 deletions(-)\n\nRange-diff versus v2:\n\n1:  04226610d7 = 1:  deda9d5530 loose: drop unused `repo_write_loose_object_map()`\n2:  34afb43448 ! 2:  f6a73a7934 setup: introduce object storage extension\n    @@ Documentation/object-storage-format.adoc (new)\n     +provided. The payload is ignored when `GIT_OBJECT_DIRECTORY` is set.\n     \n      ## odb.c ##\n    +@@\n    + #include \"trace2.h\"\n    + #include \"write-or-die.h\"\n    + \n    ++static const char * const object_storage_name_by_format[] = {\n    ++\t[OBJECT_STORAGE_FORMAT_UNKNOWN] = \"unknown\",\n    ++\t[OBJECT_STORAGE_FORMAT_FILES] = \"files\",\n    ++};\n    ++\n    ++enum object_storage_format object_storage_format_by_name(const char *name)\n    ++{\n    ++\tfor (size_t i = 0; i < ARRAY_SIZE(object_storage_name_by_format); i++)\n    ++\t\tif (!strcmp(object_storage_name_by_format[i], name))\n    ++\t\t\treturn i;\n    ++\treturn OBJECT_STORAGE_FORMAT_UNKNOWN;\n    ++}\n    ++\n    ++enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload)\n    ++{\n    ++\tenum object_storage_format format;\n    ++\tconst char *schema_end;\n    ++\tchar *name;\n    ++\n    ++\tschema_end = strstr(uri, \"://\");\n    ++\tif (!schema_end) {\n    ++\t\tname = xstrdup(uri);\n    ++\t\tif (payload)\n    ++\t\t\t*payload = NULL;\n    ++\t} else {\n    ++\t\tname = xstrndup(uri, schema_end - uri);\n    ++\t\tif (payload)\n    ++\t\t\t*payload = *(schema_end + 3) ? xstrdup(schema_end + 3) : NULL;\n    ++\t}\n    ++\n    ++\tformat = object_storage_format_by_name(name);\n    ++\n    ++\tfree(name);\n    ++\treturn format;\n    ++}\n    ++\n    + int odb_mkstemp(struct object_database *odb,\n    + \t\tstruct strbuf *temp_filename, const char *pattern)\n    + {\n     @@ odb.c: struct object_database *odb_new(struct repository *repo,\n      \to->repo = repo;\n      \tpthread_mutex_init(&o->replace_mutex, NULL);\n      \n     -\to->source = odb_source_new(o, flags);\n    -+\to->source = odb_source_new(o, repo->object_storage_format, flags);\n    ++\to->source = odb_source_new(o, repo->object_storage_format,\n    ++\t\t\t\t   repo->object_storage_payload, flags);\n      \to->inmemory_objects = &odb_source_inmemory_new(o)->base;\n      \n      \treturn o;\n     \n    + ## odb.h ##\n    +@@\n    + #include \"oid-array.h\"\n    + #include \"oidset.h\"\n    + #include \"oidmap.h\"\n    ++#include \"repository.h\"\n    + #include \"string-list.h\"\n    + #include \"thread-utils.h\"\n    + \n    +@@ odb.h: struct strvec;\n    +  */\n    + char *compute_alternate_path(const char *path, struct strbuf *err);\n    + \n    ++/*\n    ++ * Parse the given URI in the format \"<schema>[://<payload>]\" and return the\n    ++ * object storage format identified by the schema. If `payload` is non-NULL it\n    ++ * will be set to a newly allocated copy of the payload, or NULL if the URI has\n    ++ * no or an empty payload. Returns `OBJECT_STORAGE_FORMAT_UNKNOWN` for unknown\n    ++ * schemas.\n    ++ */\n    ++enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload);\n    ++\n    ++enum object_storage_format object_storage_format_by_name(const char *name);\n    ++\n    + /*\n    +  * The object database encapsulates access to objects in a repository. It\n    +  * manages the object source as well as auxiliary data structures required to\n    +\n      ## odb/source-files.c ##\n     @@ odb/source-files.c: struct odb_files_dir *odb_source_files_find_dir(struct object_database *odb, con\n      }\n    @@ odb/source-files.h: struct odb_source_files {\n      /*\n     \n      ## odb/source.c ##\n    -@@\n    - #include \"git-compat-util.h\"\n    -+#include \"gettext.h\"\n    - #include \"object-file.h\"\n    - #include \"odb/source-files.h\"\n    - #include \"odb/source.h\"\n     @@ odb/source.c: const char *odb_source_type_to_name(enum odb_source_type type)\n    - \treturn name;\n      }\n      \n    -+static enum odb_source_type odb_source_type_by_name(const char *name)\n    -+{\n    -+\tif (!strcmp(name, \"files\"))\n    -+\t\treturn ODB_SOURCE_FILES;\n    -+\treturn ODB_SOURCE_UNKNOWN;\n    -+}\n    -+\n    -+enum odb_source_type odb_source_type_by_uri(const char *uri, char **payload)\n    -+{\n    -+\tenum odb_source_type type;\n    -+\tconst char *schema_end;\n    -+\tchar *name;\n    -+\n    -+\tschema_end = strstr(uri, \"://\");\n    -+\tif (!schema_end) {\n    -+\t\tname = xstrdup(uri);\n    -+\t\tif (payload)\n    -+\t\t\t*payload = NULL;\n    -+\t} else {\n    -+\t\tname = xstrndup(uri, schema_end - uri);\n    -+\t\tif (payload)\n    -+\t\t\t*payload = *(schema_end + 3) ? xstrdup(schema_end + 3) : NULL;\n    -+\t}\n    -+\n    -+\ttype = odb_source_type_by_name(name);\n    -+\tfree(name);\n    -+\treturn type;\n    -+}\n    -+\n      struct odb_source *odb_source_new(struct object_database *odb,\n    -+\t\t\t\t  const char *object_storage_format,\n    ++\t\t\t\t  enum object_storage_format format,\n    ++\t\t\t\t  const char *payload,\n      \t\t\t\t  enum odb_new_flags flags)\n      {\n     -\treturn &odb_source_files_new(odb, flags)->base;\n     +\tstruct odb_source *source;\n    -+\tchar *payload = NULL;\n     +\n    -+\tswitch (odb_source_type_by_uri(object_storage_format, &payload)) {\n    -+\tcase ODB_SOURCE_FILES:\n    ++\tswitch (format) {\n    ++\tcase OBJECT_STORAGE_FORMAT_FILES:\n     +\t\tsource = &odb_source_files_new(odb, payload, flags)->base;\n     +\t\tbreak;\n     +\tdefault:\n    -+\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n    ++\t\tBUG(\"unknown object storage format\");\n     +\t}\n     +\n    -+\tfree(payload);\n     +\treturn source;\n      }\n      \n      void odb_source_init(struct odb_source *source,\n     \n      ## odb/source.h ##\n    -@@ odb/source.h: enum odb_source_type {\n    -  */\n    - const char *odb_source_type_to_name(enum odb_source_type type);\n    - \n    -+/*\n    -+ * Parse the given URI in the format \"<schema>[://<payload>]\" and return the\n    -+ * source type identified by the schema. If `payload` is non-NULL it will be\n    -+ * set to a newly allocated copy of the payload, or NULL if the URI has no or\n    -+ * an empty payload. Returns `ODB_SOURCE_UNKNOWN` for unknown schemas.\n    -+ */\n    -+enum odb_source_type odb_source_type_by_uri(const char *uri, char **payload);\n    -+\n    - struct object_id;\n    - struct odb_stream;\n    - struct strbuf;\n     @@ odb/source.h: struct odb_source {\n      \n      /*\n    @@ odb/source.h: struct odb_source {\n     + * format.\n       */\n      struct odb_source *odb_source_new(struct object_database *odb,\n    -+\t\t\t\t  const char *object_storage_format,\n    ++\t\t\t\t  enum object_storage_format format,\n    ++\t\t\t\t  const char *payload,\n      \t\t\t\t  enum odb_new_flags flags);\n      \n      /*\n    @@ repository.c: void repo_set_ref_storage_format(struct repository *repo,\n      }\n      \n     +void repo_set_object_storage_format(struct repository *repo,\n    -+\t\t\t\t    const char *uri)\n    ++\t\t\t\t    enum object_storage_format format,\n    ++\t\t\t\t    const char *payload)\n     +{\n    -+\tfree(repo->object_storage_format);\n    -+\tif (uri)\n    -+\t\trepo->object_storage_format = xstrdup(uri);\n    -+\telse\n    -+\t\trepo->object_storage_format = xstrdup(\"files\");\n    ++\trepo->object_storage_format = format;\n    ++\tfree(repo->object_storage_payload);\n    ++\trepo->object_storage_payload = xstrdup_or_null(payload);\n     +}\n     +\n      /*\n    @@ repository.c: void repo_clear(struct repository *repo)\n      \tfree(repo->worktree);\n      \tfree(repo->submodule_prefix);\n      \tfree(repo->ref_storage_payload);\n    -+\tfree(repo->object_storage_format);\n    ++\tfree(repo->object_storage_payload);\n      \n      \todb_free(repo->objects);\n      \n     \n      ## repository.h ##\n    +@@ repository.h: enum ref_storage_format {\n    + \tREF_STORAGE_FORMAT_REFTABLE,\n    + };\n    + \n    ++enum object_storage_format {\n    ++\tOBJECT_STORAGE_FORMAT_UNKNOWN,\n    ++\tOBJECT_STORAGE_FORMAT_FILES,\n    ++};\n    ++\n    + #ifdef WITH_BREAKING_CHANGES /* Git 3.0 */\n    + # define REF_STORAGE_FORMAT_DEFAULT REF_STORAGE_FORMAT_REFTABLE\n    + #else\n     @@ repository.h: struct repository {\n      \t */\n      \tchar *ref_storage_payload;\n      \n    ++\t/* Repository's object storage format, as serialized on disk. */\n    ++\tenum object_storage_format object_storage_format;\n    ++\n     +\t/*\n    -+\t * The object storage URI in the format \"<schema>[://<payload>]\", as\n    -+\t * configured via \"extensions.objectStorage\".\n    ++\t * Object storage information as needed for the backend. This contains\n    ++\t * only the payload from the object storage format URI without the\n    ++\t * schema.\n     +\t */\n    -+\tchar *object_storage_format;\n    ++\tchar *object_storage_payload;\n     +\n      \t/* A unique-id for tracing purposes. */\n      \tint trace2_repo_id;\n    @@ repository.h: void repo_set_compat_hash_algo(struct repository *repo, uint32_t c\n      \t\t\t\t enum ref_storage_format format,\n      \t\t\t\t const char *payload);\n     +void repo_set_object_storage_format(struct repository *repo,\n    -+\t\t\t\t    const char *uri);\n    ++\t\t\t\t    enum object_storage_format format,\n    ++\t\t\t\t    const char *payload);\n      void initialize_repository(struct repository *repo);\n      RESULT_MUST_BE_USED\n      int repo_init(struct repository *r, const char *gitdir, const char *worktree);\n     \n      ## setup.c ##\n    -@@\n    - #include \"hex.h\"\n    - #include \"object-file.h\"\n    - #include \"object-name.h\"\n    -+#include \"odb/source.h\"\n    - #include \"refs.h\"\n    - #include \"repository.h\"\n    - #include \"config.h\"\n     @@ setup.c: static enum extension_result handle_extension(const char *var,\n    + \t\t\treturn error(_(\"invalid value for '%s': '%s'\"),\n      \t\t\t\t     \"extensions.refstorage\", value);\n      \t\tdata->ref_storage_format = format;\n    - \t\treturn EXTENSION_OK;\n    ++\t\treturn EXTENSION_OK;\n     +\t} else if (!strcmp(ext, \"objectstorage\")) {\n    ++\t\tenum object_storage_format format;\n    ++\n     +\t\tif (!value)\n     +\t\t\treturn config_error_nonbool(var);\n    -+\t\tif (odb_source_type_by_uri(value, NULL) == ODB_SOURCE_UNKNOWN)\n    ++\n    ++\t\tFREE_AND_NULL(data->object_storage_payload);\n    ++\t\tformat = object_storage_format_by_uri(value, &data->object_storage_payload);\n    ++\t\tif (format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\t\treturn error(_(\"invalid value for '%s': '%s'\"),\n     +\t\t\t\t     \"extensions.objectstorage\", value);\n    -+\t\tfree(data->object_storage);\n    -+\t\tdata->object_storage = xstrdup(value);\n    -+\t\treturn EXTENSION_OK;\n    ++\t\tdata->object_storage_format = format;\n    ++\n    + \t\treturn EXTENSION_OK;\n      \t} else if (!strcmp(ext, \"relativeworktrees\")) {\n      \t\tdata->relative_worktrees = git_config_bool(var, value);\n    - \t\treturn EXTENSION_OK;\n     @@ setup.c: static enum extension_result handle_extension(const char *var,\n      \t\tdata->submodule_path_cfg = git_config_bool(var, value);\n      \t\treturn EXTENSION_OK;\n    @@ setup.c: void clear_repository_format(struct repository_format *format)\n      \tfree(format->work_tree);\n      \tfree(format->partial_clone);\n      \tfree(format->ref_storage_payload);\n    -+\tfree(format->object_storage);\n    ++\tfree(format->object_storage_payload);\n      \tinit_repository_format(format);\n      }\n      \n    @@ setup.c: int apply_repository_format(struct repository *repo,\n      \trepo_set_ref_storage_format(repo,\n      \t\t\t\t    format->ref_storage_format,\n      \t\t\t\t    format->ref_storage_payload);\n    -+\trepo_set_object_storage_format(repo, format->object_storage);\n    ++\trepo_set_object_storage_format(repo,\n    ++\t\t\t\t       format->object_storage_format,\n    ++\t\t\t\t       format->object_storage_payload);\n      \trepo->repository_format_worktree_config =\n      \t\tformat->worktree_config;\n      \trepo->repository_format_submodule_path_cfg =\n     \n      ## setup.h ##\n     @@ setup.h: struct repository_format {\n    + \tint compat_hash_algo;\n    + \tenum ref_storage_format ref_storage_format;\n      \tchar *ref_storage_payload;\n    ++\tenum object_storage_format object_storage_format;\n    ++\tchar *object_storage_payload;\n      \tint sparse_index;\n      \tchar *work_tree;\n    -+\tchar *object_storage;\n      \tstruct string_list unknown_extensions;\n    - \tstruct string_list v1_only_extensions;\n    - };\n    +@@ setup.h: struct repository_format {\n    + \t.is_bare = -1, \\\n    + \t.hash_algo = GIT_HASH_DEFAULT, \\\n    + \t.ref_storage_format = REF_STORAGE_FORMAT_FILES, \\\n    ++\t.object_storage_format = OBJECT_STORAGE_FORMAT_FILES, \\\n    + \t.unknown_extensions = STRING_LIST_INIT_DUP, \\\n    + \t.v1_only_extensions = STRING_LIST_INIT_DUP, \\\n    + }\n     \n      ## t/t0001-init.sh ##\n     @@ t/t0001-init.sh: test_expect_success 'init with --ref-storage-format=garbage' '\n    @@ t/unit-tests/u-odb-inmemory.c\n      \n      static struct repository repo = {\n      \t.hash_algo = &hash_algos[GIT_HASH_SHA1],\n    -+\t.object_storage_format = (char *) \"files\",\n    ++\t.object_storage_format = OBJECT_STORAGE_FORMAT_FILES,\n      };\n      static struct object_database *odb;\n      \n3:  05c6ce2866 ! 3:  54090c50c3 setup: allow overriding object storage format via environment\n    @@ setup.c: const char *setup_git_directory_gently(struct repository *repo, int *no\n     +\t\t\t */\n     +\t\t\tobject_storage_uri = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT);\n     +\t\t\tif (object_storage_uri) {\n    -+\t\t\t\tif (odb_source_type_by_uri(object_storage_uri, NULL) == ODB_SOURCE_UNKNOWN)\n    ++\t\t\t\tFREE_AND_NULL(discovery.format.object_storage_payload);\n    ++\t\t\t\tdiscovery.format.object_storage_format =\n    ++\t\t\t\t\tobject_storage_format_by_uri(object_storage_uri,\n    ++\t\t\t\t\t\t\t\t     &discovery.format.object_storage_payload);\n    ++\t\t\t\tif (discovery.format.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\t\t\t\tdie(_(\"unknown object storage format: '%s'\"), object_storage_uri);\n    -+\t\t\t\tfree(discovery.format.object_storage);\n    -+\t\t\t\tdiscovery.format.object_storage = xstrdup(object_storage_uri);\n     +\t\t\t}\n     +\n      \t\t\tif (apply_repository_format(repo, &discovery.format,\n4:  487e927a5c ! 4:  f6b57aa2fe builtin: expose the object storage format\n    @@ Documentation/git-rev-parse.adoc: The following options are unaffected by `--pat\n      ~~~~~~~~~~~~~\n     \n      ## builtin/repo.c ##\n    -@@\n    - #include \"hash.h\"\n    - #include \"hex.h\"\n    - #include \"odb.h\"\n    -+#include \"odb/source.h\"\n    - #include \"parse-options.h\"\n    - #include \"path.h\"\n    - #include \"path-walk.h\"\n     @@ builtin/repo.c: static int get_references_format(struct repository *repo, struct strbuf *buf)\n      \treturn 0;\n      }\n      \n     +static int get_object_storage_format(struct repository *repo, struct strbuf *buf)\n     +{\n    -+\tstrbuf_addstr(buf, repo->object_storage_format);\n    ++\tstrbuf_addstr(buf,\n    ++\t\t      object_storage_format_to_name(repo->object_storage_format));\n    ++\tif (repo->object_storage_payload)\n    ++\t\tstrbuf_addf(buf, \"://%s\", repo->object_storage_payload);\n     +\treturn 0;\n     +}\n     +\n    @@ builtin/rev-parse.c\n      #include \"gettext.h\"\n      #include \"hash.h\"\n      #include \"hex.h\"\n    -+#include \"odb/source.h\"\n    ++#include \"odb.h\"\n      #include \"refs.h\"\n      #include \"quote.h\"\n      #include \"object-name.h\"\n    @@ builtin/rev-parse.c: int cmd_rev_parse(int argc,\n      \t\t\t\tcontinue;\n      \t\t\t}\n     +\t\t\tif (!strcmp(arg, \"--show-object-storage-format\")) {\n    -+\t\t\t\tputs(the_repository->object_storage_format);\n    ++\t\t\t\tconst char *format = object_storage_format_to_name(the_repository->object_storage_format);\n    ++\t\t\t\tif (the_repository->object_storage_payload)\n    ++\t\t\t\t\tprintf(\"%s://%s\\n\", format, the_repository->object_storage_payload);\n    ++\t\t\t\telse\n    ++\t\t\t\t\tputs(format);\n     +\t\t\t\tcontinue;\n     +\t\t\t}\n      \t\t\tif (!strcmp(arg, \"--end-of-options\")) {\n      \t\t\t\tseen_end_of_options = 1;\n      \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\n     \n    + ## odb.c ##\n    +@@ odb.c: enum object_storage_format object_storage_format_by_name(const char *name)\n    + \treturn OBJECT_STORAGE_FORMAT_UNKNOWN;\n    + }\n    + \n    ++const char *object_storage_format_to_name(enum object_storage_format format)\n    ++{\n    ++\tif (format < 0 || format >= ARRAY_SIZE(object_storage_name_by_format))\n    ++\t\tformat = OBJECT_STORAGE_FORMAT_UNKNOWN;\n    ++\treturn object_storage_name_by_format[format];\n    ++}\n    ++\n    + enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload)\n    + {\n    + \tenum object_storage_format format;\n    +\n    + ## odb.h ##\n    +@@ odb.h: char *compute_alternate_path(const char *path, struct strbuf *err);\n    + enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload);\n    + \n    + enum object_storage_format object_storage_format_by_name(const char *name);\n    ++const char *object_storage_format_to_name(enum object_storage_format format);\n    + \n    + /*\n    +  * The object database encapsulates access to objects in a repository. It\n    +\n      ## t/t0001-init.sh ##\n     @@ t/t0001-init.sh: test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files bac\n      \tgit -C objstorage config set core.repositoryformatversion 1 &&\n5:  096441cb3f ! 5:  6f1ac304eb builtin/init: introduce handling of object storage format\n    @@ builtin/clone.c: int cmd_clone(int argc,\n      \n      \tif (real_git_dir) {\n      \t\tfree((char *)git_dir);\n    +@@ builtin/clone.c: int cmd_clone(int argc,\n    + \t * This is sufficient for Git commands to discover the Git directory.\n    + \t */\n    + \tinitialize_repository_version(the_repository, GIT_HASH_UNKNOWN,\n    +-\t\t\t\t      the_repository->ref_storage_format, 1);\n    ++\t\t\t\t      the_repository->ref_storage_format,\n    ++\t\t\t\t      the_repository->object_storage_format, 1);\n    + \n    + \trefs_create_refdir_stubs(the_repository, git_dir, NULL);\n    + \n    +@@ builtin/clone.c: int cmd_clone(int argc,\n    + \t * ours to the same thing.\n    + \t */\n    + \thash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n    +-\tinitialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);\n    ++\tinitialize_repository_version(the_repository, hash_algo,\n    ++\t\t\t\t      the_repository->ref_storage_format,\n    ++\t\t\t\t      the_repository->object_storage_format, 1);\n    + \trepo_set_hash_algo(the_repository, hash_algo);\n    + \tcreate_reference_database(the_repository, NULL, 1);\n    + \tstartup_info->have_repository = 1;\n     \n      ## builtin/init-db.c ##\n     @@ builtin/init-db.c: static int shared_callback(const struct option *opt, const char *arg, int unset)\n    @@ builtin/init-db.c: int cmd_init_db(int argc,\n      \tcreate_object_database(the_repository, NULL);\n      \n     \n    + ## refs.c ##\n    +@@ refs.c: int repo_migrate_ref_storage_format(struct repository *repo,\n    + \t * repository format so that clients will use the new ref store.\n    + \t * We also need to swap out the repository's main ref store.\n    + \t */\n    +-\tinitialize_repository_version(repo, hash_algo_by_ptr(repo->hash_algo), format, 1);\n    ++\tinitialize_repository_version(repo, hash_algo_by_ptr(repo->hash_algo), format,\n    ++\t\t\t\t      repo->object_storage_format, 1);\n    + \n    + \t/*\n    + \t * Unset the old ref store and release it. `get_main_ref_store()` will\n    +\n      ## setup.c ##\n    +@@ setup.c: static int needs_work_tree_config(const char *git_dir, const char *work_tree)\n    + void initialize_repository_version(struct repository *repo,\n    + \t\t\t\t   int hash_algo,\n    + \t\t\t\t   enum ref_storage_format ref_storage_format,\n    ++\t\t\t\t   enum object_storage_format object_storage_format,\n    + \t\t\t\t   int reinit)\n    + {\n    + \tstruct strbuf repo_version = STRBUF_INIT;\n     @@ setup.c: void initialize_repository_version(struct repository *repo,\n      \t */\n      \tif (hash_algo != GIT_HASH_SHA1_LEGACY ||\n      \t    ref_storage_format != REF_STORAGE_FORMAT_FILES ||\n     -\t    repo->ref_storage_payload)\n     +\t    repo->ref_storage_payload ||\n    -+\t    strcmp(repo->object_storage_format, \"files\"))\n    ++\t    object_storage_format != OBJECT_STORAGE_FORMAT_FILES ||\n    ++\t    repo->object_storage_payload)\n      \t\ttarget_version = GIT_REPO_VERSION_READ;\n      \n      \tif (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)\n    @@ setup.c: void initialize_repository_version(struct repository *repo,\n      \t\trepo_config_set_gently(repo, \"extensions.refstorage\", NULL);\n      \t}\n      \n    -+\tif (strcmp(repo->object_storage_format, \"files\"))\n    ++\tif (repo->object_storage_payload) {\n    ++\t\tstruct strbuf uri = STRBUF_INIT;\n    ++\n    ++\t\tstrbuf_addf(&uri, \"%s://%s\",\n    ++\t\t\t    object_storage_format_to_name(object_storage_format),\n    ++\t\t\t    repo->object_storage_payload);\n    ++\t\trepo_config_set(repo, \"extensions.objectstorage\", uri.buf);\n    ++\n    ++\t\tstrbuf_release(&uri);\n    ++\t} else if (object_storage_format != OBJECT_STORAGE_FORMAT_FILES) {\n     +\t\trepo_config_set(repo, \"extensions.objectstorage\",\n    -+\t\t\t\trepo->object_storage_format);\n    -+\telse if (reinit)\n    ++\t\t\t\tobject_storage_format_to_name(object_storage_format));\n    ++\t} else if (reinit) {\n     +\t\trepo_config_set_gently(repo, \"extensions.objectstorage\", NULL);\n    ++\t}\n     +\n      \tif (reinit) {\n      \t\tstruct strbuf config = STRBUF_INIT;\n      \t\tstruct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;\n    +@@ setup.c: static int create_default_files(struct repository *repo,\n    + \t\tadjust_shared_perm(repo, repo_get_git_dir(repo));\n    + \t}\n    + \n    +-\tinitialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format, reinit);\n    ++\tinitialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format,\n    ++\t\t\t\t      fmt->object_storage_format, reinit);\n    + \n    + \t/* Check filemode trustability */\n    + \trepo_git_path_replace(repo, &path, \"config\");\n     @@ setup.c: static void separate_git_dir(struct repository *repo,\n      struct default_format_config {\n      \tint hash;\n      \tenum ref_storage_format ref_storage_format;\n    -+\tchar *object_storage_format;\n    ++\tenum object_storage_format object_storage_format;\n      };\n      \n      static int read_default_format_config(const char *key, const char *value,\n    @@ setup.c: static int read_default_format_config(const char *key, const char *valu\n     +\t\tret = git_config_string(&str, key, value);\n     +\t\tif (ret)\n     +\t\t\tgoto out;\n    -+\t\tif (odb_source_type_by_uri(str, NULL) == ODB_SOURCE_UNKNOWN) {\n    ++\t\tcfg->object_storage_format = object_storage_format_by_name(str);\n    ++\t\tif (cfg->object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\t\twarning(_(\"unknown object storage format '%s'\"), str);\n    -+\t\t\tgoto out;\n    -+\t\t}\n    -+\t\tfree(cfg->object_storage_format);\n    -+\t\tcfg->object_storage_format = str;\n    -+\t\tstr = NULL;\n     +\t\tgoto out;\n     +\t}\n     +\n    @@ setup.c: static int read_default_format_config(const char *key, const char *valu\n      \tstruct default_format_config cfg = {\n      \t\t.hash = GIT_HASH_UNKNOWN,\n     @@ setup.c: static void repository_format_configure(struct repository_format *repo_fmt,\n    + \t\t.ignore_repo = 1,\n    + \t\t.ignore_worktree = 1,\n      \t};\n    ++\tenum object_storage_format object_storage_format;\n      \tenum ref_storage_format ref_storage_format;\n    ++\tchar *object_storage_payload = NULL;\n      \tchar *ref_storage_payload = NULL;\n    -+\tchar *object_storage = NULL;\n      \tconst char *env;\n      \n    - \tconfig_with_options(read_default_format_config, &cfg, NULL, NULL, &opts);\n     @@ setup.c: static void repository_format_configure(struct repository_format *repo_fmt,\n      \t\tref_storage_format = REF_STORAGE_FORMAT_DEFAULT;\n      \t}\n    @@ setup.c: static void repository_format_configure(struct repository_format *repo_\n     +\t *   6. The \"files\" format.\n     +\t */\n     +\tif (object_storage_uri) {\n    -+\t\tif (odb_source_type_by_uri(object_storage_uri, NULL) == ODB_SOURCE_UNKNOWN)\n    -+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_uri);\n    -+\t\tobject_storage = xstrdup(object_storage_uri);\n    ++\t\tobject_storage_format = object_storage_format_by_uri(object_storage_uri,\n    ++\t\t\t\t\t\t\t\t     &object_storage_payload);\n    ++\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n    ++\t\t\tdie(_(\"unknown object storage format specified via command line: '%s'\"),\n    ++\t\t\t    object_storage_uri);\n     +\t} else if ((env = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT))) {\n    -+\t\tif (odb_source_type_by_uri(env, NULL) == ODB_SOURCE_UNKNOWN)\n    ++\t\tobject_storage_format = object_storage_format_by_uri(env, &object_storage_payload);\n    ++\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n     +\t\t\t    GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT, env);\n    -+\t\tobject_storage = xstrdup(env);\n     +\t} else if (repo_fmt->version >= 0) {\n    -+\t\tobject_storage = xstrdup_or_null(repo_fmt->object_storage);\n    ++\t\tobject_storage_format = repo_fmt->object_storage_format;\n    ++\t\tobject_storage_payload = xstrdup_or_null(repo_fmt->object_storage_payload);\n     +\t} else if ((env = getenv(\"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\"))) {\n    -+\t\tif (odb_source_type_by_uri(env, NULL) == ODB_SOURCE_UNKNOWN)\n    ++\t\tobject_storage_format = object_storage_format_by_name(env);\n    ++\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n     +\t\t\t    \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\", env);\n    -+\t\tobject_storage = xstrdup(env);\n    ++\t} else if (cfg.object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN) {\n    ++\t\tobject_storage_format = cfg.object_storage_format;\n     +\t} else {\n    -+\t\tobject_storage = xstrdup_or_null(cfg.object_storage_format);\n    -+\t}\n    -+\n    -+\t/*\n    -+\t * The \"files\" format without a payload is the default and thus doesn't\n    -+\t * need to be recorded as an extension.\n    -+\t */\n    -+\tif (object_storage) {\n    -+\t\tchar *payload = NULL;\n    -+\t\tif (odb_source_type_by_uri(object_storage, &payload) == ODB_SOURCE_FILES && !payload)\n    -+\t\t\tFREE_AND_NULL(object_storage);\n    -+\t\tfree(payload);\n    ++\t\tobject_storage_format = OBJECT_STORAGE_FORMAT_FILES;\n     +\t}\n     +\n      \t/*\n    @@ setup.c: static void repository_format_configure(struct repository_format *repo_\n      \t\t    strcmp(ref_storage_payload ? ref_storage_payload : \"\",\n      \t\t\t   repo_fmt->ref_storage_payload ? repo_fmt->ref_storage_payload : \"\"))\n      \t\t\tdie(_(\"attempt to reinitialize repository with different reference storage payload\"));\n    -+\t\tif (strcmp(object_storage ? object_storage : \"\",\n    -+\t\t\t   repo_fmt->object_storage ? repo_fmt->object_storage : \"\"))\n    ++\t\tif (object_storage_format != repo_fmt->object_storage_format)\n     +\t\t\tdie(_(\"attempt to reinitialize repository with different object storage format\"));\n    ++\t\tif ((object_storage_payload || repo_fmt->object_storage_payload) &&\n    ++\t\t    strcmp(object_storage_payload ? object_storage_payload : \"\",\n    ++\t\t\t   repo_fmt->object_storage_payload ? repo_fmt->object_storage_payload : \"\"))\n    ++\t\t\tdie(_(\"attempt to reinitialize repository with different object storage payload\"));\n      \t}\n      \n      \tfree(repo_fmt->ref_storage_payload);\n      \trepo_fmt->ref_storage_format = ref_storage_format;\n      \trepo_fmt->ref_storage_payload = ref_storage_payload;\n     +\n    -+\tfree(repo_fmt->object_storage);\n    -+\trepo_fmt->object_storage = object_storage;\n    -+\tfree(cfg.object_storage_format);\n    ++\tfree(repo_fmt->object_storage_payload);\n    ++\trepo_fmt->object_storage_format = object_storage_format;\n    ++\trepo_fmt->object_storage_payload = object_storage_payload;\n      }\n      \n      void create_repository(struct repository *repo,\n    @@ setup.h: void create_repository(struct repository *repo,\n      \t\t       int init_shared_repository,\n      \t\t       int *reinit_ok);\n      \n    + void initialize_repository_version(struct repository *repo,\n    + \t\t\t\t   int hash_algo,\n    + \t\t\t\t   enum ref_storage_format ref_storage_format,\n    ++\t\t\t\t   enum object_storage_format object_storage_format,\n    + \t\t\t\t   int reinit);\n    + \n    + /*\n     \n      ## t/t0001-init.sh ##\n     @@ t/t0001-init.sh: test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides ext\n    @@ t/t0001-init.sh: test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FOR\n     +test_expect_success 'init with --object-storage-format=garbage' '\n     +\ttest_when_finished \"rm -rf objformat\" &&\n     +\tcat >expect <<-EOF &&\n    -+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n    ++\tfatal: unknown object storage format specified via command line: ${SQ}garbage${SQ}\n     +\tEOF\n     +\ttest_must_fail git init --object-storage-format=garbage objformat 2>err &&\n     +\ttest_cmp expect err\n    @@ t/t0001-init.sh: test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FOR\n     +\ttest_cmp expect err\n     +'\n     +\n    -+test_expect_success 'init with GIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://objs' '\n    -+\ttest_when_finished \"rm -rf objformat\" &&\n    -+\tGIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://objs git init objformat &&\n    -+\techo files://objs >expect &&\n    -+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n    -+\ttest_cmp expect actual\n    -+'\n    -+\n     +test_expect_success 'init with GIT_OBJECT_STORAGE_FORMAT=garbage' '\n     +\ttest_when_finished \"rm -rf objformat\" &&\n     +\tcat >expect <<-EOF &&\n    @@ t/t0001-init.sh: test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FOR\n     +\ttest_when_finished \"rm -rf objformat\" &&\n     +\tgit init --object-storage-format=files objformat &&\n     +\tcat >expect <<-EOF &&\n    -+\tfatal: attempt to reinitialize repository with different object storage format\n    ++\tfatal: attempt to reinitialize repository with different object storage payload\n     +\tEOF\n     +\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://objs git init objformat 2>err &&\n     +\ttest_cmp expect err\n    @@ t/t0001-init.sh: test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FOR\n     +\ttest_cmp expect actual\n     +'\n     +\n    ++test_expect_success DEFAULT_REPO_FORMAT 're-init with default object storage format drops extension' '\n    ++\ttest_when_finished \"rm -rf objformat\" &&\n    ++\n    ++\tgit init objformat &&\n    ++\tgit -C objformat config set core.repositoryformatversion 1 &&\n    ++\tgit -C objformat config set extensions.objectstorage files &&\n    ++\n    ++\tgit init --object-storage-format=files objformat &&\n    ++\techo 0 >expect &&\n    ++\tgit -C objformat config get core.repositoryformatversion >actual &&\n    ++\ttest_cmp expect actual &&\n    ++\ttest_must_fail git -C objformat config get extensions.objectstorage\n    ++'\n    ++\n     +test_expect_success 'init warns about invalid init.defaultObjectStorageFormat' '\n     +\ttest_when_finished \"rm -rf objformat\" &&\n     +\ttest_config_global init.defaultObjectStorageFormat garbage &&\n    @@ t/t0001-init.sh: test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FOR\n     +\n     +test_expect_success 'init with init.defaultObjectStorageFormat' '\n     +\ttest_when_finished \"rm -rf objformat\" &&\n    -+\ttest_config_global init.defaultObjectStorageFormat files://objs &&\n    ++\ttest_config_global init.defaultObjectStorageFormat files &&\n     +\tgit init objformat &&\n    -+\techo files://objs >expect &&\n    ++\techo files >expect &&\n     +\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n    -+\ttest_cmp expect actual &&\n    -+\ttest_commit -C objformat A &&\n    -+\ttest_path_is_dir objformat/.git/objs/pack\n    ++\ttest_cmp expect actual\n     +'\n     +\n      test_expect_success MINGW 'core.hidedotfiles = false' '\n6:  77586494fa ! 6:  35b38d75e8 builtin/clone: introduce \"--object-storage-format=\"\n    @@ Documentation/git-clone.adoc: include::ref-storage-format.adoc[]\n      \tThe number of submodules fetched at the same time.\n     \n      ## builtin/clone.c ##\n    -@@\n    - #include \"refspec.h\"\n    - #include \"object-file.h\"\n    - #include \"odb.h\"\n    -+#include \"odb/source.h\"\n    - #include \"tree.h\"\n    - #include \"tree-walk.h\"\n    - #include \"unpack-trees.h\"\n     @@ builtin/clone.c: static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,\n      \tdir_iterator_free(iter);\n      }\n    @@ builtin/clone.c: static void copy_or_link_directory(struct strbuf *src, struct s\n     +{\n     +\tstruct repository_format format = REPOSITORY_FORMAT_INIT;\n     +\tstruct strbuf config = STRBUF_INIT;\n    -+\tbool uses_default_format = true;\n    -+\tchar *payload = NULL;\n    ++\tbool is_default;\n     +\n     +\tget_common_dir(&config, repo_path);\n     +\tstrbuf_addstr(&config, \"/config\");\n     +\tread_repository_format(&format, config.buf);\n     +\n    -+\tif (format.version >= 1 &&\n    -+\t    format.object_storage &&\n    -+\t    (odb_source_type_by_uri(format.object_storage, &payload) != ODB_SOURCE_FILES || payload))\n    -+\t\tuses_default_format = false;\n    ++\tis_default = format.object_storage_format == OBJECT_STORAGE_FORMAT_FILES &&\n    ++\t\t!format.object_storage_payload;\n     +\n     +\tclear_repository_format(&format);\n     +\tstrbuf_release(&config);\n    -+\tfree(payload);\n    -+\treturn uses_default_format;\n    ++\treturn is_default;\n     +}\n     +\n      static void clone_local(const char *src_repo, const char *dest_repo)\n    @@ builtin/clone.c: int cmd_clone(int argc,\n      \t}\n      \n     +\tif (object_storage_format_uri &&\n    -+\t    odb_source_type_by_uri(object_storage_format_uri, NULL) == ODB_SOURCE_UNKNOWN)\n    ++\t    object_storage_format_by_uri(object_storage_format_uri, NULL) == OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n     +\n      \tif (option_mirror) {\n7:  9071a404ef ! 7:  3b5c33b7ad builtin/submodule: propagate \"--object-storage-format=\"\n    @@ builtin/clone.c: static int git_sparse_checkout_init(const char *repo)\n      \t\t    int filter_submodules,\n     -\t\t    enum ref_storage_format ref_storage_format)\n     +\t\t    enum ref_storage_format ref_storage_format,\n    -+\t\t    const char *object_storage_format_uri)\n    ++\t\t    enum object_storage_format object_storage_format)\n      {\n      \tstruct object_id oid;\n      \tchar *head;\n    @@ builtin/clone.c: static int checkout(int submodule_progress,\n      \t\t\tstrvec_pushf(&cmd.args, \"--ref-storage-format=%s\",\n      \t\t\t\t     ref_storage_format_to_name(ref_storage_format));\n      \n    -+\t\tif (object_storage_format_uri)\n    ++\t\tif (object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\t\tstrvec_pushf(&cmd.args, \"--object-storage-format=%s\",\n    -+\t\t\t\t     object_storage_format_uri);\n    ++\t\t\t\t     object_storage_format_to_name(object_storage_format));\n     +\n      \t\tif (filter_submodules && filter_options->choice)\n      \t\t\tstrvec_pushf(&cmd.args, \"--filter=%s\",\n      \t\t\t\t     expand_list_objects_filter_spec(filter_options));\n    +@@ builtin/clone.c: int cmd_clone(int argc,\n    + \tint submodule_progress;\n    + \tint filter_submodules = 0;\n    + \tint hash_algo;\n    ++\tenum object_storage_format object_storage_format = OBJECT_STORAGE_FORMAT_UNKNOWN;\n    + \tenum ref_storage_format ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;\n    + \tconst int do_not_override_repo_unix_permissions = -1;\n    + \tint option_reject_shallow = -1; /* unspecified */\n    +@@ builtin/clone.c: int cmd_clone(int argc,\n    + \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format_uri);\n    + \t}\n    + \n    +-\tif (object_storage_format_uri &&\n    +-\t    object_storage_format_by_uri(object_storage_format_uri, NULL) == OBJECT_STORAGE_FORMAT_UNKNOWN)\n    +-\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n    ++\tif (object_storage_format_uri) {\n    ++\t\tobject_storage_format = object_storage_format_by_uri(object_storage_format_uri, NULL);\n    ++\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n    ++\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n    ++\t}\n    + \n    + \tif (option_mirror) {\n    + \t\toption_bare = 1;\n     @@ builtin/clone.c: int cmd_clone(int argc,\n      \terr = checkout(submodule_progress,\n      \t\t       &filter_options,\n      \t\t       filter_submodules,\n     -\t\t       ref_storage_format);\n     +\t\t       ref_storage_format,\n    -+\t\t       object_storage_format_uri);\n    ++\t\t       object_storage_format);\n      \n      \tlist_objects_filter_release(&filter_options);\n      \n    @@ builtin/submodule--helper.c: struct module_clone_data {\n      \tint depth;\n      \tstruct list_objects_filter_options *filter_options;\n      \tenum ref_storage_format ref_storage_format;\n    -+\tconst char *object_storage_format;\n    ++\tenum object_storage_format object_storage_format;\n      \tunsigned int quiet: 1;\n      \tunsigned int progress: 1;\n      \tunsigned int dissociate: 1;\n    +@@ builtin/submodule--helper.c: struct module_clone_data {\n    + #define MODULE_CLONE_DATA_INIT { \\\n    + \t.single_branch = -1, \\\n    + \t.ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \\\n    ++\t.object_storage_format = OBJECT_STORAGE_FORMAT_UNKNOWN, \\\n    + }\n    + \n    + struct submodule_alternate_setup {\n     @@ builtin/submodule--helper.c: static int clone_submodule(const struct module_clone_data *clone_data,\n      \t\tif (clone_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n      \t\t\tstrvec_pushf(&cp.args, \"--ref-storage-format=%s\",\n      \t\t\t\t     ref_storage_format_to_name(clone_data->ref_storage_format));\n    -+\t\tif (clone_data->object_storage_format)\n    ++\t\tif (clone_data->object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\t\tstrvec_pushf(&cp.args, \"--object-storage-format=%s\",\n    -+\t\t\t\t     clone_data->object_storage_format);\n    ++\t\t\t\t     object_storage_format_to_name(clone_data->object_storage_format));\n      \t\tif (clone_data->dissociate)\n      \t\t\tstrvec_push(&cp.args, \"--dissociate\");\n      \t\tif (sm_gitdir && *sm_gitdir)\n    +@@ builtin/submodule--helper.c: static int module_clone(int argc, const char **argv, const char *prefix,\n    + \tstruct string_list reference = STRING_LIST_INIT_NODUP;\n    + \tstruct list_objects_filter_options filter_options =\n    + \t\tLIST_OBJECTS_FILTER_INIT;\n    ++\tconst char *object_storage_format = NULL;\n    + \tconst char *ref_storage_format = NULL;\n    + \n    + \tstruct option module_clone_options[] = {\n     @@ builtin/submodule--helper.c: static int module_clone(int argc, const char **argv, const char *prefix,\n      \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n      \t\t\t   N_(\"specify the reference storage format to use\")),\n      \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n    -+\t\tOPT_STRING(0, \"object-storage-format\", &clone_data.object_storage_format, N_(\"format\"),\n    ++\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n     +\t\t\t   N_(\"specify the object storage format to use\")),\n      \t\tOPT_BOOL(0, \"dissociate\", &dissociate,\n      \t\t\t   N_(\"use --reference only while cloning\")),\n    @@ builtin/submodule--helper.c: static int module_clone(int argc, const char **argv\n      \t\tif (clone_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n      \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n      \t}\n    -+\tif (clone_data.object_storage_format &&\n    -+\t    odb_source_type_by_uri(clone_data.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n    -+\t\tdie(_(\"unknown object storage format '%s'\"), clone_data.object_storage_format);\n    ++\n    ++\tif (object_storage_format) {\n    ++\t\tclone_data.object_storage_format = object_storage_format_by_name(object_storage_format);\n    ++\t\tif (clone_data.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n    ++\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n    ++\t}\n    ++\n      \tclone_data.dissociate = !!dissociate;\n      \tclone_data.quiet = !!quiet;\n      \tclone_data.progress = !!progress;\n     @@ builtin/submodule--helper.c: struct update_data {\n    + \tstruct submodule_update_strategy update_strategy;\n      \tstruct list_objects_filter_options *filter_options;\n      \tstruct module_list list;\n    ++\tenum object_storage_format object_storage_format;\n      \tenum ref_storage_format ref_storage_format;\n    -+\tconst char *object_storage_format;\n      \tint depth;\n      \tint max_jobs;\n    - \tint single_branch;\n     @@ builtin/submodule--helper.c: static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n      \tif (suc->update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n      \t\tstrvec_pushf(&child->args, \"--ref-storage-format=%s\",\n      \t\t\t     ref_storage_format_to_name(suc->update_data->ref_storage_format));\n    -+\tif (suc->update_data->object_storage_format)\n    ++\tif (suc->update_data->object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n     +\t\tstrvec_pushf(&child->args, \"--object-storage-format=%s\",\n    -+\t\t\t     suc->update_data->object_storage_format);\n    ++\t\t\t     object_storage_format_to_name(suc->update_data->object_storage_format));\n      \tstrvec_pushl(&child->args, \"--path\", sub->path, NULL);\n      \tstrvec_pushl(&child->args, \"--name\", sub->name, NULL);\n      \tstrvec_pushl(&child->args, \"--url\", url, NULL);\n    @@ builtin/submodule--helper.c: static void update_data_to_args(const struct update\n      \t\t\t     ref_storage_format_to_name(update_data->ref_storage_format));\n     +\tif (update_data->object_storage_format)\n     +\t\tstrvec_pushf(args, \"--object-storage-format=%s\",\n    -+\t\t\t     update_data->object_storage_format);\n    ++\t\t\t     object_storage_format_to_name(update_data->object_storage_format));\n      \tif (update_data->filter_options && update_data->filter_options->choice)\n      \t\tstrvec_pushf(args, \"--filter=%s\",\n      \t\t\t\texpand_list_objects_filter_spec(\n    +@@ builtin/submodule--helper.c: static int module_update(int argc, const char **argv, const char *prefix,\n    + \tstruct update_data opt = UPDATE_DATA_INIT;\n    + \tstruct list_objects_filter_options filter_options =\n    + \t\tLIST_OBJECTS_FILTER_INIT;\n    ++\tconst char *object_storage_format = NULL;\n    + \tconst char *ref_storage_format = NULL;\n    + \tint ret;\n    + \tstruct option module_update_options[] = {\n     @@ builtin/submodule--helper.c: static int module_update(int argc, const char **argv, const char *prefix,\n      \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n      \t\t\t   N_(\"specify the reference storage format to use\")),\n      \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n    -+\t\tOPT_STRING(0, \"object-storage-format\", &opt.object_storage_format, N_(\"format\"),\n    ++\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n     +\t\t\t   N_(\"specify the object storage format to use\")),\n      \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n      \t\t\t   N_(\"use --reference only while cloning\")),\n    @@ builtin/submodule--helper.c: static int module_update(int argc, const char **arg\n      \t\tif (opt.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n      \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n      \t}\n    -+\tif (opt.object_storage_format &&\n    -+\t    odb_source_type_by_uri(opt.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n    -+\t\tdie(_(\"unknown object storage format '%s'\"), opt.object_storage_format);\n    ++\tif (object_storage_format) {\n    ++\t\topt.object_storage_format = object_storage_format_by_name(object_storage_format);\n    ++\t\tif (opt.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n    ++\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n    ++\t}\n      \n      \topt.filter_options = &filter_options;\n      \topt.prefix = prefix;\n     @@ builtin/submodule--helper.c: struct add_data {\n    + \tconst char *sm_name;\n      \tconst char *repo;\n      \tconst char *realrepo;\n    ++\tenum object_storage_format object_storage_format;\n      \tenum ref_storage_format ref_storage_format;\n    -+\tconst char *object_storage_format;\n      \tint depth;\n      \tunsigned int force: 1;\n    - \tunsigned int quiet: 1;\n     @@ builtin/submodule--helper.c: static int add_submodule(const struct add_data *add_data)\n      \t\t\tstring_list_append(&reference, p)->util = p;\n      \t\t}\n    @@ builtin/submodule--helper.c: static int add_submodule(const struct add_data *add\n      \t\tclone_data.dissociate = add_data->dissociate;\n      \t\tif (add_data->depth >= 0)\n      \t\t\tclone_data.depth = add_data->depth;\n    +@@ builtin/submodule--helper.c: static int module_add(int argc, const char **argv, const char *prefix,\n    + {\n    + \tint force = 0, quiet = 0, progress = 0, dissociate = 0;\n    + \tstruct add_data add_data = ADD_DATA_INIT;\n    ++\tconst char *object_storage_format = NULL;\n    + \tconst char *ref_storage_format = NULL;\n    + \tchar *to_free = NULL;\n    + \tconst struct submodule *existing;\n     @@ builtin/submodule--helper.c: static int module_add(int argc, const char **argv, const char *prefix,\n      \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n      \t\t\t   N_(\"specify the reference storage format to use\")),\n      \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n    -+\t\tOPT_STRING(0, \"object-storage-format\", &add_data.object_storage_format, N_(\"format\"),\n    ++\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n     +\t\t\t   N_(\"specify the object storage format to use\")),\n      \t\tOPT_BOOL(0, \"dissociate\", &dissociate, N_(\"borrow the objects from reference repositories\")),\n      \t\tOPT_STRING(0, \"name\", &add_data.sm_name, N_(\"name\"),\n    @@ builtin/submodule--helper.c: static int module_add(int argc, const char **argv,\n      \t\tif (add_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n      \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n      \t}\n    -+\tif (add_data.object_storage_format &&\n    -+\t    odb_source_type_by_uri(add_data.object_storage_format, NULL) == ODB_SOURCE_UNKNOWN)\n    -+\t\tdie(_(\"unknown object storage format '%s'\"), add_data.object_storage_format);\n    ++\tif (object_storage_format) {\n    ++\t\tadd_data.object_storage_format = object_storage_format_by_name(object_storage_format);\n    ++\t\tif (add_data.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n    ++\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n    ++\t}\n      \n      \tadd_data.repo = argv[0];\n      \tif (argc == 1)\n    @@ t/t7427-submodule-object-storage-format.sh (new)\n     +\t)\n     +'\n     +\n    -+test_expect_success 'add submodules with different object storage format' '\n    ++test_expect_success 'add submodules with explicit files storage format' '\n     +\ttest_when_finished \"rm -rf submodule upstream\" &&\n     +\n     +\tgit init submodule &&\n     +\ttest_commit -C submodule submodule-initial &&\n     +\tgit init upstream &&\n     +\ttest_object_storage_format upstream files &&\n    -+\tgit -C upstream submodule add --object-storage-format=files://objs \"file://$(pwd)/submodule\" &&\n    -+\ttest_object_storage_format upstream/submodule files://objs &&\n    -+\ttest_path_is_dir upstream/.git/modules/submodule/objs/pack\n    ++\tgit -C upstream submodule add --object-storage-format=files \"file://$(pwd)/submodule\" &&\n    ++\ttest_object_storage_format upstream/submodule files\n     +'\n     +\n     +test_expect_success 'add submodules with garbage object storage format' '\n    @@ t/t7427-submodule-object-storage-format.sh (new)\n     +\ttest_cmp expect err\n     +'\n     +\n    ++test_expect_success 'add submodules with object storage payload is rejected' '\n    ++\ttest_when_finished \"rm -rf submodule upstream\" &&\n    ++\n    ++\tgit init submodule &&\n    ++\ttest_commit -C submodule submodule-initial &&\n    ++\tgit init upstream &&\n    ++\tcat >expect <<-EOF &&\n    ++\tfatal: unknown object storage format ${SQ}files://objs${SQ}\n    ++\tEOF\n    ++\ttest_must_fail git -C upstream submodule add --object-storage-format=files://objs \"file://$(pwd)/submodule\" 2>err &&\n    ++\ttest_cmp expect err\n    ++'\n    ++\n     +test_expect_success 'recursive clone propagates object storage format' '\n     +\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n     +\n    @@ t/t7427-submodule-object-storage-format.sh (new)\n     +\tgit clone --object-storage-format=files://objs --recurse-submodules \\\n     +\t\tupstream downstream &&\n     +\ttest_object_storage_format downstream files://objs &&\n    -+\ttest_object_storage_format downstream/submodule files://objs &&\n    ++\ttest_object_storage_format downstream/submodule files &&\n     +\ttest_path_is_dir downstream/.git/objs/pack &&\n    -+\ttest_path_is_dir downstream/.git/modules/submodule/objs/pack\n    ++\ttest_path_is_dir downstream/.git/modules/submodule/objects/pack\n     +'\n     +\n    -+test_expect_success 'clone submodules with different object storage format' '\n    ++test_expect_success 'clone submodules with explicit object storage format' '\n     +\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n     +\n     +\tgit init submodule &&\n    @@ t/t7427-submodule-object-storage-format.sh (new)\n     +\tgit -C upstream commit -m \"upstream submodule\" &&\n     +\n     +\tgit clone --no-recurse-submodules \"file://$(pwd)/upstream\" downstream &&\n    -+\tgit -C downstream submodule update --init --object-storage-format=files://objs &&\n     +\ttest_object_storage_format downstream files &&\n    -+\ttest_object_storage_format downstream/submodule files://objs\n    ++\tgit -C downstream submodule update --init --object-storage-format=files &&\n    ++\ttest_object_storage_format downstream/submodule files &&\n    ++\ttest_path_is_dir downstream/.git/modules/submodule/objects/pack\n     +'\n     +\n     +test_done\n\n---\nbase-commit: 0d31382da9336683214372ba328fe9ecbc8bcb9a\nchange-id: 20261006-b4-pks-odb-extension-36de693bb943\n\n\n"},{"id":"555985","messageId":"20261023-b4-pks-odb-extension-v3-1-b1bb30a006db@pks.im","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","subject":"[PATCH v3 1/7] loose: drop unused `repo_write_loose_object_map()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T11:49:10Z","receivedAt":"2026-10-23T11:49:10Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The function `repo_write_loose_object_map()` was introduced in\n23b2c7e95b (loose: add a mapping between SHA-1 and SHA-256 for loose\nobjects, 2023-10-01), but it never had any callers as loose object maps\nare instead written incrementally via `repo_add_loose_object_map()`\nwhenever a new loose object is created.\n\nBesides being dead code, the function also hardcodes the location of the\n\"loose-object-idx\" file as \"$GIT_COMMON_DIR/objects\", whereas both the\nreader and `repo_add_loose_object_map()` derive the location from the\nloose source's path. The function would thus disagree with everyone else\nwhere the loose object map is supposed to be located when the object\ndirectory is using a non-default location.\n\nRemove the function.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n loose.c | 46 ----------------------------------------------\n loose.h |  1 -\n 2 files changed, 47 deletions(-)\n\ndiff --git a/loose.c b/loose.c\nindex d6a2bb5ba3..7e26a04ec0 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -123,52 +123,6 @@ int repo_read_loose_object_map(struct repository *repo)\n \treturn 0;\n }\n \n-int repo_write_loose_object_map(struct repository *repo)\n-{\n-\tstruct odb_source_files *files = odb_source_files_downcast(repo->objects->source);\n-\tkh_oid_map_t *map = files->dirs->loose->map->to_compat;\n-\tstruct lock_file lock;\n-\tint fd;\n-\tkhiter_t iter;\n-\tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n-\n-\tif (!should_use_loose_object_map(repo))\n-\t\treturn 0;\n-\n-\trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n-\tfd = repo_hold_lock_file_for_update_timeout(repo, &lock, path.buf,\n-\t\t\t\t\t\t    LOCK_DIE_ON_ERROR, -1);\n-\titer = kh_begin(map);\n-\tif (write_in_full(fd, loose_object_header, strlen(loose_object_header)) < 0)\n-\t\tgoto errout;\n-\n-\tfor (; iter != kh_end(map); iter++) {\n-\t\tif (kh_exist(map, iter)) {\n-\t\t\tif (oideq(&kh_key(map, iter), repo->hash_algo->empty_tree) ||\n-\t\t\t    oideq(&kh_key(map, iter), repo->hash_algo->empty_blob))\n-\t\t\t\tcontinue;\n-\t\t\tstrbuf_addf(&buf, \"%s %s\\n\", oid_to_hex(&kh_key(map, iter)), oid_to_hex(kh_value(map, iter)));\n-\t\t\tif (write_in_full(fd, buf.buf, buf.len) < 0)\n-\t\t\t\tgoto errout;\n-\t\t\tstrbuf_reset(&buf);\n-\t\t}\n-\t}\n-\tstrbuf_release(&buf);\n-\tif (commit_lock_file(&lock) < 0) {\n-\t\terror_errno(_(\"could not write loose object index %s\"), path.buf);\n-\t\tstrbuf_release(&path);\n-\t\treturn -1;\n-\t}\n-\tstrbuf_release(&path);\n-\treturn 0;\n-errout:\n-\trollback_lock_file(&lock);\n-\tstrbuf_release(&buf);\n-\terror_errno(_(\"failed to write loose object index %s\"), path.buf);\n-\tstrbuf_release(&path);\n-\treturn -1;\n-}\n-\n static int write_one_object(struct odb_source_loose *loose,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\ndiff --git a/loose.h b/loose.h\nindex ed663ac550..41c4b46818 100644\n--- a/loose.h\n+++ b/loose.h\n@@ -22,6 +22,5 @@ int repo_add_loose_object_map(struct odb_source_loose *loose,\n \t\t\t      const struct object_id *oid,\n \t\t\t      const struct object_id *compat_oid);\n int repo_read_loose_object_map(struct repository *repo);\n-int repo_write_loose_object_map(struct repository *repo);\n \n #endif\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555986","messageId":"20261023-b4-pks-odb-extension-v3-2-b1bb30a006db@pks.im","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","subject":"[PATCH v3 2/7] setup: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T11:49:11Z","receivedAt":"2026-10-23T11:49:11Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Introduce a new \"extensions.objectStorage\" extension that allows the\nuser to configure the primary object database source of a repository.\nThe value is a URI in the format \"<schema>[://<payload>]\", mirroring\nthe format used by \"extensions.refStorage\":\n\n  - The schema identifies the backend that shall be used. For now the\n    only supported schema is \"files\", which is the existing object\n    database backed by loose objects and packfiles.\n\n  - The payload can be passed to configure the backend, and its\n    interpretation is backend-specific. For the \"files\" backend, it\n    allows you to configure a different location for the \".git/objects\"\n    directory.\n\nEventually, this mechanism will be used to support alternative backends.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/config/extensions.adoc     | 23 +++++++++++++++++++\n Documentation/object-storage-format.adoc |  6 +++++\n odb.c                                    | 39 +++++++++++++++++++++++++++++++-\n odb.h                                    | 12 ++++++++++\n odb/source-files.c                       |  7 ++++++\n odb/source-files.h                       |  1 +\n odb/source.c                             | 14 +++++++++++-\n odb/source.h                             |  5 +++-\n repository.c                             | 10 ++++++++\n repository.h                             | 18 +++++++++++++++\n setup.c                                  | 19 ++++++++++++++++\n setup.h                                  |  3 +++\n t/t0001-init.sh                          | 30 ++++++++++++++++++++++++\n t/unit-tests/u-odb-inmemory.c            |  1 +\n 14 files changed, 185 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config/extensions.adoc b/Documentation/config/extensions.adoc\nindex be6678bb5b..4f3a66a454 100644\n--- a/Documentation/config/extensions.adoc\n+++ b/Documentation/config/extensions.adoc\n@@ -56,6 +56,29 @@ preciousObjects:::\n For historical reasons, this extension is respected regardless of the\n `core.repositoryFormatVersion` setting.\n \n+objectStorage:::\n+\tSpecify the object storage format and a corresponding payload. The\n+\tvalue can be either a format name or a URI:\n++\n+--\n+* A format name alone (e.g., `files`).\n+\n+* A URI format `<format>://<payload>` explicitly specifies both the\n+  format and payload (e.g., `files:///foo/bar`).\n+\n+Supported formats are:\n+\n+include::../object-storage-format.adoc[]\n+\n+--\n++\n+Note that this setting should only be set by linkgit:git-init[1] or\n+linkgit:git-clone[1]. Trying to change it after initialization will make\n+preexisting objects inaccessible.\n++\n+NOTE: This extension is still considered EXPERIMENTAL and may be subject to\n+change.\n+\n refStorage:::\n \tSpecify the ref storage format and a corresponding payload. The value\n \tcan be either a format name or a URI:\ndiff --git a/Documentation/object-storage-format.adoc b/Documentation/object-storage-format.adoc\nnew file mode 100644\nindex 0000000000..4c4aef6dda\n--- /dev/null\n+++ b/Documentation/object-storage-format.adoc\n@@ -0,0 +1,6 @@\n+`files[://<path>]`;; for loose objects and packfiles. This is the default.\n++\n+The optional payload can be passed to specify an alternative filesystem path\n+where the objects will be stored. Relative paths are resolved relative to the\n+`$GIT_COMMON_DIR`. Defaults to `$GIT_COMMON_DIR/objects` when no payload is\n+provided. The payload is ignored when `GIT_OBJECT_DIRECTORY` is set.\ndiff --git a/odb.c b/odb.c\nindex 98c5c862f5..0649622bc6 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -27,6 +27,42 @@\n #include \"trace2.h\"\n #include \"write-or-die.h\"\n \n+static const char * const object_storage_name_by_format[] = {\n+\t[OBJECT_STORAGE_FORMAT_UNKNOWN] = \"unknown\",\n+\t[OBJECT_STORAGE_FORMAT_FILES] = \"files\",\n+};\n+\n+enum object_storage_format object_storage_format_by_name(const char *name)\n+{\n+\tfor (size_t i = 0; i < ARRAY_SIZE(object_storage_name_by_format); i++)\n+\t\tif (!strcmp(object_storage_name_by_format[i], name))\n+\t\t\treturn i;\n+\treturn OBJECT_STORAGE_FORMAT_UNKNOWN;\n+}\n+\n+enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload)\n+{\n+\tenum object_storage_format format;\n+\tconst char *schema_end;\n+\tchar *name;\n+\n+\tschema_end = strstr(uri, \"://\");\n+\tif (!schema_end) {\n+\t\tname = xstrdup(uri);\n+\t\tif (payload)\n+\t\t\t*payload = NULL;\n+\t} else {\n+\t\tname = xstrndup(uri, schema_end - uri);\n+\t\tif (payload)\n+\t\t\t*payload = *(schema_end + 3) ? xstrdup(schema_end + 3) : NULL;\n+\t}\n+\n+\tformat = object_storage_format_by_name(name);\n+\n+\tfree(name);\n+\treturn format;\n+}\n+\n int odb_mkstemp(struct object_database *odb,\n \t\tstruct strbuf *temp_filename, const char *pattern)\n {\n@@ -757,7 +793,8 @@ struct object_database *odb_new(struct repository *repo,\n \to->repo = repo;\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n \n-\to->source = odb_source_new(o, flags);\n+\to->source = odb_source_new(o, repo->object_storage_format,\n+\t\t\t\t   repo->object_storage_payload, flags);\n \to->inmemory_objects = &odb_source_inmemory_new(o)->base;\n \n \treturn o;\ndiff --git a/odb.h b/odb.h\nindex 0ccc47ee73..cb0505334a 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -6,6 +6,7 @@\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"oidmap.h\"\n+#include \"repository.h\"\n #include \"string-list.h\"\n #include \"thread-utils.h\"\n \n@@ -26,6 +27,17 @@ struct strvec;\n  */\n char *compute_alternate_path(const char *path, struct strbuf *err);\n \n+/*\n+ * Parse the given URI in the format \"<schema>[://<payload>]\" and return the\n+ * object storage format identified by the schema. If `payload` is non-NULL it\n+ * will be set to a newly allocated copy of the payload, or NULL if the URI has\n+ * no or an empty payload. Returns `OBJECT_STORAGE_FORMAT_UNKNOWN` for unknown\n+ * schemas.\n+ */\n+enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload);\n+\n+enum object_storage_format object_storage_format_by_name(const char *name);\n+\n /*\n  * The object database encapsulates access to objects in a repository. It\n  * manages the object source as well as auxiliary data structures required to\ndiff --git a/odb/source-files.c b/odb/source-files.c\nindex 455f409db0..4a7cbbfd9b 100644\n--- a/odb/source-files.c\n+++ b/odb/source-files.c\n@@ -1235,6 +1235,7 @@ struct odb_files_dir *odb_source_files_find_dir(struct object_database *odb, con\n }\n \n struct odb_source_files *odb_source_files_new(struct object_database *odb,\n+\t\t\t\t\t      const char *payload,\n \t\t\t\t\t      enum odb_new_flags flags)\n {\n \tstruct odb_source_files *files;\n@@ -1245,6 +1246,12 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,\n \t\tobject_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));\n \t\talternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));\n \t}\n+\tif (!object_dir && payload) {\n+\t\tif (is_absolute_path(payload))\n+\t\t\tobject_dir = xstrdup(payload);\n+\t\telse\n+\t\t\tobject_dir = xstrfmt(\"%s/%s\", odb->repo->commondir, payload);\n+\t}\n \tif (!object_dir)\n \t\tobject_dir = xstrfmt(\"%s/objects\", odb->repo->commondir);\n \ndiff --git a/odb/source-files.h b/odb/source-files.h\nindex 837e890304..71e8db84ff 100644\n--- a/odb/source-files.h\n+++ b/odb/source-files.h\n@@ -70,6 +70,7 @@ struct odb_source_files {\n \n /* Allocate and initialize a new object source. */\n struct odb_source_files *odb_source_files_new(struct object_database *odb,\n+\t\t\t\t\t      const char *payload,\n \t\t\t\t\t      enum odb_new_flags flags);\n \n /*\ndiff --git a/odb/source.c b/odb/source.c\nindex b25ef14df8..a2a6d97ccd 100644\n--- a/odb/source.c\n+++ b/odb/source.c\n@@ -24,9 +24,21 @@ const char *odb_source_type_to_name(enum odb_source_type type)\n }\n \n struct odb_source *odb_source_new(struct object_database *odb,\n+\t\t\t\t  enum object_storage_format format,\n+\t\t\t\t  const char *payload,\n \t\t\t\t  enum odb_new_flags flags)\n {\n-\treturn &odb_source_files_new(odb, flags)->base;\n+\tstruct odb_source *source;\n+\n+\tswitch (format) {\n+\tcase OBJECT_STORAGE_FORMAT_FILES:\n+\t\tsource = &odb_source_files_new(odb, payload, flags)->base;\n+\t\tbreak;\n+\tdefault:\n+\t\tBUG(\"unknown object storage format\");\n+\t}\n+\n+\treturn source;\n }\n \n void odb_source_init(struct odb_source *source,\ndiff --git a/odb/source.h b/odb/source.h\nindex 1867347dfc..1ab3208888 100644\n--- a/odb/source.h\n+++ b/odb/source.h\n@@ -304,9 +304,12 @@ struct odb_source {\n \n /*\n  * Allocate and initialize a new source for the given object database. The path\n- * of the source is derived from repository paths.\n+ * of the source is derived from repository paths or from the object storage\n+ * format.\n  */\n struct odb_source *odb_source_new(struct object_database *odb,\n+\t\t\t\t  enum object_storage_format format,\n+\t\t\t\t  const char *payload,\n \t\t\t\t  enum odb_new_flags flags);\n \n /*\ndiff --git a/repository.c b/repository.c\nindex 970d181828..77ecf6b604 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -217,6 +217,15 @@ void repo_set_ref_storage_format(struct repository *repo,\n \trepo->ref_storage_payload = xstrdup_or_null(payload);\n }\n \n+void repo_set_object_storage_format(struct repository *repo,\n+\t\t\t\t    enum object_storage_format format,\n+\t\t\t\t    const char *payload)\n+{\n+\trepo->object_storage_format = format;\n+\tfree(repo->object_storage_payload);\n+\trepo->object_storage_payload = xstrdup_or_null(payload);\n+}\n+\n /*\n  * Attempt to resolve and set the provided 'gitdir' for repository 'repo'.\n  * Return 0 upon success and a non-zero value upon failure.\n@@ -382,6 +391,7 @@ void repo_clear(struct repository *repo)\n \tfree(repo->worktree);\n \tfree(repo->submodule_prefix);\n \tfree(repo->ref_storage_payload);\n+\tfree(repo->object_storage_payload);\n \n \todb_free(repo->objects);\n \ndiff --git a/repository.h b/repository.h\nindex 2a348012e8..8c4437762e 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -22,6 +22,11 @@ enum ref_storage_format {\n \tREF_STORAGE_FORMAT_REFTABLE,\n };\n \n+enum object_storage_format {\n+\tOBJECT_STORAGE_FORMAT_UNKNOWN,\n+\tOBJECT_STORAGE_FORMAT_FILES,\n+};\n+\n #ifdef WITH_BREAKING_CHANGES /* Git 3.0 */\n # define REF_STORAGE_FORMAT_DEFAULT REF_STORAGE_FORMAT_REFTABLE\n #else\n@@ -178,6 +183,16 @@ struct repository {\n \t */\n \tchar *ref_storage_payload;\n \n+\t/* Repository's object storage format, as serialized on disk. */\n+\tenum object_storage_format object_storage_format;\n+\n+\t/*\n+\t * Object storage information as needed for the backend. This contains\n+\t * only the payload from the object storage format URI without the\n+\t * schema.\n+\t */\n+\tchar *object_storage_payload;\n+\n \t/* A unique-id for tracing purposes. */\n \tint trace2_repo_id;\n \n@@ -255,6 +270,9 @@ void repo_set_compat_hash_algo(struct repository *repo, uint32_t compat_algo);\n void repo_set_ref_storage_format(struct repository *repo,\n \t\t\t\t enum ref_storage_format format,\n \t\t\t\t const char *payload);\n+void repo_set_object_storage_format(struct repository *repo,\n+\t\t\t\t    enum object_storage_format format,\n+\t\t\t\t    const char *payload);\n void initialize_repository(struct repository *repo);\n RESULT_MUST_BE_USED\n int repo_init(struct repository *r, const char *gitdir, const char *worktree);\ndiff --git a/setup.c b/setup.c\nindex 3ee19f3e3c..249bd67876 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -686,6 +686,20 @@ static enum extension_result handle_extension(const char *var,\n \t\t\treturn error(_(\"invalid value for '%s': '%s'\"),\n \t\t\t\t     \"extensions.refstorage\", value);\n \t\tdata->ref_storage_format = format;\n+\t\treturn EXTENSION_OK;\n+\t} else if (!strcmp(ext, \"objectstorage\")) {\n+\t\tenum object_storage_format format;\n+\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\n+\t\tFREE_AND_NULL(data->object_storage_payload);\n+\t\tformat = object_storage_format_by_uri(value, &data->object_storage_payload);\n+\t\tif (format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\treturn error(_(\"invalid value for '%s': '%s'\"),\n+\t\t\t\t     \"extensions.objectstorage\", value);\n+\t\tdata->object_storage_format = format;\n+\n \t\treturn EXTENSION_OK;\n \t} else if (!strcmp(ext, \"relativeworktrees\")) {\n \t\tdata->relative_worktrees = git_config_bool(var, value);\n@@ -694,6 +708,7 @@ static enum extension_result handle_extension(const char *var,\n \t\tdata->submodule_path_cfg = git_config_bool(var, value);\n \t\treturn EXTENSION_OK;\n \t}\n+\n \treturn EXTENSION_UNKNOWN;\n }\n \n@@ -864,6 +879,7 @@ void clear_repository_format(struct repository_format *format)\n \tfree(format->work_tree);\n \tfree(format->partial_clone);\n \tfree(format->ref_storage_payload);\n+\tfree(format->object_storage_payload);\n \tinit_repository_format(format);\n }\n \n@@ -1786,6 +1802,9 @@ int apply_repository_format(struct repository *repo,\n \trepo_set_ref_storage_format(repo,\n \t\t\t\t    format->ref_storage_format,\n \t\t\t\t    format->ref_storage_payload);\n+\trepo_set_object_storage_format(repo,\n+\t\t\t\t       format->object_storage_format,\n+\t\t\t\t       format->object_storage_payload);\n \trepo->repository_format_worktree_config =\n \t\tformat->worktree_config;\n \trepo->repository_format_submodule_path_cfg =\ndiff --git a/setup.h b/setup.h\nindex 7a3efe5e48..a4afa8910e 100644\n--- a/setup.h\n+++ b/setup.h\n@@ -190,6 +190,8 @@ struct repository_format {\n \tint compat_hash_algo;\n \tenum ref_storage_format ref_storage_format;\n \tchar *ref_storage_payload;\n+\tenum object_storage_format object_storage_format;\n+\tchar *object_storage_payload;\n \tint sparse_index;\n \tchar *work_tree;\n \tstruct string_list unknown_extensions;\n@@ -207,6 +209,7 @@ struct repository_format {\n \t.is_bare = -1, \\\n \t.hash_algo = GIT_HASH_DEFAULT, \\\n \t.ref_storage_format = REF_STORAGE_FORMAT_FILES, \\\n+\t.object_storage_format = OBJECT_STORAGE_FORMAT_FILES, \\\n \t.unknown_extensions = STRING_LIST_INIT_DUP, \\\n \t.v1_only_extensions = STRING_LIST_INIT_DUP, \\\n }\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex f1d227f271..c7c464d3a2 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -839,6 +839,36 @@ test_expect_success 'init with --ref-storage-format=garbage' '\n \ttest_cmp expect err\n '\n \n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage is not allowed with repo version 0' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set extensions.objectStorage files &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"repo version is 0, but v1-only extension found\" err\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files backend' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set core.repositoryformatversion 1 &&\n+\tgit -C objstorage config set extensions.objectStorage files &&\n+\ttest_commit -C objstorage A &&\n+\tgit -C objstorage rev-parse --verify HEAD\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set core.repositoryformatversion 1 &&\n+\tgit -C objstorage config set extensions.objectStorage garbage &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage${SQ}\" err &&\n+\n+\tgit config --file objstorage/.git/config extensions.objectStorage garbage://payload &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\ndiff --git a/t/unit-tests/u-odb-inmemory.c b/t/unit-tests/u-odb-inmemory.c\nindex a8da278c68..c4412949c1 100644\n--- a/t/unit-tests/u-odb-inmemory.c\n+++ b/t/unit-tests/u-odb-inmemory.c\n@@ -12,6 +12,7 @@\n \n static struct repository repo = {\n \t.hash_algo = &hash_algos[GIT_HASH_SHA1],\n+\t.object_storage_format = OBJECT_STORAGE_FORMAT_FILES,\n };\n static struct object_database *odb;\n \n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555987","messageId":"20261023-b4-pks-odb-extension-v3-3-b1bb30a006db@pks.im","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","subject":"[PATCH v3 3/7] setup: allow overriding object storage format via environment","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T11:49:12Z","receivedAt":"2026-10-23T11:49:12Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format configured via \"extensions.refStorage\" can be\noverridden with the GIT_REF_STORAGE_FORMAT environment variable.\nIntroduce the GIT_OBJECT_STORAGE_FORMAT environment variable that\noverrides \"extensions.objectStorage\" in the same way.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git.adoc |  5 +++++\n environment.h          |  1 +\n setup.c                | 16 ++++++++++++++++\n t/t0001-init.sh        | 26 ++++++++++++++++++++++++++\n 4 files changed, 48 insertions(+)\n\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 3abb4701c3..34812131bb 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -609,6 +609,11 @@ double-quotes and respecting backslash escapes. E.g., the value\n `GIT_REFERENCE_BACKEND`::\n \tDeprecated alias of `GIT_REF_STORAGE_FORMAT`.\n \n+`GIT_OBJECT_STORAGE_FORMAT`::\n+\tSpecify which object storage format to use along with its URI.\n+\tSee `extensions.objectStorage` option in linkgit:git-config[1] for more\n+\tdetails. Overrides the config variable when used.\n+\n Git Commits\n ~~~~~~~~~~~\n `GIT_AUTHOR_NAME`::\ndiff --git a/environment.h b/environment.h\nindex b336459e90..c26ef92b52 100644\n--- a/environment.h\n+++ b/environment.h\n@@ -45,6 +45,7 @@\n #define GIT_ATTR_SOURCE_ENVIRONMENT \"GIT_ATTR_SOURCE\"\n #define GIT_REFERENCE_BACKEND_ENVIRONMENT \"GIT_REFERENCE_BACKEND\"\n #define GIT_REF_STORAGE_FORMAT_ENVIRONMENT \"GIT_REF_STORAGE_FORMAT\"\n+#define GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT \"GIT_OBJECT_STORAGE_FORMAT\"\n \n /*\n  * Environment variable used to propagate the --no-advice global option to the\ndiff --git a/setup.c b/setup.c\nindex 249bd67876..70aa90a9cb 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2079,6 +2079,7 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \n \t\tif (startup_info->have_repository) {\n \t\t\tstruct strbuf err = STRBUF_INIT;\n+\t\t\tconst char *object_storage_uri;\n \t\t\tconst char *ref_backend_uri;\n \n \t\t\t/*\n@@ -2097,6 +2098,21 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \t\t\t\t\tdie(_(\"unknown ref storage format: '%s'\"), ref_backend_uri);\n \t\t\t}\n \n+\t\t\t/*\n+\t\t\t * Likewise, the GIT_OBJECT_STORAGE_FORMAT environment\n+\t\t\t * variable should override the repository config for\n+\t\t\t * 'extensions.objectStorage'.\n+\t\t\t */\n+\t\t\tobject_storage_uri = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT);\n+\t\t\tif (object_storage_uri) {\n+\t\t\t\tFREE_AND_NULL(discovery.format.object_storage_payload);\n+\t\t\t\tdiscovery.format.object_storage_format =\n+\t\t\t\t\tobject_storage_format_by_uri(object_storage_uri,\n+\t\t\t\t\t\t\t\t     &discovery.format.object_storage_payload);\n+\t\t\t\tif (discovery.format.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\t\t\tdie(_(\"unknown object storage format: '%s'\"), object_storage_uri);\n+\t\t\t}\n+\n \t\t\tif (apply_repository_format(repo, &discovery.format,\n \t\t\t\t\t\t    APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n \t\t\t\tdie(\"%s\", err.buf);\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex c7c464d3a2..5e7c25e42c 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -869,6 +869,32 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown b\n \ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n '\n \n+test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides extensions.objectStorage' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\t(\n+\t\tcd objstorage &&\n+\t\tgit config set core.repositoryformatversion 1 &&\n+\t\tgit config set extensions.objectStorage files://objs &&\n+\t\tmkdir .git/objs .git/other &&\n+\n+\t\techo content >file &&\n+\t\toid=$(git hash-object -w file) &&\n+\t\ttest_path_is_file .git/objs/$(test_oid_to_path \"$oid\") &&\n+\t\tgit cat-file -e \"$oid\" &&\n+\n+\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://other git cat-file -e \"$oid\" &&\n+\t\tGIT_OBJECT_STORAGE_FORMAT=files://other git hash-object -w file &&\n+\t\ttest_path_is_file .git/other/$(test_oid_to_path \"$oid\") &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\tfatal: unknown object storage format: ${SQ}garbage${SQ}\n+\t\tEOF\n+\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git rev-parse 2>err &&\n+\t\ttest_cmp expect err\n+\t)\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555988","messageId":"20261023-b4-pks-odb-extension-v3-4-b1bb30a006db@pks.im","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","subject":"[PATCH v3 4/7] builtin: expose the object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T11:49:13Z","receivedAt":"2026-10-23T11:49:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format of a repository can be inspected via both\ngit-rev-parse(1)'s \"--show-ref-storage-format\" and git-repo(1)'s\n\"references.storageFormat\" field. Introduce the equivalent options for\nthe object storage format, as well.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-repo.adoc      |  6 ++++++\n Documentation/git-rev-parse.adoc |  5 +++++\n builtin/repo.c                   | 10 ++++++++++\n builtin/rev-parse.c              |  9 +++++++++\n odb.c                            |  7 +++++++\n odb.h                            |  1 +\n t/t0001-init.sh                  |  5 ++++-\n t/t1900-repo-info.sh             |  3 +++\n 8 files changed, 45 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex cb8c1e7292..d2dc9b7a69 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -105,6 +105,12 @@ values that they return:\n `object.format`::\n \tThe object format (hash algorithm) used in the repository.\n \n+`objects.storageFormat`::\n+\tThe object storage format used in the repository, as configured via\n+\t`extensions.objectStorage`. The valid values are:\n++\n+include::object-storage-format.adoc[]\n+\n `path.commondir.absolute`::\n \tThe canonical absolute path to the Git repository's common\n \tdirectory (the shared `.git` directory containing objects,\ndiff --git a/Documentation/git-rev-parse.adoc b/Documentation/git-rev-parse.adoc\nindex 5b866af66a..9103d54d53 100644\n--- a/Documentation/git-rev-parse.adoc\n+++ b/Documentation/git-rev-parse.adoc\n@@ -338,6 +338,11 @@ The following options are unaffected by `--path-format`:\n --show-ref-format::\n \tDeprecated alias of `--show-ref-storage-format`.\n \n+--show-object-storage-format::\n+\tShow the object storage format used for the repository. Prints the\n+\tvalue of `extensions.objectStorage`, or `files` when the extension is\n+\tnot set.\n+\n \n Other Options\n ~~~~~~~~~~~~~\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 84e012f83f..b73dff898f 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -128,11 +128,21 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_object_storage_format(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf,\n+\t\t      object_storage_format_to_name(repo->object_storage_format));\n+\tif (repo->object_storage_payload)\n+\t\tstrbuf_addf(buf, \"://%s\", repo->object_storage_payload);\n+\treturn 0;\n+}\n+\n /* repo_info_field keys must be in lexicographical order */\n static const struct repo_info_field repo_info_field[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n \t{ \"object.format\", get_object_format },\n+\t{ \"objects.storageFormat\", get_object_storage_format },\n \t{ \"path.commondir.absolute\", get_path_commondir_absolute },\n \t{ \"path.commondir.relative\", get_path_commondir_relative },\n \t{ \"path.gitdir.absolute\", get_path_gitdir_absolute },\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex ec33c19bdf..d2154eac8d 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -17,6 +17,7 @@\n #include \"gettext.h\"\n #include \"hash.h\"\n #include \"hex.h\"\n+#include \"odb.h\"\n #include \"refs.h\"\n #include \"quote.h\"\n #include \"object-name.h\"\n@@ -1138,6 +1139,14 @@ int cmd_rev_parse(int argc,\n \t\t\t\tputs(ref_storage_format_to_name(the_repository->ref_storage_format));\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--show-object-storage-format\")) {\n+\t\t\t\tconst char *format = object_storage_format_to_name(the_repository->object_storage_format);\n+\t\t\t\tif (the_repository->object_storage_payload)\n+\t\t\t\t\tprintf(\"%s://%s\\n\", format, the_repository->object_storage_payload);\n+\t\t\t\telse\n+\t\t\t\t\tputs(format);\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--end-of-options\")) {\n \t\t\t\tseen_end_of_options = 1;\n \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\ndiff --git a/odb.c b/odb.c\nindex 0649622bc6..a0866e6c88 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -40,6 +40,13 @@ enum object_storage_format object_storage_format_by_name(const char *name)\n \treturn OBJECT_STORAGE_FORMAT_UNKNOWN;\n }\n \n+const char *object_storage_format_to_name(enum object_storage_format format)\n+{\n+\tif (format < 0 || format >= ARRAY_SIZE(object_storage_name_by_format))\n+\t\tformat = OBJECT_STORAGE_FORMAT_UNKNOWN;\n+\treturn object_storage_name_by_format[format];\n+}\n+\n enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload)\n {\n \tenum object_storage_format format;\ndiff --git a/odb.h b/odb.h\nindex cb0505334a..1340f60632 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -37,6 +37,7 @@ char *compute_alternate_path(const char *path, struct strbuf *err);\n enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload);\n \n enum object_storage_format object_storage_format_by_name(const char *name);\n+const char *object_storage_format_to_name(enum object_storage_format format);\n \n /*\n  * The object database encapsulates access to objects in a repository. It\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 5e7c25e42c..d080ab04a8 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -853,7 +853,10 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files bac\n \tgit -C objstorage config set core.repositoryformatversion 1 &&\n \tgit -C objstorage config set extensions.objectStorage files &&\n \ttest_commit -C objstorage A &&\n-\tgit -C objstorage rev-parse --verify HEAD\n+\tgit -C objstorage rev-parse --verify HEAD &&\n+\techo files >expect &&\n+\tgit -C objstorage rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\ndiff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh\nindex d115d2d9f9..493a78f230 100755\n--- a/t/t1900-repo-info.sh\n+++ b/t/t1900-repo-info.sh\n@@ -69,6 +69,9 @@ test_repo_info 'object.format = sha1 is retrieved correctly' \\\n test_repo_info 'object.format = sha256 is retrieved correctly' \\\n \t'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'\n \n+test_repo_info 'objects.storageFormat = files is retrieved correctly' \\\n+\t'git init' 'objects-files' 'objects.storageFormat' 'files'\n+\n test_expect_success 'values returned in order requested' '\n \tcat >expect <<-\\EOF &&\n \tlayout.bare=false\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555989","messageId":"20261023-b4-pks-odb-extension-v3-5-b1bb30a006db@pks.im","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","subject":"[PATCH v3 5/7] builtin/init: introduce handling of object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T11:49:14Z","receivedAt":"2026-10-23T11:49:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"While the object storage format extension can already be configured\nmanually via git-config(1), this isn't exactly an ergonomic way of doing\nso. For the reference storage format extension, users have a host of\noptions available to them.\n\nIntroduce the equivalent options for the object storage format.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/config/init.adoc |   5 ++\n Documentation/git-init.adoc    |  10 ++-\n Documentation/git.adoc         |   5 ++\n builtin/clone.c                |   9 ++-\n builtin/init-db.c              |   7 +-\n refs.c                         |   3 +-\n setup.c                        |  98 ++++++++++++++++++++++--\n setup.h                        |   2 +\n t/t0001-init.sh                | 166 +++++++++++++++++++++++++++++++++++++++++\n 9 files changed, 293 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/config/init.adoc b/Documentation/config/init.adoc\nindex e45bd692db..dbd9c663ee 100644\n--- a/Documentation/config/init.adoc\n+++ b/Documentation/config/init.adoc\n@@ -20,6 +20,11 @@ endif::[]\n \tprecedence over this config.\n `init.defaultRefFormat`::\n \tDeprecated alias of `init.defaultRefStorageFormat`.\n+`init.defaultObjectStorageFormat`::\n+\tAllows overriding the default object storage format for new\n+\trepositories. See `--object-storage-format=` in linkgit:git-init[1].\n+\tBoth the command line option and the `GIT_DEFAULT_OBJECT_STORAGE_FORMAT`\n+\tenvironment variable take precedence over this config.\n \n init.defaultSubmodulePathConfig::\n \tA boolean that specifies if `git init` and `git clone` should\ndiff --git a/Documentation/git-init.adoc b/Documentation/git-init.adoc\nindex b02af22ad1..9e022a7ba8 100644\n--- a/Documentation/git-init.adoc\n+++ b/Documentation/git-init.adoc\n@@ -11,7 +11,7 @@ SYNOPSIS\n [synopsis]\n git init [-q | --quiet] [--bare] [--template=<template-directory>]\n \t [--separate-git-dir <git-dir>] [--object-format=<format>]\n-\t [--ref-storage-format=<format>]\n+\t [--ref-storage-format=<format>] [--object-storage-format=<format>]\n \t [-b <branch-name> | --initial-branch=<branch-name>]\n \t [--shared[=<permissions>]] [<directory>]\n \n@@ -68,6 +68,14 @@ include::ref-storage-format.adoc[]\n `--ref-format=<format>`::\n Deprecated alias of `--ref-storage-format=<format>`.\n \n+`--object-storage-format=<format>`::\n+Specify the given object storage _<format>_ for the repository. Backends that\n+require additional configuration accept a payload in the form\n+`<format>://<payload>`, for example a path or a connection string identifying\n+the database that shall store the objects. The valid values are:\n++\n+include::object-storage-format.adoc[]\n+\n `--template=<template-directory>`::\n Specify the directory from which templates will be used.  (See the \"TEMPLATE\n DIRECTORY\" section below.)\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 34812131bb..67de5646f0 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -609,6 +609,11 @@ double-quotes and respecting backslash escapes. E.g., the value\n `GIT_REFERENCE_BACKEND`::\n \tDeprecated alias of `GIT_REF_STORAGE_FORMAT`.\n \n+`GIT_DEFAULT_OBJECT_STORAGE_FORMAT`::\n+\tIf this variable is set, the default object storage format for new\n+\trepositories will be set to this value. The default is \"files\".\n+\tSee `--object-storage-format` in linkgit:git-init[1].\n+\n `GIT_OBJECT_STORAGE_FORMAT`::\n \tSpecify which object storage format to use along with its URI.\n \tSee `extensions.objectStorage` option in linkgit:git-config[1] for more\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 6047501dfc..95e641b1a4 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -1214,7 +1214,7 @@ int cmd_clone(int argc,\n \t */\n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n \t\t\t  option_template, GIT_HASH_UNKNOWN, ref_storage_format_uri,\n-\t\t\t  do_not_override_repo_unix_permissions, NULL);\n+\t\t\t  NULL, do_not_override_repo_unix_permissions, NULL);\n \n \tif (real_git_dir) {\n \t\tfree((char *)git_dir);\n@@ -1256,7 +1256,8 @@ int cmd_clone(int argc,\n \t * This is sufficient for Git commands to discover the Git directory.\n \t */\n \tinitialize_repository_version(the_repository, GIT_HASH_UNKNOWN,\n-\t\t\t\t      the_repository->ref_storage_format, 1);\n+\t\t\t\t      the_repository->ref_storage_format,\n+\t\t\t\t      the_repository->object_storage_format, 1);\n \n \trefs_create_refdir_stubs(the_repository, git_dir, NULL);\n \n@@ -1468,7 +1469,9 @@ int cmd_clone(int argc,\n \t * ours to the same thing.\n \t */\n \thash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n-\tinitialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);\n+\tinitialize_repository_version(the_repository, hash_algo,\n+\t\t\t\t      the_repository->ref_storage_format,\n+\t\t\t\t      the_repository->object_storage_format, 1);\n \trepo_set_hash_algo(the_repository, hash_algo);\n \tcreate_reference_database(the_repository, NULL, 1);\n \tstartup_info->have_repository = 1;\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 0abdbca8e9..71b748f2f2 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -57,7 +57,7 @@ static int shared_callback(const struct option *opt, const char *arg, int unset)\n static const char *const init_db_usage[] = {\n \tN_(\"git init [-q | --quiet] [--bare] [--template=<template-directory>]\\n\"\n \t   \"         [--separate-git-dir <git-dir>] [--object-format=<format>]\\n\"\n-\t   \"         [--ref-storage-format=<format>]\\n\"\n+\t   \"         [--ref-storage-format=<format>] [--object-storage-format=<format>]\\n\"\n \t   \"         [-b <branch-name> | --initial-branch=<branch-name>]\\n\"\n \t   \"         [--shared[=<permissions>]] [<directory>]\"),\n \tNULL\n@@ -84,6 +84,7 @@ int cmd_init_db(int argc,\n \tint bare = startup_info->force_bare_repository ? 1 : -1;\n \tconst char *object_format = NULL;\n \tconst char *ref_storage_format_uri = NULL;\n+\tconst char *object_storage_format_uri = NULL;\n \tconst char *initial_branch = NULL;\n \tint hash_algo = GIT_HASH_UNKNOWN;\n \tint init_shared_repository = -1;\n@@ -111,6 +112,8 @@ int cmd_init_db(int argc,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format_uri, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format_uri, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_END()\n \t};\n \tint reinit;\n@@ -232,7 +235,7 @@ int cmd_init_db(int argc,\n \n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n \t\t\t  template_dir, hash_algo, ref_storage_format_uri,\n-\t\t\t  init_shared_repository, &reinit);\n+\t\t\t  object_storage_format_uri, init_shared_repository, &reinit);\n \tcreate_reference_database(the_repository, initial_branch, quiet);\n \tcreate_object_database(the_repository, NULL);\n \ndiff --git a/refs.c b/refs.c\nindex 951db56113..3f7458332e 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -3521,7 +3521,8 @@ int repo_migrate_ref_storage_format(struct repository *repo,\n \t * repository format so that clients will use the new ref store.\n \t * We also need to swap out the repository's main ref store.\n \t */\n-\tinitialize_repository_version(repo, hash_algo_by_ptr(repo->hash_algo), format, 1);\n+\tinitialize_repository_version(repo, hash_algo_by_ptr(repo->hash_algo), format,\n+\t\t\t\t      repo->object_storage_format, 1);\n \n \t/*\n \t * Unset the old ref store and release it. `get_main_ref_store()` will\ndiff --git a/setup.c b/setup.c\nindex 70aa90a9cb..4a70977576 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2459,6 +2459,7 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)\n void initialize_repository_version(struct repository *repo,\n \t\t\t\t   int hash_algo,\n \t\t\t\t   enum ref_storage_format ref_storage_format,\n+\t\t\t\t   enum object_storage_format object_storage_format,\n \t\t\t\t   int reinit)\n {\n \tstruct strbuf repo_version = STRBUF_INIT;\n@@ -2474,7 +2475,9 @@ void initialize_repository_version(struct repository *repo,\n \t */\n \tif (hash_algo != GIT_HASH_SHA1_LEGACY ||\n \t    ref_storage_format != REF_STORAGE_FORMAT_FILES ||\n-\t    repo->ref_storage_payload)\n+\t    repo->ref_storage_payload ||\n+\t    object_storage_format != OBJECT_STORAGE_FORMAT_FILES ||\n+\t    repo->object_storage_payload)\n \t\ttarget_version = GIT_REPO_VERSION_READ;\n \n \tif (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)\n@@ -2498,6 +2501,22 @@ void initialize_repository_version(struct repository *repo,\n \t\trepo_config_set_gently(repo, \"extensions.refstorage\", NULL);\n \t}\n \n+\tif (repo->object_storage_payload) {\n+\t\tstruct strbuf uri = STRBUF_INIT;\n+\n+\t\tstrbuf_addf(&uri, \"%s://%s\",\n+\t\t\t    object_storage_format_to_name(object_storage_format),\n+\t\t\t    repo->object_storage_payload);\n+\t\trepo_config_set(repo, \"extensions.objectstorage\", uri.buf);\n+\n+\t\tstrbuf_release(&uri);\n+\t} else if (object_storage_format != OBJECT_STORAGE_FORMAT_FILES) {\n+\t\trepo_config_set(repo, \"extensions.objectstorage\",\n+\t\t\t\tobject_storage_format_to_name(object_storage_format));\n+\t} else if (reinit) {\n+\t\trepo_config_set_gently(repo, \"extensions.objectstorage\", NULL);\n+\t}\n+\n \tif (reinit) {\n \t\tstruct strbuf config = STRBUF_INIT;\n \t\tstruct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;\n@@ -2624,7 +2643,8 @@ static int create_default_files(struct repository *repo,\n \t\tadjust_shared_perm(repo, repo_get_git_dir(repo));\n \t}\n \n-\tinitialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format, reinit);\n+\tinitialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format,\n+\t\t\t\t      fmt->object_storage_format, reinit);\n \n \t/* Check filemode trustability */\n \trepo_git_path_replace(repo, &path, \"config\");\n@@ -2734,6 +2754,7 @@ static void separate_git_dir(struct repository *repo,\n struct default_format_config {\n \tint hash;\n \tenum ref_storage_format ref_storage_format;\n+\tenum object_storage_format object_storage_format;\n };\n \n static int read_default_format_config(const char *key, const char *value,\n@@ -2765,6 +2786,16 @@ static int read_default_format_config(const char *key, const char *value,\n \t\tgoto out;\n \t}\n \n+\tif (!strcmp(key, \"init.defaultobjectstorageformat\")) {\n+\t\tret = git_config_string(&str, key, value);\n+\t\tif (ret)\n+\t\t\tgoto out;\n+\t\tcfg->object_storage_format = object_storage_format_by_name(str);\n+\t\tif (cfg->object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\twarning(_(\"unknown object storage format '%s'\"), str);\n+\t\tgoto out;\n+\t}\n+\n \t/*\n \t * Enable the reftable format when \"features.experimental\" is enabled.\n \t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n@@ -2785,7 +2816,8 @@ static int read_default_format_config(const char *key, const char *value,\n \n static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t\t\t\tint hash,\n-\t\t\t\t\tconst char *ref_storage_format_uri)\n+\t\t\t\t\tconst char *ref_storage_format_uri,\n+\t\t\t\t\tconst char *object_storage_uri)\n {\n \tstruct default_format_config cfg = {\n \t\t.hash = GIT_HASH_UNKNOWN,\n@@ -2796,7 +2828,9 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t.ignore_repo = 1,\n \t\t.ignore_worktree = 1,\n \t};\n+\tenum object_storage_format object_storage_format;\n \tenum ref_storage_format ref_storage_format;\n+\tchar *object_storage_payload = NULL;\n \tchar *ref_storage_payload = NULL;\n \tconst char *env;\n \n@@ -2885,9 +2919,52 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\tref_storage_format = REF_STORAGE_FORMAT_DEFAULT;\n \t}\n \n+\t/*\n+\t * Determine the object storage format, with the same precedence as\n+\t * for the ref storage format:\n+\t *\n+\t *   1. The format specified via the command line.\n+\t *\n+\t *   2. The format specified via \"GIT_OBJECT_STORAGE_FORMAT\".\n+\t *\n+\t *   3. The format of a preexisting repository when reinitializing.\n+\t *\n+\t *   4. The default format for new repositories as configured via\n+\t *      \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\".\n+\t *\n+\t *   5. The default format for new repositories as configured via\n+\t *      \"init.defaultObjectStorageFormat\".\n+\t *\n+\t *   6. The \"files\" format.\n+\t */\n+\tif (object_storage_uri) {\n+\t\tobject_storage_format = object_storage_format_by_uri(object_storage_uri,\n+\t\t\t\t\t\t\t\t     &object_storage_payload);\n+\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via command line: '%s'\"),\n+\t\t\t    object_storage_uri);\n+\t} else if ((env = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT))) {\n+\t\tobject_storage_format = object_storage_format_by_uri(env, &object_storage_payload);\n+\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n+\t\t\t    GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT, env);\n+\t} else if (repo_fmt->version >= 0) {\n+\t\tobject_storage_format = repo_fmt->object_storage_format;\n+\t\tobject_storage_payload = xstrdup_or_null(repo_fmt->object_storage_payload);\n+\t} else if ((env = getenv(\"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\"))) {\n+\t\tobject_storage_format = object_storage_format_by_name(env);\n+\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n+\t\t\t    \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\", env);\n+\t} else if (cfg.object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN) {\n+\t\tobject_storage_format = cfg.object_storage_format;\n+\t} else {\n+\t\tobject_storage_format = OBJECT_STORAGE_FORMAT_FILES;\n+\t}\n+\n \t/*\n \t * If we have a preexisting repository we need to verify that its\n-\t * current ref storage format does not change.\n+\t * current storage formats do not change.\n \t */\n \tif (repo_fmt->version >= 0) {\n \t\tif (ref_storage_format != repo_fmt->ref_storage_format)\n@@ -2896,11 +2973,21 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t    strcmp(ref_storage_payload ? ref_storage_payload : \"\",\n \t\t\t   repo_fmt->ref_storage_payload ? repo_fmt->ref_storage_payload : \"\"))\n \t\t\tdie(_(\"attempt to reinitialize repository with different reference storage payload\"));\n+\t\tif (object_storage_format != repo_fmt->object_storage_format)\n+\t\t\tdie(_(\"attempt to reinitialize repository with different object storage format\"));\n+\t\tif ((object_storage_payload || repo_fmt->object_storage_payload) &&\n+\t\t    strcmp(object_storage_payload ? object_storage_payload : \"\",\n+\t\t\t   repo_fmt->object_storage_payload ? repo_fmt->object_storage_payload : \"\"))\n+\t\t\tdie(_(\"attempt to reinitialize repository with different object storage payload\"));\n \t}\n \n \tfree(repo_fmt->ref_storage_payload);\n \trepo_fmt->ref_storage_format = ref_storage_format;\n \trepo_fmt->ref_storage_payload = ref_storage_payload;\n+\n+\tfree(repo_fmt->object_storage_payload);\n+\trepo_fmt->object_storage_format = object_storage_format;\n+\trepo_fmt->object_storage_payload = object_storage_payload;\n }\n \n void create_repository(struct repository *repo,\n@@ -2910,6 +2997,7 @@ void create_repository(struct repository *repo,\n \t\t       const char *template_dir,\n \t\t       int hash,\n \t\t       const char *ref_storage_format_uri,\n+\t\t       const char *object_storage_format_uri,\n \t\t       int init_shared_repository,\n \t\t       int *reinit_ok)\n {\n@@ -2948,7 +3036,7 @@ void create_repository(struct repository *repo,\n \t * is an attempt to reinitialize new repository with an old tool.\n \t */\n \tread_and_verify_repository_format(&repo_fmt, repo_get_git_dir(repo), NULL);\n-\trepository_format_configure(&repo_fmt, hash, ref_storage_format_uri);\n+\trepository_format_configure(&repo_fmt, hash, ref_storage_format_uri, object_storage_format_uri);\n \tif (apply_repository_format(repo, &repo_fmt, APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n \t\tdie(\"%s\", err.buf);\n \ndiff --git a/setup.h b/setup.h\nindex a4afa8910e..829b63228e 100644\n--- a/setup.h\n+++ b/setup.h\n@@ -277,12 +277,14 @@ void create_repository(struct repository *repo,\n \t\t       const char *template_dir,\n \t\t       int hash_algo,\n \t\t       const char *ref_storage_format_uri,\n+\t\t       const char *object_storage_format_uri,\n \t\t       int init_shared_repository,\n \t\t       int *reinit_ok);\n \n void initialize_repository_version(struct repository *repo,\n \t\t\t\t   int hash_algo,\n \t\t\t\t   enum ref_storage_format ref_storage_format,\n+\t\t\t\t   enum object_storage_format object_storage_format,\n \t\t\t\t   int reinit);\n \n /*\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex d080ab04a8..23317e0733 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -898,6 +898,172 @@ test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides ext\n \t)\n '\n \n+test_expect_success 'init with --object-storage-format=files does not set extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files objformat &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\tif test_have_prereq DEFAULT_REPO_FORMAT\n+\tthen\n+\t\techo 0 >expect &&\n+\t\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\t\ttest_cmp expect actual\n+\tfi\n+'\n+\n+test_expect_success 'init with --object-storage-format=files:// does not set extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files:// objformat &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with --object-storage-format=files://<relative-path>' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat config get extensions.objectstorage >actual &&\n+\ttest_cmp expect actual &&\n+\techo 1 >expect &&\n+\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\ttest_cmp expect actual &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual &&\n+\ttest_path_is_dir objformat/.git/objects &&\n+\ttest_path_is_dir objformat/.git/objs &&\n+\ttest_commit -C objformat A &&\n+\tgit -C objformat rev-parse --verify HEAD &&\n+\ttest_path_is_missing objformat/.git/objects/pack &&\n+\ttest_path_is_dir objformat/.git/objs/pack\n+'\n+\n+test_expect_success 'init with --object-storage-format=files://<absolute-path>' '\n+\ttest_when_finished \"rm -rf objformat objdir\" &&\n+\tgit init --object-storage-format=files://\"$(pwd)/objdir\" objformat &&\n+\techo \"files://$(pwd)/objdir\" >expect &&\n+\tgit -C objformat config get extensions.objectstorage >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_commit -C objformat A &&\n+\tgit -C objformat rev-parse --verify HEAD &&\n+\ttest_path_is_dir objdir/pack\n+'\n+\n+test_expect_success 'GIT_OBJECT_DIRECTORY takes precedence over extensions.objectStorage payload' '\n+\ttest_when_finished \"rm -rf objformat objdir\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\ttest_commit -C objformat A &&\n+\tmkdir objdir &&\n+\ttest_must_fail env GIT_DIR=\"$PWD/objformat/.git\" GIT_OBJECT_DIRECTORY=\"$PWD/objdir\" \\\n+\t\tgit cat-file -e HEAD &&\n+\tGIT_DIR=\"$PWD/objformat/.git\" GIT_OBJECT_DIRECTORY=\"$PWD/objdir\" \\\n+\t\tgit hash-object -w objformat/A.t >oid &&\n+\ttest_path_is_file objdir/$(test_oid_to_path \"$(cat oid)\")\n+'\n+\n+test_expect_success 'init with --object-storage-format=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via command line: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git init --object-storage-format=garbage objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'init with GIT_DEFAULT_OBJECT_STORAGE_FORMAT=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via GIT_DEFAULT_OBJECT_STORAGE_FORMAT: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail env GIT_DEFAULT_OBJECT_STORAGE_FORMAT=garbage git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'init with GIT_OBJECT_STORAGE_FORMAT=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via GIT_OBJECT_STORAGE_FORMAT: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'GIT_OBJECT_STORAGE_FORMAT takes precedence over default' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://default \\\n+\tGIT_OBJECT_STORAGE_FORMAT=files://explicit git init objformat &&\n+\techo files://explicit >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '--object-storage-format= takes precedence over environment' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_OBJECT_STORAGE_FORMAT=files://explicit \\\n+\tgit init --object-storage-format=files://cmdline objformat &&\n+\techo files://cmdline >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 're-init refuses with different storage format' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files objformat &&\n+\tcat >expect <<-EOF &&\n+\tfatal: attempt to reinitialize repository with different object storage payload\n+\tEOF\n+\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://objs git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 're-init with same object storage format' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\tgit init objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 're-init with default object storage format drops extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\n+\tgit init objformat &&\n+\tgit -C objformat config set core.repositoryformatversion 1 &&\n+\tgit -C objformat config set extensions.objectstorage files &&\n+\n+\tgit init --object-storage-format=files objformat &&\n+\techo 0 >expect &&\n+\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage\n+'\n+\n+test_expect_success 'init warns about invalid init.defaultObjectStorageFormat' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\ttest_config_global init.defaultObjectStorageFormat garbage &&\n+\techo \"warning: unknown object storage format ${SQ}garbage${SQ}\" >expect &&\n+\tgit init objformat 2>err &&\n+\ttest_cmp expect err &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with init.defaultObjectStorageFormat' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\ttest_config_global init.defaultObjectStorageFormat files &&\n+\tgit init objformat &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555990","messageId":"20261023-b4-pks-odb-extension-v3-6-b1bb30a006db@pks.im","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","subject":"[PATCH v3 6/7] builtin/clone: introduce \"--object-storage-format=\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T11:49:15Z","receivedAt":"2026-10-23T11:49:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Wire up the new object storage format in git-clone(1) via a new\n`--object-storage-format=` option, same as we have introduced in the\npreceding commit for git-init(1).\n\nNote that \"--local\" clones will not work if either of the object\ndatabases is not using the \"files\" format. This is because we hardlink\nloose objects and packfiles into the new repository, and that is\nsomething that simply won't work with alternative backends.\nConsequently, we either downgrade to a non-local clone with a warning,\nor we die in case the user has explicitly asked for a local clone.\n\nWe _could_ in theory handle the case where the \"files\" backend has been\nconfigured with an alternative object directory path (that is, with\n\"files:///path/to/dir\"). But that's left for a future patch series to\nimplement for the sake of simplicity.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-clone.adoc | 11 +++++++\n builtin/clone.c              | 45 +++++++++++++++++++++++++++--\n t/t5601-clone.sh             | 68 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 122 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-clone.adoc b/Documentation/git-clone.adoc\nindex 07f7cf1a98..dd3b44817a 100644\n--- a/Documentation/git-clone.adoc\n+++ b/Documentation/git-clone.adoc\n@@ -360,6 +360,17 @@ include::ref-storage-format.adoc[]\n `--ref-format=<format>`::\n Deprecated alias of `--ref-storage-format=<format>`.\n \n+`--object-storage-format=<format>`::\n+Specify the given object storage _<format>_ for the repository. Backends that\n+require additional configuration accept a payload in the form\n+`<format>://<payload>`, for example a path or a connection string identifying\n+the database that shall store the objects. The valid values are:\n++\n+include::object-storage-format.adoc[]\n++\n+Local clones (see `--local`) fall back to the regular transport when either\n+repository uses a non-default object storage.\n+\n `-j<n>`::\n `--jobs=<n>`::\n \tThe number of submodules fetched at the same time.\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 95e641b1a4..437dd2b277 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -378,6 +378,24 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,\n \tdir_iterator_free(iter);\n }\n \n+static bool is_using_default_object_storage_format(const char *repo_path)\n+{\n+\tstruct repository_format format = REPOSITORY_FORMAT_INIT;\n+\tstruct strbuf config = STRBUF_INIT;\n+\tbool is_default;\n+\n+\tget_common_dir(&config, repo_path);\n+\tstrbuf_addstr(&config, \"/config\");\n+\tread_repository_format(&format, config.buf);\n+\n+\tis_default = format.object_storage_format == OBJECT_STORAGE_FORMAT_FILES &&\n+\t\t!format.object_storage_payload;\n+\n+\tclear_repository_format(&format);\n+\tstrbuf_release(&config);\n+\treturn is_default;\n+}\n+\n static void clone_local(const char *src_repo, const char *dest_repo)\n {\n \tif (!option_shared) {\n@@ -927,6 +945,7 @@ int cmd_clone(int argc,\n \tstruct string_list option_not = STRING_LIST_INIT_NODUP;\n \tconst char *real_git_dir = NULL;\n \tconst char *ref_storage_format_uri = NULL;\n+\tconst char *object_storage_format_uri = NULL;\n \tconst char *option_upload_pack = \"git-upload-pack\";\n \tint option_progress = -1;\n \tint option_sparse_checkout = 0;\n@@ -1008,6 +1027,8 @@ int cmd_clone(int argc,\n \t\t\t   N_(\"separate git dir from working tree\")),\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format_uri, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format_uri, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n \t\tOPT_STRING_LIST('c', \"config\", &option_config, N_(\"key=value\"),\n \t\t\t\tN_(\"set config inside the new repository\")),\n@@ -1060,6 +1081,10 @@ int cmd_clone(int argc,\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format_uri);\n \t}\n \n+\tif (object_storage_format_uri &&\n+\t    object_storage_format_by_uri(object_storage_format_uri, NULL) == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n+\n \tif (option_mirror) {\n \t\toption_bare = 1;\n \t\toption_tags = 0;\n@@ -1213,8 +1238,9 @@ int cmd_clone(int argc,\n \t * their on-disk data structures.\n \t */\n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n-\t\t\t  option_template, GIT_HASH_UNKNOWN, ref_storage_format_uri,\n-\t\t\t  NULL, do_not_override_repo_unix_permissions, NULL);\n+\t\t\t  option_template, GIT_HASH_UNKNOWN,\n+\t\t\t  ref_storage_format_uri, object_storage_format_uri,\n+\t\t\t  do_not_override_repo_unix_permissions, NULL);\n \n \tif (real_git_dir) {\n \t\tfree((char *)git_dir);\n@@ -1363,6 +1389,21 @@ int cmd_clone(int argc,\n \t\t\tis_local = 0;\n \t\t}\n \t}\n+\n+\t/*\n+\t * Local clones copy or hardlink the object directory of the source repository\n+\t * into the destination. This only works when both repositories use the \"files\"\n+\t * object storage format.\n+\t */\n+\tif (is_local &&\n+\t    (!is_using_default_object_storage_format(path) || !is_using_default_object_storage_format(git_dir))) {\n+\t\tif (option_local > 0)\n+\t\t\tdie(_(\"cannot perform local clone with non-default object storage format\"));\n+\t\telse\n+\t\t\twarning(_(\"falling back to non-local clone because of non-default object storage format\"));\n+\t\tis_local = 0;\n+\t}\n+\n \tif (option_local > 0 && !is_local)\n \t\twarning(_(\"--local is ignored\"));\n \ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 06f6121f82..85f439d6b6 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -181,6 +181,74 @@ test_expect_success 'clone with garbage ref format' '\n \ttest_path_is_missing ref-storage\n '\n \n+test_expect_success 'clone with files object storage format' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\tgit clone --object-storage-format=files --bare src object-storage &&\n+\ttest_must_fail git -C object-storage config get extensions.objectstorage &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\techo files >expect &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'clone with object storage payload' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\tgit clone --object-storage-format=files://objs --bare src object-storage &&\n+\tgit -C object-storage config get extensions.objectstorage >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_path_is_dir object-storage/objs/pack &&\n+\ttest_path_is_missing object-storage/objects/pack\n+'\n+\n+test_expect_success 'clone with object storage payload and bundle URI' '\n+\ttest_when_finished \"rm -rf object-storage src.bundle\" &&\n+\tgit -C src bundle create ../src.bundle --all &&\n+\tgit clone --object-storage-format=files://objs --bundle-uri=\"$PWD/src.bundle\" \\\n+\t\tsrc object-storage &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'clone with garbage object storage format' '\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git clone --object-storage-format=garbage --bare src object-storage 2>err &&\n+\ttest_cmp expect err &&\n+\ttest_path_is_missing object-storage\n+'\n+\n+test_expect_success 'local clone into non-default object storage bails' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\ttest_must_fail git clone --local --object-storage-format=files://objs src object-storage 2>err &&\n+\ttest_grep \"cannot perform local clone with non-default object storage format\" err\n+'\n+\n+test_expect_success 'local clone from explicit files object storage succeeds' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone src object-storage &&\n+\tgit -C object-storage config set core.repositoryformatversion 1 &&\n+\tgit -C object-storage config set extensions.objectstorage files &&\n+\tgit clone --local object-storage object-storage-dest\n+'\n+\n+test_expect_success 'local clone from non-default object storage bails' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone --object-storage-format=files://objs src object-storage &&\n+\ttest_must_fail git clone --local object-storage object-storage-dest 2>err &&\n+\ttest_grep \"cannot perform local clone with non-default object storage format\" err\n+'\n+\n+test_expect_success 'local clone from non-default object storage without --local warns' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone --object-storage-format=files://objs src object-storage &&\n+\tgit clone object-storage object-storage-dest 2>err &&\n+\ttest_grep \"falling back to non-local clone\" err\n+'\n+\n test_expect_success 'clone to destination with trailing /' '\n \n \tgit clone src target-1/ &&\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"555991","messageId":"20261023-b4-pks-odb-extension-v3-7-b1bb30a006db@pks.im","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","subject":"[PATCH v3 7/7] builtin/submodule: propagate \"--object-storage-format=\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T11:49:16Z","receivedAt":"2026-10-23T11:49:16Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format passed to git-clone(1) propagates to recursively\ncloned submodules, and git-submodule(1)'s \"add\" and \"update\" subcommands\naccept `--ref-storage-format=` so that newly cloned submodules can be\nset up with a specific format.\n\nTeach git-submodule(1) to also propagate the object storage format.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-submodule.adoc           |  10 ++-\n builtin/clone.c                            |  19 ++++--\n builtin/submodule--helper.c                |  40 +++++++++++\n git-submodule.sh                           |  18 +++++\n t/meson.build                              |   1 +\n t/t7427-submodule-object-storage-format.sh | 104 +++++++++++++++++++++++++++++\n 6 files changed, 185 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-submodule.adoc b/Documentation/git-submodule.adoc\nindex e9c81a7170..57a21bc8d9 100644\n--- a/Documentation/git-submodule.adoc\n+++ b/Documentation/git-submodule.adoc\n@@ -34,7 +34,7 @@ COMMANDS\n With no arguments, shows the status of existing submodules.  Several\n subcommands are available to perform operations on the submodules.\n \n-`add [-b <branch>] [-f | --force] [--name <name>] [--reference <repository>] [--ref-storage-format <format>] [--depth <depth>] [--] <repository> [<path>]`::\n+`add [-b <branch>] [-f | --force] [--name <name>] [--reference <repository>] [--ref-storage-format <format>] [--object-storage-format <format>] [--depth <depth>] [--] <repository> [<path>]`::\n \tAdd the given repository as a submodule at the given path\n \tto the changeset to be committed next to the current\n \tproject: the current project is termed the \"superproject\".\n@@ -75,6 +75,9 @@ URL in `.gitmodules`.\n If `--ref-storage-format <format>` or its deprecated alias `--ref-format\n <format>` is specified, the ref storage format of the newly cloned submodules\n will be set accordingly.\n++\n+If `--object-storage-format <format>` is specified, the object storage format\n+of the newly cloned submodules will be set accordingly.\n \n `status [--cached] [--recursive] [--] [<path>...]`::\n \tShow the status of the submodules. This will print the SHA-1 of the\n@@ -140,7 +143,7 @@ If you really want to remove a submodule from the repository and commit\n that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal\n options.\n \n-`update [--init] [--remote] [-N | --no-fetch] [--[no-]recommend-shallow] [-f | --force] [--checkout | --rebase | --merge] [--reference=<repository>] [--ref-storage-format=<format>] [--depth=<depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter=<filter-spec>] [--] [<path>...]`::\n+`update [--init] [--remote] [-N | --no-fetch] [--[no-]recommend-shallow] [-f | --force] [--checkout | --rebase | --merge] [--reference=<repository>] [--ref-storage-format=<format>] [--object-storage-format=<format>] [--depth=<depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter=<filter-spec>] [--] [<path>...]`::\n +\n --\n Update the registered submodules to match what the superproject\n@@ -193,6 +196,9 @@ If `--ref-storage-format <format>` or its deprecated alias `--ref-format\n <format>` is specified, the ref storage format of the newly cloned submodules\n will be set accordingly.\n \n+If `--object-storage-format <format>` is specified, the object storage format\n+of the newly cloned submodules will be set accordingly.\n+\n If `--filter <filter-spec>` is specified, the given partial clone filter will be\n applied to the submodule. See linkgit:git-rev-list[1] for details on filter\n specifications.\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 437dd2b277..993a4390b8 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -681,7 +681,8 @@ static int git_sparse_checkout_init(const char *repo)\n static int checkout(int submodule_progress,\n \t\t    struct list_objects_filter_options *filter_options,\n \t\t    int filter_submodules,\n-\t\t    enum ref_storage_format ref_storage_format)\n+\t\t    enum ref_storage_format ref_storage_format,\n+\t\t    enum object_storage_format object_storage_format)\n {\n \tstruct object_id oid;\n \tchar *head;\n@@ -771,6 +772,10 @@ static int checkout(int submodule_progress,\n \t\t\tstrvec_pushf(&cmd.args, \"--ref-storage-format=%s\",\n \t\t\t\t     ref_storage_format_to_name(ref_storage_format));\n \n+\t\tif (object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tstrvec_pushf(&cmd.args, \"--object-storage-format=%s\",\n+\t\t\t\t     object_storage_format_to_name(object_storage_format));\n+\n \t\tif (filter_submodules && filter_options->choice)\n \t\t\tstrvec_pushf(&cmd.args, \"--filter=%s\",\n \t\t\t\t     expand_list_objects_filter_spec(filter_options));\n@@ -936,6 +941,7 @@ int cmd_clone(int argc,\n \tint submodule_progress;\n \tint filter_submodules = 0;\n \tint hash_algo;\n+\tenum object_storage_format object_storage_format = OBJECT_STORAGE_FORMAT_UNKNOWN;\n \tenum ref_storage_format ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;\n \tconst int do_not_override_repo_unix_permissions = -1;\n \tint option_reject_shallow = -1; /* unspecified */\n@@ -1081,9 +1087,11 @@ int cmd_clone(int argc,\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format_uri);\n \t}\n \n-\tif (object_storage_format_uri &&\n-\t    object_storage_format_by_uri(object_storage_format_uri, NULL) == OBJECT_STORAGE_FORMAT_UNKNOWN)\n-\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n+\tif (object_storage_format_uri) {\n+\t\tobject_storage_format = object_storage_format_by_uri(object_storage_format_uri, NULL);\n+\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n+\t}\n \n \tif (option_mirror) {\n \t\toption_bare = 1;\n@@ -1701,7 +1709,8 @@ int cmd_clone(int argc,\n \terr = checkout(submodule_progress,\n \t\t       &filter_options,\n \t\t       filter_submodules,\n-\t\t       ref_storage_format);\n+\t\t       ref_storage_format,\n+\t\t       object_storage_format);\n \n \tlist_objects_filter_release(&filter_options);\n \ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 64412adf9f..461b682d0d 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1739,6 +1739,7 @@ struct module_clone_data {\n \tint depth;\n \tstruct list_objects_filter_options *filter_options;\n \tenum ref_storage_format ref_storage_format;\n+\tenum object_storage_format object_storage_format;\n \tunsigned int quiet: 1;\n \tunsigned int progress: 1;\n \tunsigned int dissociate: 1;\n@@ -1748,6 +1749,7 @@ struct module_clone_data {\n #define MODULE_CLONE_DATA_INIT { \\\n \t.single_branch = -1, \\\n \t.ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \\\n+\t.object_storage_format = OBJECT_STORAGE_FORMAT_UNKNOWN, \\\n }\n \n struct submodule_alternate_setup {\n@@ -1948,6 +1950,9 @@ static int clone_submodule(const struct module_clone_data *clone_data,\n \t\tif (clone_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tstrvec_pushf(&cp.args, \"--ref-storage-format=%s\",\n \t\t\t\t     ref_storage_format_to_name(clone_data->ref_storage_format));\n+\t\tif (clone_data->object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tstrvec_pushf(&cp.args, \"--object-storage-format=%s\",\n+\t\t\t\t     object_storage_format_to_name(clone_data->object_storage_format));\n \t\tif (clone_data->dissociate)\n \t\t\tstrvec_push(&cp.args, \"--dissociate\");\n \t\tif (sm_gitdir && *sm_gitdir)\n@@ -2044,6 +2049,7 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \tstruct string_list reference = STRING_LIST_INIT_NODUP;\n \tstruct list_objects_filter_options filter_options =\n \t\tLIST_OBJECTS_FILTER_INIT;\n+\tconst char *object_storage_format = NULL;\n \tconst char *ref_storage_format = NULL;\n \n \tstruct option module_clone_options[] = {\n@@ -2065,6 +2071,8 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &dissociate,\n \t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_INTEGER(0, \"depth\", &clone_data.depth,\n@@ -2095,6 +2103,13 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \t\tif (clone_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\n+\tif (object_storage_format) {\n+\t\tclone_data.object_storage_format = object_storage_format_by_name(object_storage_format);\n+\t\tif (clone_data.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n+\t}\n+\n \tclone_data.dissociate = !!dissociate;\n \tclone_data.quiet = !!quiet;\n \tclone_data.progress = !!progress;\n@@ -2201,6 +2216,7 @@ struct update_data {\n \tstruct submodule_update_strategy update_strategy;\n \tstruct list_objects_filter_options *filter_options;\n \tstruct module_list list;\n+\tenum object_storage_format object_storage_format;\n \tenum ref_storage_format ref_storage_format;\n \tint depth;\n \tint max_jobs;\n@@ -2365,6 +2381,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n \tif (suc->update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\tstrvec_pushf(&child->args, \"--ref-storage-format=%s\",\n \t\t\t     ref_storage_format_to_name(suc->update_data->ref_storage_format));\n+\tif (suc->update_data->object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\tstrvec_pushf(&child->args, \"--object-storage-format=%s\",\n+\t\t\t     object_storage_format_to_name(suc->update_data->object_storage_format));\n \tstrvec_pushl(&child->args, \"--path\", sub->path, NULL);\n \tstrvec_pushl(&child->args, \"--name\", sub->name, NULL);\n \tstrvec_pushl(&child->args, \"--url\", url, NULL);\n@@ -2809,6 +2828,9 @@ static void update_data_to_args(const struct update_data *update_data,\n \tif (update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\tstrvec_pushf(args, \"--ref-storage-format=%s\",\n \t\t\t     ref_storage_format_to_name(update_data->ref_storage_format));\n+\tif (update_data->object_storage_format)\n+\t\tstrvec_pushf(args, \"--object-storage-format=%s\",\n+\t\t\t     object_storage_format_to_name(update_data->object_storage_format));\n \tif (update_data->filter_options && update_data->filter_options->choice)\n \t\tstrvec_pushf(args, \"--filter=%s\",\n \t\t\t\texpand_list_objects_filter_spec(\n@@ -2992,6 +3014,7 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options =\n \t\tLIST_OBJECTS_FILTER_INIT;\n+\tconst char *object_storage_format = NULL;\n \tconst char *ref_storage_format = NULL;\n \tint ret;\n \tstruct option module_update_options[] = {\n@@ -3019,6 +3042,8 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n \t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_INTEGER(0, \"depth\", &opt.depth,\n@@ -3067,6 +3092,11 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \t\tif (opt.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (object_storage_format) {\n+\t\topt.object_storage_format = object_storage_format_by_name(object_storage_format);\n+\t\tif (opt.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n+\t}\n \n \topt.filter_options = &filter_options;\n \topt.prefix = prefix;\n@@ -3371,6 +3401,7 @@ struct add_data {\n \tconst char *sm_name;\n \tconst char *repo;\n \tconst char *realrepo;\n+\tenum object_storage_format object_storage_format;\n \tenum ref_storage_format ref_storage_format;\n \tint depth;\n \tunsigned int force: 1;\n@@ -3477,6 +3508,7 @@ static int add_submodule(const struct add_data *add_data)\n \t\t\tstring_list_append(&reference, p)->util = p;\n \t\t}\n \t\tclone_data.ref_storage_format = add_data->ref_storage_format;\n+\t\tclone_data.object_storage_format = add_data->object_storage_format;\n \t\tclone_data.dissociate = add_data->dissociate;\n \t\tif (add_data->depth >= 0)\n \t\t\tclone_data.depth = add_data->depth;\n@@ -3652,6 +3684,7 @@ static int module_add(int argc, const char **argv, const char *prefix,\n {\n \tint force = 0, quiet = 0, progress = 0, dissociate = 0;\n \tstruct add_data add_data = ADD_DATA_INIT;\n+\tconst char *object_storage_format = NULL;\n \tconst char *ref_storage_format = NULL;\n \tchar *to_free = NULL;\n \tconst struct submodule *existing;\n@@ -3669,6 +3702,8 @@ static int module_add(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &dissociate, N_(\"borrow the objects from reference repositories\")),\n \t\tOPT_STRING(0, \"name\", &add_data.sm_name, N_(\"name\"),\n \t\t\t   N_(\"sets the submodule's name to the given string \"\n@@ -3700,6 +3735,11 @@ static int module_add(int argc, const char **argv, const char *prefix,\n \t\tif (add_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (object_storage_format) {\n+\t\tadd_data.object_storage_format = object_storage_format_by_name(object_storage_format);\n+\t\tif (add_data.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n+\t}\n \n \tadd_data.repo = argv[0];\n \tif (argc == 1)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 8632194138..4de5ffba04 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -103,6 +103,14 @@ cmd_add()\n \t\t--ref-format=*|--ref-storage-format=*)\n \t\t\tref_storage_format=\"$1\"\n \t\t\t;;\n+\t\t--object-storage-format)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tobject_storage_format=\"--object-storage-format=$2\"\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--object-storage-format=*)\n+\t\t\tobject_storage_format=\"$1\"\n+\t\t\t;;\n \t\t--dissociate)\n \t\t\tdissociate=$1\n \t\t\t;;\n@@ -148,6 +156,7 @@ cmd_add()\n \t\t${branch:+\"$branch\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${ref_storage_format:+\"$ref_storage_format\"} \\\n+\t\t${object_storage_format:+\"$object_storage_format\"} \\\n \t\t$dissociate \\\n \t\t${name:+\"$name\"} \\\n \t\t${depth:+\"$depth\"} \\\n@@ -310,6 +319,14 @@ cmd_update()\n \t\t--ref-format=*|--ref-storage-format=*)\n \t\t\tref_storage_format=\"$1\"\n \t\t\t;;\n+\t\t--object-storage-format)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tobject_storage_format=\"--object-storage-format=$2\"\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--object-storage-format=*)\n+\t\t\tobject_storage_format=\"$1\"\n+\t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n \t\t\treference=\"--reference=$2\"\n@@ -386,6 +403,7 @@ cmd_update()\n \t\t$merge \\\n \t\t$checkout \\\n \t\t${ref_storage_format:+\"$ref_storage_format\"} \\\n+\t\t${object_storage_format:+\"$object_storage_format\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t$dissociate \\\n \t\t${depth:+\"$depth\"} \\\ndiff --git a/t/meson.build b/t/meson.build\nindex 11b3752f00..8542035b6f 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -926,6 +926,7 @@ integration_tests = [\n   't7424-submodule-mixed-ref-formats.sh',\n   't7425-submodule-gitdir-path-extension.sh',\n   't7426-submodule-get-default-remote.sh',\n+  't7427-submodule-object-storage-format.sh',\n   't7450-bad-git-dotfiles.sh',\n   't7500-commit-template-squash-signoff.sh',\n   't7501-commit-basic-functionality.sh',\ndiff --git a/t/t7427-submodule-object-storage-format.sh b/t/t7427-submodule-object-storage-format.sh\nnew file mode 100755\nindex 0000000000..e4e554b073\n--- /dev/null\n+++ b/t/t7427-submodule-object-storage-format.sh\n@@ -0,0 +1,104 @@\n+#!/bin/sh\n+\n+test_description='submodules handle the object storage format'\n+\n+. ./test-lib.sh\n+\n+test_object_storage_format () {\n+\techo \"$2\" >expect &&\n+\tgit -C \"$1\" rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+}\n+\n+test_expect_success 'setup' '\n+\tgit config set --global protocol.file.allow always\n+'\n+\n+test_expect_success 'add existing repository with different object storage format' '\n+\ttest_when_finished \"rm -rf parent\" &&\n+\n+\tgit init parent &&\n+\t(\n+\t\tcd parent &&\n+\t\ttest_commit parent &&\n+\t\tgit init --object-storage-format=files://objs submodule &&\n+\t\ttest_commit -C submodule submodule &&\n+\t\tgit submodule add ./submodule &&\n+\t\ttest_object_storage_format submodule files://objs\n+\t)\n+'\n+\n+test_expect_success 'add submodules with explicit files storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\ttest_object_storage_format upstream files &&\n+\tgit -C upstream submodule add --object-storage-format=files \"file://$(pwd)/submodule\" &&\n+\ttest_object_storage_format upstream/submodule files\n+'\n+\n+test_expect_success 'add submodules with garbage object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git -C upstream submodule add --object-storage-format=garbage \"file://$(pwd)/submodule\" 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'add submodules with object storage payload is rejected' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}files://objs${SQ}\n+\tEOF\n+\ttest_must_fail git -C upstream submodule add --object-storage-format=files://objs \"file://$(pwd)/submodule\" 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'recursive clone propagates object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tgit -C upstream submodule add \"file://$(pwd)/submodule\" &&\n+\tgit -C upstream commit -am \"add submodule\" &&\n+\n+\ttest_object_storage_format upstream files &&\n+\ttest_object_storage_format upstream/submodule files &&\n+\n+\tgit clone --object-storage-format=files://objs --recurse-submodules \\\n+\t\tupstream downstream &&\n+\ttest_object_storage_format downstream files://objs &&\n+\ttest_object_storage_format downstream/submodule files &&\n+\ttest_path_is_dir downstream/.git/objs/pack &&\n+\ttest_path_is_dir downstream/.git/modules/submodule/objects/pack\n+'\n+\n+test_expect_success 'clone submodules with explicit object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tgit -C upstream submodule add \"file://$(pwd)/submodule\" &&\n+\tgit -C upstream commit -m \"upstream submodule\" &&\n+\n+\tgit clone --no-recurse-submodules \"file://$(pwd)/upstream\" downstream &&\n+\ttest_object_storage_format downstream files &&\n+\tgit -C downstream submodule update --init --object-storage-format=files &&\n+\ttest_object_storage_format downstream/submodule files &&\n+\ttest_path_is_dir downstream/.git/modules/submodule/objects/pack\n+'\n+\n+test_done\n\n-- \n2.56.0.307.g5fe7bd680c.dirty\n\n\n"},{"id":"556157","messageId":"atzFrKoU/mrhq31L@szeder.dev","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-2-b1bb30a006db@pks.im","subject":"Re: [PATCH v3 2/7] setup: introduce object storage extension","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2026-10-24T14:50:20Z","receivedAt":"2026-10-24T14:50:20Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Oct 23, 2026 at 01:49:11PM +0200, Patrick Steinhardt wrote:\n> Introduce a new \"extensions.objectStorage\" extension that allows the\n> user to configure the primary object database source of a repository.\n> The value is a URI in the format \"<schema>[://<payload>]\", mirroring\n> the format used by \"extensions.refStorage\":\n> \n>   - The schema identifies the backend that shall be used. For now the\n>     only supported schema is \"files\", which is the existing object\n>     database backed by loose objects and packfiles.\n> \n>   - The payload can be passed to configure the backend, and its\n>     interpretation is backend-specific. For the \"files\" backend, it\n>     allows you to configure a different location for the \".git/objects\"\n>     directory.\n\nPlease justify why you want to make this configurable.\n\n\n"},{"id":"556301","messageId":"at8l86Eiz73QSAe_@pks.im","threadId":"66584","inReplyTo":"atzFrKoU/mrhq31L@szeder.dev","subject":"Re: [PATCH v3 2/7] setup: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-26T10:05:39Z","receivedAt":"2026-10-26T10:05:39Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sat, Oct 24, 2026 at 04:50:20PM +0200, SZEDER Gábor wrote:\n> On Fri, Oct 23, 2026 at 01:49:11PM +0200, Patrick Steinhardt wrote:\n> > Introduce a new \"extensions.objectStorage\" extension that allows the\n> > user to configure the primary object database source of a repository.\n> > The value is a URI in the format \"<schema>[://<payload>]\", mirroring\n> > the format used by \"extensions.refStorage\":\n> > \n> >   - The schema identifies the backend that shall be used. For now the\n> >     only supported schema is \"files\", which is the existing object\n> >     database backed by loose objects and packfiles.\n> > \n> >   - The payload can be passed to configure the backend, and its\n> >     interpretation is backend-specific. For the \"files\" backend, it\n> >     allows you to configure a different location for the \".git/objects\"\n> >     directory.\n> \n> Please justify why you want to make this configurable.\n\nIt allows us to already start testing pluggable object databases and the\nobject storage format extension together with a payload. But more\nimportantly it matches the semantics that we also have with the ref\nstorage format, where you can also configure the location.\n\nWe also have some use case for this at GitLab as a building block for\nmigrations. But the above two reasons are the more interesting ones for\nnow.\n\nI'll adapt the commit message.\n\nPatrick\n\n"},{"id":"556315","messageId":"CAOLa=ZTwedYbV+vFJcrACohX+epp4hUXSFXYvRTZ1tJPSNaj9A@mail.gmail.com","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-2-b1bb30a006db@pks.im","subject":"Re: [PATCH v3 2/7] setup: introduce object storage extension","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-26T11:22:38Z","receivedAt":"2026-10-26T11:22:38Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n[snip]\n\n> diff --git a/odb.c b/odb.c\n> index 98c5c862f5..0649622bc6 100644\n> --- a/odb.c\n> +++ b/odb.c\n> @@ -27,6 +27,42 @@\n>  #include \"trace2.h\"\n>  #include \"write-or-die.h\"\n>\n> +static const char * const object_storage_name_by_format[] = {\n> +\t[OBJECT_STORAGE_FORMAT_UNKNOWN] = \"unknown\",\n> +\t[OBJECT_STORAGE_FORMAT_FILES] = \"files\",\n> +};\n> +\n\nSuper Nit: I would have dropped from this, as that is the default, this\nmakes it seem like it is one of the backends. Feel free to ignore\nthough.\n\n> +enum object_storage_format object_storage_format_by_name(const char *name)\n> +{\n> +\tfor (size_t i = 0; i < ARRAY_SIZE(object_storage_name_by_format); i++)\n> +\t\tif (!strcmp(object_storage_name_by_format[i], name))\n> +\t\t\treturn i;\n> +\treturn OBJECT_STORAGE_FORMAT_UNKNOWN;\n> +}\n> +\n> +enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload)\n> +{\n> +\tenum object_storage_format format;\n> +\tconst char *schema_end;\n> +\tchar *name;\n> +\n> +\tschema_end = strstr(uri, \"://\");\n> +\tif (!schema_end) {\n> +\t\tname = xstrdup(uri);\n> +\t\tif (payload)\n> +\t\t\t*payload = NULL;\n> +\t} else {\n> +\t\tname = xstrndup(uri, schema_end - uri);\n> +\t\tif (payload)\n> +\t\t\t*payload = *(schema_end + 3) ? xstrdup(schema_end + 3) : NULL;\n> +\t}\n> +\n> +\tformat = object_storage_format_by_name(name);\n> +\n> +\tfree(name);\n\nWe need to allocate since we only want to send the format and not the\npayload, makes sense.\n\n> +\treturn format;\n> +}\n> +\n>\n>  int odb_mkstemp(struct object_database *odb,\n>  \t\tstruct strbuf *temp_filename, const char *pattern)\n>  {\n\n[snip]\n\n> diff --git a/repository.h b/repository.h\n> index 2a348012e8..8c4437762e 100644\n> --- a/repository.h\n> +++ b/repository.h\n> @@ -694,6 +708,7 @@ static enum extension_result handle_extension(const char *var,\n>  \t\tdata->submodule_path_cfg = git_config_bool(var, value);\n>  \t\treturn EXTENSION_OK;\n>  \t}\n> +\n\nNit: stray newline addition\n\n>  \treturn EXTENSION_UNKNOWN;\n>  }\n>\n\n[snip]\n\nThe patch looks to be in order!\n"},{"id":"556317","messageId":"CAOLa=ZTrYBtLOPMh04-J8AkH0797aeKsnXB61H-V8vb1x0r2Jg@mail.gmail.com","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-3-b1bb30a006db@pks.im","subject":"Re: [PATCH v3 3/7] setup: allow overriding object storage format via environment","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-26T11:25:11Z","receivedAt":"2026-10-26T11:25:11Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> The ref storage format configured via \"extensions.refStorage\" can be\n> overridden with the GIT_REF_STORAGE_FORMAT environment variable.\n> Introduce the GIT_OBJECT_STORAGE_FORMAT environment variable that\n> overrides \"extensions.objectStorage\" in the same way.\n\n[snip]\n\n> diff --git a/setup.c b/setup.c\n> index 249bd67876..70aa90a9cb 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -2097,6 +2098,21 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n>  \t\t\t\t\tdie(_(\"unknown ref storage format: '%s'\"), ref_backend_uri);\n>  \t\t\t}\n>\n> +\t\t\t/*\n> +\t\t\t * Likewise, the GIT_OBJECT_STORAGE_FORMAT environment\n\nReally nitpicking today: I would drop the 'Likewise' here as this binds\nthis section of the code to the previous, which may not stay the same\nover time.\n\n> +\t\t\t * variable should override the repository config for\n> +\t\t\t * 'extensions.objectStorage'.\n> +\t\t\t */\n> +\t\t\tobject_storage_uri = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT);\n> +\t\t\tif (object_storage_uri) {\n> +\t\t\t\tFREE_AND_NULL(discovery.format.object_storage_payload);\n> +\t\t\t\tdiscovery.format.object_storage_format =\n> +\t\t\t\t\tobject_storage_format_by_uri(object_storage_uri,\n> +\t\t\t\t\t\t\t\t     &discovery.format.object_storage_payload);\n> +\t\t\t\tif (discovery.format.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n> +\t\t\t\t\tdie(_(\"unknown object storage format: '%s'\"), object_storage_uri);\n> +\t\t\t}\n> +\n>  \t\t\tif (apply_repository_format(repo, &discovery.format,\n>  \t\t\t\t\t\t    APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n>  \t\t\t\tdie(\"%s\", err.buf);\n\n[snip]\n"},{"id":"556318","messageId":"CAOLa=ZQ+25HBP5NAOQ+6TKBtNH2gSk-sH8d6DPDmxgGShowvAw@mail.gmail.com","threadId":"66584","inReplyTo":"20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im","subject":"Re: [PATCH v3 0/7] odb: introduce object storage extension","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-26T11:35:27Z","receivedAt":"2026-10-26T11:35:27Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Hi,\n>\n> this patch series introduces the object storage extension. The extension\n> is of course similar in spirit and design to the ref storage extension:\n> it can be configured via \"extensions.objectStorage\", has the same syntax\n> with \"<schema>[://<payload>]\", and we have the same mechanisms to\n> configure it (\"--object-storage-format=\", GIT_OBJECT_STORAGE_FORMAT,\n> GIT_DEFAULT_OBJECT_STORAGE_FORMAT, \"init.defaultObjetcStorageFormat\").\n>\n> For now, we only support the \"files\" object storage format, so not a lot\n> of stuff really changes. That being said, its optional payload allows\n> you to configure a different location for the \".git/objects\" directory.\n> So if you specify \"extensions.objectStorage=files://objs\", objects would\n> be stored in \".git/objs\" instead.\n>\n> The series is built on top of c51408889c (The 6th batch, 2026-10-16)\n> with the following dependencies merged into it:\n>\n>   - ps/odb-files-alternates at 0ba59c8453 (odb/source: drop\n>     `read_alternates` callback, 2026-10-08) merged into it.\n>\n>   - ps/setup-enforce-repo-passed-to-create-repository-has-no-state\n>     (phew, what a mouthful) at 0ba59c8453 (odb/source: drop\n>     `read_alternates` callback, 2026-10-08).\n>\n> Note that these two series conflict with one another. The conflict can\n> easily be resolved by just deleting the whole conflicting sections.\n>\n\nI went through the patches since the range-diff was on the larger side.\nApart from some nits, the series looks good. I think we can ignore my\nnits too :)\n\n[snip]\n"},{"id":"556322","messageId":"at8_QLCDRoH0DX4K@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZQ+25HBP5NAOQ+6TKBtNH2gSk-sH8d6DPDmxgGShowvAw@mail.gmail.com","subject":"Re: [PATCH v3 0/7] odb: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-26T11:53:36Z","receivedAt":"2026-10-26T11:53:36Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Oct 26, 2026 at 04:35:27AM -0700, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > Hi,\n> >\n> > this patch series introduces the object storage extension. The extension\n> > is of course similar in spirit and design to the ref storage extension:\n> > it can be configured via \"extensions.objectStorage\", has the same syntax\n> > with \"<schema>[://<payload>]\", and we have the same mechanisms to\n> > configure it (\"--object-storage-format=\", GIT_OBJECT_STORAGE_FORMAT,\n> > GIT_DEFAULT_OBJECT_STORAGE_FORMAT, \"init.defaultObjetcStorageFormat\").\n> >\n> > For now, we only support the \"files\" object storage format, so not a lot\n> > of stuff really changes. That being said, its optional payload allows\n> > you to configure a different location for the \".git/objects\" directory.\n> > So if you specify \"extensions.objectStorage=files://objs\", objects would\n> > be stored in \".git/objs\" instead.\n> >\n> > The series is built on top of c51408889c (The 6th batch, 2026-10-16)\n> > with the following dependencies merged into it:\n> >\n> >   - ps/odb-files-alternates at 0ba59c8453 (odb/source: drop\n> >     `read_alternates` callback, 2026-10-08) merged into it.\n> >\n> >   - ps/setup-enforce-repo-passed-to-create-repository-has-no-state\n> >     (phew, what a mouthful) at 0ba59c8453 (odb/source: drop\n> >     `read_alternates` callback, 2026-10-08).\n> >\n> > Note that these two series conflict with one another. The conflict can\n> > easily be resolved by just deleting the whole conflicting sections.\n> >\n> \n> I went through the patches since the range-diff was on the larger side.\n> Apart from some nits, the series looks good. I think we can ignore my\n> nits too :)\n\nThanks! I'll wait a bit and send out a new version tomorrow morning.\n\nPatrick\n\n"},{"id":"556323","messageId":"at8_RyoMSePPIUyb@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZTwedYbV+vFJcrACohX+epp4hUXSFXYvRTZ1tJPSNaj9A@mail.gmail.com","subject":"Re: [PATCH v3 2/7] setup: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-26T11:53:43Z","receivedAt":"2026-10-26T11:53:43Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Oct 26, 2026 at 04:22:38AM -0700, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > diff --git a/odb.c b/odb.c\n> > index 98c5c862f5..0649622bc6 100644\n> > --- a/odb.c\n> > +++ b/odb.c\n> > @@ -27,6 +27,42 @@\n> >  #include \"trace2.h\"\n> >  #include \"write-or-die.h\"\n> >\n> > +static const char * const object_storage_name_by_format[] = {\n> > +\t[OBJECT_STORAGE_FORMAT_UNKNOWN] = \"unknown\",\n> > +\t[OBJECT_STORAGE_FORMAT_FILES] = \"files\",\n> > +};\n> > +\n> \n> Super Nit: I would have dropped from this, as that is the default, this\n> makes it seem like it is one of the backends. Feel free to ignore\n> though.\n\nHm. I need the `OBJECT_STORAGE_FORMAT_UNKNOWN` enum value anyway, so if\nI were to drop that backend above I'd have to add another special case\nto handle the case where its value is `NULL`. So I'd prefer to keep this\nas-is.\n\n> > diff --git a/repository.h b/repository.h\n> > index 2a348012e8..8c4437762e 100644\n> > --- a/repository.h\n> > +++ b/repository.h\n> > @@ -694,6 +708,7 @@ static enum extension_result handle_extension(const char *var,\n> >  \t\tdata->submodule_path_cfg = git_config_bool(var, value);\n> >  \t\treturn EXTENSION_OK;\n> >  \t}\n> > +\n> \n> Nit: stray newline addition\n\nI was confused at first because you snipped to the wrong diff header --\nthis is in \"setup.c\", not in \"repository.h\". Fixed now.\n\nPatrick\n\n"},{"id":"556324","messageId":"at8_TFBej0ZITu4D@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZTrYBtLOPMh04-J8AkH0797aeKsnXB61H-V8vb1x0r2Jg@mail.gmail.com","subject":"Re: [PATCH v3 3/7] setup: allow overriding object storage format via environment","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-26T11:53:48Z","receivedAt":"2026-10-26T11:53:48Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Oct 26, 2026 at 04:25:11AM -0700, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > diff --git a/setup.c b/setup.c\n> > index 249bd67876..70aa90a9cb 100644\n> > --- a/setup.c\n> > +++ b/setup.c\n> > @@ -2097,6 +2098,21 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n> >  \t\t\t\t\tdie(_(\"unknown ref storage format: '%s'\"), ref_backend_uri);\n> >  \t\t\t}\n> >\n> > +\t\t\t/*\n> > +\t\t\t * Likewise, the GIT_OBJECT_STORAGE_FORMAT environment\n> \n> Really nitpicking today: I would drop the 'Likewise' here as this binds\n> this section of the code to the previous, which may not stay the same\n> over time.\n\nFair, can do.\n\nPatrick\n\n"},{"id":"556428","messageId":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","threadId":"66584","inReplyTo":"20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im","subject":"[PATCH v4 0/7] odb: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-27T06:59:24Z","receivedAt":"2026-10-27T06:59:24Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series introduces the object storage extension. The extension\nis of course similar in spirit and design to the ref storage extension:\nit can be configured via \"extensions.objectStorage\", has the same syntax\nwith \"<schema>[://<payload>]\", and we have the same mechanisms to\nconfigure it (\"--object-storage-format=\", GIT_OBJECT_STORAGE_FORMAT,\nGIT_DEFAULT_OBJECT_STORAGE_FORMAT, \"init.defaultObjetcStorageFormat\").\n\nFor now, we only support the \"files\" object storage format, so not a lot\nof stuff really changes. That being said, its optional payload allows\nyou to configure a different location for the \".git/objects\" directory.\nSo if you specify \"extensions.objectStorage=files://objs\", objects would\nbe stored in \".git/objs\" instead.\n\nThe series is built on top of c51408889c (The 6th batch, 2026-10-16)\nwith the following dependencies merged into it:\n\n  - ps/odb-files-alternates at 0ba59c8453 (odb/source: drop\n    `read_alternates` callback, 2026-10-08) merged into it.\n\n  - ps/setup-enforce-repo-passed-to-create-repository-has-no-state\n    (phew, what a mouthful) at 0ba59c8453 (odb/source: drop\n    `read_alternates` callback, 2026-10-08).\n\nNote that these two series conflict with one another. The conflict can\neasily be resolved by just deleting the whole conflicting sections.\n\nChanges in v4:\n  - Provide some justification for the payload of the \"files\" backend.\n  - Remove stray added newline.\n  - Some comment smithing.\n  - Link to v3: https://patch.msgid.link/20261023-b4-pks-odb-extension-v3-0-b1bb30a006db@pks.im\n\nChanges in v3:\n  - Split up object storage format URI into object storage format and\n    payload. This matches how we do it for the ref storage format and\n    thus brings us much closer to it, where we mostly use the exact same\n    logic. For now though this restricts a couple cases, like for\n    example submodule clones do not pass down payloads to the submodules\n    anymore. This is intentional so that object and ref storage format\n    have the same behaviour.\n  - There's an en explicit `enum object_storage_format` now, matching\n    how we handle this for the ref storage format.\n  - Link to v2: https://patch.msgid.link/20261021-b4-pks-odb-extension-v2-0-8cf11b65eda8@pks.im\n\nChanges in v2:\n  - Ensure that `repo->object_storage_format` is always populated.\n  - Link to v1: https://patch.msgid.link/20261019-b4-pks-odb-extension-v1-0-143a5963b77f@pks.im\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (7):\n      loose: drop unused `repo_write_loose_object_map()`\n      setup: introduce object storage extension\n      setup: allow overriding object storage format via environment\n      builtin: expose the object storage format\n      builtin/init: introduce handling of object storage format\n      builtin/clone: introduce \"--object-storage-format=\"\n      builtin/submodule: propagate \"--object-storage-format=\"\n\n Documentation/config/extensions.adoc       |  23 +++\n Documentation/config/init.adoc             |   5 +\n Documentation/git-clone.adoc               |  11 ++\n Documentation/git-init.adoc                |  10 +-\n Documentation/git-repo.adoc                |   6 +\n Documentation/git-rev-parse.adoc           |   5 +\n Documentation/git-submodule.adoc           |  10 +-\n Documentation/git.adoc                     |  10 ++\n Documentation/object-storage-format.adoc   |   6 +\n builtin/clone.c                            |  63 +++++++-\n builtin/init-db.c                          |   7 +-\n builtin/repo.c                             |  10 ++\n builtin/rev-parse.c                        |   9 ++\n builtin/submodule--helper.c                |  40 +++++\n environment.h                              |   1 +\n git-submodule.sh                           |  18 +++\n loose.c                                    |  46 ------\n loose.h                                    |   1 -\n odb.c                                      |  46 +++++-\n odb.h                                      |  13 ++\n odb/source-files.c                         |   7 +\n odb/source-files.h                         |   1 +\n odb/source.c                               |  14 +-\n odb/source.h                               |   5 +-\n refs.c                                     |   3 +-\n repository.c                               |  10 ++\n repository.h                               |  18 +++\n setup.c                                    | 132 ++++++++++++++++-\n setup.h                                    |   5 +\n t/meson.build                              |   1 +\n t/t0001-init.sh                            | 225 +++++++++++++++++++++++++++++\n t/t1900-repo-info.sh                       |   3 +\n t/t5601-clone.sh                           |  68 +++++++++\n t/t7427-submodule-object-storage-format.sh | 104 +++++++++++++\n t/unit-tests/u-odb-inmemory.c              |   1 +\n 35 files changed, 871 insertions(+), 66 deletions(-)\n\nRange-diff versus v3:\n\n1:  906c3d3e3c3 = 1:  f09fc3200f9 loose: drop unused `repo_write_loose_object_map()`\n2:  3d3bcf0f825 ! 2:  655e1de3b9d setup: introduce object storage extension\n    @@ Commit message\n             allows you to configure a different location for the \".git/objects\"\n             directory.\n     \n    +    Making the location of the \"files\" backend configurable is not he most\n    +    thrilling feature of this new extension. But it gives us a couple of\n    +    advantages:\n    +\n    +      - It allows us to start exercising the payload logic in our tests so\n    +        that we know it's working properly for backends that will need it.\n    +\n    +      - It allows us to easily detect tests that are broken with the new\n    +        extension because they for example assume that an object is a file\n    +        in \".git/objects/\". Testing is not part of this series yet, but will\n    +        be done in subsequent patch series.\n    +\n    +      - It aligns with how we handle the ref storage extension, where we can\n    +        also change its location to an arbitrary path.\n    +\n    +      - It allows for some very esoteric and edge-case-y gimmicks. For\n    +        example, you can initialize a single repository \"skeleton\" and then\n    +        multiplex therein by setting both GIT_REF_STORAGE_FORMAT and\n    +        GIT_OBJECT_STORAGE_FORMAT to point to different databases. These\n    +        edge cases won't matter to many people out there, but we will use\n    +        this for example as a building block for migrations.\n    +\n         Eventually, this mechanism will be used to support alternative backends.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n    @@ setup.c: static enum extension_result handle_extension(const char *var,\n      \t\treturn EXTENSION_OK;\n      \t} else if (!strcmp(ext, \"relativeworktrees\")) {\n      \t\tdata->relative_worktrees = git_config_bool(var, value);\n    -@@ setup.c: static enum extension_result handle_extension(const char *var,\n    - \t\tdata->submodule_path_cfg = git_config_bool(var, value);\n    - \t\treturn EXTENSION_OK;\n    - \t}\n    -+\n    - \treturn EXTENSION_UNKNOWN;\n    - }\n    - \n     @@ setup.c: void clear_repository_format(struct repository_format *format)\n      \tfree(format->work_tree);\n      \tfree(format->partial_clone);\n3:  8c7fcbe8659 ! 3:  9b57baa86f4 setup: allow overriding object storage format via environment\n    @@ setup.c: const char *setup_git_directory_gently(struct repository *repo, int *no\n      \t\t\t}\n      \n     +\t\t\t/*\n    -+\t\t\t * Likewise, the GIT_OBJECT_STORAGE_FORMAT environment\n    -+\t\t\t * variable should override the repository config for\n    ++\t\t\t * The GIT_OBJECT_STORAGE_FORMAT env variable\n    ++\t\t\t * should override the repository config for\n     +\t\t\t * 'extensions.objectStorage'.\n     +\t\t\t */\n     +\t\t\tobject_storage_uri = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT);\n4:  e09beec6d1e = 4:  69f11546357 builtin: expose the object storage format\n5:  7ff9419d250 = 5:  9a3d8abd624 builtin/init: introduce handling of object storage format\n6:  03e119eadbb = 6:  f37be19589a builtin/clone: introduce \"--object-storage-format=\"\n7:  02d33ab036d = 7:  aec7e0f12e8 builtin/submodule: propagate \"--object-storage-format=\"\n\n---\nbase-commit: 0d31382da9336683214372ba328fe9ecbc8bcb9a\nchange-id: 20261006-b4-pks-odb-extension-36de693bb943\n\n\n"},{"id":"556429","messageId":"20261027-b4-pks-odb-extension-v4-1-5d28ca0ea1dc@pks.im","threadId":"66584","inReplyTo":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","subject":"[PATCH v4 1/7] loose: drop unused `repo_write_loose_object_map()`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-27T06:59:25Z","receivedAt":"2026-10-27T06:59:25Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The function `repo_write_loose_object_map()` was introduced in\n23b2c7e95b (loose: add a mapping between SHA-1 and SHA-256 for loose\nobjects, 2023-10-01), but it never had any callers as loose object maps\nare instead written incrementally via `repo_add_loose_object_map()`\nwhenever a new loose object is created.\n\nBesides being dead code, the function also hardcodes the location of the\n\"loose-object-idx\" file as \"$GIT_COMMON_DIR/objects\", whereas both the\nreader and `repo_add_loose_object_map()` derive the location from the\nloose source's path. The function would thus disagree with everyone else\nwhere the loose object map is supposed to be located when the object\ndirectory is using a non-default location.\n\nRemove the function.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n loose.c | 46 ----------------------------------------------\n loose.h |  1 -\n 2 files changed, 47 deletions(-)\n\ndiff --git a/loose.c b/loose.c\nindex d6a2bb5ba3c..7e26a04ec08 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -123,52 +123,6 @@ int repo_read_loose_object_map(struct repository *repo)\n \treturn 0;\n }\n \n-int repo_write_loose_object_map(struct repository *repo)\n-{\n-\tstruct odb_source_files *files = odb_source_files_downcast(repo->objects->source);\n-\tkh_oid_map_t *map = files->dirs->loose->map->to_compat;\n-\tstruct lock_file lock;\n-\tint fd;\n-\tkhiter_t iter;\n-\tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n-\n-\tif (!should_use_loose_object_map(repo))\n-\t\treturn 0;\n-\n-\trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n-\tfd = repo_hold_lock_file_for_update_timeout(repo, &lock, path.buf,\n-\t\t\t\t\t\t    LOCK_DIE_ON_ERROR, -1);\n-\titer = kh_begin(map);\n-\tif (write_in_full(fd, loose_object_header, strlen(loose_object_header)) < 0)\n-\t\tgoto errout;\n-\n-\tfor (; iter != kh_end(map); iter++) {\n-\t\tif (kh_exist(map, iter)) {\n-\t\t\tif (oideq(&kh_key(map, iter), repo->hash_algo->empty_tree) ||\n-\t\t\t    oideq(&kh_key(map, iter), repo->hash_algo->empty_blob))\n-\t\t\t\tcontinue;\n-\t\t\tstrbuf_addf(&buf, \"%s %s\\n\", oid_to_hex(&kh_key(map, iter)), oid_to_hex(kh_value(map, iter)));\n-\t\t\tif (write_in_full(fd, buf.buf, buf.len) < 0)\n-\t\t\t\tgoto errout;\n-\t\t\tstrbuf_reset(&buf);\n-\t\t}\n-\t}\n-\tstrbuf_release(&buf);\n-\tif (commit_lock_file(&lock) < 0) {\n-\t\terror_errno(_(\"could not write loose object index %s\"), path.buf);\n-\t\tstrbuf_release(&path);\n-\t\treturn -1;\n-\t}\n-\tstrbuf_release(&path);\n-\treturn 0;\n-errout:\n-\trollback_lock_file(&lock);\n-\tstrbuf_release(&buf);\n-\terror_errno(_(\"failed to write loose object index %s\"), path.buf);\n-\tstrbuf_release(&path);\n-\treturn -1;\n-}\n-\n static int write_one_object(struct odb_source_loose *loose,\n \t\t\t    const struct object_id *oid,\n \t\t\t    const struct object_id *compat_oid)\ndiff --git a/loose.h b/loose.h\nindex ed663ac550f..41c4b468182 100644\n--- a/loose.h\n+++ b/loose.h\n@@ -22,6 +22,5 @@ int repo_add_loose_object_map(struct odb_source_loose *loose,\n \t\t\t      const struct object_id *oid,\n \t\t\t      const struct object_id *compat_oid);\n int repo_read_loose_object_map(struct repository *repo);\n-int repo_write_loose_object_map(struct repository *repo);\n \n #endif\n\n-- \n2.56.0.341.g393f52fd96.dirty\n\n\n"},{"id":"556430","messageId":"20261027-b4-pks-odb-extension-v4-2-5d28ca0ea1dc@pks.im","threadId":"66584","inReplyTo":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","subject":"[PATCH v4 2/7] setup: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-27T06:59:26Z","receivedAt":"2026-10-27T06:59:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Introduce a new \"extensions.objectStorage\" extension that allows the\nuser to configure the primary object database source of a repository.\nThe value is a URI in the format \"<schema>[://<payload>]\", mirroring\nthe format used by \"extensions.refStorage\":\n\n  - The schema identifies the backend that shall be used. For now the\n    only supported schema is \"files\", which is the existing object\n    database backed by loose objects and packfiles.\n\n  - The payload can be passed to configure the backend, and its\n    interpretation is backend-specific. For the \"files\" backend, it\n    allows you to configure a different location for the \".git/objects\"\n    directory.\n\nMaking the location of the \"files\" backend configurable is not he most\nthrilling feature of this new extension. But it gives us a couple of\nadvantages:\n\n  - It allows us to start exercising the payload logic in our tests so\n    that we know it's working properly for backends that will need it.\n\n  - It allows us to easily detect tests that are broken with the new\n    extension because they for example assume that an object is a file\n    in \".git/objects/\". Testing is not part of this series yet, but will\n    be done in subsequent patch series.\n\n  - It aligns with how we handle the ref storage extension, where we can\n    also change its location to an arbitrary path.\n\n  - It allows for some very esoteric and edge-case-y gimmicks. For\n    example, you can initialize a single repository \"skeleton\" and then\n    multiplex therein by setting both GIT_REF_STORAGE_FORMAT and\n    GIT_OBJECT_STORAGE_FORMAT to point to different databases. These\n    edge cases won't matter to many people out there, but we will use\n    this for example as a building block for migrations.\n\nEventually, this mechanism will be used to support alternative backends.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/config/extensions.adoc     | 23 +++++++++++++++++++\n Documentation/object-storage-format.adoc |  6 +++++\n odb.c                                    | 39 +++++++++++++++++++++++++++++++-\n odb.h                                    | 12 ++++++++++\n odb/source-files.c                       |  7 ++++++\n odb/source-files.h                       |  1 +\n odb/source.c                             | 14 +++++++++++-\n odb/source.h                             |  5 +++-\n repository.c                             | 10 ++++++++\n repository.h                             | 18 +++++++++++++++\n setup.c                                  | 18 +++++++++++++++\n setup.h                                  |  3 +++\n t/t0001-init.sh                          | 30 ++++++++++++++++++++++++\n t/unit-tests/u-odb-inmemory.c            |  1 +\n 14 files changed, 184 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config/extensions.adoc b/Documentation/config/extensions.adoc\nindex be6678bb5b5..4f3a66a4543 100644\n--- a/Documentation/config/extensions.adoc\n+++ b/Documentation/config/extensions.adoc\n@@ -56,6 +56,29 @@ preciousObjects:::\n For historical reasons, this extension is respected regardless of the\n `core.repositoryFormatVersion` setting.\n \n+objectStorage:::\n+\tSpecify the object storage format and a corresponding payload. The\n+\tvalue can be either a format name or a URI:\n++\n+--\n+* A format name alone (e.g., `files`).\n+\n+* A URI format `<format>://<payload>` explicitly specifies both the\n+  format and payload (e.g., `files:///foo/bar`).\n+\n+Supported formats are:\n+\n+include::../object-storage-format.adoc[]\n+\n+--\n++\n+Note that this setting should only be set by linkgit:git-init[1] or\n+linkgit:git-clone[1]. Trying to change it after initialization will make\n+preexisting objects inaccessible.\n++\n+NOTE: This extension is still considered EXPERIMENTAL and may be subject to\n+change.\n+\n refStorage:::\n \tSpecify the ref storage format and a corresponding payload. The value\n \tcan be either a format name or a URI:\ndiff --git a/Documentation/object-storage-format.adoc b/Documentation/object-storage-format.adoc\nnew file mode 100644\nindex 00000000000..4c4aef6dda6\n--- /dev/null\n+++ b/Documentation/object-storage-format.adoc\n@@ -0,0 +1,6 @@\n+`files[://<path>]`;; for loose objects and packfiles. This is the default.\n++\n+The optional payload can be passed to specify an alternative filesystem path\n+where the objects will be stored. Relative paths are resolved relative to the\n+`$GIT_COMMON_DIR`. Defaults to `$GIT_COMMON_DIR/objects` when no payload is\n+provided. The payload is ignored when `GIT_OBJECT_DIRECTORY` is set.\ndiff --git a/odb.c b/odb.c\nindex 98c5c862f56..0649622bc6f 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -27,6 +27,42 @@\n #include \"trace2.h\"\n #include \"write-or-die.h\"\n \n+static const char * const object_storage_name_by_format[] = {\n+\t[OBJECT_STORAGE_FORMAT_UNKNOWN] = \"unknown\",\n+\t[OBJECT_STORAGE_FORMAT_FILES] = \"files\",\n+};\n+\n+enum object_storage_format object_storage_format_by_name(const char *name)\n+{\n+\tfor (size_t i = 0; i < ARRAY_SIZE(object_storage_name_by_format); i++)\n+\t\tif (!strcmp(object_storage_name_by_format[i], name))\n+\t\t\treturn i;\n+\treturn OBJECT_STORAGE_FORMAT_UNKNOWN;\n+}\n+\n+enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload)\n+{\n+\tenum object_storage_format format;\n+\tconst char *schema_end;\n+\tchar *name;\n+\n+\tschema_end = strstr(uri, \"://\");\n+\tif (!schema_end) {\n+\t\tname = xstrdup(uri);\n+\t\tif (payload)\n+\t\t\t*payload = NULL;\n+\t} else {\n+\t\tname = xstrndup(uri, schema_end - uri);\n+\t\tif (payload)\n+\t\t\t*payload = *(schema_end + 3) ? xstrdup(schema_end + 3) : NULL;\n+\t}\n+\n+\tformat = object_storage_format_by_name(name);\n+\n+\tfree(name);\n+\treturn format;\n+}\n+\n int odb_mkstemp(struct object_database *odb,\n \t\tstruct strbuf *temp_filename, const char *pattern)\n {\n@@ -757,7 +793,8 @@ struct object_database *odb_new(struct repository *repo,\n \to->repo = repo;\n \tpthread_mutex_init(&o->replace_mutex, NULL);\n \n-\to->source = odb_source_new(o, flags);\n+\to->source = odb_source_new(o, repo->object_storage_format,\n+\t\t\t\t   repo->object_storage_payload, flags);\n \to->inmemory_objects = &odb_source_inmemory_new(o)->base;\n \n \treturn o;\ndiff --git a/odb.h b/odb.h\nindex 0ccc47ee73f..cb0505334a4 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -6,6 +6,7 @@\n #include \"oid-array.h\"\n #include \"oidset.h\"\n #include \"oidmap.h\"\n+#include \"repository.h\"\n #include \"string-list.h\"\n #include \"thread-utils.h\"\n \n@@ -26,6 +27,17 @@ struct strvec;\n  */\n char *compute_alternate_path(const char *path, struct strbuf *err);\n \n+/*\n+ * Parse the given URI in the format \"<schema>[://<payload>]\" and return the\n+ * object storage format identified by the schema. If `payload` is non-NULL it\n+ * will be set to a newly allocated copy of the payload, or NULL if the URI has\n+ * no or an empty payload. Returns `OBJECT_STORAGE_FORMAT_UNKNOWN` for unknown\n+ * schemas.\n+ */\n+enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload);\n+\n+enum object_storage_format object_storage_format_by_name(const char *name);\n+\n /*\n  * The object database encapsulates access to objects in a repository. It\n  * manages the object source as well as auxiliary data structures required to\ndiff --git a/odb/source-files.c b/odb/source-files.c\nindex 455f409db04..4a7cbbfd9bb 100644\n--- a/odb/source-files.c\n+++ b/odb/source-files.c\n@@ -1235,6 +1235,7 @@ struct odb_files_dir *odb_source_files_find_dir(struct object_database *odb, con\n }\n \n struct odb_source_files *odb_source_files_new(struct object_database *odb,\n+\t\t\t\t\t      const char *payload,\n \t\t\t\t\t      enum odb_new_flags flags)\n {\n \tstruct odb_source_files *files;\n@@ -1245,6 +1246,12 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,\n \t\tobject_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));\n \t\talternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));\n \t}\n+\tif (!object_dir && payload) {\n+\t\tif (is_absolute_path(payload))\n+\t\t\tobject_dir = xstrdup(payload);\n+\t\telse\n+\t\t\tobject_dir = xstrfmt(\"%s/%s\", odb->repo->commondir, payload);\n+\t}\n \tif (!object_dir)\n \t\tobject_dir = xstrfmt(\"%s/objects\", odb->repo->commondir);\n \ndiff --git a/odb/source-files.h b/odb/source-files.h\nindex 837e8903044..71e8db84ff4 100644\n--- a/odb/source-files.h\n+++ b/odb/source-files.h\n@@ -70,6 +70,7 @@ struct odb_source_files {\n \n /* Allocate and initialize a new object source. */\n struct odb_source_files *odb_source_files_new(struct object_database *odb,\n+\t\t\t\t\t      const char *payload,\n \t\t\t\t\t      enum odb_new_flags flags);\n \n /*\ndiff --git a/odb/source.c b/odb/source.c\nindex b25ef14df83..a2a6d97ccd8 100644\n--- a/odb/source.c\n+++ b/odb/source.c\n@@ -24,9 +24,21 @@ const char *odb_source_type_to_name(enum odb_source_type type)\n }\n \n struct odb_source *odb_source_new(struct object_database *odb,\n+\t\t\t\t  enum object_storage_format format,\n+\t\t\t\t  const char *payload,\n \t\t\t\t  enum odb_new_flags flags)\n {\n-\treturn &odb_source_files_new(odb, flags)->base;\n+\tstruct odb_source *source;\n+\n+\tswitch (format) {\n+\tcase OBJECT_STORAGE_FORMAT_FILES:\n+\t\tsource = &odb_source_files_new(odb, payload, flags)->base;\n+\t\tbreak;\n+\tdefault:\n+\t\tBUG(\"unknown object storage format\");\n+\t}\n+\n+\treturn source;\n }\n \n void odb_source_init(struct odb_source *source,\ndiff --git a/odb/source.h b/odb/source.h\nindex 1867347dfcf..1ab32088882 100644\n--- a/odb/source.h\n+++ b/odb/source.h\n@@ -304,9 +304,12 @@ struct odb_source {\n \n /*\n  * Allocate and initialize a new source for the given object database. The path\n- * of the source is derived from repository paths.\n+ * of the source is derived from repository paths or from the object storage\n+ * format.\n  */\n struct odb_source *odb_source_new(struct object_database *odb,\n+\t\t\t\t  enum object_storage_format format,\n+\t\t\t\t  const char *payload,\n \t\t\t\t  enum odb_new_flags flags);\n \n /*\ndiff --git a/repository.c b/repository.c\nindex 970d1818281..77ecf6b604e 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -217,6 +217,15 @@ void repo_set_ref_storage_format(struct repository *repo,\n \trepo->ref_storage_payload = xstrdup_or_null(payload);\n }\n \n+void repo_set_object_storage_format(struct repository *repo,\n+\t\t\t\t    enum object_storage_format format,\n+\t\t\t\t    const char *payload)\n+{\n+\trepo->object_storage_format = format;\n+\tfree(repo->object_storage_payload);\n+\trepo->object_storage_payload = xstrdup_or_null(payload);\n+}\n+\n /*\n  * Attempt to resolve and set the provided 'gitdir' for repository 'repo'.\n  * Return 0 upon success and a non-zero value upon failure.\n@@ -382,6 +391,7 @@ void repo_clear(struct repository *repo)\n \tfree(repo->worktree);\n \tfree(repo->submodule_prefix);\n \tfree(repo->ref_storage_payload);\n+\tfree(repo->object_storage_payload);\n \n \todb_free(repo->objects);\n \ndiff --git a/repository.h b/repository.h\nindex 2a348012e8a..8c4437762e4 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -22,6 +22,11 @@ enum ref_storage_format {\n \tREF_STORAGE_FORMAT_REFTABLE,\n };\n \n+enum object_storage_format {\n+\tOBJECT_STORAGE_FORMAT_UNKNOWN,\n+\tOBJECT_STORAGE_FORMAT_FILES,\n+};\n+\n #ifdef WITH_BREAKING_CHANGES /* Git 3.0 */\n # define REF_STORAGE_FORMAT_DEFAULT REF_STORAGE_FORMAT_REFTABLE\n #else\n@@ -178,6 +183,16 @@ struct repository {\n \t */\n \tchar *ref_storage_payload;\n \n+\t/* Repository's object storage format, as serialized on disk. */\n+\tenum object_storage_format object_storage_format;\n+\n+\t/*\n+\t * Object storage information as needed for the backend. This contains\n+\t * only the payload from the object storage format URI without the\n+\t * schema.\n+\t */\n+\tchar *object_storage_payload;\n+\n \t/* A unique-id for tracing purposes. */\n \tint trace2_repo_id;\n \n@@ -255,6 +270,9 @@ void repo_set_compat_hash_algo(struct repository *repo, uint32_t compat_algo);\n void repo_set_ref_storage_format(struct repository *repo,\n \t\t\t\t enum ref_storage_format format,\n \t\t\t\t const char *payload);\n+void repo_set_object_storage_format(struct repository *repo,\n+\t\t\t\t    enum object_storage_format format,\n+\t\t\t\t    const char *payload);\n void initialize_repository(struct repository *repo);\n RESULT_MUST_BE_USED\n int repo_init(struct repository *r, const char *gitdir, const char *worktree);\ndiff --git a/setup.c b/setup.c\nindex 3ee19f3e3c6..99ead7d90c1 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -686,6 +686,20 @@ static enum extension_result handle_extension(const char *var,\n \t\t\treturn error(_(\"invalid value for '%s': '%s'\"),\n \t\t\t\t     \"extensions.refstorage\", value);\n \t\tdata->ref_storage_format = format;\n+\t\treturn EXTENSION_OK;\n+\t} else if (!strcmp(ext, \"objectstorage\")) {\n+\t\tenum object_storage_format format;\n+\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\n+\t\tFREE_AND_NULL(data->object_storage_payload);\n+\t\tformat = object_storage_format_by_uri(value, &data->object_storage_payload);\n+\t\tif (format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\treturn error(_(\"invalid value for '%s': '%s'\"),\n+\t\t\t\t     \"extensions.objectstorage\", value);\n+\t\tdata->object_storage_format = format;\n+\n \t\treturn EXTENSION_OK;\n \t} else if (!strcmp(ext, \"relativeworktrees\")) {\n \t\tdata->relative_worktrees = git_config_bool(var, value);\n@@ -864,6 +878,7 @@ void clear_repository_format(struct repository_format *format)\n \tfree(format->work_tree);\n \tfree(format->partial_clone);\n \tfree(format->ref_storage_payload);\n+\tfree(format->object_storage_payload);\n \tinit_repository_format(format);\n }\n \n@@ -1786,6 +1801,9 @@ int apply_repository_format(struct repository *repo,\n \trepo_set_ref_storage_format(repo,\n \t\t\t\t    format->ref_storage_format,\n \t\t\t\t    format->ref_storage_payload);\n+\trepo_set_object_storage_format(repo,\n+\t\t\t\t       format->object_storage_format,\n+\t\t\t\t       format->object_storage_payload);\n \trepo->repository_format_worktree_config =\n \t\tformat->worktree_config;\n \trepo->repository_format_submodule_path_cfg =\ndiff --git a/setup.h b/setup.h\nindex 7a3efe5e483..a4afa8910ed 100644\n--- a/setup.h\n+++ b/setup.h\n@@ -190,6 +190,8 @@ struct repository_format {\n \tint compat_hash_algo;\n \tenum ref_storage_format ref_storage_format;\n \tchar *ref_storage_payload;\n+\tenum object_storage_format object_storage_format;\n+\tchar *object_storage_payload;\n \tint sparse_index;\n \tchar *work_tree;\n \tstruct string_list unknown_extensions;\n@@ -207,6 +209,7 @@ struct repository_format {\n \t.is_bare = -1, \\\n \t.hash_algo = GIT_HASH_DEFAULT, \\\n \t.ref_storage_format = REF_STORAGE_FORMAT_FILES, \\\n+\t.object_storage_format = OBJECT_STORAGE_FORMAT_FILES, \\\n \t.unknown_extensions = STRING_LIST_INIT_DUP, \\\n \t.v1_only_extensions = STRING_LIST_INIT_DUP, \\\n }\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex f1d227f2716..c7c464d3a26 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -839,6 +839,36 @@ test_expect_success 'init with --ref-storage-format=garbage' '\n \ttest_cmp expect err\n '\n \n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage is not allowed with repo version 0' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set extensions.objectStorage files &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"repo version is 0, but v1-only extension found\" err\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files backend' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set core.repositoryformatversion 1 &&\n+\tgit -C objstorage config set extensions.objectStorage files &&\n+\ttest_commit -C objstorage A &&\n+\tgit -C objstorage rev-parse --verify HEAD\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\tgit -C objstorage config set core.repositoryformatversion 1 &&\n+\tgit -C objstorage config set extensions.objectStorage garbage &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage${SQ}\" err &&\n+\n+\tgit config --file objstorage/.git/config extensions.objectStorage garbage://payload &&\n+\ttest_must_fail git -C objstorage rev-parse 2>err &&\n+\ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\ndiff --git a/t/unit-tests/u-odb-inmemory.c b/t/unit-tests/u-odb-inmemory.c\nindex a8da278c681..c4412949c12 100644\n--- a/t/unit-tests/u-odb-inmemory.c\n+++ b/t/unit-tests/u-odb-inmemory.c\n@@ -12,6 +12,7 @@\n \n static struct repository repo = {\n \t.hash_algo = &hash_algos[GIT_HASH_SHA1],\n+\t.object_storage_format = OBJECT_STORAGE_FORMAT_FILES,\n };\n static struct object_database *odb;\n \n\n-- \n2.56.0.341.g393f52fd96.dirty\n\n\n"},{"id":"556431","messageId":"20261027-b4-pks-odb-extension-v4-3-5d28ca0ea1dc@pks.im","threadId":"66584","inReplyTo":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","subject":"[PATCH v4 3/7] setup: allow overriding object storage format via environment","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-27T06:59:27Z","receivedAt":"2026-10-27T06:59:27Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format configured via \"extensions.refStorage\" can be\noverridden with the GIT_REF_STORAGE_FORMAT environment variable.\nIntroduce the GIT_OBJECT_STORAGE_FORMAT environment variable that\noverrides \"extensions.objectStorage\" in the same way.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git.adoc |  5 +++++\n environment.h          |  1 +\n setup.c                | 16 ++++++++++++++++\n t/t0001-init.sh        | 26 ++++++++++++++++++++++++++\n 4 files changed, 48 insertions(+)\n\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 3abb4701c30..34812131bb0 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -609,6 +609,11 @@ double-quotes and respecting backslash escapes. E.g., the value\n `GIT_REFERENCE_BACKEND`::\n \tDeprecated alias of `GIT_REF_STORAGE_FORMAT`.\n \n+`GIT_OBJECT_STORAGE_FORMAT`::\n+\tSpecify which object storage format to use along with its URI.\n+\tSee `extensions.objectStorage` option in linkgit:git-config[1] for more\n+\tdetails. Overrides the config variable when used.\n+\n Git Commits\n ~~~~~~~~~~~\n `GIT_AUTHOR_NAME`::\ndiff --git a/environment.h b/environment.h\nindex b336459e901..c26ef92b529 100644\n--- a/environment.h\n+++ b/environment.h\n@@ -45,6 +45,7 @@\n #define GIT_ATTR_SOURCE_ENVIRONMENT \"GIT_ATTR_SOURCE\"\n #define GIT_REFERENCE_BACKEND_ENVIRONMENT \"GIT_REFERENCE_BACKEND\"\n #define GIT_REF_STORAGE_FORMAT_ENVIRONMENT \"GIT_REF_STORAGE_FORMAT\"\n+#define GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT \"GIT_OBJECT_STORAGE_FORMAT\"\n \n /*\n  * Environment variable used to propagate the --no-advice global option to the\ndiff --git a/setup.c b/setup.c\nindex 99ead7d90c1..5580aaa10e1 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2078,6 +2078,7 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \n \t\tif (startup_info->have_repository) {\n \t\t\tstruct strbuf err = STRBUF_INIT;\n+\t\t\tconst char *object_storage_uri;\n \t\t\tconst char *ref_backend_uri;\n \n \t\t\t/*\n@@ -2096,6 +2097,21 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \t\t\t\t\tdie(_(\"unknown ref storage format: '%s'\"), ref_backend_uri);\n \t\t\t}\n \n+\t\t\t/*\n+\t\t\t * The GIT_OBJECT_STORAGE_FORMAT env variable\n+\t\t\t * should override the repository config for\n+\t\t\t * 'extensions.objectStorage'.\n+\t\t\t */\n+\t\t\tobject_storage_uri = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT);\n+\t\t\tif (object_storage_uri) {\n+\t\t\t\tFREE_AND_NULL(discovery.format.object_storage_payload);\n+\t\t\t\tdiscovery.format.object_storage_format =\n+\t\t\t\t\tobject_storage_format_by_uri(object_storage_uri,\n+\t\t\t\t\t\t\t\t     &discovery.format.object_storage_payload);\n+\t\t\t\tif (discovery.format.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\t\t\tdie(_(\"unknown object storage format: '%s'\"), object_storage_uri);\n+\t\t\t}\n+\n \t\t\tif (apply_repository_format(repo, &discovery.format,\n \t\t\t\t\t\t    APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n \t\t\t\tdie(\"%s\", err.buf);\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex c7c464d3a26..5e7c25e42cc 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -869,6 +869,32 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown b\n \ttest_grep \"invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}\" err\n '\n \n+test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides extensions.objectStorage' '\n+\ttest_when_finished \"rm -rf objstorage\" &&\n+\tgit init objstorage &&\n+\t(\n+\t\tcd objstorage &&\n+\t\tgit config set core.repositoryformatversion 1 &&\n+\t\tgit config set extensions.objectStorage files://objs &&\n+\t\tmkdir .git/objs .git/other &&\n+\n+\t\techo content >file &&\n+\t\toid=$(git hash-object -w file) &&\n+\t\ttest_path_is_file .git/objs/$(test_oid_to_path \"$oid\") &&\n+\t\tgit cat-file -e \"$oid\" &&\n+\n+\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://other git cat-file -e \"$oid\" &&\n+\t\tGIT_OBJECT_STORAGE_FORMAT=files://other git hash-object -w file &&\n+\t\ttest_path_is_file .git/other/$(test_oid_to_path \"$oid\") &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\tfatal: unknown object storage format: ${SQ}garbage${SQ}\n+\t\tEOF\n+\t\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git rev-parse 2>err &&\n+\t\ttest_cmp expect err\n+\t)\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.341.g393f52fd96.dirty\n\n\n"},{"id":"556432","messageId":"20261027-b4-pks-odb-extension-v4-4-5d28ca0ea1dc@pks.im","threadId":"66584","inReplyTo":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","subject":"[PATCH v4 4/7] builtin: expose the object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-27T06:59:28Z","receivedAt":"2026-10-27T06:59:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format of a repository can be inspected via both\ngit-rev-parse(1)'s \"--show-ref-storage-format\" and git-repo(1)'s\n\"references.storageFormat\" field. Introduce the equivalent options for\nthe object storage format, as well.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-repo.adoc      |  6 ++++++\n Documentation/git-rev-parse.adoc |  5 +++++\n builtin/repo.c                   | 10 ++++++++++\n builtin/rev-parse.c              |  9 +++++++++\n odb.c                            |  7 +++++++\n odb.h                            |  1 +\n t/t0001-init.sh                  |  5 ++++-\n t/t1900-repo-info.sh             |  3 +++\n 8 files changed, 45 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex cb8c1e72927..d2dc9b7a69b 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -105,6 +105,12 @@ values that they return:\n `object.format`::\n \tThe object format (hash algorithm) used in the repository.\n \n+`objects.storageFormat`::\n+\tThe object storage format used in the repository, as configured via\n+\t`extensions.objectStorage`. The valid values are:\n++\n+include::object-storage-format.adoc[]\n+\n `path.commondir.absolute`::\n \tThe canonical absolute path to the Git repository's common\n \tdirectory (the shared `.git` directory containing objects,\ndiff --git a/Documentation/git-rev-parse.adoc b/Documentation/git-rev-parse.adoc\nindex 5b866af66a1..9103d54d53d 100644\n--- a/Documentation/git-rev-parse.adoc\n+++ b/Documentation/git-rev-parse.adoc\n@@ -338,6 +338,11 @@ The following options are unaffected by `--path-format`:\n --show-ref-format::\n \tDeprecated alias of `--show-ref-storage-format`.\n \n+--show-object-storage-format::\n+\tShow the object storage format used for the repository. Prints the\n+\tvalue of `extensions.objectStorage`, or `files` when the extension is\n+\tnot set.\n+\n \n Other Options\n ~~~~~~~~~~~~~\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 84e012f83f6..b73dff898f1 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -128,11 +128,21 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_object_storage_format(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf,\n+\t\t      object_storage_format_to_name(repo->object_storage_format));\n+\tif (repo->object_storage_payload)\n+\t\tstrbuf_addf(buf, \"://%s\", repo->object_storage_payload);\n+\treturn 0;\n+}\n+\n /* repo_info_field keys must be in lexicographical order */\n static const struct repo_info_field repo_info_field[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n \t{ \"object.format\", get_object_format },\n+\t{ \"objects.storageFormat\", get_object_storage_format },\n \t{ \"path.commondir.absolute\", get_path_commondir_absolute },\n \t{ \"path.commondir.relative\", get_path_commondir_relative },\n \t{ \"path.gitdir.absolute\", get_path_gitdir_absolute },\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex ec33c19bdfc..d2154eac8d2 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -17,6 +17,7 @@\n #include \"gettext.h\"\n #include \"hash.h\"\n #include \"hex.h\"\n+#include \"odb.h\"\n #include \"refs.h\"\n #include \"quote.h\"\n #include \"object-name.h\"\n@@ -1138,6 +1139,14 @@ int cmd_rev_parse(int argc,\n \t\t\t\tputs(ref_storage_format_to_name(the_repository->ref_storage_format));\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--show-object-storage-format\")) {\n+\t\t\t\tconst char *format = object_storage_format_to_name(the_repository->object_storage_format);\n+\t\t\t\tif (the_repository->object_storage_payload)\n+\t\t\t\t\tprintf(\"%s://%s\\n\", format, the_repository->object_storage_payload);\n+\t\t\t\telse\n+\t\t\t\t\tputs(format);\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--end-of-options\")) {\n \t\t\t\tseen_end_of_options = 1;\n \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\ndiff --git a/odb.c b/odb.c\nindex 0649622bc6f..a0866e6c889 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -40,6 +40,13 @@ enum object_storage_format object_storage_format_by_name(const char *name)\n \treturn OBJECT_STORAGE_FORMAT_UNKNOWN;\n }\n \n+const char *object_storage_format_to_name(enum object_storage_format format)\n+{\n+\tif (format < 0 || format >= ARRAY_SIZE(object_storage_name_by_format))\n+\t\tformat = OBJECT_STORAGE_FORMAT_UNKNOWN;\n+\treturn object_storage_name_by_format[format];\n+}\n+\n enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload)\n {\n \tenum object_storage_format format;\ndiff --git a/odb.h b/odb.h\nindex cb0505334a4..1340f606327 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -37,6 +37,7 @@ char *compute_alternate_path(const char *path, struct strbuf *err);\n enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload);\n \n enum object_storage_format object_storage_format_by_name(const char *name);\n+const char *object_storage_format_to_name(enum object_storage_format format);\n \n /*\n  * The object database encapsulates access to objects in a repository. It\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 5e7c25e42cc..d080ab04a82 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -853,7 +853,10 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files bac\n \tgit -C objstorage config set core.repositoryformatversion 1 &&\n \tgit -C objstorage config set extensions.objectStorage files &&\n \ttest_commit -C objstorage A &&\n-\tgit -C objstorage rev-parse --verify HEAD\n+\tgit -C objstorage rev-parse --verify HEAD &&\n+\techo files >expect &&\n+\tgit -C objstorage rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' '\ndiff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh\nindex d115d2d9f98..493a78f2302 100755\n--- a/t/t1900-repo-info.sh\n+++ b/t/t1900-repo-info.sh\n@@ -69,6 +69,9 @@ test_repo_info 'object.format = sha1 is retrieved correctly' \\\n test_repo_info 'object.format = sha256 is retrieved correctly' \\\n \t'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'\n \n+test_repo_info 'objects.storageFormat = files is retrieved correctly' \\\n+\t'git init' 'objects-files' 'objects.storageFormat' 'files'\n+\n test_expect_success 'values returned in order requested' '\n \tcat >expect <<-\\EOF &&\n \tlayout.bare=false\n\n-- \n2.56.0.341.g393f52fd96.dirty\n\n\n"},{"id":"556433","messageId":"20261027-b4-pks-odb-extension-v4-5-5d28ca0ea1dc@pks.im","threadId":"66584","inReplyTo":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","subject":"[PATCH v4 5/7] builtin/init: introduce handling of object storage format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-27T06:59:29Z","receivedAt":"2026-10-27T06:59:29Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"While the object storage format extension can already be configured\nmanually via git-config(1), this isn't exactly an ergonomic way of doing\nso. For the reference storage format extension, users have a host of\noptions available to them.\n\nIntroduce the equivalent options for the object storage format.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/config/init.adoc |   5 ++\n Documentation/git-init.adoc    |  10 ++-\n Documentation/git.adoc         |   5 ++\n builtin/clone.c                |   9 ++-\n builtin/init-db.c              |   7 +-\n refs.c                         |   3 +-\n setup.c                        |  98 ++++++++++++++++++++++--\n setup.h                        |   2 +\n t/t0001-init.sh                | 166 +++++++++++++++++++++++++++++++++++++++++\n 9 files changed, 293 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/config/init.adoc b/Documentation/config/init.adoc\nindex e45bd692dbc..dbd9c663ee3 100644\n--- a/Documentation/config/init.adoc\n+++ b/Documentation/config/init.adoc\n@@ -20,6 +20,11 @@ endif::[]\n \tprecedence over this config.\n `init.defaultRefFormat`::\n \tDeprecated alias of `init.defaultRefStorageFormat`.\n+`init.defaultObjectStorageFormat`::\n+\tAllows overriding the default object storage format for new\n+\trepositories. See `--object-storage-format=` in linkgit:git-init[1].\n+\tBoth the command line option and the `GIT_DEFAULT_OBJECT_STORAGE_FORMAT`\n+\tenvironment variable take precedence over this config.\n \n init.defaultSubmodulePathConfig::\n \tA boolean that specifies if `git init` and `git clone` should\ndiff --git a/Documentation/git-init.adoc b/Documentation/git-init.adoc\nindex b02af22ad11..9e022a7ba8b 100644\n--- a/Documentation/git-init.adoc\n+++ b/Documentation/git-init.adoc\n@@ -11,7 +11,7 @@ SYNOPSIS\n [synopsis]\n git init [-q | --quiet] [--bare] [--template=<template-directory>]\n \t [--separate-git-dir <git-dir>] [--object-format=<format>]\n-\t [--ref-storage-format=<format>]\n+\t [--ref-storage-format=<format>] [--object-storage-format=<format>]\n \t [-b <branch-name> | --initial-branch=<branch-name>]\n \t [--shared[=<permissions>]] [<directory>]\n \n@@ -68,6 +68,14 @@ include::ref-storage-format.adoc[]\n `--ref-format=<format>`::\n Deprecated alias of `--ref-storage-format=<format>`.\n \n+`--object-storage-format=<format>`::\n+Specify the given object storage _<format>_ for the repository. Backends that\n+require additional configuration accept a payload in the form\n+`<format>://<payload>`, for example a path or a connection string identifying\n+the database that shall store the objects. The valid values are:\n++\n+include::object-storage-format.adoc[]\n+\n `--template=<template-directory>`::\n Specify the directory from which templates will be used.  (See the \"TEMPLATE\n DIRECTORY\" section below.)\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 34812131bb0..67de5646f08 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -609,6 +609,11 @@ double-quotes and respecting backslash escapes. E.g., the value\n `GIT_REFERENCE_BACKEND`::\n \tDeprecated alias of `GIT_REF_STORAGE_FORMAT`.\n \n+`GIT_DEFAULT_OBJECT_STORAGE_FORMAT`::\n+\tIf this variable is set, the default object storage format for new\n+\trepositories will be set to this value. The default is \"files\".\n+\tSee `--object-storage-format` in linkgit:git-init[1].\n+\n `GIT_OBJECT_STORAGE_FORMAT`::\n \tSpecify which object storage format to use along with its URI.\n \tSee `extensions.objectStorage` option in linkgit:git-config[1] for more\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 6047501dfc7..95e641b1a49 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -1214,7 +1214,7 @@ int cmd_clone(int argc,\n \t */\n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n \t\t\t  option_template, GIT_HASH_UNKNOWN, ref_storage_format_uri,\n-\t\t\t  do_not_override_repo_unix_permissions, NULL);\n+\t\t\t  NULL, do_not_override_repo_unix_permissions, NULL);\n \n \tif (real_git_dir) {\n \t\tfree((char *)git_dir);\n@@ -1256,7 +1256,8 @@ int cmd_clone(int argc,\n \t * This is sufficient for Git commands to discover the Git directory.\n \t */\n \tinitialize_repository_version(the_repository, GIT_HASH_UNKNOWN,\n-\t\t\t\t      the_repository->ref_storage_format, 1);\n+\t\t\t\t      the_repository->ref_storage_format,\n+\t\t\t\t      the_repository->object_storage_format, 1);\n \n \trefs_create_refdir_stubs(the_repository, git_dir, NULL);\n \n@@ -1468,7 +1469,9 @@ int cmd_clone(int argc,\n \t * ours to the same thing.\n \t */\n \thash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n-\tinitialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);\n+\tinitialize_repository_version(the_repository, hash_algo,\n+\t\t\t\t      the_repository->ref_storage_format,\n+\t\t\t\t      the_repository->object_storage_format, 1);\n \trepo_set_hash_algo(the_repository, hash_algo);\n \tcreate_reference_database(the_repository, NULL, 1);\n \tstartup_info->have_repository = 1;\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 0abdbca8e93..71b748f2f24 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -57,7 +57,7 @@ static int shared_callback(const struct option *opt, const char *arg, int unset)\n static const char *const init_db_usage[] = {\n \tN_(\"git init [-q | --quiet] [--bare] [--template=<template-directory>]\\n\"\n \t   \"         [--separate-git-dir <git-dir>] [--object-format=<format>]\\n\"\n-\t   \"         [--ref-storage-format=<format>]\\n\"\n+\t   \"         [--ref-storage-format=<format>] [--object-storage-format=<format>]\\n\"\n \t   \"         [-b <branch-name> | --initial-branch=<branch-name>]\\n\"\n \t   \"         [--shared[=<permissions>]] [<directory>]\"),\n \tNULL\n@@ -84,6 +84,7 @@ int cmd_init_db(int argc,\n \tint bare = startup_info->force_bare_repository ? 1 : -1;\n \tconst char *object_format = NULL;\n \tconst char *ref_storage_format_uri = NULL;\n+\tconst char *object_storage_format_uri = NULL;\n \tconst char *initial_branch = NULL;\n \tint hash_algo = GIT_HASH_UNKNOWN;\n \tint init_shared_repository = -1;\n@@ -111,6 +112,8 @@ int cmd_init_db(int argc,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format_uri, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format_uri, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_END()\n \t};\n \tint reinit;\n@@ -232,7 +235,7 @@ int cmd_init_db(int argc,\n \n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n \t\t\t  template_dir, hash_algo, ref_storage_format_uri,\n-\t\t\t  init_shared_repository, &reinit);\n+\t\t\t  object_storage_format_uri, init_shared_repository, &reinit);\n \tcreate_reference_database(the_repository, initial_branch, quiet);\n \tcreate_object_database(the_repository, NULL);\n \ndiff --git a/refs.c b/refs.c\nindex 951db56113d..3f7458332e4 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -3521,7 +3521,8 @@ int repo_migrate_ref_storage_format(struct repository *repo,\n \t * repository format so that clients will use the new ref store.\n \t * We also need to swap out the repository's main ref store.\n \t */\n-\tinitialize_repository_version(repo, hash_algo_by_ptr(repo->hash_algo), format, 1);\n+\tinitialize_repository_version(repo, hash_algo_by_ptr(repo->hash_algo), format,\n+\t\t\t\t      repo->object_storage_format, 1);\n \n \t/*\n \t * Unset the old ref store and release it. `get_main_ref_store()` will\ndiff --git a/setup.c b/setup.c\nindex 5580aaa10e1..6473c62fa4b 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2458,6 +2458,7 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)\n void initialize_repository_version(struct repository *repo,\n \t\t\t\t   int hash_algo,\n \t\t\t\t   enum ref_storage_format ref_storage_format,\n+\t\t\t\t   enum object_storage_format object_storage_format,\n \t\t\t\t   int reinit)\n {\n \tstruct strbuf repo_version = STRBUF_INIT;\n@@ -2473,7 +2474,9 @@ void initialize_repository_version(struct repository *repo,\n \t */\n \tif (hash_algo != GIT_HASH_SHA1_LEGACY ||\n \t    ref_storage_format != REF_STORAGE_FORMAT_FILES ||\n-\t    repo->ref_storage_payload)\n+\t    repo->ref_storage_payload ||\n+\t    object_storage_format != OBJECT_STORAGE_FORMAT_FILES ||\n+\t    repo->object_storage_payload)\n \t\ttarget_version = GIT_REPO_VERSION_READ;\n \n \tif (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)\n@@ -2497,6 +2500,22 @@ void initialize_repository_version(struct repository *repo,\n \t\trepo_config_set_gently(repo, \"extensions.refstorage\", NULL);\n \t}\n \n+\tif (repo->object_storage_payload) {\n+\t\tstruct strbuf uri = STRBUF_INIT;\n+\n+\t\tstrbuf_addf(&uri, \"%s://%s\",\n+\t\t\t    object_storage_format_to_name(object_storage_format),\n+\t\t\t    repo->object_storage_payload);\n+\t\trepo_config_set(repo, \"extensions.objectstorage\", uri.buf);\n+\n+\t\tstrbuf_release(&uri);\n+\t} else if (object_storage_format != OBJECT_STORAGE_FORMAT_FILES) {\n+\t\trepo_config_set(repo, \"extensions.objectstorage\",\n+\t\t\t\tobject_storage_format_to_name(object_storage_format));\n+\t} else if (reinit) {\n+\t\trepo_config_set_gently(repo, \"extensions.objectstorage\", NULL);\n+\t}\n+\n \tif (reinit) {\n \t\tstruct strbuf config = STRBUF_INIT;\n \t\tstruct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;\n@@ -2623,7 +2642,8 @@ static int create_default_files(struct repository *repo,\n \t\tadjust_shared_perm(repo, repo_get_git_dir(repo));\n \t}\n \n-\tinitialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format, reinit);\n+\tinitialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format,\n+\t\t\t\t      fmt->object_storage_format, reinit);\n \n \t/* Check filemode trustability */\n \trepo_git_path_replace(repo, &path, \"config\");\n@@ -2733,6 +2753,7 @@ static void separate_git_dir(struct repository *repo,\n struct default_format_config {\n \tint hash;\n \tenum ref_storage_format ref_storage_format;\n+\tenum object_storage_format object_storage_format;\n };\n \n static int read_default_format_config(const char *key, const char *value,\n@@ -2764,6 +2785,16 @@ static int read_default_format_config(const char *key, const char *value,\n \t\tgoto out;\n \t}\n \n+\tif (!strcmp(key, \"init.defaultobjectstorageformat\")) {\n+\t\tret = git_config_string(&str, key, value);\n+\t\tif (ret)\n+\t\t\tgoto out;\n+\t\tcfg->object_storage_format = object_storage_format_by_name(str);\n+\t\tif (cfg->object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\twarning(_(\"unknown object storage format '%s'\"), str);\n+\t\tgoto out;\n+\t}\n+\n \t/*\n \t * Enable the reftable format when \"features.experimental\" is enabled.\n \t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n@@ -2784,7 +2815,8 @@ static int read_default_format_config(const char *key, const char *value,\n \n static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t\t\t\tint hash,\n-\t\t\t\t\tconst char *ref_storage_format_uri)\n+\t\t\t\t\tconst char *ref_storage_format_uri,\n+\t\t\t\t\tconst char *object_storage_uri)\n {\n \tstruct default_format_config cfg = {\n \t\t.hash = GIT_HASH_UNKNOWN,\n@@ -2795,7 +2827,9 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t.ignore_repo = 1,\n \t\t.ignore_worktree = 1,\n \t};\n+\tenum object_storage_format object_storage_format;\n \tenum ref_storage_format ref_storage_format;\n+\tchar *object_storage_payload = NULL;\n \tchar *ref_storage_payload = NULL;\n \tconst char *env;\n \n@@ -2884,9 +2918,52 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\tref_storage_format = REF_STORAGE_FORMAT_DEFAULT;\n \t}\n \n+\t/*\n+\t * Determine the object storage format, with the same precedence as\n+\t * for the ref storage format:\n+\t *\n+\t *   1. The format specified via the command line.\n+\t *\n+\t *   2. The format specified via \"GIT_OBJECT_STORAGE_FORMAT\".\n+\t *\n+\t *   3. The format of a preexisting repository when reinitializing.\n+\t *\n+\t *   4. The default format for new repositories as configured via\n+\t *      \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\".\n+\t *\n+\t *   5. The default format for new repositories as configured via\n+\t *      \"init.defaultObjectStorageFormat\".\n+\t *\n+\t *   6. The \"files\" format.\n+\t */\n+\tif (object_storage_uri) {\n+\t\tobject_storage_format = object_storage_format_by_uri(object_storage_uri,\n+\t\t\t\t\t\t\t\t     &object_storage_payload);\n+\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via command line: '%s'\"),\n+\t\t\t    object_storage_uri);\n+\t} else if ((env = getenv(GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT))) {\n+\t\tobject_storage_format = object_storage_format_by_uri(env, &object_storage_payload);\n+\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n+\t\t\t    GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT, env);\n+\t} else if (repo_fmt->version >= 0) {\n+\t\tobject_storage_format = repo_fmt->object_storage_format;\n+\t\tobject_storage_payload = xstrdup_or_null(repo_fmt->object_storage_payload);\n+\t} else if ((env = getenv(\"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\"))) {\n+\t\tobject_storage_format = object_storage_format_by_name(env);\n+\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format specified via %s: '%s'\"),\n+\t\t\t    \"GIT_DEFAULT_OBJECT_STORAGE_FORMAT\", env);\n+\t} else if (cfg.object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN) {\n+\t\tobject_storage_format = cfg.object_storage_format;\n+\t} else {\n+\t\tobject_storage_format = OBJECT_STORAGE_FORMAT_FILES;\n+\t}\n+\n \t/*\n \t * If we have a preexisting repository we need to verify that its\n-\t * current ref storage format does not change.\n+\t * current storage formats do not change.\n \t */\n \tif (repo_fmt->version >= 0) {\n \t\tif (ref_storage_format != repo_fmt->ref_storage_format)\n@@ -2895,11 +2972,21 @@ static void repository_format_configure(struct repository_format *repo_fmt,\n \t\t    strcmp(ref_storage_payload ? ref_storage_payload : \"\",\n \t\t\t   repo_fmt->ref_storage_payload ? repo_fmt->ref_storage_payload : \"\"))\n \t\t\tdie(_(\"attempt to reinitialize repository with different reference storage payload\"));\n+\t\tif (object_storage_format != repo_fmt->object_storage_format)\n+\t\t\tdie(_(\"attempt to reinitialize repository with different object storage format\"));\n+\t\tif ((object_storage_payload || repo_fmt->object_storage_payload) &&\n+\t\t    strcmp(object_storage_payload ? object_storage_payload : \"\",\n+\t\t\t   repo_fmt->object_storage_payload ? repo_fmt->object_storage_payload : \"\"))\n+\t\t\tdie(_(\"attempt to reinitialize repository with different object storage payload\"));\n \t}\n \n \tfree(repo_fmt->ref_storage_payload);\n \trepo_fmt->ref_storage_format = ref_storage_format;\n \trepo_fmt->ref_storage_payload = ref_storage_payload;\n+\n+\tfree(repo_fmt->object_storage_payload);\n+\trepo_fmt->object_storage_format = object_storage_format;\n+\trepo_fmt->object_storage_payload = object_storage_payload;\n }\n \n void create_repository(struct repository *repo,\n@@ -2909,6 +2996,7 @@ void create_repository(struct repository *repo,\n \t\t       const char *template_dir,\n \t\t       int hash,\n \t\t       const char *ref_storage_format_uri,\n+\t\t       const char *object_storage_format_uri,\n \t\t       int init_shared_repository,\n \t\t       int *reinit_ok)\n {\n@@ -2947,7 +3035,7 @@ void create_repository(struct repository *repo,\n \t * is an attempt to reinitialize new repository with an old tool.\n \t */\n \tread_and_verify_repository_format(&repo_fmt, repo_get_git_dir(repo), NULL);\n-\trepository_format_configure(&repo_fmt, hash, ref_storage_format_uri);\n+\trepository_format_configure(&repo_fmt, hash, ref_storage_format_uri, object_storage_format_uri);\n \tif (apply_repository_format(repo, &repo_fmt, APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)\n \t\tdie(\"%s\", err.buf);\n \ndiff --git a/setup.h b/setup.h\nindex a4afa8910ed..829b63228ed 100644\n--- a/setup.h\n+++ b/setup.h\n@@ -277,12 +277,14 @@ void create_repository(struct repository *repo,\n \t\t       const char *template_dir,\n \t\t       int hash_algo,\n \t\t       const char *ref_storage_format_uri,\n+\t\t       const char *object_storage_format_uri,\n \t\t       int init_shared_repository,\n \t\t       int *reinit_ok);\n \n void initialize_repository_version(struct repository *repo,\n \t\t\t\t   int hash_algo,\n \t\t\t\t   enum ref_storage_format ref_storage_format,\n+\t\t\t\t   enum object_storage_format object_storage_format,\n \t\t\t\t   int reinit);\n \n /*\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex d080ab04a82..23317e0733a 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -898,6 +898,172 @@ test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides ext\n \t)\n '\n \n+test_expect_success 'init with --object-storage-format=files does not set extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files objformat &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\tif test_have_prereq DEFAULT_REPO_FORMAT\n+\tthen\n+\t\techo 0 >expect &&\n+\t\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\t\ttest_cmp expect actual\n+\tfi\n+'\n+\n+test_expect_success 'init with --object-storage-format=files:// does not set extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files:// objformat &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with --object-storage-format=files://<relative-path>' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat config get extensions.objectstorage >actual &&\n+\ttest_cmp expect actual &&\n+\techo 1 >expect &&\n+\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\ttest_cmp expect actual &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual &&\n+\ttest_path_is_dir objformat/.git/objects &&\n+\ttest_path_is_dir objformat/.git/objs &&\n+\ttest_commit -C objformat A &&\n+\tgit -C objformat rev-parse --verify HEAD &&\n+\ttest_path_is_missing objformat/.git/objects/pack &&\n+\ttest_path_is_dir objformat/.git/objs/pack\n+'\n+\n+test_expect_success 'init with --object-storage-format=files://<absolute-path>' '\n+\ttest_when_finished \"rm -rf objformat objdir\" &&\n+\tgit init --object-storage-format=files://\"$(pwd)/objdir\" objformat &&\n+\techo \"files://$(pwd)/objdir\" >expect &&\n+\tgit -C objformat config get extensions.objectstorage >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_commit -C objformat A &&\n+\tgit -C objformat rev-parse --verify HEAD &&\n+\ttest_path_is_dir objdir/pack\n+'\n+\n+test_expect_success 'GIT_OBJECT_DIRECTORY takes precedence over extensions.objectStorage payload' '\n+\ttest_when_finished \"rm -rf objformat objdir\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\ttest_commit -C objformat A &&\n+\tmkdir objdir &&\n+\ttest_must_fail env GIT_DIR=\"$PWD/objformat/.git\" GIT_OBJECT_DIRECTORY=\"$PWD/objdir\" \\\n+\t\tgit cat-file -e HEAD &&\n+\tGIT_DIR=\"$PWD/objformat/.git\" GIT_OBJECT_DIRECTORY=\"$PWD/objdir\" \\\n+\t\tgit hash-object -w objformat/A.t >oid &&\n+\ttest_path_is_file objdir/$(test_oid_to_path \"$(cat oid)\")\n+'\n+\n+test_expect_success 'init with --object-storage-format=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via command line: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git init --object-storage-format=garbage objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'init with GIT_DEFAULT_OBJECT_STORAGE_FORMAT=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via GIT_DEFAULT_OBJECT_STORAGE_FORMAT: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail env GIT_DEFAULT_OBJECT_STORAGE_FORMAT=garbage git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'init with GIT_OBJECT_STORAGE_FORMAT=garbage' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format specified via GIT_OBJECT_STORAGE_FORMAT: ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=garbage git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'GIT_OBJECT_STORAGE_FORMAT takes precedence over default' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_DEFAULT_OBJECT_STORAGE_FORMAT=files://default \\\n+\tGIT_OBJECT_STORAGE_FORMAT=files://explicit git init objformat &&\n+\techo files://explicit >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '--object-storage-format= takes precedence over environment' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tGIT_OBJECT_STORAGE_FORMAT=files://explicit \\\n+\tgit init --object-storage-format=files://cmdline objformat &&\n+\techo files://cmdline >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 're-init refuses with different storage format' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files objformat &&\n+\tcat >expect <<-EOF &&\n+\tfatal: attempt to reinitialize repository with different object storage payload\n+\tEOF\n+\ttest_must_fail env GIT_OBJECT_STORAGE_FORMAT=files://objs git init objformat 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 're-init with same object storage format' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\tgit init --object-storage-format=files://objs objformat &&\n+\tgit init objformat &&\n+\techo files://objs >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success DEFAULT_REPO_FORMAT 're-init with default object storage format drops extension' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\n+\tgit init objformat &&\n+\tgit -C objformat config set core.repositoryformatversion 1 &&\n+\tgit -C objformat config set extensions.objectstorage files &&\n+\n+\tgit init --object-storage-format=files objformat &&\n+\techo 0 >expect &&\n+\tgit -C objformat config get core.repositoryformatversion >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_must_fail git -C objformat config get extensions.objectstorage\n+'\n+\n+test_expect_success 'init warns about invalid init.defaultObjectStorageFormat' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\ttest_config_global init.defaultObjectStorageFormat garbage &&\n+\techo \"warning: unknown object storage format ${SQ}garbage${SQ}\" >expect &&\n+\tgit init objformat 2>err &&\n+\ttest_cmp expect err &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init with init.defaultObjectStorageFormat' '\n+\ttest_when_finished \"rm -rf objformat\" &&\n+\ttest_config_global init.defaultObjectStorageFormat files &&\n+\tgit init objformat &&\n+\techo files >expect &&\n+\tgit -C objformat rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success MINGW 'core.hidedotfiles = false' '\n \tgit config --global core.hidedotfiles false &&\n \trm -rf newdir &&\n\n-- \n2.56.0.341.g393f52fd96.dirty\n\n\n"},{"id":"556434","messageId":"20261027-b4-pks-odb-extension-v4-6-5d28ca0ea1dc@pks.im","threadId":"66584","inReplyTo":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","subject":"[PATCH v4 6/7] builtin/clone: introduce \"--object-storage-format=\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-27T06:59:30Z","receivedAt":"2026-10-27T06:59:30Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Wire up the new object storage format in git-clone(1) via a new\n`--object-storage-format=` option, same as we have introduced in the\npreceding commit for git-init(1).\n\nNote that \"--local\" clones will not work if either of the object\ndatabases is not using the \"files\" format. This is because we hardlink\nloose objects and packfiles into the new repository, and that is\nsomething that simply won't work with alternative backends.\nConsequently, we either downgrade to a non-local clone with a warning,\nor we die in case the user has explicitly asked for a local clone.\n\nWe _could_ in theory handle the case where the \"files\" backend has been\nconfigured with an alternative object directory path (that is, with\n\"files:///path/to/dir\"). But that's left for a future patch series to\nimplement for the sake of simplicity.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-clone.adoc | 11 +++++++\n builtin/clone.c              | 45 +++++++++++++++++++++++++++--\n t/t5601-clone.sh             | 68 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 122 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-clone.adoc b/Documentation/git-clone.adoc\nindex 07f7cf1a98d..dd3b44817a7 100644\n--- a/Documentation/git-clone.adoc\n+++ b/Documentation/git-clone.adoc\n@@ -360,6 +360,17 @@ include::ref-storage-format.adoc[]\n `--ref-format=<format>`::\n Deprecated alias of `--ref-storage-format=<format>`.\n \n+`--object-storage-format=<format>`::\n+Specify the given object storage _<format>_ for the repository. Backends that\n+require additional configuration accept a payload in the form\n+`<format>://<payload>`, for example a path or a connection string identifying\n+the database that shall store the objects. The valid values are:\n++\n+include::object-storage-format.adoc[]\n++\n+Local clones (see `--local`) fall back to the regular transport when either\n+repository uses a non-default object storage.\n+\n `-j<n>`::\n `--jobs=<n>`::\n \tThe number of submodules fetched at the same time.\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 95e641b1a49..437dd2b2776 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -378,6 +378,24 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,\n \tdir_iterator_free(iter);\n }\n \n+static bool is_using_default_object_storage_format(const char *repo_path)\n+{\n+\tstruct repository_format format = REPOSITORY_FORMAT_INIT;\n+\tstruct strbuf config = STRBUF_INIT;\n+\tbool is_default;\n+\n+\tget_common_dir(&config, repo_path);\n+\tstrbuf_addstr(&config, \"/config\");\n+\tread_repository_format(&format, config.buf);\n+\n+\tis_default = format.object_storage_format == OBJECT_STORAGE_FORMAT_FILES &&\n+\t\t!format.object_storage_payload;\n+\n+\tclear_repository_format(&format);\n+\tstrbuf_release(&config);\n+\treturn is_default;\n+}\n+\n static void clone_local(const char *src_repo, const char *dest_repo)\n {\n \tif (!option_shared) {\n@@ -927,6 +945,7 @@ int cmd_clone(int argc,\n \tstruct string_list option_not = STRING_LIST_INIT_NODUP;\n \tconst char *real_git_dir = NULL;\n \tconst char *ref_storage_format_uri = NULL;\n+\tconst char *object_storage_format_uri = NULL;\n \tconst char *option_upload_pack = \"git-upload-pack\";\n \tint option_progress = -1;\n \tint option_sparse_checkout = 0;\n@@ -1008,6 +1027,8 @@ int cmd_clone(int argc,\n \t\t\t   N_(\"separate git dir from working tree\")),\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format_uri, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format_uri, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n \t\tOPT_STRING_LIST('c', \"config\", &option_config, N_(\"key=value\"),\n \t\t\t\tN_(\"set config inside the new repository\")),\n@@ -1060,6 +1081,10 @@ int cmd_clone(int argc,\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format_uri);\n \t}\n \n+\tif (object_storage_format_uri &&\n+\t    object_storage_format_by_uri(object_storage_format_uri, NULL) == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n+\n \tif (option_mirror) {\n \t\toption_bare = 1;\n \t\toption_tags = 0;\n@@ -1213,8 +1238,9 @@ int cmd_clone(int argc,\n \t * their on-disk data structures.\n \t */\n \tcreate_repository(the_repository, git_dir, real_git_dir, work_tree,\n-\t\t\t  option_template, GIT_HASH_UNKNOWN, ref_storage_format_uri,\n-\t\t\t  NULL, do_not_override_repo_unix_permissions, NULL);\n+\t\t\t  option_template, GIT_HASH_UNKNOWN,\n+\t\t\t  ref_storage_format_uri, object_storage_format_uri,\n+\t\t\t  do_not_override_repo_unix_permissions, NULL);\n \n \tif (real_git_dir) {\n \t\tfree((char *)git_dir);\n@@ -1363,6 +1389,21 @@ int cmd_clone(int argc,\n \t\t\tis_local = 0;\n \t\t}\n \t}\n+\n+\t/*\n+\t * Local clones copy or hardlink the object directory of the source repository\n+\t * into the destination. This only works when both repositories use the \"files\"\n+\t * object storage format.\n+\t */\n+\tif (is_local &&\n+\t    (!is_using_default_object_storage_format(path) || !is_using_default_object_storage_format(git_dir))) {\n+\t\tif (option_local > 0)\n+\t\t\tdie(_(\"cannot perform local clone with non-default object storage format\"));\n+\t\telse\n+\t\t\twarning(_(\"falling back to non-local clone because of non-default object storage format\"));\n+\t\tis_local = 0;\n+\t}\n+\n \tif (option_local > 0 && !is_local)\n \t\twarning(_(\"--local is ignored\"));\n \ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 06f6121f82e..85f439d6b62 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -181,6 +181,74 @@ test_expect_success 'clone with garbage ref format' '\n \ttest_path_is_missing ref-storage\n '\n \n+test_expect_success 'clone with files object storage format' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\tgit clone --object-storage-format=files --bare src object-storage &&\n+\ttest_must_fail git -C object-storage config get extensions.objectstorage &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\techo files >expect &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'clone with object storage payload' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\tgit clone --object-storage-format=files://objs --bare src object-storage &&\n+\tgit -C object-storage config get extensions.objectstorage >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual &&\n+\ttest_path_is_dir object-storage/objs/pack &&\n+\ttest_path_is_missing object-storage/objects/pack\n+'\n+\n+test_expect_success 'clone with object storage payload and bundle URI' '\n+\ttest_when_finished \"rm -rf object-storage src.bundle\" &&\n+\tgit -C src bundle create ../src.bundle --all &&\n+\tgit clone --object-storage-format=files://objs --bundle-uri=\"$PWD/src.bundle\" \\\n+\t\tsrc object-storage &&\n+\tgit -C object-storage rev-parse --show-object-storage-format >actual &&\n+\techo files://objs >expect &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'clone with garbage object storage format' '\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git clone --object-storage-format=garbage --bare src object-storage 2>err &&\n+\ttest_cmp expect err &&\n+\ttest_path_is_missing object-storage\n+'\n+\n+test_expect_success 'local clone into non-default object storage bails' '\n+\ttest_when_finished \"rm -rf object-storage\" &&\n+\ttest_must_fail git clone --local --object-storage-format=files://objs src object-storage 2>err &&\n+\ttest_grep \"cannot perform local clone with non-default object storage format\" err\n+'\n+\n+test_expect_success 'local clone from explicit files object storage succeeds' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone src object-storage &&\n+\tgit -C object-storage config set core.repositoryformatversion 1 &&\n+\tgit -C object-storage config set extensions.objectstorage files &&\n+\tgit clone --local object-storage object-storage-dest\n+'\n+\n+test_expect_success 'local clone from non-default object storage bails' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone --object-storage-format=files://objs src object-storage &&\n+\ttest_must_fail git clone --local object-storage object-storage-dest 2>err &&\n+\ttest_grep \"cannot perform local clone with non-default object storage format\" err\n+'\n+\n+test_expect_success 'local clone from non-default object storage without --local warns' '\n+\ttest_when_finished \"rm -rf object-storage object-storage-dest\" &&\n+\tgit clone --object-storage-format=files://objs src object-storage &&\n+\tgit clone object-storage object-storage-dest 2>err &&\n+\ttest_grep \"falling back to non-local clone\" err\n+'\n+\n test_expect_success 'clone to destination with trailing /' '\n \n \tgit clone src target-1/ &&\n\n-- \n2.56.0.341.g393f52fd96.dirty\n\n\n"},{"id":"556435","messageId":"20261027-b4-pks-odb-extension-v4-7-5d28ca0ea1dc@pks.im","threadId":"66584","inReplyTo":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","subject":"[PATCH v4 7/7] builtin/submodule: propagate \"--object-storage-format=\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-27T06:59:31Z","receivedAt":"2026-10-27T06:59:31Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The ref storage format passed to git-clone(1) propagates to recursively\ncloned submodules, and git-submodule(1)'s \"add\" and \"update\" subcommands\naccept `--ref-storage-format=` so that newly cloned submodules can be\nset up with a specific format.\n\nTeach git-submodule(1) to also propagate the object storage format.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/git-submodule.adoc           |  10 ++-\n builtin/clone.c                            |  19 ++++--\n builtin/submodule--helper.c                |  40 +++++++++++\n git-submodule.sh                           |  18 +++++\n t/meson.build                              |   1 +\n t/t7427-submodule-object-storage-format.sh | 104 +++++++++++++++++++++++++++++\n 6 files changed, 185 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-submodule.adoc b/Documentation/git-submodule.adoc\nindex e9c81a7170f..57a21bc8d96 100644\n--- a/Documentation/git-submodule.adoc\n+++ b/Documentation/git-submodule.adoc\n@@ -34,7 +34,7 @@ COMMANDS\n With no arguments, shows the status of existing submodules.  Several\n subcommands are available to perform operations on the submodules.\n \n-`add [-b <branch>] [-f | --force] [--name <name>] [--reference <repository>] [--ref-storage-format <format>] [--depth <depth>] [--] <repository> [<path>]`::\n+`add [-b <branch>] [-f | --force] [--name <name>] [--reference <repository>] [--ref-storage-format <format>] [--object-storage-format <format>] [--depth <depth>] [--] <repository> [<path>]`::\n \tAdd the given repository as a submodule at the given path\n \tto the changeset to be committed next to the current\n \tproject: the current project is termed the \"superproject\".\n@@ -75,6 +75,9 @@ URL in `.gitmodules`.\n If `--ref-storage-format <format>` or its deprecated alias `--ref-format\n <format>` is specified, the ref storage format of the newly cloned submodules\n will be set accordingly.\n++\n+If `--object-storage-format <format>` is specified, the object storage format\n+of the newly cloned submodules will be set accordingly.\n \n `status [--cached] [--recursive] [--] [<path>...]`::\n \tShow the status of the submodules. This will print the SHA-1 of the\n@@ -140,7 +143,7 @@ If you really want to remove a submodule from the repository and commit\n that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal\n options.\n \n-`update [--init] [--remote] [-N | --no-fetch] [--[no-]recommend-shallow] [-f | --force] [--checkout | --rebase | --merge] [--reference=<repository>] [--ref-storage-format=<format>] [--depth=<depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter=<filter-spec>] [--] [<path>...]`::\n+`update [--init] [--remote] [-N | --no-fetch] [--[no-]recommend-shallow] [-f | --force] [--checkout | --rebase | --merge] [--reference=<repository>] [--ref-storage-format=<format>] [--object-storage-format=<format>] [--depth=<depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter=<filter-spec>] [--] [<path>...]`::\n +\n --\n Update the registered submodules to match what the superproject\n@@ -193,6 +196,9 @@ If `--ref-storage-format <format>` or its deprecated alias `--ref-format\n <format>` is specified, the ref storage format of the newly cloned submodules\n will be set accordingly.\n \n+If `--object-storage-format <format>` is specified, the object storage format\n+of the newly cloned submodules will be set accordingly.\n+\n If `--filter <filter-spec>` is specified, the given partial clone filter will be\n applied to the submodule. See linkgit:git-rev-list[1] for details on filter\n specifications.\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 437dd2b2776..993a4390b8a 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -681,7 +681,8 @@ static int git_sparse_checkout_init(const char *repo)\n static int checkout(int submodule_progress,\n \t\t    struct list_objects_filter_options *filter_options,\n \t\t    int filter_submodules,\n-\t\t    enum ref_storage_format ref_storage_format)\n+\t\t    enum ref_storage_format ref_storage_format,\n+\t\t    enum object_storage_format object_storage_format)\n {\n \tstruct object_id oid;\n \tchar *head;\n@@ -771,6 +772,10 @@ static int checkout(int submodule_progress,\n \t\t\tstrvec_pushf(&cmd.args, \"--ref-storage-format=%s\",\n \t\t\t\t     ref_storage_format_to_name(ref_storage_format));\n \n+\t\tif (object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tstrvec_pushf(&cmd.args, \"--object-storage-format=%s\",\n+\t\t\t\t     object_storage_format_to_name(object_storage_format));\n+\n \t\tif (filter_submodules && filter_options->choice)\n \t\t\tstrvec_pushf(&cmd.args, \"--filter=%s\",\n \t\t\t\t     expand_list_objects_filter_spec(filter_options));\n@@ -936,6 +941,7 @@ int cmd_clone(int argc,\n \tint submodule_progress;\n \tint filter_submodules = 0;\n \tint hash_algo;\n+\tenum object_storage_format object_storage_format = OBJECT_STORAGE_FORMAT_UNKNOWN;\n \tenum ref_storage_format ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;\n \tconst int do_not_override_repo_unix_permissions = -1;\n \tint option_reject_shallow = -1; /* unspecified */\n@@ -1081,9 +1087,11 @@ int cmd_clone(int argc,\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format_uri);\n \t}\n \n-\tif (object_storage_format_uri &&\n-\t    object_storage_format_by_uri(object_storage_format_uri, NULL) == OBJECT_STORAGE_FORMAT_UNKNOWN)\n-\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n+\tif (object_storage_format_uri) {\n+\t\tobject_storage_format = object_storage_format_by_uri(object_storage_format_uri, NULL);\n+\t\tif (object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format_uri);\n+\t}\n \n \tif (option_mirror) {\n \t\toption_bare = 1;\n@@ -1701,7 +1709,8 @@ int cmd_clone(int argc,\n \terr = checkout(submodule_progress,\n \t\t       &filter_options,\n \t\t       filter_submodules,\n-\t\t       ref_storage_format);\n+\t\t       ref_storage_format,\n+\t\t       object_storage_format);\n \n \tlist_objects_filter_release(&filter_options);\n \ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 64412adf9f6..461b682d0d5 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1739,6 +1739,7 @@ struct module_clone_data {\n \tint depth;\n \tstruct list_objects_filter_options *filter_options;\n \tenum ref_storage_format ref_storage_format;\n+\tenum object_storage_format object_storage_format;\n \tunsigned int quiet: 1;\n \tunsigned int progress: 1;\n \tunsigned int dissociate: 1;\n@@ -1748,6 +1749,7 @@ struct module_clone_data {\n #define MODULE_CLONE_DATA_INIT { \\\n \t.single_branch = -1, \\\n \t.ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \\\n+\t.object_storage_format = OBJECT_STORAGE_FORMAT_UNKNOWN, \\\n }\n \n struct submodule_alternate_setup {\n@@ -1948,6 +1950,9 @@ static int clone_submodule(const struct module_clone_data *clone_data,\n \t\tif (clone_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tstrvec_pushf(&cp.args, \"--ref-storage-format=%s\",\n \t\t\t\t     ref_storage_format_to_name(clone_data->ref_storage_format));\n+\t\tif (clone_data->object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tstrvec_pushf(&cp.args, \"--object-storage-format=%s\",\n+\t\t\t\t     object_storage_format_to_name(clone_data->object_storage_format));\n \t\tif (clone_data->dissociate)\n \t\t\tstrvec_push(&cp.args, \"--dissociate\");\n \t\tif (sm_gitdir && *sm_gitdir)\n@@ -2044,6 +2049,7 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \tstruct string_list reference = STRING_LIST_INIT_NODUP;\n \tstruct list_objects_filter_options filter_options =\n \t\tLIST_OBJECTS_FILTER_INIT;\n+\tconst char *object_storage_format = NULL;\n \tconst char *ref_storage_format = NULL;\n \n \tstruct option module_clone_options[] = {\n@@ -2065,6 +2071,8 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &dissociate,\n \t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_INTEGER(0, \"depth\", &clone_data.depth,\n@@ -2095,6 +2103,13 @@ static int module_clone(int argc, const char **argv, const char *prefix,\n \t\tif (clone_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\n+\tif (object_storage_format) {\n+\t\tclone_data.object_storage_format = object_storage_format_by_name(object_storage_format);\n+\t\tif (clone_data.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n+\t}\n+\n \tclone_data.dissociate = !!dissociate;\n \tclone_data.quiet = !!quiet;\n \tclone_data.progress = !!progress;\n@@ -2201,6 +2216,7 @@ struct update_data {\n \tstruct submodule_update_strategy update_strategy;\n \tstruct list_objects_filter_options *filter_options;\n \tstruct module_list list;\n+\tenum object_storage_format object_storage_format;\n \tenum ref_storage_format ref_storage_format;\n \tint depth;\n \tint max_jobs;\n@@ -2365,6 +2381,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n \tif (suc->update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\tstrvec_pushf(&child->args, \"--ref-storage-format=%s\",\n \t\t\t     ref_storage_format_to_name(suc->update_data->ref_storage_format));\n+\tif (suc->update_data->object_storage_format != OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\tstrvec_pushf(&child->args, \"--object-storage-format=%s\",\n+\t\t\t     object_storage_format_to_name(suc->update_data->object_storage_format));\n \tstrvec_pushl(&child->args, \"--path\", sub->path, NULL);\n \tstrvec_pushl(&child->args, \"--name\", sub->name, NULL);\n \tstrvec_pushl(&child->args, \"--url\", url, NULL);\n@@ -2809,6 +2828,9 @@ static void update_data_to_args(const struct update_data *update_data,\n \tif (update_data->ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN)\n \t\tstrvec_pushf(args, \"--ref-storage-format=%s\",\n \t\t\t     ref_storage_format_to_name(update_data->ref_storage_format));\n+\tif (update_data->object_storage_format)\n+\t\tstrvec_pushf(args, \"--object-storage-format=%s\",\n+\t\t\t     object_storage_format_to_name(update_data->object_storage_format));\n \tif (update_data->filter_options && update_data->filter_options->choice)\n \t\tstrvec_pushf(args, \"--filter=%s\",\n \t\t\t\texpand_list_objects_filter_spec(\n@@ -2992,6 +3014,7 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options =\n \t\tLIST_OBJECTS_FILTER_INIT;\n+\tconst char *object_storage_format = NULL;\n \tconst char *ref_storage_format = NULL;\n \tint ret;\n \tstruct option module_update_options[] = {\n@@ -3019,6 +3042,8 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n \t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_INTEGER(0, \"depth\", &opt.depth,\n@@ -3067,6 +3092,11 @@ static int module_update(int argc, const char **argv, const char *prefix,\n \t\tif (opt.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (object_storage_format) {\n+\t\topt.object_storage_format = object_storage_format_by_name(object_storage_format);\n+\t\tif (opt.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n+\t}\n \n \topt.filter_options = &filter_options;\n \topt.prefix = prefix;\n@@ -3371,6 +3401,7 @@ struct add_data {\n \tconst char *sm_name;\n \tconst char *repo;\n \tconst char *realrepo;\n+\tenum object_storage_format object_storage_format;\n \tenum ref_storage_format ref_storage_format;\n \tint depth;\n \tunsigned int force: 1;\n@@ -3477,6 +3508,7 @@ static int add_submodule(const struct add_data *add_data)\n \t\t\tstring_list_append(&reference, p)->util = p;\n \t\t}\n \t\tclone_data.ref_storage_format = add_data->ref_storage_format;\n+\t\tclone_data.object_storage_format = add_data->object_storage_format;\n \t\tclone_data.dissociate = add_data->dissociate;\n \t\tif (add_data->depth >= 0)\n \t\t\tclone_data.depth = add_data->depth;\n@@ -3652,6 +3684,7 @@ static int module_add(int argc, const char **argv, const char *prefix,\n {\n \tint force = 0, quiet = 0, progress = 0, dissociate = 0;\n \tstruct add_data add_data = ADD_DATA_INIT;\n+\tconst char *object_storage_format = NULL;\n \tconst char *ref_storage_format = NULL;\n \tchar *to_free = NULL;\n \tconst struct submodule *existing;\n@@ -3669,6 +3702,8 @@ static int module_add(int argc, const char **argv, const char *prefix,\n \t\tOPT_STRING(0, \"ref-storage-format\", &ref_storage_format, N_(\"format\"),\n \t\t\t   N_(\"specify the reference storage format to use\")),\n \t\tOPT_ALIAS_F(0, \"ref-format\", \"ref-storage-format\", PARSE_OPT_HIDDEN),\n+\t\tOPT_STRING(0, \"object-storage-format\", &object_storage_format, N_(\"format\"),\n+\t\t\t   N_(\"specify the object storage format to use\")),\n \t\tOPT_BOOL(0, \"dissociate\", &dissociate, N_(\"borrow the objects from reference repositories\")),\n \t\tOPT_STRING(0, \"name\", &add_data.sm_name, N_(\"name\"),\n \t\t\t   N_(\"sets the submodule's name to the given string \"\n@@ -3700,6 +3735,11 @@ static int module_add(int argc, const char **argv, const char *prefix,\n \t\tif (add_data.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n \t\t\tdie(_(\"unknown ref storage format '%s'\"), ref_storage_format);\n \t}\n+\tif (object_storage_format) {\n+\t\tadd_data.object_storage_format = object_storage_format_by_name(object_storage_format);\n+\t\tif (add_data.object_storage_format == OBJECT_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tdie(_(\"unknown object storage format '%s'\"), object_storage_format);\n+\t}\n \n \tadd_data.repo = argv[0];\n \tif (argc == 1)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 86321941380..4de5ffba049 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -103,6 +103,14 @@ cmd_add()\n \t\t--ref-format=*|--ref-storage-format=*)\n \t\t\tref_storage_format=\"$1\"\n \t\t\t;;\n+\t\t--object-storage-format)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tobject_storage_format=\"--object-storage-format=$2\"\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--object-storage-format=*)\n+\t\t\tobject_storage_format=\"$1\"\n+\t\t\t;;\n \t\t--dissociate)\n \t\t\tdissociate=$1\n \t\t\t;;\n@@ -148,6 +156,7 @@ cmd_add()\n \t\t${branch:+\"$branch\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${ref_storage_format:+\"$ref_storage_format\"} \\\n+\t\t${object_storage_format:+\"$object_storage_format\"} \\\n \t\t$dissociate \\\n \t\t${name:+\"$name\"} \\\n \t\t${depth:+\"$depth\"} \\\n@@ -310,6 +319,14 @@ cmd_update()\n \t\t--ref-format=*|--ref-storage-format=*)\n \t\t\tref_storage_format=\"$1\"\n \t\t\t;;\n+\t\t--object-storage-format)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tobject_storage_format=\"--object-storage-format=$2\"\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--object-storage-format=*)\n+\t\t\tobject_storage_format=\"$1\"\n+\t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n \t\t\treference=\"--reference=$2\"\n@@ -386,6 +403,7 @@ cmd_update()\n \t\t$merge \\\n \t\t$checkout \\\n \t\t${ref_storage_format:+\"$ref_storage_format\"} \\\n+\t\t${object_storage_format:+\"$object_storage_format\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t$dissociate \\\n \t\t${depth:+\"$depth\"} \\\ndiff --git a/t/meson.build b/t/meson.build\nindex 11b3752f006..8542035b6f9 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -926,6 +926,7 @@ integration_tests = [\n   't7424-submodule-mixed-ref-formats.sh',\n   't7425-submodule-gitdir-path-extension.sh',\n   't7426-submodule-get-default-remote.sh',\n+  't7427-submodule-object-storage-format.sh',\n   't7450-bad-git-dotfiles.sh',\n   't7500-commit-template-squash-signoff.sh',\n   't7501-commit-basic-functionality.sh',\ndiff --git a/t/t7427-submodule-object-storage-format.sh b/t/t7427-submodule-object-storage-format.sh\nnew file mode 100755\nindex 00000000000..e4e554b0732\n--- /dev/null\n+++ b/t/t7427-submodule-object-storage-format.sh\n@@ -0,0 +1,104 @@\n+#!/bin/sh\n+\n+test_description='submodules handle the object storage format'\n+\n+. ./test-lib.sh\n+\n+test_object_storage_format () {\n+\techo \"$2\" >expect &&\n+\tgit -C \"$1\" rev-parse --show-object-storage-format >actual &&\n+\ttest_cmp expect actual\n+}\n+\n+test_expect_success 'setup' '\n+\tgit config set --global protocol.file.allow always\n+'\n+\n+test_expect_success 'add existing repository with different object storage format' '\n+\ttest_when_finished \"rm -rf parent\" &&\n+\n+\tgit init parent &&\n+\t(\n+\t\tcd parent &&\n+\t\ttest_commit parent &&\n+\t\tgit init --object-storage-format=files://objs submodule &&\n+\t\ttest_commit -C submodule submodule &&\n+\t\tgit submodule add ./submodule &&\n+\t\ttest_object_storage_format submodule files://objs\n+\t)\n+'\n+\n+test_expect_success 'add submodules with explicit files storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\ttest_object_storage_format upstream files &&\n+\tgit -C upstream submodule add --object-storage-format=files \"file://$(pwd)/submodule\" &&\n+\ttest_object_storage_format upstream/submodule files\n+'\n+\n+test_expect_success 'add submodules with garbage object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}garbage${SQ}\n+\tEOF\n+\ttest_must_fail git -C upstream submodule add --object-storage-format=garbage \"file://$(pwd)/submodule\" 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'add submodules with object storage payload is rejected' '\n+\ttest_when_finished \"rm -rf submodule upstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tcat >expect <<-EOF &&\n+\tfatal: unknown object storage format ${SQ}files://objs${SQ}\n+\tEOF\n+\ttest_must_fail git -C upstream submodule add --object-storage-format=files://objs \"file://$(pwd)/submodule\" 2>err &&\n+\ttest_cmp expect err\n+'\n+\n+test_expect_success 'recursive clone propagates object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tgit -C upstream submodule add \"file://$(pwd)/submodule\" &&\n+\tgit -C upstream commit -am \"add submodule\" &&\n+\n+\ttest_object_storage_format upstream files &&\n+\ttest_object_storage_format upstream/submodule files &&\n+\n+\tgit clone --object-storage-format=files://objs --recurse-submodules \\\n+\t\tupstream downstream &&\n+\ttest_object_storage_format downstream files://objs &&\n+\ttest_object_storage_format downstream/submodule files &&\n+\ttest_path_is_dir downstream/.git/objs/pack &&\n+\ttest_path_is_dir downstream/.git/modules/submodule/objects/pack\n+'\n+\n+test_expect_success 'clone submodules with explicit object storage format' '\n+\ttest_when_finished \"rm -rf submodule upstream downstream\" &&\n+\n+\tgit init submodule &&\n+\ttest_commit -C submodule submodule-initial &&\n+\tgit init upstream &&\n+\tgit -C upstream submodule add \"file://$(pwd)/submodule\" &&\n+\tgit -C upstream commit -m \"upstream submodule\" &&\n+\n+\tgit clone --no-recurse-submodules \"file://$(pwd)/upstream\" downstream &&\n+\ttest_object_storage_format downstream files &&\n+\tgit -C downstream submodule update --init --object-storage-format=files &&\n+\ttest_object_storage_format downstream/submodule files &&\n+\ttest_path_is_dir downstream/.git/modules/submodule/objects/pack\n+'\n+\n+test_done\n\n-- \n2.56.0.341.g393f52fd96.dirty\n\n\n"},{"id":"556633","messageId":"CAOLa=ZRWktyBmeeiMbPqnX_OkizqPA2mmGrnTABW7Pkk7DcKpA@mail.gmail.com","threadId":"66584","inReplyTo":"20261027-b4-pks-odb-extension-v4-0-5d28ca0ea1dc@pks.im","subject":"Re: [PATCH v4 0/7] odb: introduce object storage extension","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-28T10:53:18Z","receivedAt":"2026-10-28T10:53:18Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n[snip]\n\n> Range-diff versus v3:\n>\n> 1:  906c3d3e3c3 = 1:  f09fc3200f9 loose: drop unused `repo_write_loose_object_map()`\n> 2:  3d3bcf0f825 ! 2:  655e1de3b9d setup: introduce object storage extension\n>     @@ Commit message\n>              allows you to configure a different location for the \".git/objects\"\n>              directory.\n>\n>     +    Making the location of the \"files\" backend configurable is not he most\n\ns/he/the\n\n>     +    thrilling feature of this new extension. But it gives us a couple of\n>     +    advantages:\n>     +\n>     +      - It allows us to start exercising the payload logic in our tests so\n>     +        that we know it's working properly for backends that will need it.\n>     +\n>     +      - It allows us to easily detect tests that are broken with the new\n>     +        extension because they for example assume that an object is a file\n>     +        in \".git/objects/\". Testing is not part of this series yet, but will\n>     +        be done in subsequent patch series.\n>     +\n>     +      - It aligns with how we handle the ref storage extension, where we can\n>     +        also change its location to an arbitrary path.\n>     +\n>     +      - It allows for some very esoteric and edge-case-y gimmicks. For\n>     +        example, you can initialize a single repository \"skeleton\" and then\n>     +        multiplex therein by setting both GIT_REF_STORAGE_FORMAT and\n>     +        GIT_OBJECT_STORAGE_FORMAT to point to different databases. These\n>     +        edge cases won't matter to many people out there, but we will use\n>     +        this for example as a building block for migrations.\n>     +\n>          Eventually, this mechanism will be used to support alternative backends.\n>\n>          Signed-off-by: Patrick Steinhardt <ps@pks.im>\n>     @@ setup.c: static enum extension_result handle_extension(const char *var,\n>       \t\treturn EXTENSION_OK;\n>       \t} else if (!strcmp(ext, \"relativeworktrees\")) {\n>       \t\tdata->relative_worktrees = git_config_bool(var, value);\n>     -@@ setup.c: static enum extension_result handle_extension(const char *var,\n>     - \t\tdata->submodule_path_cfg = git_config_bool(var, value);\n>     - \t\treturn EXTENSION_OK;\n>     - \t}\n>     -+\n>     - \treturn EXTENSION_UNKNOWN;\n>     - }\n>     -\n>      @@ setup.c: void clear_repository_format(struct repository_format *format)\n>       \tfree(format->work_tree);\n>       \tfree(format->partial_clone);\n\n[snip]\n\nThe rest looks good. Overall I'm happy with this version!\n"},{"id":"556636","messageId":"auHc9TeCfrCurKTM@pks.im","threadId":"66584","inReplyTo":"CAOLa=ZRWktyBmeeiMbPqnX_OkizqPA2mmGrnTABW7Pkk7DcKpA@mail.gmail.com","subject":"Re: [PATCH v4 0/7] odb: introduce object storage extension","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-28T11:31:01Z","receivedAt":"2026-10-28T11:31:01Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Oct 28, 2026 at 06:53:18AM -0400, Karthik Nayak wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> > Range-diff versus v3:\n> >\n> > 1:  906c3d3e3c3 = 1:  f09fc3200f9 loose: drop unused `repo_write_loose_object_map()`\n> > 2:  3d3bcf0f825 ! 2:  655e1de3b9d setup: introduce object storage extension\n> >     @@ Commit message\n> >              allows you to configure a different location for the \".git/objects\"\n> >              directory.\n> >\n> >     +    Making the location of the \"files\" backend configurable is not he most\n> \n> s/he/the\n\nFixed locally, but I'll refrain from sending out a new version just to\nfix this one typo.\n\n> [snip]\n> \n> The rest looks good. Overall I'm happy with this version!\n\nThanks for your review!\n\nPatrick\n\n"}]}