Skip to content

Commit 50e71a3

Browse files
pks-tgitster
authored andcommitted
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>
1 parent 8792ccb commit 50e71a3

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

builtin/clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ int cmd_clone(int argc,
12271227
*
12281228
* This is sufficient for Git commands to discover the Git directory.
12291229
*/
1230-
initialize_repository_version(GIT_HASH_UNKNOWN,
1230+
initialize_repository_version(the_repository, GIT_HASH_UNKNOWN,
12311231
the_repository->ref_storage_format, 1);
12321232

12331233
refs_create_refdir_stubs(the_repository, git_dir, NULL);
@@ -1440,7 +1440,7 @@ int cmd_clone(int argc,
14401440
* ours to the same thing.
14411441
*/
14421442
hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
1443-
initialize_repository_version(hash_algo, the_repository->ref_storage_format, 1);
1443+
initialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);
14441444
repo_set_hash_algo(the_repository, hash_algo);
14451445
create_reference_database(NULL, 1);
14461446

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3450,7 +3450,7 @@ int repo_migrate_ref_storage_format(struct repository *repo,
34503450
* repository format so that clients will use the new ref store.
34513451
* We also need to swap out the repository's main ref store.
34523452
*/
3453-
initialize_repository_version(hash_algo_by_ptr(repo->hash_algo), format, 1);
3453+
initialize_repository_version(the_repository, hash_algo_by_ptr(repo->hash_algo), format, 1);
34543454

34553455
/*
34563456
* Unset the old ref store and release it. `get_main_ref_store()` will

setup.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,8 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)
23822382
return 1;
23832383
}
23842384

2385-
void initialize_repository_version(int hash_algo,
2385+
void initialize_repository_version(struct repository *repo,
2386+
int hash_algo,
23862387
enum ref_storage_format ref_storage_format,
23872388
int reinit)
23882389
{
@@ -2399,35 +2400,35 @@ void initialize_repository_version(int hash_algo,
23992400
*/
24002401
if (hash_algo != GIT_HASH_SHA1_LEGACY ||
24012402
ref_storage_format != REF_STORAGE_FORMAT_FILES ||
2402-
the_repository->ref_storage_payload)
2403+
repo->ref_storage_payload)
24032404
target_version = GIT_REPO_VERSION_READ;
24042405

24052406
if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)
2406-
repo_config_set(the_repository, "extensions.objectformat",
2407+
repo_config_set(repo, "extensions.objectformat",
24072408
hash_algos[hash_algo].name);
24082409
else if (reinit)
2409-
repo_config_set_gently(the_repository, "extensions.objectformat", NULL);
2410+
repo_config_set_gently(repo, "extensions.objectformat", NULL);
24102411

2411-
if (the_repository->ref_storage_payload) {
2412+
if (repo->ref_storage_payload) {
24122413
struct strbuf ref_uri = STRBUF_INIT;
24132414

24142415
strbuf_addf(&ref_uri, "%s://%s",
24152416
ref_storage_format_to_name(ref_storage_format),
2416-
the_repository->ref_storage_payload);
2417-
repo_config_set(the_repository, "extensions.refstorage", ref_uri.buf);
2417+
repo->ref_storage_payload);
2418+
repo_config_set(repo, "extensions.refstorage", ref_uri.buf);
24182419
strbuf_release(&ref_uri);
24192420
} else if (ref_storage_format != REF_STORAGE_FORMAT_FILES) {
2420-
repo_config_set(the_repository, "extensions.refstorage",
2421+
repo_config_set(repo, "extensions.refstorage",
24212422
ref_storage_format_to_name(ref_storage_format));
24222423
} else if (reinit) {
2423-
repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
2424+
repo_config_set_gently(repo, "extensions.refstorage", NULL);
24242425
}
24252426

24262427
if (reinit) {
24272428
struct strbuf config = STRBUF_INIT;
24282429
struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
24292430

2430-
repo_common_path_append(the_repository, &config, "config");
2431+
repo_common_path_append(repo, &config, "config");
24312432
read_repository_format(&repo_fmt, config.buf);
24322433

24332434
if (repo_fmt.v1_only_extensions.nr)
@@ -2437,17 +2438,17 @@ void initialize_repository_version(int hash_algo,
24372438
clear_repository_format(&repo_fmt);
24382439
}
24392440

2440-
repo_config_get_bool(the_repository, "init.defaultSubmodulePathConfig",
2441+
repo_config_get_bool(repo, "init.defaultSubmodulePathConfig",
24412442
&default_submodule_path_config);
24422443
if (default_submodule_path_config) {
24432444
/* extensions.submodulepathconfig requires at least version 1 */
24442445
if (target_version == 0)
24452446
target_version = 1;
2446-
repo_config_set(the_repository, "extensions.submodulepathconfig", "true");
2447+
repo_config_set(repo, "extensions.submodulepathconfig", "true");
24472448
}
24482449

24492450
strbuf_addf(&repo_version, "%d", target_version);
2450-
repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
2451+
repo_config_set(repo, "core.repositoryformatversion", repo_version.buf);
24512452

24522453
strbuf_release(&repo_version);
24532454
}
@@ -2548,7 +2549,7 @@ static int create_default_files(struct repository *repo,
25482549
adjust_shared_perm(repo, repo_get_git_dir(repo));
25492550
}
25502551

2551-
initialize_repository_version(fmt->hash_algo, fmt->ref_storage_format, reinit);
2552+
initialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format, reinit);
25522553

25532554
/* Check filemode trustability */
25542555
repo_git_path_replace(repo, &path, "config");

setup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ int init_db(const char *git_dir, const char *real_git_dir,
232232
enum ref_storage_format ref_storage_format,
233233
const char *initial_branch, int init_shared_repository,
234234
unsigned int flags);
235-
void initialize_repository_version(int hash_algo,
235+
void initialize_repository_version(struct repository *repo,
236+
int hash_algo,
236237
enum ref_storage_format ref_storage_format,
237238
int reinit);
238239
void create_reference_database(const char *initial_branch, int quiet);

0 commit comments

Comments
 (0)