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

[PATCH 08/14] mailinfo: stop using `the_repository`

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 17, 2024, 06:43 UTC
Message-ID
<20241217-pks-use-the-repository-conversion-v1-8-0dba48bcc239@pks.im>
In-Reply-To
<20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im>

Stop using `the_repository` in the "mailinfo" subsystem by passing in a repository when setting up the mailinfo structure.

Adjust callers accordingly by using `the_repository`. While there may be some callers that have a repository available in their context, this trivial conversion allows for easier verification and bubbles up the use of `the_repository` by one level.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/am.c       | 2 +-
 builtin/mailinfo.c | 2 +-
 mailinfo.c         | 5 ++---
 mailinfo.h         | 4 +++-
 4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/builtin/am.c b/builtin/am.c
index 27ccca8341feefcda5e1c4a850f14fce9e4deecb..e94d08e04b2387b6d45053e17c78c93038fa9531 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1211,7 +1211,7 @@ static int parse_mail(struct am_state *state, const char *mail)
 	int ret = 0;
 	struct mailinfo mi;
 
-	setup_mailinfo(&mi);
+	setup_mailinfo(the_repository, &mi);
 
 	if (state->utf8)
 		mi.metainfo_charset = get_commit_output_encoding();
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index e17dec27b1df69c1e2a1020f245dd99c0973eaad..8de7ba7de1d6aadc610adec11e7394f7b1f538b9 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -83,7 +83,7 @@ int cmd_mailinfo(int argc,
 		OPT_END()
 	};
 
-	setup_mailinfo(&mi);
+	setup_mailinfo(the_repository, &mi);
 	meta_charset.policy = CHARSET_DEFAULT;
 
 	argc = parse_options(argc, argv, prefix, options, mailinfo_usage, 0);
diff --git a/mailinfo.c b/mailinfo.c
index aa263bf490881daa915a03a681c00979f138d09b..7b001fa5dbd685cbe2b51c880e961e68461bef31 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
@@ -1269,7 +1268,7 @@ static int git_mailinfo_config(const char *var, const char *value,
 	return 0;
 }
 
-void setup_mailinfo(struct mailinfo *mi)
+void setup_mailinfo(struct repository *r, struct mailinfo *mi)
 {
 	memset(mi, 0, sizeof(*mi));
 	strbuf_init(&mi->name, 0);
@@ -1281,7 +1280,7 @@ void setup_mailinfo(struct mailinfo *mi)
 	mi->header_stage = 1;
 	mi->use_inbody_headers = 1;
 	mi->content_top = mi->content;
-	git_config(git_mailinfo_config, mi);
+	repo_config(r, git_mailinfo_config, mi);
 }
 
 void clear_mailinfo(struct mailinfo *mi)
diff --git a/mailinfo.h b/mailinfo.h
index f2ffd0349e8007256f5b2118d41faf35a53edf0d..1f2066416578ace2fe6798e543959da43d718a5d 100644
--- a/mailinfo.h
+++ b/mailinfo.h
@@ -5,6 +5,8 @@
 
 #define MAX_BOUNDARIES 5
 
+struct repository;
+
 enum quoted_cr_action {
 	quoted_cr_unset = -1,
 	quoted_cr_nowarn,
@@ -49,7 +51,7 @@ struct mailinfo {
 };
 
 int mailinfo_parse_quoted_cr_action(const char *actionstr, int *action);
-void setup_mailinfo(struct mailinfo *);
+void setup_mailinfo(struct repository *r, struct mailinfo *);
 int mailinfo(struct mailinfo *, const char *msg, const char *patch);
 void clear_mailinfo(struct mailinfo *);
 
-- 
2.48.0.rc0.184.g0fc57dec57.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 15 of 26 in “Stop using `the_repository` in some trivial cases”
  1. 00/14 Stop using `the_repository` in some trivial casesPatrick Steinhardt, Dec 17, 2024
  2. 01/14 progress: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  3. Karthik NayakDec 31, 2024
  4. Toon ClaesJan 6, 2025
  5. Patrick SteinhardtJan 7, 2025
  6. 02/14 pager: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  7. shejialuoDec 17, 2024
  8. Karthik NayakDec 31, 2024
  9. 03/14 trace: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  10. 04/14 serve: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  11. 05/14 send-pack: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  12. 06/14 server-info: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  13. shejialuoDec 17, 2024
  14. 07/14 diagnose: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  15. 08/14 mailinfo: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  16. 09/14 credential: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  17. 10/14 resolve-undo: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  18. 11/14 tmp-objdir: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  19. 12/14 add-interactive: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  20. 13/14 graph: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  21. 14/14 match-trees: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  22. shejialuoDec 17, 2024
  23. Patrick SteinhardtDec 27, 2024
  24. Karthik NayakJan 7, 2025
  25. Toon ClaesJan 7, 2025
  26. Junio C HamanoJan 7, 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.