mailmap: stop using the_repository

The 'read_mailmap' and 'read_mailmap_blob' functions rely on the global 'the_repository' variable. Update both functions to accept a 'struct repository' parameter. Update all callers to pass 'the_repository' to retain the current behavior. Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Burak Kaan Karaçay committed Feb 20, 2026 at 09:04 UTC 999b09348d6302d018165b4b3d289d4579d08e9e
10 files changed +19 -16
builtin/blame.c
+1 -1
@@ -1252,7 +1252,7 @@ parse_done:
1252 sb.xdl_opts = xdl_opts;
1253 sb.no_whole_file_rename = no_whole_file_rename;
1254
1255 - read_mailmap(&mailmap);
1255 + read_mailmap(the_repository, &mailmap);
1256
1257 sb.found_guilty_entry = &found_guilty_entry;
1258 sb.found_guilty_entry_data = &pi;
builtin/cat-file.c
+1 -1
@@ -1105,7 +1105,7 @@ int cmd_cat_file(int argc,
1105 opt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's');
1106
1107 if (use_mailmap)
1108 - read_mailmap(&mailmap);
1108 + read_mailmap(the_repository, &mailmap);
1109
1110 switch (batch.objects_filter.choice) {
1111 case LOFC_DISABLED:
builtin/check-mailmap.c
+2 -2
@@ -63,9 +63,9 @@ int cmd_check_mailmap(int argc,
63 if (argc == 0 && !use_stdin)
64 die(_("no contacts specified"));
65
66 - read_mailmap(&mailmap);
66 + read_mailmap(the_repository, &mailmap);
67 if (mailmap_blob)
68 - read_mailmap_blob(&mailmap, mailmap_blob);
68 + read_mailmap_blob(the_repository, &mailmap, mailmap_blob);
69 if (mailmap_file)
70 read_mailmap_file(&mailmap, mailmap_file, 0);
71
builtin/commit.c
+1 -1
@@ -1155,7 +1155,7 @@ static const char *find_author_by_nickname(const char *name)
1155 setup_revisions(ac, av, &revs, NULL);
1156 revs.mailmap = xmalloc(sizeof(struct string_list));
1157 string_list_init_nodup(revs.mailmap);
1158 - read_mailmap(revs.mailmap);
1158 + read_mailmap(the_repository, revs.mailmap);
1159
1160 if (prepare_revision_walk(&revs))
1161 die(_("revision walk setup failed"));
builtin/log.c
+1 -1
@@ -336,7 +336,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
336 if (mailmap) {
337 rev->mailmap = xmalloc(sizeof(struct string_list));
338 string_list_init_nodup(rev->mailmap);
339 - read_mailmap(rev->mailmap);
339 + read_mailmap(the_repository, rev->mailmap);
340 }
341
342 if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
builtin/shortlog.c
+1 -1
@@ -357,7 +357,7 @@ void shortlog_init(struct shortlog *log)
357 {
358 memset(log, 0, sizeof(*log));
359
360 - read_mailmap(&log->mailmap);
360 + read_mailmap(the_repository, &log->mailmap);
361
362 log->list.strdup_strings = 1;
363 log->wrap = DEFAULT_WRAPLEN;
mailmap.c
+6 -5
@@ -183,7 +183,8 @@ static void read_mailmap_string(struct string_list *map, char *buf)
183 }
184 }
185
186 -int read_mailmap_blob(struct string_list *map, const char *name)
186 +int read_mailmap_blob(struct repository *repo, struct string_list *map,
187 + const char *name)
188 {
189 struct object_id oid;
190 char *buf;
@@ -192,10 +193,10 @@ int read_mailmap_blob(struct string_list *map, const char *name)
193
194 if (!name)
195 return 0;
195 - if (repo_get_oid(the_repository, name, &oid) < 0)
196 + if (repo_get_oid(repo, name, &oid) < 0)
197 return 0;
198
198 - buf = odb_read_object(the_repository->objects, &oid, &type, &size);
199 + buf = odb_read_object(repo->objects, &oid, &type, &size);
200 if (!buf)
201 return error("unable to read mailmap object at %s", name);
202 if (type != OBJ_BLOB) {
@@ -209,7 +210,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)
210 return 0;
211 }
212
212 -int read_mailmap(struct string_list *map)
213 +int read_mailmap(struct repository *repo, struct string_list *map)
214 {
215 int err = 0;
216
@@ -224,7 +225,7 @@ int read_mailmap(struct string_list *map)
225 startup_info->have_repository ?
226 MAILMAP_NOFOLLOW : 0);
227 if (startup_info->have_repository)
227 - err |= read_mailmap_blob(map, git_mailmap_blob);
228 + err |= read_mailmap_blob(repo, map, git_mailmap_blob);
229 err |= read_mailmap_file(map, git_mailmap_file, 0);
230 return err;
231 }
mailmap.h
+4 -2
@@ -1,6 +1,7 @@
1 #ifndef MAILMAP_H
2 #define MAILMAP_H
3
4 +struct repository;
5 struct string_list;
6
7 extern char *git_mailmap_file;
@@ -11,9 +12,10 @@ extern char *git_mailmap_blob;
12
13 int read_mailmap_file(struct string_list *map, const char *filename,
14 unsigned flags);
14 -int read_mailmap_blob(struct string_list *map, const char *name);
15 +int read_mailmap_blob(struct repository *repo, struct string_list *map,
16 + const char *name);
17
16 -int read_mailmap(struct string_list *map);
18 +int read_mailmap(struct repository *repo, struct string_list *map);
19 void clear_mailmap(struct string_list *map);
20
21 int map_user(struct string_list *map,
pretty.c
+1 -1
@@ -781,7 +781,7 @@ static int mailmap_name(const char **email, size_t *email_len,
781 static struct string_list *mail_map;
782 if (!mail_map) {
783 CALLOC_ARRAY(mail_map, 1);
784 - read_mailmap(mail_map);
784 + read_mailmap(the_repository, mail_map);
785 }
786 return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
787 }
ref-filter.c
+1 -1
@@ -1753,7 +1753,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, void
1753 (starts_with(name + wholen, "email") &&
1754 (atom->u.email_option.option & EO_MAILMAP))) {
1755 if (!mailmap.items)
1756 - read_mailmap(&mailmap);
1756 + read_mailmap(the_repository, &mailmap);
1757 strbuf_addstr(&mailmap_buf, buf);
1758 apply_mailmap_to_header(&mailmap_buf, headers, &mailmap);
1759 wholine = find_wholine(who, wholen, mailmap_buf.buf);