Git fork

config: drop `git_config_set_multivar()` 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()`.
All callsites are adjusted so that they use
`repo_config_set_multivar(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
a538250d 1bb3e410

+13 -20
+2 -2
builtin/branch.c
··· 987 988 strbuf_reset(&buf); 989 strbuf_addf(&buf, "branch.%s.remote", branch->name); 990 - git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE); 991 strbuf_reset(&buf); 992 strbuf_addf(&buf, "branch.%s.merge", branch->name); 993 - git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE); 994 strbuf_release(&buf); 995 } else if (!noncreate_actions && argc > 0 && argc <= 2) { 996 const char *branch_name = argv[0];
··· 987 988 strbuf_reset(&buf); 989 strbuf_addf(&buf, "branch.%s.remote", branch->name); 990 + repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE); 991 strbuf_reset(&buf); 992 strbuf_addf(&buf, "branch.%s.merge", branch->name); 993 + repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE); 994 strbuf_release(&buf); 995 } else if (!noncreate_actions && argc > 0 && argc <= 2) { 996 const char *branch_name = argv[0];
+1 -1
builtin/clone.c
··· 822 /* Configure the remote */ 823 if (value.len) { 824 strbuf_addf(&key, "remote.%s.fetch", remote_name); 825 - git_config_set_multivar(key.buf, value.buf, "^$", 0); 826 strbuf_reset(&key); 827 828 if (option_mirror) {
··· 822 /* Configure the remote */ 823 if (value.len) { 824 strbuf_addf(&key, "remote.%s.fetch", remote_name); 825 + repo_config_set_multivar(the_repository, key.buf, value.buf, "^$", 0); 826 strbuf_reset(&key); 827 828 if (option_mirror) {
+10 -10
builtin/remote.c
··· 132 else 133 strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s", 134 branchname, remotename, branchname); 135 - git_config_set_multivar(key, tmp->buf, "^$", 0); 136 } 137 138 static const char mirror_advice[] = ··· 634 635 strbuf_addf(&buf, "remote.%s.url", remote->name); 636 for (i = 0; i < remote->url.nr; i++) 637 - git_config_set_multivar(buf.buf, remote->url.v[i], "^$", 0); 638 strbuf_reset(&buf); 639 strbuf_addf(&buf, "remote.%s.push", remote->name); 640 for (i = 0; i < remote->push.nr; i++) 641 - git_config_set_multivar(buf.buf, remote->push.items[i].raw, "^$", 0); 642 strbuf_reset(&buf); 643 strbuf_addf(&buf, "remote.%s.fetch", remote->name); 644 for (i = 0; i < remote->fetch.nr; i++) 645 - git_config_set_multivar(buf.buf, remote->fetch.items[i].raw, "^$", 0); 646 #ifndef WITH_BREAKING_CHANGES 647 if (remote->origin == REMOTE_REMOTES) 648 unlink_or_warn(repo_git_path_replace(the_repository, &buf, ··· 771 if (oldremote->fetch.nr) { 772 strbuf_reset(&buf); 773 strbuf_addf(&buf, "remote.%s.fetch", rename.new_name); 774 - git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE); 775 strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old_name); 776 for (i = 0; i < oldremote->fetch.nr; i++) { 777 char *ptr; ··· 791 "\tPlease update the configuration manually if necessary."), 792 buf2.buf); 793 794 - git_config_set_multivar(buf.buf, buf2.buf, "^$", 0); 795 } 796 } 797 ··· 1790 /* Special cases that add new entry. */ 1791 if ((!oldurl && !delete_mode) || add_mode) { 1792 if (add_mode) 1793 - git_config_set_multivar(name_buf.buf, newurl, 1794 "^$", 0); 1795 else 1796 repo_config_set(the_repository, name_buf.buf, newurl); ··· 1814 regfree(&old_regex); 1815 1816 if (!delete_mode) 1817 - git_config_set_multivar(name_buf.buf, newurl, oldurl, 0); 1818 else 1819 - git_config_set_multivar(name_buf.buf, NULL, oldurl, 1820 - CONFIG_FLAGS_MULTI_REPLACE); 1821 out: 1822 strbuf_release(&name_buf); 1823 return 0;
··· 132 else 133 strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s", 134 branchname, remotename, branchname); 135 + repo_config_set_multivar(the_repository, key, tmp->buf, "^$", 0); 136 } 137 138 static const char mirror_advice[] = ··· 634 635 strbuf_addf(&buf, "remote.%s.url", remote->name); 636 for (i = 0; i < remote->url.nr; i++) 637 + repo_config_set_multivar(the_repository, buf.buf, remote->url.v[i], "^$", 0); 638 strbuf_reset(&buf); 639 strbuf_addf(&buf, "remote.%s.push", remote->name); 640 for (i = 0; i < remote->push.nr; i++) 641 + repo_config_set_multivar(the_repository, buf.buf, remote->push.items[i].raw, "^$", 0); 642 strbuf_reset(&buf); 643 strbuf_addf(&buf, "remote.%s.fetch", remote->name); 644 for (i = 0; i < remote->fetch.nr; i++) 645 + repo_config_set_multivar(the_repository, buf.buf, remote->fetch.items[i].raw, "^$", 0); 646 #ifndef WITH_BREAKING_CHANGES 647 if (remote->origin == REMOTE_REMOTES) 648 unlink_or_warn(repo_git_path_replace(the_repository, &buf, ··· 771 if (oldremote->fetch.nr) { 772 strbuf_reset(&buf); 773 strbuf_addf(&buf, "remote.%s.fetch", rename.new_name); 774 + repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE); 775 strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old_name); 776 for (i = 0; i < oldremote->fetch.nr; i++) { 777 char *ptr; ··· 791 "\tPlease update the configuration manually if necessary."), 792 buf2.buf); 793 794 + repo_config_set_multivar(the_repository, buf.buf, buf2.buf, "^$", 0); 795 } 796 } 797 ··· 1790 /* Special cases that add new entry. */ 1791 if ((!oldurl && !delete_mode) || add_mode) { 1792 if (add_mode) 1793 + repo_config_set_multivar(the_repository, name_buf.buf, newurl, 1794 "^$", 0); 1795 else 1796 repo_config_set(the_repository, name_buf.buf, newurl); ··· 1814 regfree(&old_regex); 1815 1816 if (!delete_mode) 1817 + repo_config_set_multivar(the_repository, name_buf.buf, newurl, oldurl, 0); 1818 else 1819 + repo_config_set_multivar(the_repository, name_buf.buf, NULL, oldurl, 1820 + CONFIG_FLAGS_MULTI_REPLACE); 1821 out: 1822 strbuf_release(&name_buf); 1823 return 0;
-7
config.h
··· 744 repo_config_set_multivar_in_file(the_repository, config_filename, 745 key, value, value_pattern, flags); 746 } 747 - 748 - static inline void git_config_set_multivar(const char *key, const char *value, 749 - const char *value_pattern, unsigned flags) 750 - { 751 - repo_config_set_multivar(the_repository, key, value, 752 - value_pattern, flags); 753 - } 754 # endif /* USE_THE_REPOSITORY_VARIABLE */ 755 756 #endif /* CONFIG_H */
··· 744 repo_config_set_multivar_in_file(the_repository, config_filename, 745 key, value, value_pattern, flags); 746 } 747 # endif /* USE_THE_REPOSITORY_VARIABLE */ 748 749 #endif /* CONFIG_H */