config: drop `git_config_set()` wrapper

In 036876a106 (config: hide functions using `the_repository` by
default, 2024-08-13) we have moved around a bunch of functions in the
config subsystem that depend on `the_repository`. Those function have
been converted into mere wrappers around their equivalent function that
takes in a repository as parameter, and the intent was that we'll
eventually remove those wrappers to make the dependency on the global
repository variable explicit at the callsite.

Follow through with that intent and remove `git_config_set()`. All
callsites are adjusted so that they use `repo_config_set(the_repository,
...)` instead. While some callsites might already have a repository
available, this mechanical conversion is the exact same as the current
situation and thus cannot cause any regression. Those sites should
eventually be cleaned up in a later patch series.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Patrick Steinhardt 2025-07-23 16:08:35 +02:00 committed by Junio C Hamano
parent b1659e63e2
commit e957ed2b27
9 changed files with 36 additions and 41 deletions

View File

@ -699,7 +699,7 @@ static int edit_branch_description(const char *branch_name)

strbuf_addf(&name, "branch.%s.description", branch_name);
if (buf.len || exists)
git_config_set(name.buf, buf.len ? buf.buf : NULL);
repo_config_set(the_repository, name.buf, buf.len ? buf.buf : NULL);
strbuf_release(&name);
strbuf_release(&buf);


View File

@ -827,7 +827,7 @@ static void write_refspec_config(const char *src_ref_prefix,

if (option_mirror) {
strbuf_addf(&key, "remote.%s.mirror", remote_name);
git_config_set(key.buf, "true");
repo_config_set(the_repository, key.buf, "true");
strbuf_reset(&key);
}
}
@ -1294,18 +1294,18 @@ int cmd_clone(int argc,
src_ref_prefix = "refs/";
strbuf_addstr(&branch_top, src_ref_prefix);

git_config_set("core.bare", "true");
repo_config_set(the_repository, "core.bare", "true");
} else if (!option_rev) {
strbuf_addf(&branch_top, "refs/remotes/%s/", remote_name);
}

strbuf_addf(&key, "remote.%s.url", remote_name);
git_config_set(key.buf, repo);
repo_config_set(the_repository, key.buf, repo);
strbuf_reset(&key);

if (!option_tags) {
strbuf_addf(&key, "remote.%s.tagOpt", remote_name);
git_config_set(key.buf, "--no-tags");
repo_config_set(the_repository, key.buf, "--no-tags");
strbuf_reset(&key);
}


View File

@ -1913,11 +1913,11 @@ static int maintenance_register(int argc, const char **argv, const char *prefix,
options);

/* Disable foreground maintenance */
git_config_set("maintenance.auto", "false");
repo_config_set(the_repository, "maintenance.auto", "false");

/* Set maintenance strategy, if unset */
if (repo_config_get(the_repository, "maintenance.strategy"))
git_config_set("maintenance.strategy", "incremental");
repo_config_set(the_repository, "maintenance.strategy", "incremental");

if (!repo_config_get_string_multi(the_repository, key, &list)) {
for_each_string_list_item(item, list) {

View File

@ -209,7 +209,7 @@ static int add(int argc, const char **argv, const char *prefix,
die(_("'%s' is not a valid remote name"), name);

strbuf_addf(&buf, "remote.%s.url", name);
git_config_set(buf.buf, url);
repo_config_set(the_repository, buf.buf, url);

if (!mirror || mirror & MIRROR_FETCH) {
strbuf_reset(&buf);
@ -225,13 +225,13 @@ static int add(int argc, const char **argv, const char *prefix,
if (mirror & MIRROR_PUSH) {
strbuf_reset(&buf);
strbuf_addf(&buf, "remote.%s.mirror", name);
git_config_set(buf.buf, "true");
repo_config_set(the_repository, buf.buf, "true");
}

if (fetch_tags != TAGS_DEFAULT) {
strbuf_reset(&buf);
strbuf_addf(&buf, "remote.%s.tagOpt", name);
git_config_set(buf.buf,
repo_config_set(the_repository, buf.buf,
fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
}

@ -802,12 +802,12 @@ static int mv(int argc, const char **argv, const char *prefix,
if (info->remote_name && !strcmp(info->remote_name, rename.old_name)) {
strbuf_reset(&buf);
strbuf_addf(&buf, "branch.%s.remote", item->string);
git_config_set(buf.buf, rename.new_name);
repo_config_set(the_repository, buf.buf, rename.new_name);
}
if (info->push_remote_name && !strcmp(info->push_remote_name, rename.old_name)) {
strbuf_reset(&buf);
strbuf_addf(&buf, "branch.%s.pushRemote", item->string);
git_config_set(buf.buf, rename.new_name);
repo_config_set(the_repository, buf.buf, rename.new_name);
}
}

@ -1503,7 +1503,7 @@ static int set_head(int argc, const char **argv, const char *prefix,
struct strbuf config_name = STRBUF_INIT;
strbuf_addf(&config_name,
"remote.%s.followremotehead", remote->name);
git_config_set(config_name.buf, "warn");
repo_config_set(the_repository, config_name.buf, "warn");
strbuf_release(&config_name);
}

@ -1793,7 +1793,7 @@ static int set_url(int argc, const char **argv, const char *prefix,
git_config_set_multivar(name_buf.buf, newurl,
"^$", 0);
else
git_config_set(name_buf.buf, newurl);
repo_config_set(the_repository, name_buf.buf, newurl);
goto out;
}


View File

@ -56,7 +56,7 @@ void probe_utf8_pathname_composition(void)
close(output_fd);
repo_git_path_replace(the_repository, &path, "%s", auml_nfd);
precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
git_config_set("core.precomposeunicode",
repo_config_set(the_repository, "core.precomposeunicode",
precomposed_unicode ? "true" : "false");
repo_git_path_replace(the_repository, &path, "%s", auml_nfc);
if (unlink(path.buf))

View File

@ -2748,7 +2748,7 @@ void git_die_config(struct repository *r, const char *key, const char *err, ...)
}

/*
* Find all the stuff for git_config_set() below.
* Find all the stuff for repo_config_set() below.
*/

struct config_store_data {

View File

@ -734,11 +734,6 @@ static inline int git_config_get_pathname(const char *key, char **dest)
return repo_config_get_pathname(the_repository, key, dest);
}

static inline void git_config_set(const char *key, const char *value)
{
repo_config_set(the_repository, key, value);
}

static inline int git_config_set_in_file_gently(
const char *config_filename,
const char *key,

View File

@ -350,7 +350,7 @@ void partial_clone_register(

/* Add promisor config for the remote */
cfg_name = xstrfmt("remote.%s.promisor", remote);
git_config_set(cfg_name, "true");
repo_config_set(the_repository, cfg_name, "true");
free(cfg_name);
}

@ -360,7 +360,7 @@ void partial_clone_register(
*/
filter_name = xstrfmt("remote.%s.partialclonefilter", remote);
/* NEEDSWORK: 'expand' result leaking??? */
git_config_set(filter_name,
repo_config_set(the_repository, filter_name,
expand_list_objects_filter_spec(filter_options));
free(filter_name);


26
setup.c
View File

@ -815,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;

@ -2233,13 +2233,13 @@ void initialize_repository_version(int hash_algo,
target_version = GIT_REPO_VERSION_READ;

if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)
git_config_set("extensions.objectformat",
repo_config_set(the_repository, "extensions.objectformat",
hash_algos[hash_algo].name);
else if (reinit)
repo_config_set_gently(the_repository, "extensions.objectformat", NULL);

if (ref_storage_format != REF_STORAGE_FORMAT_FILES)
git_config_set("extensions.refstorage",
repo_config_set(the_repository, "extensions.refstorage",
ref_storage_format_to_name(ref_storage_format));
else if (reinit)
repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
@ -2259,7 +2259,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);
}
@ -2375,17 +2375,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) {
@ -2398,12 +2398,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();
}

@ -2639,8 +2639,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)) {