From: "Burak Kaan Karaçay" <bkkaracay@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, christian.couder@gmail.com,
"Burak Kaan Karaçay" <bkkaracay@gmail.com>
Subject: [GSOC PATCH v2 2/2] mailmap: drop global config variables
Date: Fri, 20 Feb 2026 09:04:42 +0300 [thread overview]
Message-ID: <20260220060442.29469-3-bkkaracay@gmail.com> (raw)
In-Reply-To: <20260220060442.29469-1-bkkaracay@gmail.com>
The 'mailmap.file' and 'mailmap.blob' configurations are currently
parsed and stored in the global variables 'git_mailmap_file' and
'git_mailmap_blob'. Since these values are typically only needed once
when initializing a mailmap, there is no need to keep them as global
state throughout the lifetime of the Git process.
To reduce global state, remove these global variables and instead use
'repo_config_get_*' functions to read the configuration on demand.
Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>
---
environment.c | 19 -------------------
mailmap.c | 21 ++++++++++++++-------
mailmap.h | 3 ---
3 files changed, 14 insertions(+), 29 deletions(-)
diff --git a/environment.c b/environment.c
index 0026eb2274..2764d8f481 100644
--- a/environment.c
+++ b/environment.c
@@ -647,22 +647,6 @@ static int git_default_push_config(const char *var, const char *value)
return 0;
}
-static int git_default_mailmap_config(const char *var, const char *value)
-{
- if (!strcmp(var, "mailmap.file")) {
- FREE_AND_NULL(git_mailmap_file);
- return git_config_pathname(&git_mailmap_file, var, value);
- }
-
- if (!strcmp(var, "mailmap.blob")) {
- FREE_AND_NULL(git_mailmap_blob);
- return git_config_string(&git_mailmap_blob, var, value);
- }
-
- /* Add other config variables here and to Documentation/config.adoc. */
- return 0;
-}
-
static int git_default_attr_config(const char *var, const char *value)
{
if (!strcmp(var, "attr.tree")) {
@@ -697,9 +681,6 @@ int git_default_config(const char *var, const char *value,
if (starts_with(var, "push."))
return git_default_push_config(var, value);
- if (starts_with(var, "mailmap."))
- return git_default_mailmap_config(var, value);
-
if (starts_with(var, "attr."))
return git_default_attr_config(var, value);
diff --git a/mailmap.c b/mailmap.c
index cf70956675..3b2691781d 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -7,9 +7,7 @@
#include "object-name.h"
#include "odb.h"
#include "setup.h"
-
-char *git_mailmap_file;
-char *git_mailmap_blob;
+#include "config.h"
struct mailmap_info {
char *name;
@@ -213,20 +211,29 @@ int read_mailmap_blob(struct repository *repo, struct string_list *map,
int read_mailmap(struct repository *repo, struct string_list *map)
{
int err = 0;
+ char *mailmap_file = NULL, *mailmap_blob = NULL;
+
+ repo_config_get_pathname(repo, "mailmap.file", &mailmap_file);
+ repo_config_get_string(repo, "mailmap.blob", &mailmap_blob);
map->strdup_strings = 1;
map->cmp = namemap_cmp;
- if (!git_mailmap_blob && is_bare_repository())
- git_mailmap_blob = xstrdup("HEAD:.mailmap");
+ if (!mailmap_blob && is_bare_repository())
+ mailmap_blob = xstrdup("HEAD:.mailmap");
if (!startup_info->have_repository || !is_bare_repository())
err |= read_mailmap_file(map, ".mailmap",
startup_info->have_repository ?
MAILMAP_NOFOLLOW : 0);
if (startup_info->have_repository)
- err |= read_mailmap_blob(repo, map, git_mailmap_blob);
- err |= read_mailmap_file(map, git_mailmap_file, 0);
+ err |= read_mailmap_blob(repo, map, mailmap_blob);
+
+ err |= read_mailmap_file(map, mailmap_file, 0);
+
+ free(mailmap_file);
+ free(mailmap_blob);
+
return err;
}
diff --git a/mailmap.h b/mailmap.h
index fda329d715..6866cb6f1d 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -4,9 +4,6 @@
struct repository;
struct string_list;
-extern char *git_mailmap_file;
-extern char *git_mailmap_blob;
-
/* Flags for read_mailmap_file() */
#define MAILMAP_NOFOLLOW (1<<0)
--
2.52.0
next prev parent reply other threads:[~2026-02-20 6:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 12:59 [GSOC PATCH 0/2] mailmap: reduce global state Burak Kaan Karaçay
2026-02-19 12:59 ` [GSOC PATCH 1/2] mailmap: stop using the_repository Burak Kaan Karaçay
2026-02-19 12:59 ` [GSOC PATCH 2/2] mailmap: drop global config variables Burak Kaan Karaçay
2026-02-19 21:22 ` [GSOC PATCH 0/2] mailmap: reduce global state Junio C Hamano
2026-02-19 22:50 ` Junio C Hamano
2026-02-20 6:04 ` [GSOC PATCH v2 " Burak Kaan Karaçay
2026-02-20 6:04 ` [GSOC PATCH v2 1/2] mailmap: stop using the_repository Burak Kaan Karaçay
2026-02-20 6:04 ` Burak Kaan Karaçay [this message]
2026-02-20 16:16 ` [GSOC PATCH v2 0/2] mailmap: reduce global state Junio C Hamano
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=20260220060442.29469-3-bkkaracay@gmail.com \
--to=bkkaracay@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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