Git fork

config: drop `git_config_set_multivar_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_multivar_in_file_gently()`. All callsites are adjusted
so that they use
`repo_config_set_multivar_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>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
adf9e5f8 62c1ed3e

+26 -38
+22 -22
builtin/config.c
··· 966 value = normalize_value(argv[0], argv[1], type, &default_kvi); 967 968 if ((flags & CONFIG_FLAGS_MULTI_REPLACE) || value_pattern) { 969 - ret = git_config_set_multivar_in_file_gently(location_opts.source.file, 970 - argv[0], value, value_pattern, 971 - comment, flags); 972 } else { 973 ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, 974 argv[0], comment, value); ··· 1010 check_write(&location_opts.source); 1011 1012 if ((flags & CONFIG_FLAGS_MULTI_REPLACE) || value_pattern) 1013 - ret = git_config_set_multivar_in_file_gently(location_opts.source.file, 1014 - argv[0], NULL, value_pattern, 1015 - NULL, flags); 1016 else 1017 ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, argv[0], 1018 NULL, NULL); ··· 1305 check_write(&location_opts.source); 1306 check_argc(argc, 2, 3); 1307 value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi); 1308 - ret = git_config_set_multivar_in_file_gently(location_opts.source.file, 1309 - argv[0], value, argv[2], 1310 - comment, flags); 1311 } 1312 else if (actions == ACTION_ADD) { 1313 check_write(&location_opts.source); 1314 check_argc(argc, 2, 2); 1315 value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi); 1316 - ret = git_config_set_multivar_in_file_gently(location_opts.source.file, 1317 - argv[0], value, 1318 - CONFIG_REGEX_NONE, 1319 - comment, flags); 1320 } 1321 else if (actions == ACTION_REPLACE_ALL) { 1322 check_write(&location_opts.source); 1323 check_argc(argc, 2, 3); 1324 value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi); 1325 - ret = git_config_set_multivar_in_file_gently(location_opts.source.file, 1326 - argv[0], value, argv[2], 1327 - comment, flags | CONFIG_FLAGS_MULTI_REPLACE); 1328 } 1329 else if (actions == ACTION_GET) { 1330 check_argc(argc, 1, 2); ··· 1350 check_write(&location_opts.source); 1351 check_argc(argc, 1, 2); 1352 if (argc == 2) 1353 - ret = git_config_set_multivar_in_file_gently(location_opts.source.file, 1354 - argv[0], NULL, argv[1], 1355 - NULL, flags); 1356 else 1357 ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, 1358 argv[0], NULL, NULL); ··· 1360 else if (actions == ACTION_UNSET_ALL) { 1361 check_write(&location_opts.source); 1362 check_argc(argc, 1, 2); 1363 - ret = git_config_set_multivar_in_file_gently(location_opts.source.file, 1364 - argv[0], NULL, argv[1], 1365 - NULL, flags | CONFIG_FLAGS_MULTI_REPLACE); 1366 } 1367 else if (actions == ACTION_RENAME_SECTION) { 1368 check_write(&location_opts.source);
··· 966 value = normalize_value(argv[0], argv[1], type, &default_kvi); 967 968 if ((flags & CONFIG_FLAGS_MULTI_REPLACE) || value_pattern) { 969 + ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file, 970 + argv[0], value, value_pattern, 971 + comment, flags); 972 } else { 973 ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, 974 argv[0], comment, value); ··· 1010 check_write(&location_opts.source); 1011 1012 if ((flags & CONFIG_FLAGS_MULTI_REPLACE) || value_pattern) 1013 + ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file, 1014 + argv[0], NULL, value_pattern, 1015 + NULL, flags); 1016 else 1017 ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, argv[0], 1018 NULL, NULL); ··· 1305 check_write(&location_opts.source); 1306 check_argc(argc, 2, 3); 1307 value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi); 1308 + ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file, 1309 + argv[0], value, argv[2], 1310 + comment, flags); 1311 } 1312 else if (actions == ACTION_ADD) { 1313 check_write(&location_opts.source); 1314 check_argc(argc, 2, 2); 1315 value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi); 1316 + ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file, 1317 + argv[0], value, 1318 + CONFIG_REGEX_NONE, 1319 + comment, flags); 1320 } 1321 else if (actions == ACTION_REPLACE_ALL) { 1322 check_write(&location_opts.source); 1323 check_argc(argc, 2, 3); 1324 value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi); 1325 + ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file, 1326 + argv[0], value, argv[2], 1327 + comment, flags | CONFIG_FLAGS_MULTI_REPLACE); 1328 } 1329 else if (actions == ACTION_GET) { 1330 check_argc(argc, 1, 2); ··· 1350 check_write(&location_opts.source); 1351 check_argc(argc, 1, 2); 1352 if (argc == 2) 1353 + ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file, 1354 + argv[0], NULL, argv[1], 1355 + NULL, flags); 1356 else 1357 ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, 1358 argv[0], NULL, NULL); ··· 1360 else if (actions == ACTION_UNSET_ALL) { 1361 check_write(&location_opts.source); 1362 check_argc(argc, 1, 2); 1363 + ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file, 1364 + argv[0], NULL, argv[1], 1365 + NULL, flags | CONFIG_FLAGS_MULTI_REPLACE); 1366 } 1367 else if (actions == ACTION_RENAME_SECTION) { 1368 check_write(&location_opts.source);
+2 -2
builtin/gc.c
··· 1938 } 1939 if (!config_file) 1940 die(_("$HOME not set")); 1941 - rc = git_config_set_multivar_in_file_gently( 1942 config_file, "maintenance.repo", maintpath, 1943 CONFIG_REGEX_NONE, NULL, 0); 1944 free(global_config_file); ··· 2007 } 2008 if (!config_file) 2009 die(_("$HOME not set")); 2010 - rc = git_config_set_multivar_in_file_gently( 2011 config_file, key, NULL, maintpath, NULL, 2012 CONFIG_FLAGS_MULTI_REPLACE | CONFIG_FLAGS_FIXED_VALUE); 2013 free(global_config_file);
··· 1938 } 1939 if (!config_file) 1940 die(_("$HOME not set")); 1941 + rc = repo_config_set_multivar_in_file_gently(the_repository, 1942 config_file, "maintenance.repo", maintpath, 1943 CONFIG_REGEX_NONE, NULL, 0); 1944 free(global_config_file); ··· 2007 } 2008 if (!config_file) 2009 die(_("$HOME not set")); 2010 + rc = repo_config_set_multivar_in_file_gently(the_repository, 2011 config_file, key, NULL, maintpath, NULL, 2012 CONFIG_FLAGS_MULTI_REPLACE | CONFIG_FLAGS_FIXED_VALUE); 2013 free(global_config_file);
+1 -1
builtin/worktree.c
··· 379 380 if (!git_configset_get_bool(&cs, "core.bare", &bare) && 381 bare && 382 - git_config_set_multivar_in_file_gently( 383 to_file, "core.bare", NULL, "true", NULL, 0)) 384 error(_("failed to unset '%s' in '%s'"), 385 "core.bare", to_file);
··· 379 380 if (!git_configset_get_bool(&cs, "core.bare", &bare) && 381 bare && 382 + repo_config_set_multivar_in_file_gently(the_repository, 383 to_file, "core.bare", NULL, "true", NULL, 0)) 384 error(_("failed to unset '%s' in '%s'"), 385 "core.bare", to_file);
-12
config.h
··· 734 return repo_config_get_pathname(the_repository, key, dest); 735 } 736 737 - static inline int git_config_set_multivar_in_file_gently( 738 - const char *config_filename, 739 - const char *key, const char *value, 740 - const char *value_pattern, 741 - const char *comment, 742 - unsigned flags) 743 - { 744 - return repo_config_set_multivar_in_file_gently(the_repository, config_filename, 745 - key, value, value_pattern, 746 - comment, flags); 747 - } 748 - 749 static inline void git_config_set_multivar_in_file( 750 const char *config_filename, 751 const char *key,
··· 734 return repo_config_get_pathname(the_repository, key, dest); 735 } 736 737 static inline void git_config_set_multivar_in_file( 738 const char *config_filename, 739 const char *key,
+1 -1
sequencer.c
··· 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)
··· 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 |= repo_config_set_multivar_in_file_gently(the_repository, opts_file, 3694 "options.strategy-option", 3695 opts->xopts.v[i], "^$", NULL, 0); 3696 if (opts->allow_rerere_auto)