setup: stop using `the_repository` in `initialize_repository_version()`

Stop using `the_repository` in `initialize_repository_version()` and instead accept the repository as a parameter. The injection of `the_repository` is thus bumped one level higher, where callers now pass it in explicitly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed May 19, 2026 at 11:52 UTC 779fbcd9ebe8590e13ecd072d2e37dcbebd86ce5
4 files changed +20 -18
builtin/clone.c
+2 -2
@@ -1229,7 +1229,7 @@ int cmd_clone(int argc,
1229 *
1230 * This is sufficient for Git commands to discover the Git directory.
1231 */
1232 - initialize_repository_version(GIT_HASH_UNKNOWN,
1232 + initialize_repository_version(the_repository, GIT_HASH_UNKNOWN,
1233 the_repository->ref_storage_format, 1);
1234
1235 refs_create_refdir_stubs(the_repository, git_dir, NULL);
@@ -1442,7 +1442,7 @@ int cmd_clone(int argc,
1442 * ours to the same thing.
1443 */
1444 hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
1445 - initialize_repository_version(hash_algo, the_repository->ref_storage_format, 1);
1445 + initialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);
1446 repo_set_hash_algo(the_repository, hash_algo);
1447 create_reference_database(NULL, 1);
1448
refs.c
+1 -1
@@ -3453,7 +3453,7 @@ int repo_migrate_ref_storage_format(struct repository *repo,
3453 * repository format so that clients will use the new ref store.
3454 * We also need to swap out the repository's main ref store.
3455 */
3456 - initialize_repository_version(hash_algo_by_ptr(repo->hash_algo), format, 1);
3456 + initialize_repository_version(the_repository, hash_algo_by_ptr(repo->hash_algo), format, 1);
3457
3458 /*
3459 * Unset the old ref store and release it. `get_main_ref_store()` will
setup.c
+15 -14
@@ -2385,7 +2385,8 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)
2385 return 1;
2386 }
2387
2388 -void initialize_repository_version(int hash_algo,
2388 +void initialize_repository_version(struct repository *repo,
2389 + int hash_algo,
2390 enum ref_storage_format ref_storage_format,
2391 int reinit)
2392 {
@@ -2402,35 +2403,35 @@ void initialize_repository_version(int hash_algo,
2403 */
2404 if (hash_algo != GIT_HASH_SHA1_LEGACY ||
2405 ref_storage_format != REF_STORAGE_FORMAT_FILES ||
2405 - the_repository->ref_storage_payload)
2406 + repo->ref_storage_payload)
2407 target_version = GIT_REPO_VERSION_READ;
2408
2409 if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)
2409 - repo_config_set(the_repository, "extensions.objectformat",
2410 + repo_config_set(repo, "extensions.objectformat",
2411 hash_algos[hash_algo].name);
2412 else if (reinit)
2412 - repo_config_set_gently(the_repository, "extensions.objectformat", NULL);
2413 + repo_config_set_gently(repo, "extensions.objectformat", NULL);
2414
2414 - if (the_repository->ref_storage_payload) {
2415 + if (repo->ref_storage_payload) {
2416 struct strbuf ref_uri = STRBUF_INIT;
2417
2418 strbuf_addf(&ref_uri, "%s://%s",
2419 ref_storage_format_to_name(ref_storage_format),
2419 - the_repository->ref_storage_payload);
2420 - repo_config_set(the_repository, "extensions.refstorage", ref_uri.buf);
2420 + repo->ref_storage_payload);
2421 + repo_config_set(repo, "extensions.refstorage", ref_uri.buf);
2422 strbuf_release(&ref_uri);
2423 } else if (ref_storage_format != REF_STORAGE_FORMAT_FILES) {
2423 - repo_config_set(the_repository, "extensions.refstorage",
2424 + repo_config_set(repo, "extensions.refstorage",
2425 ref_storage_format_to_name(ref_storage_format));
2426 } else if (reinit) {
2426 - repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
2427 + repo_config_set_gently(repo, "extensions.refstorage", NULL);
2428 }
2429
2430 if (reinit) {
2431 struct strbuf config = STRBUF_INIT;
2432 struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
2433
2433 - repo_common_path_append(the_repository, &config, "config");
2434 + repo_common_path_append(repo, &config, "config");
2435 read_repository_format(&repo_fmt, config.buf);
2436
2437 if (repo_fmt.v1_only_extensions.nr)
@@ -2440,17 +2441,17 @@ void initialize_repository_version(int hash_algo,
2441 clear_repository_format(&repo_fmt);
2442 }
2443
2443 - repo_config_get_bool(the_repository, "init.defaultSubmodulePathConfig",
2444 + repo_config_get_bool(repo, "init.defaultSubmodulePathConfig",
2445 &default_submodule_path_config);
2446 if (default_submodule_path_config) {
2447 /* extensions.submodulepathconfig requires at least version 1 */
2448 if (target_version == 0)
2449 target_version = 1;
2449 - repo_config_set(the_repository, "extensions.submodulepathconfig", "true");
2450 + repo_config_set(repo, "extensions.submodulepathconfig", "true");
2451 }
2452
2453 strbuf_addf(&repo_version, "%d", target_version);
2453 - repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
2454 + repo_config_set(repo, "core.repositoryformatversion", repo_version.buf);
2455
2456 strbuf_release(&repo_version);
2457 }
@@ -2551,7 +2552,7 @@ static int create_default_files(struct repository *repo,
2552 adjust_shared_perm(repo, repo_get_git_dir(repo));
2553 }
2554
2554 - initialize_repository_version(fmt->hash_algo, fmt->ref_storage_format, reinit);
2555 + initialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format, reinit);
2556
2557 /* Check filemode trustability */
2558 repo_git_path_replace(repo, &path, "config");
setup.h
+2 -1
@@ -232,7 +232,8 @@ int init_db(const char *git_dir, const char *real_git_dir,
232 enum ref_storage_format ref_storage_format,
233 const char *initial_branch, int init_shared_repository,
234 unsigned int flags);
235 -void initialize_repository_version(int hash_algo,
235 +void initialize_repository_version(struct repository *repo,
236 + int hash_algo,
237 enum ref_storage_format ref_storage_format,
238 int reinit);
239 void create_reference_database(const char *initial_branch, int quiet);