{"thread":{"id":"65022","subject":"[GSOC PATCH 0/2] mailmap: reduce global state","startedAt":"2026-02-19T13:00:08Z","lastAt":"2026-02-20T16:16:19Z","messageCount":9,"participants":["Burak Kaan Karaçay","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"536400","messageId":"20260219125954.3539324-1-bkkaracay@gmail.com","threadId":"65022","inReplyTo":null,"subject":"[GSOC PATCH 0/2] mailmap: reduce global state","fromName":"Burak Kaan Karaçay","fromEmail":"bkkaracay@gmail.com","sentAt":"2026-02-19T12:59:52Z","receivedAt":"2026-02-19T13:00:08Z","isPatch":true,"sender":{"key":"bkkaracay@gmail.com","avatar":"https://avatars.githubusercontent.com/u/29117336?v=4"},"body":"Hi,\n\nI am an applicant for GSoC 2026, aiming for the \"Refactoring in order to\nreduce Git's global state\" project. I have already submitted my\nmicroproject, so please treat this series simply as an extra\nfamiliarization exercise to better understand the codebase and the goals\nof the project.\n\nThe project description mainly focuses on 'environment.c' but I noticed\nthat an Outreachy intern is currently working in that area. To avoid\nstepping on anyone's toes or duplicating work, I decided to look for\nother subsystems and chose 'mailmap.c', which currently relies on\n'the_repository' and global configuration variables.\n\nThis patch series aims to reduce the global variable dependency of the\nmailmap subsystem:\n\n  - Patch 1 eliminates the implicit 'the_repository' dependency in the\n    'read_mailmap' and 'read_mailmap_blob' functions by adding a\n    'struct repository' parameter.\n\n  - Patch 2 removes the 'git_mailmap_file' and 'git_mailmap_blob' global\n    variables, shifting to on-demand configuration reading via the config\n    set helpers and using local variables.\n\nThanks.\n\nBurak Kaan Karaçay (2):\n  mailmap: stop using the_repository\n  mailmap: drop global config variables\n\n builtin/blame.c         |  2 +-\n builtin/cat-file.c      |  2 +-\n builtin/check-mailmap.c |  4 ++--\n builtin/commit.c        |  2 +-\n builtin/log.c           |  2 +-\n builtin/shortlog.c      |  2 +-\n environment.c           | 19 -------------------\n mailmap.c               | 30 +++++++++++++++++++-----------\n mailmap.h               |  8 +++-----\n pretty.c                |  2 +-\n ref-filter.c            |  2 +-\n 11 files changed, 31 insertions(+), 44 deletions(-)\n\n-- \n2.52.0\n\n"},{"id":"536401","messageId":"20260219125954.3539324-2-bkkaracay@gmail.com","threadId":"65022","inReplyTo":"20260219125954.3539324-1-bkkaracay@gmail.com","subject":"[GSOC PATCH 1/2] mailmap: stop using the_repository","fromName":"Burak Kaan Karaçay","fromEmail":"bkkaracay@gmail.com","sentAt":"2026-02-19T12:59:53Z","receivedAt":"2026-02-19T13:00:11Z","isPatch":true,"sender":{"key":"bkkaracay@gmail.com","avatar":"https://avatars.githubusercontent.com/u/29117336?v=4"},"body":"The 'read_mailmap' and 'read_mailmap_blob' functions rely on the global\n'the_repository' variable. Update both functions to accept a\n'struct repository' parameter.\n\nUpdate all callers to pass 'the_repository' to retain the current\nbehavior.\n\nSigned-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>\n---\n builtin/blame.c         |  2 +-\n builtin/cat-file.c      |  2 +-\n builtin/check-mailmap.c |  4 ++--\n builtin/commit.c        |  2 +-\n builtin/log.c           |  2 +-\n builtin/shortlog.c      |  2 +-\n mailmap.c               | 11 ++++++-----\n mailmap.h               |  5 +++--\n pretty.c                |  2 +-\n ref-filter.c            |  2 +-\n 10 files changed, 18 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex eac2fe7320..f3a11eff44 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1252,7 +1252,7 @@ int cmd_blame(int argc,\n \tsb.xdl_opts = xdl_opts;\n \tsb.no_whole_file_rename = no_whole_file_rename;\n \n-\tread_mailmap(&mailmap);\n+\tread_mailmap(the_repository, &mailmap);\n \n \tsb.found_guilty_entry = &found_guilty_entry;\n \tsb.found_guilty_entry_data = &pi;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex df8e87a81f..d298e95797 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -1105,7 +1105,7 @@ int cmd_cat_file(int argc,\n \topt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's');\n \n \tif (use_mailmap)\n-\t\tread_mailmap(&mailmap);\n+\t\tread_mailmap(the_repository, &mailmap);\n \n \tswitch (batch.objects_filter.choice) {\n \tcase LOFC_DISABLED:\ndiff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c\nindex 9cc5c59830..3f2a39cae0 100644\n--- a/builtin/check-mailmap.c\n+++ b/builtin/check-mailmap.c\n@@ -63,9 +63,9 @@ int cmd_check_mailmap(int argc,\n \tif (argc == 0 && !use_stdin)\n \t\tdie(_(\"no contacts specified\"));\n \n-\tread_mailmap(&mailmap);\n+\tread_mailmap(the_repository, &mailmap);\n \tif (mailmap_blob)\n-\t\tread_mailmap_blob(&mailmap, mailmap_blob);\n+\t\tread_mailmap_blob(the_repository, &mailmap, mailmap_blob);\n \tif (mailmap_file)\n \t\tread_mailmap_file(&mailmap, mailmap_file, 0);\n \ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 9e3a09d532..3700f66ba9 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1155,7 +1155,7 @@ static const char *find_author_by_nickname(const char *name)\n \tsetup_revisions(ac, av, &revs, NULL);\n \trevs.mailmap = xmalloc(sizeof(struct string_list));\n \tstring_list_init_nodup(revs.mailmap);\n-\tread_mailmap(revs.mailmap);\n+\tread_mailmap(the_repository, revs.mailmap);\n \n \tif (prepare_revision_walk(&revs))\n \t\tdie(_(\"revision walk setup failed\"));\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 8ab6d3a943..ff0227e32d 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -336,7 +336,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \tif (mailmap) {\n \t\trev->mailmap = xmalloc(sizeof(struct string_list));\n \t\tstring_list_init_nodup(rev->mailmap);\n-\t\tread_mailmap(rev->mailmap);\n+\t\tread_mailmap(the_repository, rev->mailmap);\n \t}\n \n \tif (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex d80bf1a7d0..6b2a0b93b5 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -357,7 +357,7 @@ void shortlog_init(struct shortlog *log)\n {\n \tmemset(log, 0, sizeof(*log));\n \n-\tread_mailmap(&log->mailmap);\n+\tread_mailmap(the_repository, &log->mailmap);\n \n \tlog->list.strdup_strings = 1;\n \tlog->wrap = DEFAULT_WRAPLEN;\ndiff --git a/mailmap.c b/mailmap.c\nindex 37fd158a51..6628975f30 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -183,7 +183,8 @@ static void read_mailmap_string(struct string_list *map, char *buf)\n \t}\n }\n \n-int read_mailmap_blob(struct string_list *map, const char *name)\n+int read_mailmap_blob(struct repository *repo, struct string_list *map,\n+                      const char *name)\n {\n \tstruct object_id oid;\n \tchar *buf;\n@@ -192,10 +193,10 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \n \tif (!name)\n \t\treturn 0;\n-\tif (repo_get_oid(the_repository, name, &oid) < 0)\n+\tif (repo_get_oid(repo, name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = odb_read_object(the_repository->objects, &oid, &type, &size);\n+\tbuf = odb_read_object(repo->objects, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB) {\n@@ -209,7 +210,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \treturn 0;\n }\n \n-int read_mailmap(struct string_list *map)\n+int read_mailmap(struct repository *repo, struct string_list *map)\n {\n \tint err = 0;\n \n@@ -224,7 +225,7 @@ int read_mailmap(struct string_list *map)\n \t\t\t\t\t startup_info->have_repository ?\n \t\t\t\t\t MAILMAP_NOFOLLOW : 0);\n \tif (startup_info->have_repository)\n-\t\terr |= read_mailmap_blob(map, git_mailmap_blob);\n+\t\terr |= read_mailmap_blob(repo, map, git_mailmap_blob);\n \terr |= read_mailmap_file(map, git_mailmap_file, 0);\n \treturn err;\n }\ndiff --git a/mailmap.h b/mailmap.h\nindex 908365e1bf..11346835cb 100644\n--- a/mailmap.h\n+++ b/mailmap.h\n@@ -11,9 +11,10 @@ extern char *git_mailmap_blob;\n \n int read_mailmap_file(struct string_list *map, const char *filename,\n \t\t      unsigned flags);\n-int read_mailmap_blob(struct string_list *map, const char *name);\n+int read_mailmap_blob(struct repository *repo, struct string_list *map,\n+                      const char *name);\n \n-int read_mailmap(struct string_list *map);\n+int read_mailmap(struct repository *repo, struct string_list *map);\n void clear_mailmap(struct string_list *map);\n \n int map_user(struct string_list *map,\ndiff --git a/pretty.c b/pretty.c\nindex e0646bbc5d..ebf4da4834 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -781,7 +781,7 @@ static int mailmap_name(const char **email, size_t *email_len,\n \tstatic struct string_list *mail_map;\n \tif (!mail_map) {\n \t\tCALLOC_ARRAY(mail_map, 1);\n-\t\tread_mailmap(mail_map);\n+\t\tread_mailmap(the_repository, mail_map);\n \t}\n \treturn mail_map->nr && map_user(mail_map, email, email_len, name, name_len);\n }\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 3917c4ccd9..d7a23a7b61 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1753,7 +1753,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, void\n \t\t    (starts_with(name + wholen, \"email\") &&\n \t\t    (atom->u.email_option.option & EO_MAILMAP))) {\n \t\t\tif (!mailmap.items)\n-\t\t\t\tread_mailmap(&mailmap);\n+\t\t\t\tread_mailmap(the_repository, &mailmap);\n \t\t\tstrbuf_addstr(&mailmap_buf, buf);\n \t\t\tapply_mailmap_to_header(&mailmap_buf, headers, &mailmap);\n \t\t\twholine = find_wholine(who, wholen, mailmap_buf.buf);\n-- \n2.52.0\n\n"},{"id":"536402","messageId":"20260219125954.3539324-3-bkkaracay@gmail.com","threadId":"65022","inReplyTo":"20260219125954.3539324-1-bkkaracay@gmail.com","subject":"[GSOC PATCH 2/2] mailmap: drop global config variables","fromName":"Burak Kaan Karaçay","fromEmail":"bkkaracay@gmail.com","sentAt":"2026-02-19T12:59:54Z","receivedAt":"2026-02-19T13:00:13Z","isPatch":true,"sender":{"key":"bkkaracay@gmail.com","avatar":"https://avatars.githubusercontent.com/u/29117336?v=4"},"body":"The 'mailmap.file' and 'mailmap.blob' configurations are currently\nparsed and stored in the global variables 'git_mailmap_file' and\n'git_mailmap_blob'. Since these values are typically only needed once\nwhen initializing a mailmap, there is no need to keep them as global\nstate throughout the lifetime of the Git process.\n\nTo reduce global state, remove these global variables and instead use\n'repo_config_get_*' functions to read the configuration on demand.\n\nSigned-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>\n---\n environment.c | 19 -------------------\n mailmap.c     | 21 ++++++++++++++-------\n mailmap.h     |  3 ---\n 3 files changed, 14 insertions(+), 29 deletions(-)\n\ndiff --git a/environment.c b/environment.c\nindex 0026eb2274..2764d8f481 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -647,22 +647,6 @@ static int git_default_push_config(const char *var, const char *value)\n \treturn 0;\n }\n \n-static int git_default_mailmap_config(const char *var, const char *value)\n-{\n-\tif (!strcmp(var, \"mailmap.file\")) {\n-\t\tFREE_AND_NULL(git_mailmap_file);\n-\t\treturn git_config_pathname(&git_mailmap_file, var, value);\n-\t}\n-\n-\tif (!strcmp(var, \"mailmap.blob\")) {\n-\t\tFREE_AND_NULL(git_mailmap_blob);\n-\t\treturn git_config_string(&git_mailmap_blob, var, value);\n-\t}\n-\n-\t/* Add other config variables here and to Documentation/config.adoc. */\n-\treturn 0;\n-}\n-\n static int git_default_attr_config(const char *var, const char *value)\n {\n \tif (!strcmp(var, \"attr.tree\")) {\n@@ -697,9 +681,6 @@ int git_default_config(const char *var, const char *value,\n \tif (starts_with(var, \"push.\"))\n \t\treturn git_default_push_config(var, value);\n \n-\tif (starts_with(var, \"mailmap.\"))\n-\t\treturn git_default_mailmap_config(var, value);\n-\n \tif (starts_with(var, \"attr.\"))\n \t\treturn git_default_attr_config(var, value);\n \ndiff --git a/mailmap.c b/mailmap.c\nindex 6628975f30..cdae3f65bc 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -7,9 +7,7 @@\n #include \"object-name.h\"\n #include \"odb.h\"\n #include \"setup.h\"\n-\n-char *git_mailmap_file;\n-char *git_mailmap_blob;\n+#include \"config.h\"\n \n struct mailmap_info {\n \tchar *name;\n@@ -213,20 +211,29 @@ int read_mailmap_blob(struct repository *repo, struct string_list *map,\n int read_mailmap(struct repository *repo, struct string_list *map)\n {\n \tint err = 0;\n+\tchar *mailmap_file = NULL, *mailmap_blob = NULL;\n+\n+\trepo_config_get_pathname(repo, \"mailmap.file\", &mailmap_file);\n+\trepo_config_get_string(repo, \"mailmap.blob\", &mailmap_blob);\n \n \tmap->strdup_strings = 1;\n \tmap->cmp = namemap_cmp;\n \n-\tif (!git_mailmap_blob && is_bare_repository())\n-\t\tgit_mailmap_blob = xstrdup(\"HEAD:.mailmap\");\n+\tif (!mailmap_blob && is_bare_repository())\n+\t\tmailmap_blob = xstrdup(\"HEAD:.mailmap\");\n \n \tif (!startup_info->have_repository || !is_bare_repository())\n \t\terr |= read_mailmap_file(map, \".mailmap\",\n \t\t\t\t\t startup_info->have_repository ?\n \t\t\t\t\t MAILMAP_NOFOLLOW : 0);\n \tif (startup_info->have_repository)\n-\t\terr |= read_mailmap_blob(repo, map, git_mailmap_blob);\n-\terr |= read_mailmap_file(map, git_mailmap_file, 0);\n+\t\terr |= read_mailmap_blob(repo, map, mailmap_blob);\n+\t\n+\terr |= read_mailmap_file(map, mailmap_file, 0);\n+\n+\tfree(mailmap_file);\n+\tfree(mailmap_blob);\n+\n \treturn err;\n }\n \ndiff --git a/mailmap.h b/mailmap.h\nindex 11346835cb..36d5d10daf 100644\n--- a/mailmap.h\n+++ b/mailmap.h\n@@ -3,9 +3,6 @@\n \n struct string_list;\n \n-extern char *git_mailmap_file;\n-extern char *git_mailmap_blob;\n-\n /* Flags for read_mailmap_file() */\n #define MAILMAP_NOFOLLOW (1<<0)\n \n-- \n2.52.0\n\n"},{"id":"536442","messageId":"xmqqh5rc2zuq.fsf@gitster.g","threadId":"65022","inReplyTo":"20260219125954.3539324-1-bkkaracay@gmail.com","subject":"Re: [GSOC PATCH 0/2] mailmap: reduce global state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-19T21:22:05Z","receivedAt":"2026-02-19T21:22:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Burak Kaan Karaçay <bkkaracay@gmail.com> writes:\n\n> This patch series aims to reduce the global variable dependency of the\n> mailmap subsystem:\n>\n>   - Patch 1 eliminates the implicit 'the_repository' dependency in the\n>     'read_mailmap' and 'read_mailmap_blob' functions by adding a\n>     'struct repository' parameter.\n>\n>   - Patch 2 removes the 'git_mailmap_file' and 'git_mailmap_blob' global\n>     variables, shifting to on-demand configuration reading via the config\n>     set helpers and using local variables.\n\nThese are surprisingly simple and straight-forward, as the final\ndestination has nothing to do with any global, and not even part of\na long-lived structure like \"repo\", but just a simple string_list\nmailmap.  Nicely done.\n\nWill queue.\n"},{"id":"536447","messageId":"xmqqpl601h7e.fsf@gitster.g","threadId":"65022","inReplyTo":"xmqqh5rc2zuq.fsf@gitster.g","subject":"Re: [GSOC PATCH 0/2] mailmap: reduce global state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-19T22:50:13Z","receivedAt":"2026-02-19T22:50:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Burak Kaan Karaçay <bkkaracay@gmail.com> writes:\n>\n>> This patch series aims to reduce the global variable dependency of the\n>> mailmap subsystem:\n>>\n>>   - Patch 1 eliminates the implicit 'the_repository' dependency in the\n>>     'read_mailmap' and 'read_mailmap_blob' functions by adding a\n>>     'struct repository' parameter.\n>>\n>>   - Patch 2 removes the 'git_mailmap_file' and 'git_mailmap_blob' global\n>>     variables, shifting to on-demand configuration reading via the config\n>>     set helpers and using local variables.\n>\n> These are surprisingly simple and straight-forward, as the final\n> destination has nothing to do with any global, and not even part of\n> a long-lived structure like \"repo\", but just a simple string_list\n> mailmap.  Nicely done.\n>\n> Will queue.\n\nOops, not so fast.  \"make hdr-check\" catches a problem in this topic.\n\n    mailmap.h:11:30: error: 'struct repository' declared inside parameter list will not be visible outside of this definition or\n    declaration [-Werror]\n\n"},{"id":"536461","messageId":"20260220060442.29469-1-bkkaracay@gmail.com","threadId":"65022","inReplyTo":"20260219125954.3539324-1-bkkaracay@gmail.com","subject":"[GSOC PATCH v2 0/2] mailmap: reduce global state","fromName":"Burak Kaan Karaçay","fromEmail":"bkkaracay@gmail.com","sentAt":"2026-02-20T06:04:40Z","receivedAt":"2026-02-20T06:04:48Z","isPatch":true,"sender":{"key":"bkkaracay@gmail.com","avatar":"https://avatars.githubusercontent.com/u/29117336?v=4"},"body":"Hi,\n\nThis patch series aims to reduce the global variable dependency of the\nmailmap subsystem:\n\n  - Patch 1 eliminates the implicit 'the_repository' dependency in the\n    'read_mailmap' and 'read_mailmap_blob' functions by adding a\n    'struct repository' parameter.\n\n  - Patch 2 removes the 'git_mailmap_file' and 'git_mailmap_blob' global\n    variables, shifting to on-demand configuration reading via the config\n    set helpers and using local variables.\n    \nChanges in v2:\n  - Forward declare 'struct repository' in mailmap.h\n  - Fix whitespace problems\n\nThanks to Junio for the kind words and for catching the 'make hdr-check' issue.\n\nBurak Kaan Karaçay (2):\n  mailmap: stop using the_repository\n  mailmap: drop global config variables\n\n builtin/blame.c         |  2 +-\n builtin/cat-file.c      |  2 +-\n builtin/check-mailmap.c |  4 ++--\n builtin/commit.c        |  2 +-\n builtin/log.c           |  2 +-\n builtin/shortlog.c      |  2 +-\n environment.c           | 19 -------------------\n mailmap.c               | 30 +++++++++++++++++++-----------\n mailmap.h               |  9 ++++-----\n pretty.c                |  2 +-\n ref-filter.c            |  2 +-\n 11 files changed, 32 insertions(+), 44 deletions(-)\n\n-- \n2.52.0\n\n"},{"id":"536462","messageId":"20260220060442.29469-2-bkkaracay@gmail.com","threadId":"65022","inReplyTo":"20260220060442.29469-1-bkkaracay@gmail.com","subject":"[GSOC PATCH v2 1/2] mailmap: stop using the_repository","fromName":"Burak Kaan Karaçay","fromEmail":"bkkaracay@gmail.com","sentAt":"2026-02-20T06:04:41Z","receivedAt":"2026-02-20T06:04:50Z","isPatch":true,"sender":{"key":"bkkaracay@gmail.com","avatar":"https://avatars.githubusercontent.com/u/29117336?v=4"},"body":"The 'read_mailmap' and 'read_mailmap_blob' functions rely on the global\n'the_repository' variable. Update both functions to accept a\n'struct repository' parameter.\n\nUpdate all callers to pass 'the_repository' to retain the current\nbehavior.\n\nSigned-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>\n---\n builtin/blame.c         |  2 +-\n builtin/cat-file.c      |  2 +-\n builtin/check-mailmap.c |  4 ++--\n builtin/commit.c        |  2 +-\n builtin/log.c           |  2 +-\n builtin/shortlog.c      |  2 +-\n mailmap.c               | 11 ++++++-----\n mailmap.h               |  6 ++++--\n pretty.c                |  2 +-\n ref-filter.c            |  2 +-\n 10 files changed, 19 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex eac2fe7320..f3a11eff44 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1252,7 +1252,7 @@ int cmd_blame(int argc,\n \tsb.xdl_opts = xdl_opts;\n \tsb.no_whole_file_rename = no_whole_file_rename;\n \n-\tread_mailmap(&mailmap);\n+\tread_mailmap(the_repository, &mailmap);\n \n \tsb.found_guilty_entry = &found_guilty_entry;\n \tsb.found_guilty_entry_data = &pi;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex df8e87a81f..d298e95797 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -1105,7 +1105,7 @@ int cmd_cat_file(int argc,\n \topt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's');\n \n \tif (use_mailmap)\n-\t\tread_mailmap(&mailmap);\n+\t\tread_mailmap(the_repository, &mailmap);\n \n \tswitch (batch.objects_filter.choice) {\n \tcase LOFC_DISABLED:\ndiff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c\nindex 9cc5c59830..3f2a39cae0 100644\n--- a/builtin/check-mailmap.c\n+++ b/builtin/check-mailmap.c\n@@ -63,9 +63,9 @@ int cmd_check_mailmap(int argc,\n \tif (argc == 0 && !use_stdin)\n \t\tdie(_(\"no contacts specified\"));\n \n-\tread_mailmap(&mailmap);\n+\tread_mailmap(the_repository, &mailmap);\n \tif (mailmap_blob)\n-\t\tread_mailmap_blob(&mailmap, mailmap_blob);\n+\t\tread_mailmap_blob(the_repository, &mailmap, mailmap_blob);\n \tif (mailmap_file)\n \t\tread_mailmap_file(&mailmap, mailmap_file, 0);\n \ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 9e3a09d532..3700f66ba9 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1155,7 +1155,7 @@ static const char *find_author_by_nickname(const char *name)\n \tsetup_revisions(ac, av, &revs, NULL);\n \trevs.mailmap = xmalloc(sizeof(struct string_list));\n \tstring_list_init_nodup(revs.mailmap);\n-\tread_mailmap(revs.mailmap);\n+\tread_mailmap(the_repository, revs.mailmap);\n \n \tif (prepare_revision_walk(&revs))\n \t\tdie(_(\"revision walk setup failed\"));\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 8ab6d3a943..ff0227e32d 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -336,7 +336,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \tif (mailmap) {\n \t\trev->mailmap = xmalloc(sizeof(struct string_list));\n \t\tstring_list_init_nodup(rev->mailmap);\n-\t\tread_mailmap(rev->mailmap);\n+\t\tread_mailmap(the_repository, rev->mailmap);\n \t}\n \n \tif (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex d80bf1a7d0..6b2a0b93b5 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -357,7 +357,7 @@ void shortlog_init(struct shortlog *log)\n {\n \tmemset(log, 0, sizeof(*log));\n \n-\tread_mailmap(&log->mailmap);\n+\tread_mailmap(the_repository, &log->mailmap);\n \n \tlog->list.strdup_strings = 1;\n \tlog->wrap = DEFAULT_WRAPLEN;\ndiff --git a/mailmap.c b/mailmap.c\nindex 37fd158a51..cf70956675 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -183,7 +183,8 @@ static void read_mailmap_string(struct string_list *map, char *buf)\n \t}\n }\n \n-int read_mailmap_blob(struct string_list *map, const char *name)\n+int read_mailmap_blob(struct repository *repo, struct string_list *map,\n+\t\t      const char *name)\n {\n \tstruct object_id oid;\n \tchar *buf;\n@@ -192,10 +193,10 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \n \tif (!name)\n \t\treturn 0;\n-\tif (repo_get_oid(the_repository, name, &oid) < 0)\n+\tif (repo_get_oid(repo, name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = odb_read_object(the_repository->objects, &oid, &type, &size);\n+\tbuf = odb_read_object(repo->objects, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB) {\n@@ -209,7 +210,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)\n \treturn 0;\n }\n \n-int read_mailmap(struct string_list *map)\n+int read_mailmap(struct repository *repo, struct string_list *map)\n {\n \tint err = 0;\n \n@@ -224,7 +225,7 @@ int read_mailmap(struct string_list *map)\n \t\t\t\t\t startup_info->have_repository ?\n \t\t\t\t\t MAILMAP_NOFOLLOW : 0);\n \tif (startup_info->have_repository)\n-\t\terr |= read_mailmap_blob(map, git_mailmap_blob);\n+\t\terr |= read_mailmap_blob(repo, map, git_mailmap_blob);\n \terr |= read_mailmap_file(map, git_mailmap_file, 0);\n \treturn err;\n }\ndiff --git a/mailmap.h b/mailmap.h\nindex 908365e1bf..fda329d715 100644\n--- a/mailmap.h\n+++ b/mailmap.h\n@@ -1,6 +1,7 @@\n #ifndef MAILMAP_H\n #define MAILMAP_H\n \n+struct repository;\n struct string_list;\n \n extern char *git_mailmap_file;\n@@ -11,9 +12,10 @@ extern char *git_mailmap_blob;\n \n int read_mailmap_file(struct string_list *map, const char *filename,\n \t\t      unsigned flags);\n-int read_mailmap_blob(struct string_list *map, const char *name);\n+int read_mailmap_blob(struct repository *repo, struct string_list *map,\n+\t\t      const char *name);\n \n-int read_mailmap(struct string_list *map);\n+int read_mailmap(struct repository *repo, struct string_list *map);\n void clear_mailmap(struct string_list *map);\n \n int map_user(struct string_list *map,\ndiff --git a/pretty.c b/pretty.c\nindex e0646bbc5d..ebf4da4834 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -781,7 +781,7 @@ static int mailmap_name(const char **email, size_t *email_len,\n \tstatic struct string_list *mail_map;\n \tif (!mail_map) {\n \t\tCALLOC_ARRAY(mail_map, 1);\n-\t\tread_mailmap(mail_map);\n+\t\tread_mailmap(the_repository, mail_map);\n \t}\n \treturn mail_map->nr && map_user(mail_map, email, email_len, name, name_len);\n }\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 3917c4ccd9..d7a23a7b61 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1753,7 +1753,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, void\n \t\t    (starts_with(name + wholen, \"email\") &&\n \t\t    (atom->u.email_option.option & EO_MAILMAP))) {\n \t\t\tif (!mailmap.items)\n-\t\t\t\tread_mailmap(&mailmap);\n+\t\t\t\tread_mailmap(the_repository, &mailmap);\n \t\t\tstrbuf_addstr(&mailmap_buf, buf);\n \t\t\tapply_mailmap_to_header(&mailmap_buf, headers, &mailmap);\n \t\t\twholine = find_wholine(who, wholen, mailmap_buf.buf);\n-- \n2.52.0\n\n"},{"id":"536463","messageId":"20260220060442.29469-3-bkkaracay@gmail.com","threadId":"65022","inReplyTo":"20260220060442.29469-1-bkkaracay@gmail.com","subject":"[GSOC PATCH v2 2/2] mailmap: drop global config variables","fromName":"Burak Kaan Karaçay","fromEmail":"bkkaracay@gmail.com","sentAt":"2026-02-20T06:04:42Z","receivedAt":"2026-02-20T06:04:55Z","isPatch":true,"sender":{"key":"bkkaracay@gmail.com","avatar":"https://avatars.githubusercontent.com/u/29117336?v=4"},"body":"The 'mailmap.file' and 'mailmap.blob' configurations are currently\nparsed and stored in the global variables 'git_mailmap_file' and\n'git_mailmap_blob'. Since these values are typically only needed once\nwhen initializing a mailmap, there is no need to keep them as global\nstate throughout the lifetime of the Git process.\n\nTo reduce global state, remove these global variables and instead use\n'repo_config_get_*' functions to read the configuration on demand.\n\nSigned-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>\n---\n environment.c | 19 -------------------\n mailmap.c     | 21 ++++++++++++++-------\n mailmap.h     |  3 ---\n 3 files changed, 14 insertions(+), 29 deletions(-)\n\ndiff --git a/environment.c b/environment.c\nindex 0026eb2274..2764d8f481 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -647,22 +647,6 @@ static int git_default_push_config(const char *var, const char *value)\n \treturn 0;\n }\n \n-static int git_default_mailmap_config(const char *var, const char *value)\n-{\n-\tif (!strcmp(var, \"mailmap.file\")) {\n-\t\tFREE_AND_NULL(git_mailmap_file);\n-\t\treturn git_config_pathname(&git_mailmap_file, var, value);\n-\t}\n-\n-\tif (!strcmp(var, \"mailmap.blob\")) {\n-\t\tFREE_AND_NULL(git_mailmap_blob);\n-\t\treturn git_config_string(&git_mailmap_blob, var, value);\n-\t}\n-\n-\t/* Add other config variables here and to Documentation/config.adoc. */\n-\treturn 0;\n-}\n-\n static int git_default_attr_config(const char *var, const char *value)\n {\n \tif (!strcmp(var, \"attr.tree\")) {\n@@ -697,9 +681,6 @@ int git_default_config(const char *var, const char *value,\n \tif (starts_with(var, \"push.\"))\n \t\treturn git_default_push_config(var, value);\n \n-\tif (starts_with(var, \"mailmap.\"))\n-\t\treturn git_default_mailmap_config(var, value);\n-\n \tif (starts_with(var, \"attr.\"))\n \t\treturn git_default_attr_config(var, value);\n \ndiff --git a/mailmap.c b/mailmap.c\nindex cf70956675..3b2691781d 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -7,9 +7,7 @@\n #include \"object-name.h\"\n #include \"odb.h\"\n #include \"setup.h\"\n-\n-char *git_mailmap_file;\n-char *git_mailmap_blob;\n+#include \"config.h\"\n \n struct mailmap_info {\n \tchar *name;\n@@ -213,20 +211,29 @@ int read_mailmap_blob(struct repository *repo, struct string_list *map,\n int read_mailmap(struct repository *repo, struct string_list *map)\n {\n \tint err = 0;\n+\tchar *mailmap_file = NULL, *mailmap_blob = NULL;\n+\n+\trepo_config_get_pathname(repo, \"mailmap.file\", &mailmap_file);\n+\trepo_config_get_string(repo, \"mailmap.blob\", &mailmap_blob);\n \n \tmap->strdup_strings = 1;\n \tmap->cmp = namemap_cmp;\n \n-\tif (!git_mailmap_blob && is_bare_repository())\n-\t\tgit_mailmap_blob = xstrdup(\"HEAD:.mailmap\");\n+\tif (!mailmap_blob && is_bare_repository())\n+\t\tmailmap_blob = xstrdup(\"HEAD:.mailmap\");\n \n \tif (!startup_info->have_repository || !is_bare_repository())\n \t\terr |= read_mailmap_file(map, \".mailmap\",\n \t\t\t\t\t startup_info->have_repository ?\n \t\t\t\t\t MAILMAP_NOFOLLOW : 0);\n \tif (startup_info->have_repository)\n-\t\terr |= read_mailmap_blob(repo, map, git_mailmap_blob);\n-\terr |= read_mailmap_file(map, git_mailmap_file, 0);\n+\t\terr |= read_mailmap_blob(repo, map, mailmap_blob);\n+\n+\terr |= read_mailmap_file(map, mailmap_file, 0);\n+\n+\tfree(mailmap_file);\n+\tfree(mailmap_blob);\n+\n \treturn err;\n }\n \ndiff --git a/mailmap.h b/mailmap.h\nindex fda329d715..6866cb6f1d 100644\n--- a/mailmap.h\n+++ b/mailmap.h\n@@ -4,9 +4,6 @@\n struct repository;\n struct string_list;\n \n-extern char *git_mailmap_file;\n-extern char *git_mailmap_blob;\n-\n /* Flags for read_mailmap_file() */\n #define MAILMAP_NOFOLLOW (1<<0)\n \n-- \n2.52.0\n\n"},{"id":"536531","messageId":"xmqqtsvbz8z2.fsf@gitster.g","threadId":"65022","inReplyTo":"20260220060442.29469-1-bkkaracay@gmail.com","subject":"Re: [GSOC PATCH v2 0/2] mailmap: reduce global state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-20T16:16:17Z","receivedAt":"2026-02-20T16:16:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Burak Kaan Karaçay <bkkaracay@gmail.com> writes:\n\n> This patch series aims to reduce the global variable dependency of the\n> mailmap subsystem:\n>\n>   - Patch 1 eliminates the implicit 'the_repository' dependency in the\n>     'read_mailmap' and 'read_mailmap_blob' functions by adding a\n>     'struct repository' parameter.\n>\n>   - Patch 2 removes the 'git_mailmap_file' and 'git_mailmap_blob' global\n>     variables, shifting to on-demand configuration reading via the config\n>     set helpers and using local variables.\n>     \n> Changes in v2:\n>   - Forward declare 'struct repository' in mailmap.h\n>   - Fix whitespace problems\n\nThanks for a quick reroll.  Looking very good.\n\nWill queue.\n"}]}