setup: replace use of `the_repository` in static functions
Replace the use of `the_repository` in "setup.c" for all static functions. For now, we simply add `the_repository` to invocations of these functions. This will be addressed in subsequent commits, where we'll move up `the_repository` one more layer to callers of "setup.c". 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
bb50ec6b26a37789208c18d0d3f7cbf047090145
1 file changed
+100
-88
setup.c
+100
-88
@@ -50,13 +50,13 @@ const char *tmp_original_cwd;
50
* /dir/repolink/file (repolink points to /dir/repo) -> file
51
* /dir/repo (exactly equal to work tree) -> (empty string)
52
*/
53
-static int abspath_part_inside_repo(char *path)
53
+static int abspath_part_inside_repo(struct repository *repo, char *path)
54
{
55
size_t len;
56
size_t wtlen;
57
char *path0;
58
int off;
59
- const char *work_tree = precompose_string_if_needed(repo_get_work_tree(the_repository));
59
+ const char *work_tree = precompose_string_if_needed(repo_get_work_tree(repo));
60
struct strbuf realpath = STRBUF_INIT;
61
62
if (!work_tree)
@@ -132,7 +132,7 @@ char *prefix_path_gently(const char *prefix, int len,
132
free(sanitized);
133
return NULL;
134
}
135
- if (abspath_part_inside_repo(sanitized)) {
135
+ if (abspath_part_inside_repo(the_repository, sanitized)) {
136
free(sanitized);
137
return NULL;
138
}
@@ -509,7 +509,7 @@ void setup_work_tree(void)
509
initialized = 1;
510
}
511
512
-static void setup_original_cwd(void)
512
+static void setup_original_cwd(struct repository *repo)
513
{
514
struct strbuf tmp = STRBUF_INIT;
515
const char *worktree = NULL;
@@ -535,9 +535,9 @@ static void setup_original_cwd(void)
535
536
/* Normalize the directory */
537
if (!strbuf_realpath(&tmp, tmp_original_cwd, 0)) {
538
- trace2_data_string("setup", the_repository,
538
+ trace2_data_string("setup", repo,
539
"realpath-path", tmp_original_cwd);
540
- trace2_data_string("setup", the_repository,
540
+ trace2_data_string("setup", repo,
541
"realpath-failure", strerror(errno));
542
free((char*)tmp_original_cwd);
543
tmp_original_cwd = NULL;
@@ -552,7 +552,7 @@ static void setup_original_cwd(void)
552
* Get our worktree; we only protect the current working directory
553
* if it's in the worktree.
554
*/
555
- worktree = repo_get_work_tree(the_repository);
555
+ worktree = repo_get_work_tree(repo);
556
if (!worktree)
557
goto no_prevention_needed;
558
@@ -747,7 +747,10 @@ static int check_repo_format(const char *var, const char *value,
747
return read_worktree_config(var, value, ctx, vdata);
748
}
749
750
-static int check_repository_format_gently(const char *gitdir, struct repository_format *candidate, int *nongit_ok)
750
+static int check_repository_format_gently(struct repository *repo,
751
+ const char *gitdir,
752
+ struct repository_format *candidate,
753
+ int *nongit_ok)
754
{
755
struct strbuf sb = STRBUF_INIT;
756
struct strbuf err = STRBUF_INIT;
@@ -776,7 +779,7 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
779
die("%s", err.buf);
780
}
781
779
- the_repository->repository_format_precious_objects = candidate->precious_objects;
782
+ repo->repository_format_precious_objects = candidate->precious_objects;
783
784
string_list_clear(&candidate->unknown_extensions, 0);
785
string_list_clear(&candidate->v1_only_extensions, 0);
@@ -1034,7 +1037,8 @@ cleanup_return:
1037
return error_code ? NULL : path;
1038
}
1039
1037
-static void setup_git_env_internal(const char *git_dir,
1040
+static void setup_git_env_internal(struct repository *repo,
1041
+ const char *git_dir,
1042
bool skip_initializing_odb)
1043
{
1044
char *git_replace_ref_base;
@@ -1052,7 +1056,7 @@ static void setup_git_env_internal(const char *git_dir,
1056
args.disable_ref_updates = true;
1057
args.skip_initializing_odb = skip_initializing_odb;
1058
1055
- repo_set_gitdir(the_repository, git_dir, &args);
1059
+ repo_set_gitdir(repo, git_dir, &args);
1060
strvec_clear(&to_free);
1061
1062
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
@@ -1064,7 +1068,7 @@ static void setup_git_env_internal(const char *git_dir,
1068
1069
shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);
1070
if (shallow_file)
1067
- set_alternate_shallow_file(the_repository, shallow_file, 0);
1071
+ set_alternate_shallow_file(repo, shallow_file, 0);
1072
1073
if (git_env_bool(NO_LAZY_FETCH_ENVIRONMENT, 0))
1074
fetch_if_missing = 0;
@@ -1072,30 +1076,31 @@ static void setup_git_env_internal(const char *git_dir,
1076
1077
void setup_git_env(const char *git_dir)
1078
{
1075
- setup_git_env_internal(git_dir, false);
1079
+ setup_git_env_internal(the_repository, git_dir, false);
1080
}
1081
1078
-static void set_git_dir_1(const char *path, bool skip_initializing_odb)
1082
+static void set_git_dir_1(struct repository *repo, const char *path, bool skip_initializing_odb)
1083
{
1084
xsetenv(GIT_DIR_ENVIRONMENT, path, 1);
1081
- setup_git_env_internal(path, skip_initializing_odb);
1085
+ setup_git_env_internal(repo, path, skip_initializing_odb);
1086
}
1087
1088
static void update_relative_gitdir(const char *name UNUSED,
1089
const char *old_cwd,
1090
const char *new_cwd,
1087
- void *data UNUSED)
1091
+ void *data)
1092
{
1093
+ struct repository *repo = data;
1094
char *path = reparent_relative_path(old_cwd, new_cwd,
1090
- repo_get_git_dir(the_repository));
1095
+ repo_get_git_dir(repo));
1096
trace_printf_key(&trace_setup_key,
1097
"setup: move $GIT_DIR to '%s'",
1098
path);
1094
- set_git_dir_1(path, true);
1099
+ set_git_dir_1(repo, path, true);
1100
free(path);
1101
}
1102
1098
-static void set_git_dir(const char *path, int make_realpath)
1103
+static void set_git_dir(struct repository *repo, const char *path, int make_realpath)
1104
{
1105
struct strbuf realpath = STRBUF_INIT;
1106
@@ -1104,14 +1109,15 @@ static void set_git_dir(const char *path, int make_realpath)
1109
path = realpath.buf;
1110
}
1111
1107
- set_git_dir_1(path, false);
1112
+ set_git_dir_1(repo, path, false);
1113
if (!is_absolute_path(path))
1109
- chdir_notify_register(NULL, update_relative_gitdir, NULL);
1114
+ chdir_notify_register(NULL, update_relative_gitdir, repo);
1115
1116
strbuf_release(&realpath);
1117
}
1118
1114
-static const char *setup_explicit_git_dir(const char *gitdirenv,
1119
+static const char *setup_explicit_git_dir(struct repository *repo,
1120
+ const char *gitdirenv,
1121
struct strbuf *cwd,
1122
struct repository_format *repo_fmt,
1123
int *nongit_ok)
@@ -1139,7 +1145,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
1145
die(_("not a git repository: '%s'"), gitdirenv);
1146
}
1147
1142
- if (check_repository_format_gently(gitdirenv, repo_fmt, nongit_ok)) {
1148
+ if (check_repository_format_gently(repo, gitdirenv, repo_fmt, nongit_ok)) {
1149
free(gitfile);
1150
return NULL;
1151
}
@@ -1155,7 +1161,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
1161
}
1162
1163
/* #18, #26 */
1158
- set_git_dir(gitdirenv, 0);
1164
+ set_git_dir(repo, gitdirenv, 0);
1165
free(gitfile);
1166
return NULL;
1167
}
@@ -1177,7 +1183,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
1183
}
1184
else if (!git_env_bool(GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, 1)) {
1185
/* #16d */
1180
- set_git_dir(gitdirenv, 0);
1186
+ set_git_dir(repo, gitdirenv, 0);
1187
free(gitfile);
1188
return NULL;
1189
}
@@ -1185,18 +1191,18 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
1191
set_git_work_tree(".");
1192
1193
/* set_git_work_tree() must have been called by now */
1188
- worktree = repo_get_work_tree(the_repository);
1194
+ worktree = repo_get_work_tree(repo);
1195
1196
/* both repo_get_work_tree() and cwd are already normalized */
1197
if (!strcmp(cwd->buf, worktree)) { /* cwd == worktree */
1192
- set_git_dir(gitdirenv, 0);
1198
+ set_git_dir(repo, gitdirenv, 0);
1199
free(gitfile);
1200
return NULL;
1201
}
1202
1203
offset = dir_inside_of(cwd->buf, worktree);
1204
if (offset >= 0) { /* cwd inside worktree? */
1199
- set_git_dir(gitdirenv, 1);
1205
+ set_git_dir(repo, gitdirenv, 1);
1206
if (chdir(worktree))
1207
die_errno(_("cannot chdir to '%s'"), worktree);
1208
strbuf_addch(cwd, '/');
@@ -1205,17 +1211,18 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
1211
}
1212
1213
/* cwd outside worktree */
1208
- set_git_dir(gitdirenv, 0);
1214
+ set_git_dir(repo, gitdirenv, 0);
1215
free(gitfile);
1216
return NULL;
1217
}
1218
1213
-static const char *setup_discovered_git_dir(const char *gitdir,
1219
+static const char *setup_discovered_git_dir(struct repository *repo,
1220
+ const char *gitdir,
1221
struct strbuf *cwd, int offset,
1222
struct repository_format *repo_fmt,
1223
int *nongit_ok)
1224
{
1218
- if (check_repository_format_gently(gitdir, repo_fmt, nongit_ok))
1225
+ if (check_repository_format_gently(repo, gitdir, repo_fmt, nongit_ok))
1226
return NULL;
1227
1228
/* --work-tree is set without --git-dir; use discovered one */
@@ -1227,14 +1234,14 @@ static const char *setup_discovered_git_dir(const char *gitdir,
1234
gitdir = to_free = real_pathdup(gitdir, 1);
1235
if (chdir(cwd->buf))
1236
die_errno(_("cannot come back to cwd"));
1230
- ret = setup_explicit_git_dir(gitdir, cwd, repo_fmt, nongit_ok);
1237
+ ret = setup_explicit_git_dir(repo, gitdir, cwd, repo_fmt, nongit_ok);
1238
free(to_free);
1239
return ret;
1240
}
1241
1242
/* #16.2, #17.2, #20.2, #21.2, #24, #25, #28, #29 (see t1510) */
1243
if (is_bare_repository_cfg > 0) {
1237
- set_git_dir(gitdir, (offset != cwd->len));
1244
+ set_git_dir(repo, gitdir, (offset != cwd->len));
1245
if (chdir(cwd->buf))
1246
die_errno(_("cannot come back to cwd"));
1247
return NULL;
@@ -1243,7 +1250,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
1250
/* #0, #1, #5, #8, #9, #12, #13 */
1251
set_git_work_tree(".");
1252
if (strcmp(gitdir, DEFAULT_GIT_DIR_ENVIRONMENT))
1246
- set_git_dir(gitdir, 0);
1253
+ set_git_dir(repo, gitdir, 0);
1254
inside_git_dir = 0;
1255
inside_work_tree = 1;
1256
if (offset >= cwd->len)
@@ -1258,13 +1265,14 @@ static const char *setup_discovered_git_dir(const char *gitdir,
1265
}
1266
1267
/* #16.1, #17.1, #20.1, #21.1, #22.1 (see t1510) */
1261
-static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
1268
+static const char *setup_bare_git_dir(struct repository *repo,
1269
+ struct strbuf *cwd, int offset,
1270
struct repository_format *repo_fmt,
1271
int *nongit_ok)
1272
{
1273
int root_len;
1274
1267
- if (check_repository_format_gently(".", repo_fmt, nongit_ok))
1275
+ if (check_repository_format_gently(repo, ".", repo_fmt, nongit_ok))
1276
return NULL;
1277
1278
setenv(GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, "0", 1);
@@ -1276,7 +1284,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
1284
gitdir = offset == cwd->len ? "." : xmemdupz(cwd->buf, offset);
1285
if (chdir(cwd->buf))
1286
die_errno(_("cannot come back to cwd"));
1279
- return setup_explicit_git_dir(gitdir, cwd, repo_fmt, nongit_ok);
1287
+ return setup_explicit_git_dir(repo, gitdir, cwd, repo_fmt, nongit_ok);
1288
}
1289
1290
inside_git_dir = 1;
@@ -1286,10 +1294,10 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
1294
die_errno(_("cannot come back to cwd"));
1295
root_len = offset_1st_component(cwd->buf);
1296
strbuf_setlen(cwd, offset > root_len ? offset : root_len);
1289
- set_git_dir(cwd->buf, 0);
1297
+ set_git_dir(repo, cwd->buf, 0);
1298
}
1299
else
1292
- set_git_dir(".", 0);
1300
+ set_git_dir(repo, ".", 0);
1301
return NULL;
1302
}
1303
@@ -1827,7 +1835,7 @@ const char *enter_repo(const char *path, unsigned flags)
1835
}
1836
1837
if (is_git_directory(".")) {
1830
- set_git_dir(".", 0);
1838
+ set_git_dir(the_repository, ".", 0);
1839
check_repository_format(NULL);
1840
return path;
1841
}
@@ -1891,18 +1899,18 @@ const char *setup_git_directory_gently(int *nongit_ok)
1899
1900
switch (setup_git_directory_gently_1(&dir, &gitdir, &report, 1)) {
1901
case GIT_DIR_EXPLICIT:
1894
- prefix = setup_explicit_git_dir(gitdir.buf, &cwd, &repo_fmt, nongit_ok);
1902
+ prefix = setup_explicit_git_dir(the_repository, gitdir.buf, &cwd, &repo_fmt, nongit_ok);
1903
break;
1904
case GIT_DIR_DISCOVERED:
1905
if (dir.len < cwd.len && chdir(dir.buf))
1906
die(_("cannot change to '%s'"), dir.buf);
1899
- prefix = setup_discovered_git_dir(gitdir.buf, &cwd, dir.len,
1907
+ prefix = setup_discovered_git_dir(the_repository, gitdir.buf, &cwd, dir.len,
1908
&repo_fmt, nongit_ok);
1909
break;
1910
case GIT_DIR_BARE:
1911
if (dir.len < cwd.len && chdir(dir.buf))
1912
die(_("cannot change to '%s'"), dir.buf);
1905
- prefix = setup_bare_git_dir(&cwd, dir.len, &repo_fmt, nongit_ok);
1913
+ prefix = setup_bare_git_dir(the_repository, &cwd, dir.len, &repo_fmt, nongit_ok);
1914
break;
1915
case GIT_DIR_HIT_CEILING:
1916
if (!nongit_ok)
@@ -2044,7 +2052,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
2052
free(payload);
2053
}
2054
2047
- setup_original_cwd();
2055
+ setup_original_cwd(the_repository);
2056
2057
strbuf_release(&dir);
2058
strbuf_release(&gitdir);
@@ -2110,7 +2118,7 @@ void check_repository_format(struct repository_format *fmt)
2118
struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
2119
if (!fmt)
2120
fmt = &repo_fmt;
2113
- check_repository_format_gently(repo_get_git_dir(the_repository), fmt, NULL);
2121
+ check_repository_format_gently(the_repository, repo_get_git_dir(the_repository), fmt, NULL);
2122
startup_info->have_repository = 1;
2123
repo_set_hash_algo(the_repository, fmt->hash_algo);
2124
repo_set_compat_hash_algo(the_repository, fmt->compat_hash_algo);
@@ -2239,7 +2247,9 @@ const char *get_template_dir(const char *option_template)
2247
2248
#define GIT_DEFAULT_HASH_ENVIRONMENT "GIT_DEFAULT_HASH"
2249
2242
-static void copy_templates_1(struct strbuf *path, struct strbuf *template_path,
2250
+static void copy_templates_1(struct repository *repo,
2251
+ struct strbuf *path,
2252
+ struct strbuf *template_path,
2253
DIR *dir)
2254
{
2255
size_t path_baselen = path->len;
@@ -2253,7 +2263,7 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template_path,
2263
* with the way the namespace under .git/ is organized, should
2264
* be really carefully chosen.
2265
*/
2256
- safe_create_dir(the_repository, path->buf, 1);
2266
+ safe_create_dir(repo, path->buf, 1);
2267
while ((de = readdir(dir)) != NULL) {
2268
struct stat st_git, st_template;
2269
int exists = 0;
@@ -2281,7 +2291,7 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template_path,
2291
die_errno(_("cannot opendir '%s'"), template_path->buf);
2292
strbuf_addch(path, '/');
2293
strbuf_addch(template_path, '/');
2284
- copy_templates_1(path, template_path, subdir);
2294
+ copy_templates_1(repo, path, template_path, subdir);
2295
closedir(subdir);
2296
}
2297
else if (exists)
@@ -2306,7 +2316,7 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template_path,
2316
}
2317
}
2318
2309
-static void copy_templates(const char *option_template)
2319
+static void copy_templates(struct repository *repo, const char *option_template)
2320
{
2321
const char *template_dir = get_template_dir(option_template);
2322
struct strbuf path = STRBUF_INIT;
@@ -2347,9 +2357,9 @@ static void copy_templates(const char *option_template)
2357
goto close_free_return;
2358
}
2359
2350
- strbuf_addstr(&path, repo_get_common_dir(the_repository));
2360
+ strbuf_addstr(&path, repo_get_common_dir(repo));
2361
strbuf_complete(&path, '/');
2352
- copy_templates_1(&path, &template_path, dir);
2362
+ copy_templates_1(repo, &path, &template_path, dir);
2363
close_free_return:
2364
closedir(dir);
2365
free_return:
@@ -2443,13 +2453,13 @@ void initialize_repository_version(int hash_algo,
2453
strbuf_release(&repo_version);
2454
}
2455
2446
-static int is_reinit(void)
2456
+static int is_reinit(struct repository *repo)
2457
{
2458
struct strbuf buf = STRBUF_INIT;
2459
char junk[2];
2460
int ret;
2461
2452
- repo_git_path_replace(the_repository, &buf, "HEAD");
2462
+ repo_git_path_replace(repo, &buf, "HEAD");
2463
ret = !access(buf.buf, R_OK) || readlink(buf.buf, junk, sizeof(junk) - 1) != -1;
2464
strbuf_release(&buf);
2465
return ret;
@@ -2459,7 +2469,7 @@ void create_reference_database(const char *initial_branch, int quiet)
2469
{
2470
struct strbuf err = STRBUF_INIT;
2471
char *to_free = NULL;
2462
- int reinit = is_reinit();
2472
+ int reinit = is_reinit(the_repository);
2473
2474
if (ref_store_create_on_disk(get_main_ref_store(the_repository), 0, &err))
2475
die("failed to set up refs db: %s", err.buf);
@@ -2493,7 +2503,8 @@ void create_reference_database(const char *initial_branch, int quiet)
2503
free(to_free);
2504
}
2505
2496
-static int create_default_files(const char *template_path,
2506
+static int create_default_files(struct repository *repo,
2507
+ const char *template_path,
2508
const char *original_git_dir,
2509
const struct repository_format *fmt,
2510
int init_shared_repository)
@@ -2502,7 +2513,7 @@ static int create_default_files(const char *template_path,
2513
struct strbuf path = STRBUF_INIT;
2514
int reinit;
2515
int filemode;
2505
- const char *work_tree = repo_get_work_tree(the_repository);
2516
+ const char *work_tree = repo_get_work_tree(repo);
2517
2518
/*
2519
* First copy the templates -- we might have the default
@@ -2513,19 +2524,19 @@ static int create_default_files(const char *template_path,
2524
* values (since we've just potentially changed what's available on
2525
* disk).
2526
*/
2516
- copy_templates(template_path);
2517
- repo_config_clear(the_repository);
2518
- repo_settings_reset_shared_repository(the_repository);
2519
- repo_config(the_repository, git_default_config, NULL);
2527
+ copy_templates(repo, template_path);
2528
+ repo_config_clear(repo);
2529
+ repo_settings_reset_shared_repository(repo);
2530
+ repo_config(repo, git_default_config, NULL);
2531
2521
- reinit = is_reinit();
2532
+ reinit = is_reinit(repo);
2533
2534
/*
2535
* We must make sure command-line options continue to override any
2536
* values we might have just re-read from the config.
2537
*/
2538
if (init_shared_repository != -1)
2528
- repo_settings_set_shared_repository(the_repository,
2539
+ repo_settings_set_shared_repository(repo,
2540
init_shared_repository);
2541
2542
is_bare_repository_cfg = !work_tree;
@@ -2534,14 +2545,14 @@ static int create_default_files(const char *template_path,
2545
* We would have created the above under user's umask -- under
2546
* shared-repository settings, we would need to fix them up.
2547
*/
2537
- if (repo_settings_get_shared_repository(the_repository)) {
2538
- adjust_shared_perm(the_repository, repo_get_git_dir(the_repository));
2548
+ if (repo_settings_get_shared_repository(repo)) {
2549
+ adjust_shared_perm(repo, repo_get_git_dir(repo));
2550
}
2551
2552
initialize_repository_version(fmt->hash_algo, fmt->ref_storage_format, reinit);
2553
2554
/* Check filemode trustability */
2544
- repo_git_path_replace(the_repository, &path, "config");
2555
+ repo_git_path_replace(repo, &path, "config");
2556
filemode = TEST_FILEMODE;
2557
if (TEST_FILEMODE && !lstat(path.buf, &st1)) {
2558
struct stat st2;
@@ -2552,22 +2563,22 @@ static int create_default_files(const char *template_path,
2563
if (filemode && !reinit && (st1.st_mode & S_IXUSR))
2564
filemode = 0;
2565
}
2555
- repo_config_set(the_repository, "core.filemode", filemode ? "true" : "false");
2566
+ repo_config_set(repo, "core.filemode", filemode ? "true" : "false");
2567
2568
if (is_bare_repository())
2558
- repo_config_set(the_repository, "core.bare", "true");
2569
+ repo_config_set(repo, "core.bare", "true");
2570
else {
2560
- repo_config_set(the_repository, "core.bare", "false");
2571
+ repo_config_set(repo, "core.bare", "false");
2572
/* allow template config file to override the default */
2562
- if (repo_settings_get_log_all_ref_updates(the_repository) == LOG_REFS_UNSET)
2563
- repo_config_set(the_repository, "core.logallrefupdates", "true");
2573
+ if (repo_settings_get_log_all_ref_updates(repo) == LOG_REFS_UNSET)
2574
+ repo_config_set(repo, "core.logallrefupdates", "true");
2575
if (needs_work_tree_config(original_git_dir, work_tree))
2565
- repo_config_set(the_repository, "core.worktree", work_tree);
2576
+ repo_config_set(repo, "core.worktree", work_tree);
2577
}
2578
2579
if (!reinit) {
2580
/* Check if symlink is supported in the work tree */
2570
- repo_git_path_replace(the_repository, &path, "tXXXXXX");
2581
+ repo_git_path_replace(repo, &path, "tXXXXXX");
2582
if (!close(xmkstemp(path.buf)) &&
2583
!unlink(path.buf) &&
2584
!symlink("testing", path.buf) &&
@@ -2575,12 +2586,12 @@ static int create_default_files(const char *template_path,
2586
S_ISLNK(st1.st_mode))
2587
unlink(path.buf); /* good */
2588
else
2578
- repo_config_set(the_repository, "core.symlinks", "false");
2589
+ repo_config_set(repo, "core.symlinks", "false");
2590
2591
/* Check if the filesystem is case-insensitive */
2581
- repo_git_path_replace(the_repository, &path, "CoNfIg");
2592
+ repo_git_path_replace(repo, &path, "CoNfIg");
2593
if (!access(path.buf, F_OK))
2583
- repo_config_set(the_repository, "core.ignorecase", "true");
2594
+ repo_config_set(repo, "core.ignorecase", "true");
2595
probe_utf8_pathname_composition();
2596
}
2597
@@ -2588,23 +2599,23 @@ static int create_default_files(const char *template_path,
2599
return reinit;
2600
}
2601
2591
-static void create_object_directory(void)
2602
+static void create_object_directory(struct repository *repo)
2603
{
2604
struct strbuf path = STRBUF_INIT;
2605
size_t baselen;
2606
2596
- strbuf_addstr(&path, repo_get_object_directory(the_repository));
2607
+ strbuf_addstr(&path, repo_get_object_directory(repo));
2608
baselen = path.len;
2609
2599
- safe_create_dir(the_repository, path.buf, 1);
2610
+ safe_create_dir(repo, path.buf, 1);
2611
2612
strbuf_setlen(&path, baselen);
2613
strbuf_addstr(&path, "/pack");
2603
- safe_create_dir(the_repository, path.buf, 1);
2614
+ safe_create_dir(repo, path.buf, 1);
2615
2616
strbuf_setlen(&path, baselen);
2617
strbuf_addstr(&path, "/info");
2607
- safe_create_dir(the_repository, path.buf, 1);
2618
+ safe_create_dir(repo, path.buf, 1);
2619
2620
strbuf_release(&path);
2621
}
@@ -2682,7 +2693,8 @@ out:
2693
return ret;
2694
}
2695
2685
-static void repository_format_configure(struct repository_format *repo_fmt,
2696
+static void repository_format_configure(struct repository *repo,
2697
+ struct repository_format *repo_fmt,
2698
int hash, enum ref_storage_format ref_format)
2699
{
2700
struct default_format_config cfg = {
@@ -2719,7 +2731,7 @@ static void repository_format_configure(struct repository_format *repo_fmt,
2731
} else if (cfg.hash != GIT_HASH_UNKNOWN) {
2732
repo_fmt->hash_algo = cfg.hash;
2733
}
2722
- repo_set_hash_algo(the_repository, repo_fmt->hash_algo);
2734
+ repo_set_hash_algo(repo, repo_fmt->hash_algo);
2735
2736
env = getenv("GIT_DEFAULT_REF_FORMAT");
2737
if (repo_fmt->version >= 0 &&
@@ -2758,7 +2770,7 @@ static void repository_format_configure(struct repository_format *repo_fmt,
2770
free(backend);
2771
}
2772
2761
- repo_set_ref_storage_format(the_repository, repo_fmt->ref_storage_format,
2773
+ repo_set_ref_storage_format(repo, repo_fmt->ref_storage_format,
2774
repo_fmt->ref_storage_payload);
2775
}
2776
@@ -2782,12 +2794,12 @@ int init_db(const char *git_dir, const char *real_git_dir,
2794
if (!exist_ok && !stat(real_git_dir, &st))
2795
die(_("%s already exists"), real_git_dir);
2796
2785
- set_git_dir(real_git_dir, 1);
2797
+ set_git_dir(the_repository, real_git_dir, 1);
2798
git_dir = repo_get_git_dir(the_repository);
2799
separate_git_dir(git_dir, original_git_dir);
2800
}
2801
else {
2790
- set_git_dir(git_dir, 1);
2802
+ set_git_dir(the_repository, git_dir, 1);
2803
git_dir = repo_get_git_dir(the_repository);
2804
}
2805
startup_info->have_repository = 1;
@@ -2800,7 +2812,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
2812
*/
2813
check_repository_format(&repo_fmt);
2814
2803
- repository_format_configure(&repo_fmt, hash, ref_storage_format);
2815
+ repository_format_configure(the_repository, &repo_fmt, hash, ref_storage_format);
2816
2817
/*
2818
* Ensure `core.hidedotfiles` is processed. This must happen after we
@@ -2811,12 +2823,12 @@ int init_db(const char *git_dir, const char *real_git_dir,
2823
2824
safe_create_dir(the_repository, git_dir, 0);
2825
2814
- reinit = create_default_files(template_dir, original_git_dir,
2826
+ reinit = create_default_files(the_repository, template_dir, original_git_dir,
2827
&repo_fmt, init_shared_repository);
2828
2829
if (!(flags & INIT_DB_SKIP_REFDB))
2830
create_reference_database(initial_branch, flags & INIT_DB_QUIET);
2819
- create_object_directory();
2831
+ create_object_directory(the_repository);
2832
2833
if (repo_settings_get_shared_repository(the_repository)) {
2834
char buf[10];