summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c75
1 files changed, 48 insertions, 27 deletions
diff --git a/setup.c b/setup.c
index f93bd6a24a..7086741e6c 100644
--- a/setup.c
+++ b/setup.c
@@ -753,7 +753,8 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
die("%s", err.buf);
}
- repository_format_precious_objects = candidate->precious_objects;
+ the_repository->repository_format_precious_objects = candidate->precious_objects;
+
string_list_clear(&candidate->unknown_extensions, 0);
string_list_clear(&candidate->v1_only_extensions, 0);
@@ -814,7 +815,7 @@ int upgrade_repository_format(int target_version)
}
strbuf_addf(&repo_version, "%d", target_version);
- git_config_set("core.repositoryformatversion", repo_version.buf);
+ repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
ret = 1;
@@ -835,9 +836,12 @@ static void init_repository_format(struct repository_format *format)
int read_repository_format(struct repository_format *format, const char *path)
{
clear_repository_format(format);
+ format->hash_algo = GIT_HASH_SHA1_LEGACY;
git_config_from_file(check_repo_format, path, format);
- if (format->version == -1)
+ if (format->version == -1) {
clear_repository_format(format);
+ format->hash_algo = GIT_HASH_SHA1_LEGACY;
+ }
return format->version;
}
@@ -1456,8 +1460,9 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
if (env_ceiling_dirs) {
int empty_entry_found = 0;
+ static const char path_sep[] = { PATH_SEP, '\0' };
- string_list_split(&ceiling_dirs, env_ceiling_dirs, PATH_SEP, -1);
+ string_list_split(&ceiling_dirs, env_ceiling_dirs, path_sep, -1);
filter_string_list(&ceiling_dirs, 0,
canonicalize_ceiling_entry, &empty_entry_found);
ceil_offset = longest_ancestor_length(dir->buf, &ceiling_dirs);
@@ -1737,7 +1742,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
* configuration (including the per-repo config file that we
* ignored previously).
*/
- git_config_clear();
+ repo_config_clear(the_repository);
/*
* Let's assume that we are in a git repository.
@@ -1864,6 +1869,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
the_repository->repository_format_partial_clone =
repo_fmt.partial_clone;
repo_fmt.partial_clone = NULL;
+ the_repository->repository_format_precious_objects =
+ repo_fmt.precious_objects;
}
}
/*
@@ -1871,7 +1878,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
* the core.precomposeunicode configuration, this
* has to happen after the above block that finds
* out where the repository is, i.e. a preparation
- * for calling git_config_get_bool().
+ * for calling repo_config_get_bool().
*/
if (prefix) {
prefix = precompose_string_if_needed(prefix);
@@ -2222,21 +2229,21 @@ void initialize_repository_version(int hash_algo,
* version will get adjusted by git-clone(1) once it has learned about
* the remote repository's format.
*/
- if (hash_algo != GIT_HASH_SHA1 ||
+ if (hash_algo != GIT_HASH_SHA1_LEGACY ||
ref_storage_format != REF_STORAGE_FORMAT_FILES)
target_version = GIT_REPO_VERSION_READ;
- if (hash_algo != GIT_HASH_SHA1 && hash_algo != GIT_HASH_UNKNOWN)
- git_config_set("extensions.objectformat",
- hash_algos[hash_algo].name);
+ if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)
+ repo_config_set(the_repository, "extensions.objectformat",
+ hash_algos[hash_algo].name);
else if (reinit)
- git_config_set_gently("extensions.objectformat", NULL);
+ repo_config_set_gently(the_repository, "extensions.objectformat", NULL);
if (ref_storage_format != REF_STORAGE_FORMAT_FILES)
- git_config_set("extensions.refstorage",
- ref_storage_format_to_name(ref_storage_format));
+ repo_config_set(the_repository, "extensions.refstorage",
+ ref_storage_format_to_name(ref_storage_format));
else if (reinit)
- git_config_set_gently("extensions.refstorage", NULL);
+ repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
if (reinit) {
struct strbuf config = STRBUF_INIT;
@@ -2253,7 +2260,7 @@ void initialize_repository_version(int hash_algo,
}
strbuf_addf(&repo_version, "%d", target_version);
- git_config_set("core.repositoryformatversion", repo_version.buf);
+ repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
strbuf_release(&repo_version);
}
@@ -2331,9 +2338,9 @@ static int create_default_files(const char *template_path,
* disk).
*/
copy_templates(template_path);
- git_config_clear();
+ repo_config_clear(the_repository);
repo_settings_reset_shared_repository(the_repository);
- git_config(git_default_config, NULL);
+ repo_config(the_repository, git_default_config, NULL);
reinit = is_reinit();
@@ -2369,17 +2376,17 @@ static int create_default_files(const char *template_path,
if (filemode && !reinit && (st1.st_mode & S_IXUSR))
filemode = 0;
}
- git_config_set("core.filemode", filemode ? "true" : "false");
+ repo_config_set(the_repository, "core.filemode", filemode ? "true" : "false");
if (is_bare_repository())
- git_config_set("core.bare", "true");
+ repo_config_set(the_repository, "core.bare", "true");
else {
- git_config_set("core.bare", "false");
+ repo_config_set(the_repository, "core.bare", "false");
/* allow template config file to override the default */
if (repo_settings_get_log_all_ref_updates(the_repository) == LOG_REFS_UNSET)
- git_config_set("core.logallrefupdates", "true");
+ repo_config_set(the_repository, "core.logallrefupdates", "true");
if (needs_work_tree_config(original_git_dir, work_tree))
- git_config_set("core.worktree", work_tree);
+ repo_config_set(the_repository, "core.worktree", work_tree);
}
if (!reinit) {
@@ -2392,12 +2399,12 @@ static int create_default_files(const char *template_path,
S_ISLNK(st1.st_mode))
unlink(path.buf); /* good */
else
- git_config_set("core.symlinks", "false");
+ repo_config_set(the_repository, "core.symlinks", "false");
/* Check if the filesystem is case-insensitive */
repo_git_path_replace(the_repository, &path, "CoNfIg");
if (!access(path.buf, F_OK))
- git_config_set("core.ignorecase", "true");
+ repo_config_set(the_repository, "core.ignorecase", "true");
probe_utf8_pathname_composition();
}
@@ -2481,6 +2488,18 @@ static int read_default_format_config(const char *key, const char *value,
goto out;
}
+ /*
+ * Enable the reftable format when "features.experimental" is enabled.
+ * "init.defaultRefFormat" takes precedence over this setting.
+ */
+ if (!strcmp(key, "feature.experimental") &&
+ cfg->ref_format == REF_STORAGE_FORMAT_UNKNOWN &&
+ git_config_bool(key, value)) {
+ cfg->ref_format = REF_STORAGE_FORMAT_REFTABLE;
+ ret = 0;
+ goto out;
+ }
+
ret = 0;
out:
free(str);
@@ -2541,6 +2560,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
repo_fmt->ref_storage_format = ref_format;
} else if (cfg.ref_format != REF_STORAGE_FORMAT_UNKNOWN) {
repo_fmt->ref_storage_format = cfg.ref_format;
+ } else {
+ repo_fmt->ref_storage_format = REF_STORAGE_FORMAT_DEFAULT;
}
repo_set_ref_storage_format(the_repository, repo_fmt->ref_storage_format);
}
@@ -2590,7 +2611,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
* have set up the repository format such that we can evaluate
* includeIf conditions correctly in the case of re-initialization.
*/
- git_config(platform_core_config, NULL);
+ repo_config(the_repository, platform_core_config, NULL);
safe_create_dir(the_repository, git_dir, 0);
@@ -2619,8 +2640,8 @@ int init_db(const char *git_dir, const char *real_git_dir,
xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
else
BUG("invalid value for shared_repository");
- git_config_set("core.sharedrepository", buf);
- git_config_set("receive.denyNonFastforwards", "true");
+ repo_config_set(the_repository, "core.sharedrepository", buf);
+ repo_config_set(the_repository, "receive.denyNonFastforwards", "true");
}
if (!(flags & INIT_DB_QUIET)) {