Skip to content

Commit 999b093

Browse files
bkkaracaygitster
authored andcommitted
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>
1 parent 73fd778 commit 999b093

10 files changed

Lines changed: 19 additions & 16 deletions

File tree

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ int cmd_blame(int argc,
12521252
sb.xdl_opts = xdl_opts;
12531253
sb.no_whole_file_rename = no_whole_file_rename;
12541254

1255-
read_mailmap(&mailmap);
1255+
read_mailmap(the_repository, &mailmap);
12561256

12571257
sb.found_guilty_entry = &found_guilty_entry;
12581258
sb.found_guilty_entry_data = &pi;

builtin/cat-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ int cmd_cat_file(int argc,
11051105
opt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's');
11061106

11071107
if (use_mailmap)
1108-
read_mailmap(&mailmap);
1108+
read_mailmap(the_repository, &mailmap);
11091109

11101110
switch (batch.objects_filter.choice) {
11111111
case LOFC_DISABLED:

builtin/check-mailmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ int cmd_check_mailmap(int argc,
6363
if (argc == 0 && !use_stdin)
6464
die(_("no contacts specified"));
6565

66-
read_mailmap(&mailmap);
66+
read_mailmap(the_repository, &mailmap);
6767
if (mailmap_blob)
68-
read_mailmap_blob(&mailmap, mailmap_blob);
68+
read_mailmap_blob(the_repository, &mailmap, mailmap_blob);
6969
if (mailmap_file)
7070
read_mailmap_file(&mailmap, mailmap_file, 0);
7171

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ static const char *find_author_by_nickname(const char *name)
11551155
setup_revisions(ac, av, &revs, NULL);
11561156
revs.mailmap = xmalloc(sizeof(struct string_list));
11571157
string_list_init_nodup(revs.mailmap);
1158-
read_mailmap(revs.mailmap);
1158+
read_mailmap(the_repository, revs.mailmap);
11591159

11601160
if (prepare_revision_walk(&revs))
11611161
die(_("revision walk setup failed"));

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
336336
if (mailmap) {
337337
rev->mailmap = xmalloc(sizeof(struct string_list));
338338
string_list_init_nodup(rev->mailmap);
339-
read_mailmap(rev->mailmap);
339+
read_mailmap(the_repository, rev->mailmap);
340340
}
341341

342342
if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {

builtin/shortlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void shortlog_init(struct shortlog *log)
357357
{
358358
memset(log, 0, sizeof(*log));
359359

360-
read_mailmap(&log->mailmap);
360+
read_mailmap(the_repository, &log->mailmap);
361361

362362
log->list.strdup_strings = 1;
363363
log->wrap = DEFAULT_WRAPLEN;

mailmap.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ static void read_mailmap_string(struct string_list *map, char *buf)
183183
}
184184
}
185185

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)
187188
{
188189
struct object_id oid;
189190
char *buf;
@@ -192,10 +193,10 @@ int read_mailmap_blob(struct string_list *map, const char *name)
192193

193194
if (!name)
194195
return 0;
195-
if (repo_get_oid(the_repository, name, &oid) < 0)
196+
if (repo_get_oid(repo, name, &oid) < 0)
196197
return 0;
197198

198-
buf = odb_read_object(the_repository->objects, &oid, &type, &size);
199+
buf = odb_read_object(repo->objects, &oid, &type, &size);
199200
if (!buf)
200201
return error("unable to read mailmap object at %s", name);
201202
if (type != OBJ_BLOB) {
@@ -209,7 +210,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)
209210
return 0;
210211
}
211212

212-
int read_mailmap(struct string_list *map)
213+
int read_mailmap(struct repository *repo, struct string_list *map)
213214
{
214215
int err = 0;
215216

@@ -224,7 +225,7 @@ int read_mailmap(struct string_list *map)
224225
startup_info->have_repository ?
225226
MAILMAP_NOFOLLOW : 0);
226227
if (startup_info->have_repository)
227-
err |= read_mailmap_blob(map, git_mailmap_blob);
228+
err |= read_mailmap_blob(repo, map, git_mailmap_blob);
228229
err |= read_mailmap_file(map, git_mailmap_file, 0);
229230
return err;
230231
}

mailmap.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef MAILMAP_H
22
#define MAILMAP_H
33

4+
struct repository;
45
struct string_list;
56

67
extern char *git_mailmap_file;
@@ -11,9 +12,10 @@ extern char *git_mailmap_blob;
1112

1213
int read_mailmap_file(struct string_list *map, const char *filename,
1314
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);
1517

16-
int read_mailmap(struct string_list *map);
18+
int read_mailmap(struct repository *repo, struct string_list *map);
1719
void clear_mailmap(struct string_list *map);
1820

1921
int map_user(struct string_list *map,

pretty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ static int mailmap_name(const char **email, size_t *email_len,
781781
static struct string_list *mail_map;
782782
if (!mail_map) {
783783
CALLOC_ARRAY(mail_map, 1);
784-
read_mailmap(mail_map);
784+
read_mailmap(the_repository, mail_map);
785785
}
786786
return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
787787
}

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, void
17531753
(starts_with(name + wholen, "email") &&
17541754
(atom->u.email_option.option & EO_MAILMAP))) {
17551755
if (!mailmap.items)
1756-
read_mailmap(&mailmap);
1756+
read_mailmap(the_repository, &mailmap);
17571757
strbuf_addstr(&mailmap_buf, buf);
17581758
apply_mailmap_to_header(&mailmap_buf, headers, &mailmap);
17591759
wholine = find_wholine(who, wholen, mailmap_buf.buf);

0 commit comments

Comments
 (0)