git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 18/21] config: drop `git_config_set_multivar()` wrapper

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 23, 2025, 14:08 UTC
Message-ID
<20250723-pks-config-wo-the-repository-v2-18-1502d60d3867@pks.im>
In-Reply-To
<20250723-pks-config-wo-the-repository-v2-0-1502d60d3867@pks.im>

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>
---
 builtin/branch.c |  4 ++--
 builtin/clone.c  |  2 +-
 builtin/remote.c | 20 ++++++++++----------
 config.h         |  7 -------
 4 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 5de0691d18d..fa5ced452e5 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -987,10 +987,10 @@ int cmd_branch(int argc,
 
 		strbuf_reset(&buf);
 		strbuf_addf(&buf, "branch.%s.remote", branch->name);
-		git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
+		repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
 		strbuf_reset(&buf);
 		strbuf_addf(&buf, "branch.%s.merge", branch->name);
-		git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
+		repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
 		strbuf_release(&buf);
 	} else if (!noncreate_actions && argc > 0 && argc <= 2) {
 		const char *branch_name = argv[0];
diff --git a/builtin/clone.c b/builtin/clone.c
index 183297787cb..c990f398ef6 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -822,7 +822,7 @@ static void write_refspec_config(const char *src_ref_prefix,
 		/* Configure the remote */
 		if (value.len) {
 			strbuf_addf(&key, "remote.%s.fetch", remote_name);
-			git_config_set_multivar(key.buf, value.buf, "^$", 0);
+			repo_config_set_multivar(the_repository, key.buf, value.buf, "^$", 0);
 			strbuf_reset(&key);
 
 			if (option_mirror) {
diff --git a/builtin/remote.c b/builtin/remote.c
index dd340a33259..4c63a8bb576 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -132,7 +132,7 @@ static void add_branch(const char *key, const char *branchname,
 	else
 		strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s",
 				branchname, remotename, branchname);
-	git_config_set_multivar(key, tmp->buf, "^$", 0);
+	repo_config_set_multivar(the_repository, key, tmp->buf, "^$", 0);
 }
 
 static const char mirror_advice[] =
@@ -634,15 +634,15 @@ static int migrate_file(struct remote *remote)
 
 	strbuf_addf(&buf, "remote.%s.url", remote->name);
 	for (i = 0; i < remote->url.nr; i++)
-		git_config_set_multivar(buf.buf, remote->url.v[i], "^$", 0);
+		repo_config_set_multivar(the_repository, buf.buf, remote->url.v[i], "^$", 0);
 	strbuf_reset(&buf);
 	strbuf_addf(&buf, "remote.%s.push", remote->name);
 	for (i = 0; i < remote->push.nr; i++)
-		git_config_set_multivar(buf.buf, remote->push.items[i].raw, "^$", 0);
+		repo_config_set_multivar(the_repository, buf.buf, remote->push.items[i].raw, "^$", 0);
 	strbuf_reset(&buf);
 	strbuf_addf(&buf, "remote.%s.fetch", remote->name);
 	for (i = 0; i < remote->fetch.nr; i++)
-		git_config_set_multivar(buf.buf, remote->fetch.items[i].raw, "^$", 0);
+		repo_config_set_multivar(the_repository, buf.buf, remote->fetch.items[i].raw, "^$", 0);
 #ifndef WITH_BREAKING_CHANGES
 	if (remote->origin == REMOTE_REMOTES)
 		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,
 	if (oldremote->fetch.nr) {
 		strbuf_reset(&buf);
 		strbuf_addf(&buf, "remote.%s.fetch", rename.new_name);
-		git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
+		repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
 		strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old_name);
 		for (i = 0; i < oldremote->fetch.nr; i++) {
 			char *ptr;
@@ -791,7 +791,7 @@ static int mv(int argc, const char **argv, const char *prefix,
 					  "\tPlease update the configuration manually if necessary."),
 					buf2.buf);
 
-			git_config_set_multivar(buf.buf, buf2.buf, "^$", 0);
+			repo_config_set_multivar(the_repository, buf.buf, buf2.buf, "^$", 0);
 		}
 	}
 
@@ -1790,7 +1790,7 @@ static int set_url(int argc, const char **argv, const char *prefix,
 	/* Special cases that add new entry. */
 	if ((!oldurl && !delete_mode) || add_mode) {
 		if (add_mode)
-			git_config_set_multivar(name_buf.buf, newurl,
+			repo_config_set_multivar(the_repository, name_buf.buf, newurl,
 						       "^$", 0);
 		else
 			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,
 	regfree(&old_regex);
 
 	if (!delete_mode)
-		git_config_set_multivar(name_buf.buf, newurl, oldurl, 0);
+		repo_config_set_multivar(the_repository, name_buf.buf, newurl, oldurl, 0);
 	else
-		git_config_set_multivar(name_buf.buf, NULL, oldurl,
-					CONFIG_FLAGS_MULTI_REPLACE);
+		repo_config_set_multivar(the_repository, name_buf.buf, NULL, oldurl,
+					 CONFIG_FLAGS_MULTI_REPLACE);
 out:
 	strbuf_release(&name_buf);
 	return 0;
diff --git a/config.h b/config.h
index a90b814292c..61774f17db3 100644
--- a/config.h
+++ b/config.h
@@ -744,13 +744,6 @@ static inline void git_config_set_multivar_in_file(
 	repo_config_set_multivar_in_file(the_repository, config_filename,
 					 key, value, value_pattern, flags);
 }
-
-static inline void git_config_set_multivar(const char *key, const char *value,
-			     const char *value_pattern, unsigned flags)
-{
-	repo_config_set_multivar(the_repository, key, value,
-				 value_pattern, flags);
-}
 # endif /* USE_THE_REPOSITORY_VARIABLE */
 
 #endif /* CONFIG_H */
-- 
2.50.1.552.g942d659e1b.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 43 of 48 in “config: remove use of `the_repository`”
  1. 00/21 config: remove use of `the_repository`Patrick Steinhardt, Jul 17, 2025
  2. 01/21 config: drop `git_config()` wrapperPatrick Steinhardt, Jul 17, 2025
  3. 02/21 config: drop `git_config_clear()` wrapperPatrick Steinhardt, Jul 17, 2025
  4. 03/21 config: drop `git_config_get()` wrapperPatrick Steinhardt, Jul 17, 2025
  5. 04/21 config: drop `git_config_get_value()` wrapperPatrick Steinhardt, Jul 17, 2025
  6. 05/21 config: drop `git_config_get_value()` wrapperPatrick Steinhardt, Jul 17, 2025
  7. 06/21 config: drop `git_config_get_string_multi()` wrapperPatrick Steinhardt, Jul 17, 2025
  8. 07/21 config: drop `git_config_get_string()` wrapperPatrick Steinhardt, Jul 17, 2025
  9. 08/21 config: drop `git_config_get_string()` wrapperPatrick Steinhardt, Jul 17, 2025
  10. 09/21 config: drop `git_config_get_int()` wrapperPatrick Steinhardt, Jul 17, 2025
  11. 10/21 config: drop `git_config_get_ulong()` wrapperPatrick Steinhardt, Jul 17, 2025
  12. 11/21 config: drop `git_config_get_bool()` wrapperPatrick Steinhardt, Jul 17, 2025
  13. 12/21 config: drop `git_config_set_in_file()` wrapperPatrick Steinhardt, Jul 17, 2025
  14. 13/21 config: drop `git_config_set_gently()` wrapperPatrick Steinhardt, Jul 17, 2025
  15. 14/21 config: drop `git_config_set()` wrapperPatrick Steinhardt, Jul 17, 2025
  16. 15/21 config: drop `git_config_set_in_file_gently()` wrapperPatrick Steinhardt, Jul 17, 2025
  17. 16/21 config: drop `git_config_set_multivar_in_file_gently()` wrapperPatrick Steinhardt, Jul 17, 2025
  18. 17/21 config: drop `git_config_get_multivar_gently()` wrapperPatrick Steinhardt, Jul 17, 2025
  19. 18/21 config: drop `git_config_set_multivar()` wrapperPatrick Steinhardt, Jul 17, 2025
  20. 19/21 config: remove unused `the_repository` wrappersPatrick Steinhardt, Jul 17, 2025
  21. 20/21 config: move Git config parsing into "environment.c"Patrick Steinhardt, Jul 17, 2025
  22. 21/21 config: fix sign comparison warningsPatrick Steinhardt, Jul 17, 2025
  23. Phillip WoodJul 23, 2025
  24. Patrick SteinhardtJul 23, 2025
  25. 00/21 config: remove use of `the_repository`Patrick Steinhardt, Jul 23, 2025
  26. 01/21 config: drop `git_config()` wrapperPatrick Steinhardt, Jul 23, 2025
  27. 02/21 config: drop `git_config_clear()` wrapperPatrick Steinhardt, Jul 23, 2025
  28. 03/21 config: drop `git_config_get()` wrapperPatrick Steinhardt, Jul 23, 2025
  29. 04/21 config: drop `git_config_get_value()` wrapperPatrick Steinhardt, Jul 23, 2025
  30. 05/21 config: drop `git_config_get_value()` wrapperPatrick Steinhardt, Jul 23, 2025
  31. 06/21 config: drop `git_config_get_string_multi()` wrapperPatrick Steinhardt, Jul 23, 2025
  32. 07/21 config: drop `git_config_get_string()` wrapperPatrick Steinhardt, Jul 23, 2025
  33. 08/21 config: drop `git_config_get_string()` wrapperPatrick Steinhardt, Jul 23, 2025
  34. 09/21 config: drop `git_config_get_int()` wrapperPatrick Steinhardt, Jul 23, 2025
  35. 10/21 config: drop `git_config_get_ulong()` wrapperPatrick Steinhardt, Jul 23, 2025
  36. 11/21 config: drop `git_config_get_bool()` wrapperPatrick Steinhardt, Jul 23, 2025
  37. 12/21 config: drop `git_config_set_in_file()` wrapperPatrick Steinhardt, Jul 23, 2025
  38. 13/21 config: drop `git_config_set_gently()` wrapperPatrick Steinhardt, Jul 23, 2025
  39. 14/21 config: drop `git_config_set()` wrapperPatrick Steinhardt, Jul 23, 2025
  40. 15/21 config: drop `git_config_set_in_file_gently()` wrapperPatrick Steinhardt, Jul 23, 2025
  41. 16/21 config: drop `git_config_set_multivar_in_file_gently()` wrapperPatrick Steinhardt, Jul 23, 2025
  42. 17/21 config: drop `git_config_get_multivar_gently()` wrapperPatrick Steinhardt, Jul 23, 2025
  43. 18/21 config: drop `git_config_set_multivar()` wrapperPatrick Steinhardt, Jul 23, 2025
  44. 19/21 config: remove unused `the_repository` wrappersPatrick Steinhardt, Jul 23, 2025
  45. 20/21 config: move Git config parsing into "environment.c"Patrick Steinhardt, Jul 23, 2025
  46. 21/21 config: fix sign comparison warningsPatrick Steinhardt, Jul 23, 2025
  47. Phillip WoodJul 23, 2025
  48. Junio C HamanoJul 23, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.