config: drop `git_config_set_in_file_gently()` wrapper

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_in_file_gently()`. All callsites are adjusted so that they use `repo_config_set_in_file_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>

Patrick Steinhardt committed Jul 23, 2025 at 16:08 UTC 62c1ed3e9d03b7434fd86c257fa04abe47e7b626
8 files changed +28 -38
builtin/config.c
+7 -7
@@ -970,8 +970,8 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix,
970 argv[0], value, value_pattern,
971 comment, flags);
972 } else {
973 - ret = git_config_set_in_file_gently(location_opts.source.file,
974 - argv[0], comment, value);
973 + ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file,
974 + argv[0], comment, value);
975 if (ret == CONFIG_NOTHING_SET)
976 error(_("cannot overwrite multiple values with a single value\n"
977 " Use a regexp, --add or --replace-all to change %s."), argv[0]);
@@ -1014,8 +1014,8 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix,
1014 argv[0], NULL, value_pattern,
1015 NULL, flags);
1016 else
1017 - ret = git_config_set_in_file_gently(location_opts.source.file, argv[0],
1018 - NULL, NULL);
1017 + ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, argv[0],
1018 + NULL, NULL);
1019
1020 location_options_release(&location_opts);
1021 return ret;
@@ -1296,7 +1296,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1296 check_write(&location_opts.source);
1297 check_argc(argc, 2, 2);
1298 value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi);
1299 - ret = git_config_set_in_file_gently(location_opts.source.file, argv[0], comment, value);
1299 + ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, argv[0], comment, value);
1300 if (ret == CONFIG_NOTHING_SET)
1301 error(_("cannot overwrite multiple values with a single value\n"
1302 " Use a regexp, --add or --replace-all to change %s."), argv[0]);
@@ -1354,8 +1354,8 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1354 argv[0], NULL, argv[1],
1355 NULL, flags);
1356 else
1357 - ret = git_config_set_in_file_gently(location_opts.source.file,
1358 - argv[0], NULL, NULL);
1357 + ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file,
1358 + argv[0], NULL, NULL);
1359 }
1360 else if (actions == ACTION_UNSET_ALL) {
1361 check_write(&location_opts.source);
builtin/submodule--helper.c
+1 -1
@@ -1280,7 +1280,7 @@ static void sync_submodule(const char *path, const char *prefix,
1280 submodule_to_gitdir(the_repository, &sb, path);
1281 strbuf_addstr(&sb, "/config");
1282
1283 - if (git_config_set_in_file_gently(sb.buf, remote_key, NULL, sub_origin_url))
1283 + if (repo_config_set_in_file_gently(the_repository, sb.buf, remote_key, NULL, sub_origin_url))
1284 die(_("failed to update remote for submodule '%s'"),
1285 path);
1286
builtin/worktree.c
+2 -2
@@ -384,8 +384,8 @@ static void copy_filtered_worktree_config(const char *worktree_git_dir)
384 error(_("failed to unset '%s' in '%s'"),
385 "core.bare", to_file);
386 if (!git_configset_get(&cs, "core.worktree") &&
387 - git_config_set_in_file_gently(to_file,
388 - "core.worktree", NULL, NULL))
387 + repo_config_set_in_file_gently(the_repository, to_file,
388 + "core.worktree", NULL, NULL))
389 error(_("failed to unset '%s' in '%s'"),
390 "core.worktree", to_file);
391
config.h
-10
@@ -734,16 +734,6 @@ static inline int git_config_get_pathname(const char *key, char **dest)
734 return repo_config_get_pathname(the_repository, key, dest);
735 }
736
737 -static inline int git_config_set_in_file_gently(
738 - const char *config_filename,
739 - const char *key,
740 - const char *comment,
741 - const char *value)
742 -{
743 - return repo_config_set_in_file_gently(the_repository, config_filename,
744 - key, comment, value);
745 -}
746 -
737 static inline int git_config_set_multivar_in_file_gently(
738 const char *config_filename,
739 const char *key, const char *value,
sequencer.c
+14 -14
@@ -3650,57 +3650,57 @@ static int save_opts(struct replay_opts *opts)
3650 int res = 0;
3651
3652 if (opts->no_commit)
3653 - res |= git_config_set_in_file_gently(opts_file,
3653 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3654 "options.no-commit", NULL, "true");
3655 if (opts->edit >= 0)
3656 - res |= git_config_set_in_file_gently(opts_file, "options.edit", NULL,
3656 + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.edit", NULL,
3657 opts->edit ? "true" : "false");
3658 if (opts->allow_empty)
3659 - res |= git_config_set_in_file_gently(opts_file,
3659 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3660 "options.allow-empty", NULL, "true");
3661 if (opts->allow_empty_message)
3662 - res |= git_config_set_in_file_gently(opts_file,
3662 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3663 "options.allow-empty-message", NULL, "true");
3664 if (opts->drop_redundant_commits)
3665 - res |= git_config_set_in_file_gently(opts_file,
3665 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3666 "options.drop-redundant-commits", NULL, "true");
3667 if (opts->keep_redundant_commits)
3668 - res |= git_config_set_in_file_gently(opts_file,
3668 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3669 "options.keep-redundant-commits", NULL, "true");
3670 if (opts->signoff)
3671 - res |= git_config_set_in_file_gently(opts_file,
3671 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3672 "options.signoff", NULL, "true");
3673 if (opts->record_origin)
3674 - res |= git_config_set_in_file_gently(opts_file,
3674 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3675 "options.record-origin", NULL, "true");
3676 if (opts->allow_ff)
3677 - res |= git_config_set_in_file_gently(opts_file,
3677 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3678 "options.allow-ff", NULL, "true");
3679 if (opts->mainline) {
3680 struct strbuf buf = STRBUF_INIT;
3681 strbuf_addf(&buf, "%d", opts->mainline);
3682 - res |= git_config_set_in_file_gently(opts_file,
3682 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3683 "options.mainline", NULL, buf.buf);
3684 strbuf_release(&buf);
3685 }
3686 if (opts->strategy)
3687 - res |= git_config_set_in_file_gently(opts_file,
3687 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3688 "options.strategy", NULL, opts->strategy);
3689 if (opts->gpg_sign)
3690 - res |= git_config_set_in_file_gently(opts_file,
3690 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3691 "options.gpg-sign", NULL, opts->gpg_sign);
3692 for (size_t i = 0; i < opts->xopts.nr; i++)
3693 res |= git_config_set_multivar_in_file_gently(opts_file,
3694 "options.strategy-option",
3695 opts->xopts.v[i], "^$", NULL, 0);
3696 if (opts->allow_rerere_auto)
3697 - res |= git_config_set_in_file_gently(opts_file,
3697 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3698 "options.allow-rerere-auto", NULL,
3699 opts->allow_rerere_auto == RERERE_AUTOUPDATE ?
3700 "true" : "false");
3701
3702 if (opts->explicit_cleanup)
3703 - res |= git_config_set_in_file_gently(opts_file,
3703 + res |= repo_config_set_in_file_gently(the_repository, opts_file,
3704 "options.default-msg-cleanup", NULL,
3705 describe_cleanup_mode(opts->default_msg_cleanup));
3706 return res;
submodule-config.c
+1 -1
@@ -983,7 +983,7 @@ int config_set_in_gitmodules_file_gently(const char *key, const char *value)
983 {
984 int ret;
985
986 - ret = git_config_set_in_file_gently(GITMODULES_FILE, key, NULL, value);
986 + ret = repo_config_set_in_file_gently(the_repository, GITMODULES_FILE, key, NULL, value);
987 if (ret < 0)
988 /* Maybe the user already did that, don't error out here */
989 warning(_("Could not update .gitmodules entry %s"), key);
submodule.c
+1 -1
@@ -2058,7 +2058,7 @@ void submodule_unset_core_worktree(const struct submodule *sub)
2058 submodule_name_to_gitdir(&config_path, the_repository, sub->name);
2059 strbuf_addstr(&config_path, "/config");
2060
2061 - if (git_config_set_in_file_gently(config_path.buf, "core.worktree", NULL, NULL))
2061 + if (repo_config_set_in_file_gently(the_repository, config_path.buf, "core.worktree", NULL, NULL))
2062 warning(_("Could not unset core.worktree setting in submodule '%s'"),
2063 sub->path);
2064
worktree.c
+2 -2
@@ -991,9 +991,9 @@ done:
991 static int move_config_setting(const char *key, const char *value,
992 const char *from_file, const char *to_file)
993 {
994 - if (git_config_set_in_file_gently(to_file, key, NULL, value))
994 + if (repo_config_set_in_file_gently(the_repository, to_file, key, NULL, value))
995 return error(_("unable to set %s in '%s'"), key, to_file);
996 - if (git_config_set_in_file_gently(from_file, key, NULL, NULL))
996 + if (repo_config_set_in_file_gently(the_repository, from_file, key, NULL, NULL))
997 return error(_("unable to unset %s in '%s'"), key, from_file);
998 return 0;
999 }