git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Justin Tobler <jltobler@gmail.com>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 15/20] config: pass repo to `git_die_config()`
Date: Tue, 13 Aug 2024 11:14:07 +0200	[thread overview]
Message-ID: <6adee5633a7093f62c7b3041ae23afb528bb9452.1723540226.git.ps@pks.im> (raw)
In-Reply-To: <cover.1723540226.git.ps@pks.im>

Refactor `git_die_config()` to accept a `struct repository` such that we
can get rid of the implicit dependency on `the_repository`. Rename the
function accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/fast-import.c |  4 ++--
 builtin/notes.c       |  2 +-
 config.c              | 12 ++++++------
 config.h              |  3 ++-
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index d21c4053a7..0249503c70 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -3481,8 +3481,8 @@ static void git_pack_config(void)
 	if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
 		pack_idx_opts.version = indexversion_value;
 		if (pack_idx_opts.version > 2)
-			git_die_config("pack.indexversion",
-					"bad pack.indexVersion=%"PRIu32, pack_idx_opts.version);
+			git_die_config(the_repository, "pack.indexversion",
+				       "bad pack.indexVersion=%"PRIu32, pack_idx_opts.version);
 	}
 	if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value))
 		max_packsize = packsizelimit_value;
diff --git a/builtin/notes.c b/builtin/notes.c
index d9c356e354..c0fa86d847 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -868,7 +868,7 @@ static int git_config_get_notes_strategy(const char *key,
 	if (git_config_get_string(key, &value))
 		return 1;
 	if (parse_notes_merge_strategy(value, strategy))
-		git_die_config(key, _("unknown notes merge strategy %s"), value);
+		git_die_config(the_repository, key, _("unknown notes merge strategy %s"), value);
 
 	free(value);
 	return 0;
diff --git a/config.c b/config.c
index 33d9af29c8..e35fc90238 100644
--- a/config.c
+++ b/config.c
@@ -2611,7 +2611,7 @@ int repo_config_get_string(struct repository *repo,
 	git_config_check_init(repo);
 	ret = git_configset_get_string(repo->config, key, dest);
 	if (ret < 0)
-		git_die_config(key, NULL);
+		git_die_config(repo, key, NULL);
 	return ret;
 }
 
@@ -2622,7 +2622,7 @@ int repo_config_get_string_tmp(struct repository *repo,
 	git_config_check_init(repo);
 	ret = git_configset_get_string_tmp(repo->config, key, dest);
 	if (ret < 0)
-		git_die_config(key, NULL);
+		git_die_config(repo, key, NULL);
 	return ret;
 }
 
@@ -2668,7 +2668,7 @@ int repo_config_get_pathname(struct repository *repo,
 	git_config_check_init(repo);
 	ret = git_configset_get_pathname(repo->config, key, dest);
 	if (ret < 0)
-		git_die_config(key, NULL);
+		git_die_config(repo, key, NULL);
 	return ret;
 }
 
@@ -2774,7 +2774,7 @@ int repo_config_get_expiry(struct repository *r, const char *key, const char **o
 	if (strcmp(*output, "now")) {
 		timestamp_t now = approxidate("now");
 		if (approxidate(*output) >= now)
-			git_die_config(key, _("Invalid %s: '%s'"), key, *output);
+			git_die_config(r, key, _("Invalid %s: '%s'"), key, *output);
 	}
 	return ret;
 }
@@ -2858,7 +2858,7 @@ void git_die_config_linenr(const char *key, const char *filename, int linenr)
 		    key, filename, linenr);
 }
 
-void git_die_config(const char *key, const char *err, ...)
+void git_die_config(struct repository *r, const char *key, const char *err, ...)
 {
 	const struct string_list *values;
 	struct key_value_info *kv_info;
@@ -2870,7 +2870,7 @@ void git_die_config(const char *key, const char *err, ...)
 		error_fn(err, params);
 		va_end(params);
 	}
-	if (git_config_get_value_multi(key, &values))
+	if (repo_config_get_value_multi(r, key, &values))
 		BUG("for key '%s' we must have a value to report on", key);
 	kv_info = values->items[values->nr - 1].util;
 	git_die_config_linenr(key, kv_info->filename, kv_info->linenr);
diff --git a/config.h b/config.h
index 3a5016afea..947307c591 100644
--- a/config.h
+++ b/config.h
@@ -726,7 +726,8 @@ int repo_config_get_expiry_in_days(struct repository *r, const char *key,
  * dies printing the line number and the file name of the highest priority
  * value for the configuration variable `key`.
  */
-NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
+NORETURN void git_die_config(struct repository *r, const char *key, const char *err, ...)
+	__attribute__((format(printf, 3, 4)));
 
 /**
  * Helper function which formats the die error message according to the
-- 
2.46.0.46.g406f326d27.dirty


  parent reply	other threads:[~2024-08-13  9:14 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  6:56 [PATCH 00/20] Stop using `the_repository` in "config.c" Patrick Steinhardt
2024-08-07  6:56 ` [PATCH 01/20] path: expose `do_git_path()` as `repo_git_pathv()` Patrick Steinhardt
2024-08-09 16:58   ` Justin Tobler
2024-08-13  9:25     ` Patrick Steinhardt
2024-08-07  6:56 ` [PATCH 02/20] path: expose `do_git_common_path()` as `strbuf_git_common_pathv()` Patrick Steinhardt
2024-08-09 17:18   ` Justin Tobler
2024-08-09 17:32     ` Junio C Hamano
2024-08-13  9:25       ` Patrick Steinhardt
2024-08-13 15:12         ` Junio C Hamano
2024-08-07  6:56 ` [PATCH 03/20] editor: do not rely on `the_repository` for interactive edits Patrick Steinhardt
2024-08-09 17:36   ` Justin Tobler
2024-08-07  6:57 ` [PATCH 04/20] hooks: remove implicit dependency on `the_repository` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 05/20] path: stop relying on `the_repository` when reporting garbage Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 06/20] path: stop relying on `the_repository` in `worktree_git_path()` Patrick Steinhardt
2024-08-09 19:02   ` Justin Tobler
2024-08-13  9:25     ` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 07/20] path: hide functions using `the_repository` by default Patrick Steinhardt
2024-08-09 19:43   ` Justin Tobler
2024-08-13  9:25     ` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 08/20] config: introduce missing setters that take repo as parameter Patrick Steinhardt
2024-08-09 20:07   ` Justin Tobler
2024-08-13  9:25     ` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 09/20] config: expose `repo_config_clear()` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 10/20] config: pass repo to `git_config_get_index_threads()` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 11/20] config: pass repo to `git_config_get_split_index()` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 12/20] config: pass repo to `git_config_get_max_percent_split_change()` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 13/20] config: pass repo to `git_config_get_expiry()` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 14/20] config: pass repo to `git_config_get_expiry_in_days()` Patrick Steinhardt
2024-08-09 20:21   ` Justin Tobler
2024-08-09 21:14     ` Junio C Hamano
2024-08-07  6:57 ` [PATCH 15/20] config: pass repo to `git_die_config()` Patrick Steinhardt
2024-08-07  6:57 ` [PATCH 16/20] config: pass repo to functions that rename or copy sections Patrick Steinhardt
2024-08-07  6:58 ` [PATCH 17/20] config: don't have setters depend on `the_repository` Patrick Steinhardt
2024-08-07  6:58 ` [PATCH 18/20] config: don't depend on `the_repository` with branch conditions Patrick Steinhardt
2024-08-09 20:47   ` Justin Tobler
2024-08-13  9:25     ` Patrick Steinhardt
2024-08-07  6:58 ` [PATCH 19/20] global: prepare for hiding away repo-less config functions Patrick Steinhardt
2024-08-09 20:57   ` Justin Tobler
2024-08-07  6:58 ` [PATCH 20/20] config: hide functions using `the_repository` by default Patrick Steinhardt
2024-08-09 21:13   ` Justin Tobler
2024-08-07  9:48 ` [PATCH 00/20] Stop using `the_repository` in "config.c" Ghanshyam Thakkar
2024-08-07 13:11   ` Patrick Steinhardt
2024-08-13  9:13 ` [PATCH v2 " Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 01/20] path: expose `do_git_path()` as `repo_git_pathv()` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 02/20] path: expose `do_git_common_path()` as `repo_common_pathv()` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 03/20] editor: do not rely on `the_repository` for interactive edits Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 04/20] hooks: remove implicit dependency on `the_repository` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 05/20] path: stop relying on `the_repository` when reporting garbage Patrick Steinhardt
2024-08-14 18:28     ` Calvin Wan
2024-08-15  5:26       ` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 06/20] path: stop relying on `the_repository` in `worktree_git_path()` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 07/20] path: hide functions using `the_repository` by default Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 08/20] config: introduce missing setters that take repo as parameter Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 09/20] config: expose `repo_config_clear()` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 10/20] config: pass repo to `git_config_get_index_threads()` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 11/20] config: pass repo to `git_config_get_split_index()` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 12/20] config: pass repo to `git_config_get_max_percent_split_change()` Patrick Steinhardt
2024-08-13  9:13   ` [PATCH v2 13/20] config: pass repo to `git_config_get_expiry()` Patrick Steinhardt
2024-08-13  9:14   ` [PATCH v2 14/20] config: pass repo to `git_config_get_expiry_in_days()` Patrick Steinhardt
2024-08-13  9:14   ` Patrick Steinhardt [this message]
2024-08-13  9:14   ` [PATCH v2 16/20] config: pass repo to functions that rename or copy sections Patrick Steinhardt
2024-08-13  9:14   ` [PATCH v2 17/20] config: don't have setters depend on `the_repository` Patrick Steinhardt
2024-08-13  9:14   ` [PATCH v2 18/20] config: don't depend on `the_repository` with branch conditions Patrick Steinhardt
2024-08-13  9:14   ` [PATCH v2 19/20] global: prepare for hiding away repo-less config functions Patrick Steinhardt
2024-08-13  9:14   ` [PATCH v2 20/20] config: hide functions using `the_repository` by default Patrick Steinhardt
2024-08-13 17:07   ` [PATCH v2 00/20] Stop using `the_repository` in "config.c" Junio C Hamano
2024-08-14 19:29   ` Calvin Wan
2024-08-15  5:13     ` Patrick Steinhardt
2024-08-15  0:58   ` Justin Tobler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6adee5633a7093f62c7b3041ae23afb528bb9452.1723540226.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).