In
036876a1067 (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_gently()`.
All callsites are adjusted so that they use
`repo_config_set_gently(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>
}
strbuf_addf(&key, "branch.%s.remote", local);
- if (git_config_set_gently(key.buf, origin ? origin : ".") < 0)
+ if (repo_config_set_gently(the_repository, key.buf, origin ? origin : ".") < 0)
goto out_err;
strbuf_reset(&key);
* more than one is provided, use CONFIG_REGEX_NONE to preserve what
* we've written so far.
*/
- if (git_config_set_gently(key.buf, NULL) < 0)
+ if (repo_config_set_gently(the_repository, key.buf, NULL) < 0)
goto out_err;
for_each_string_list_item(item, remotes)
if (git_config_set_multivar_gently(key.buf, item->string, CONFIG_REGEX_NONE, 0) < 0)
if (rebasing) {
strbuf_reset(&key);
strbuf_addf(&key, "branch.%s.rebase", local);
- if (git_config_set_gently(key.buf, "true") < 0)
+ if (repo_config_set_gently(the_repository, key.buf, "true") < 0)
goto out_err;
}
strbuf_release(&key);
warning(_("failed to fetch objects from bundle URI '%s'"),
bundle_uri);
else if (has_heuristic)
- git_config_set_gently("fetch.bundleuri", bundle_uri);
+ repo_config_set_gently(the_repository, "fetch.bundleuri", bundle_uri);
remote_state_clear(the_repository->remote_state);
free(the_repository->remote_state);
if (push_default.scope >= CONFIG_SCOPE_COMMAND)
; /* pass */
else if (push_default.scope >= CONFIG_SCOPE_LOCAL) {
- int result = git_config_set_gently("remote.pushDefault",
- new_name);
+ int result = repo_config_set_gently(the_repository, "remote.pushDefault",
+ new_name);
if (new_name && result && result != CONFIG_NOTHING_SET)
die(_("could not set '%s'"), "remote.pushDefault");
else if (!new_name && result && result != CONFIG_NOTHING_SET)
strbuf_reset(&buf);
strbuf_addf(&buf, "branch.%s.%s",
item->string, *k);
- result = git_config_set_gently(buf.buf, NULL);
+ result = repo_config_set_gently(the_repository, buf.buf, NULL);
if (result && result != CONFIG_NOTHING_SET)
die(_("could not unset '%s'"), buf.buf);
}
if (info->push_remote_name && !strcmp(info->push_remote_name, remote->name)) {
strbuf_reset(&buf);
strbuf_addf(&buf, "branch.%s.pushremote", item->string);
- result = git_config_set_gently(buf.buf, NULL);
+ result = repo_config_set_gently(the_repository, buf.buf, NULL);
if (result && result != CONFIG_NOTHING_SET)
die(_("could not unset '%s'"), buf.buf);
}
*/
if (!is_submodule_active(the_repository, path)) {
strbuf_addf(&sb, "submodule.%s.active", sub->name);
- git_config_set_gently(sb.buf, "true");
+ repo_config_set_gently(the_repository, sb.buf, "true");
strbuf_reset(&sb);
}
free(oldurl);
}
- if (git_config_set_gently(sb.buf, url))
+ if (repo_config_set_gently(the_repository, sb.buf, url))
die(_("Failed to register url for submodule path '%s'"),
displaypath);
if (!(flags & OPT_QUIET))
upd = submodule_update_type_to_string(sub->update_strategy.type);
}
- if (git_config_set_gently(sb.buf, upd))
+ if (repo_config_set_gently(the_repository, sb.buf, upd))
die(_("Failed to register update mode for submodule path '%s'"), displaypath);
}
strbuf_release(&sb);
strbuf_reset(&sb);
strbuf_addf(&sb, "submodule.%s.url", sub->name);
- if (git_config_set_gently(sb.buf, super_config_url))
+ if (repo_config_set_gently(the_repository, sb.buf, super_config_url))
die(_("failed to register url for submodule path '%s'"),
displaypath);
struct child_process add_gitmodules = CHILD_PROCESS_INIT;
key = xstrfmt("submodule.%s.url", add_data->sm_name);
- git_config_set_gently(key, add_data->realrepo);
+ repo_config_set_gently(the_repository, key, add_data->realrepo);
free(key);
add_submod.git_cmd = 1;
*/
if (!is_submodule_active(the_repository, add_data->sm_path)) {
key = xstrfmt("submodule.%s.active", add_data->sm_name);
- git_config_set_gently(key, "true");
+ repo_config_set_gently(the_repository, key, "true");
free(key);
}
} else {
key = xstrfmt("submodule.%s.active", add_data->sm_name);
- git_config_set_gently(key, "true");
+ repo_config_set_gently(the_repository, key, "true");
free(key);
}
}
return repo_config_get_pathname(the_repository, key, dest);
}
-static inline int git_config_set_gently(const char *key, const char *value)
-{
- return repo_config_set_gently(the_repository, key, value);
-}
-
static inline void git_config_set(const char *key, const char *value)
{
repo_config_set(the_repository, key, value);
if ((reconfigure && config->overwrite_on_reconfigure) ||
repo_config_get_string(the_repository, config->key, &value)) {
trace2_data_string("scalar", the_repository, config->key, "created");
- res = git_config_set_gently(config->key, config->value);
+ res = repo_config_set_gently(the_repository, config->key, config->value);
} else {
trace2_data_string("scalar", the_repository, config->key, "exists");
res = 0;
value = strchr(buf.buf, '=');
if (value)
*(value++) = '\0';
- res = git_config_set_gently(buf.buf, value);
+ res = repo_config_set_gently(the_repository, buf.buf, value);
strbuf_release(&buf);
return res;
git_config_set("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));
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;
*/
if (r->repository_format_worktree_config)
return 0;
- if ((res = git_config_set_gently("extensions.worktreeConfig", "true")))
+ if ((res = repo_config_set_gently(the_repository, "extensions.worktreeConfig", "true")))
return error(_("failed to set extensions.worktreeConfig setting"));
common_config_file = xstrfmt("%s/config", r->commondir);
if (use_relative_paths && !the_repository->repository_format_relative_worktrees) {
if (upgrade_repository_format(1) < 0)
die(_("unable to upgrade repository format to support relative worktrees"));
- if (git_config_set_gently("extensions.relativeWorktrees", "true"))
+ if (repo_config_set_gently(the_repository, "extensions.relativeWorktrees", "true"))
die(_("unable to set extensions.relativeWorktrees setting"));
the_repository->repository_format_relative_worktrees = 1;
}