Skip to content

Commit a538250

Browse files
pks-tgitster
authored andcommitted
config: drop git_config_set_multivar() wrapper
In 036876a (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1bb3e41 commit a538250

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

builtin/branch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,10 @@ int cmd_branch(int argc,
987987

988988
strbuf_reset(&buf);
989989
strbuf_addf(&buf, "branch.%s.remote", branch->name);
990-
git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
990+
repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
991991
strbuf_reset(&buf);
992992
strbuf_addf(&buf, "branch.%s.merge", branch->name);
993-
git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
993+
repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
994994
strbuf_release(&buf);
995995
} else if (!noncreate_actions && argc > 0 && argc <= 2) {
996996
const char *branch_name = argv[0];

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ static void write_refspec_config(const char *src_ref_prefix,
822822
/* Configure the remote */
823823
if (value.len) {
824824
strbuf_addf(&key, "remote.%s.fetch", remote_name);
825-
git_config_set_multivar(key.buf, value.buf, "^$", 0);
825+
repo_config_set_multivar(the_repository, key.buf, value.buf, "^$", 0);
826826
strbuf_reset(&key);
827827

828828
if (option_mirror) {

builtin/remote.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void add_branch(const char *key, const char *branchname,
132132
else
133133
strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s",
134134
branchname, remotename, branchname);
135-
git_config_set_multivar(key, tmp->buf, "^$", 0);
135+
repo_config_set_multivar(the_repository, key, tmp->buf, "^$", 0);
136136
}
137137

138138
static const char mirror_advice[] =
@@ -634,15 +634,15 @@ static int migrate_file(struct remote *remote)
634634

635635
strbuf_addf(&buf, "remote.%s.url", remote->name);
636636
for (i = 0; i < remote->url.nr; i++)
637-
git_config_set_multivar(buf.buf, remote->url.v[i], "^$", 0);
637+
repo_config_set_multivar(the_repository, buf.buf, remote->url.v[i], "^$", 0);
638638
strbuf_reset(&buf);
639639
strbuf_addf(&buf, "remote.%s.push", remote->name);
640640
for (i = 0; i < remote->push.nr; i++)
641-
git_config_set_multivar(buf.buf, remote->push.items[i].raw, "^$", 0);
641+
repo_config_set_multivar(the_repository, buf.buf, remote->push.items[i].raw, "^$", 0);
642642
strbuf_reset(&buf);
643643
strbuf_addf(&buf, "remote.%s.fetch", remote->name);
644644
for (i = 0; i < remote->fetch.nr; i++)
645-
git_config_set_multivar(buf.buf, remote->fetch.items[i].raw, "^$", 0);
645+
repo_config_set_multivar(the_repository, buf.buf, remote->fetch.items[i].raw, "^$", 0);
646646
#ifndef WITH_BREAKING_CHANGES
647647
if (remote->origin == REMOTE_REMOTES)
648648
unlink_or_warn(repo_git_path_replace(the_repository, &buf,
@@ -771,7 +771,7 @@ static int mv(int argc, const char **argv, const char *prefix,
771771
if (oldremote->fetch.nr) {
772772
strbuf_reset(&buf);
773773
strbuf_addf(&buf, "remote.%s.fetch", rename.new_name);
774-
git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
774+
repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
775775
strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old_name);
776776
for (i = 0; i < oldremote->fetch.nr; i++) {
777777
char *ptr;
@@ -791,7 +791,7 @@ static int mv(int argc, const char **argv, const char *prefix,
791791
"\tPlease update the configuration manually if necessary."),
792792
buf2.buf);
793793

794-
git_config_set_multivar(buf.buf, buf2.buf, "^$", 0);
794+
repo_config_set_multivar(the_repository, buf.buf, buf2.buf, "^$", 0);
795795
}
796796
}
797797

@@ -1790,7 +1790,7 @@ static int set_url(int argc, const char **argv, const char *prefix,
17901790
/* Special cases that add new entry. */
17911791
if ((!oldurl && !delete_mode) || add_mode) {
17921792
if (add_mode)
1793-
git_config_set_multivar(name_buf.buf, newurl,
1793+
repo_config_set_multivar(the_repository, name_buf.buf, newurl,
17941794
"^$", 0);
17951795
else
17961796
repo_config_set(the_repository, name_buf.buf, newurl);
@@ -1814,10 +1814,10 @@ static int set_url(int argc, const char **argv, const char *prefix,
18141814
regfree(&old_regex);
18151815

18161816
if (!delete_mode)
1817-
git_config_set_multivar(name_buf.buf, newurl, oldurl, 0);
1817+
repo_config_set_multivar(the_repository, name_buf.buf, newurl, oldurl, 0);
18181818
else
1819-
git_config_set_multivar(name_buf.buf, NULL, oldurl,
1820-
CONFIG_FLAGS_MULTI_REPLACE);
1819+
repo_config_set_multivar(the_repository, name_buf.buf, NULL, oldurl,
1820+
CONFIG_FLAGS_MULTI_REPLACE);
18211821
out:
18221822
strbuf_release(&name_buf);
18231823
return 0;

config.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,6 @@ static inline void git_config_set_multivar_in_file(
744744
repo_config_set_multivar_in_file(the_repository, config_filename,
745745
key, value, value_pattern, flags);
746746
}
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-
}
754747
# endif /* USE_THE_REPOSITORY_VARIABLE */
755748

756749
#endif /* CONFIG_H */

0 commit comments

Comments
 (0)