mirror of
https://github.com/git/git.git
synced 2026-03-04 06:27:36 +01:00
Merge branch 'bk/mailmap-wo-the-repository' into jch
Wean the mailmap code off of the_repository dependency. * bk/mailmap-wo-the-repository: mailmap: drop global config variables mailmap: stop using the_repository
This commit is contained in:
@@ -1252,7 +1252,7 @@ parse_done:
|
||||
sb.xdl_opts = xdl_opts;
|
||||
sb.no_whole_file_rename = no_whole_file_rename;
|
||||
|
||||
read_mailmap(&mailmap);
|
||||
read_mailmap(the_repository, &mailmap);
|
||||
|
||||
sb.found_guilty_entry = &found_guilty_entry;
|
||||
sb.found_guilty_entry_data = π
|
||||
|
||||
@@ -1127,7 +1127,7 @@ int cmd_cat_file(int argc,
|
||||
opt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's');
|
||||
|
||||
if (use_mailmap)
|
||||
read_mailmap(&mailmap);
|
||||
read_mailmap(the_repository, &mailmap);
|
||||
|
||||
switch (batch.objects_filter.choice) {
|
||||
case LOFC_DISABLED:
|
||||
|
||||
@@ -63,9 +63,9 @@ int cmd_check_mailmap(int argc,
|
||||
if (argc == 0 && !use_stdin)
|
||||
die(_("no contacts specified"));
|
||||
|
||||
read_mailmap(&mailmap);
|
||||
read_mailmap(the_repository, &mailmap);
|
||||
if (mailmap_blob)
|
||||
read_mailmap_blob(&mailmap, mailmap_blob);
|
||||
read_mailmap_blob(the_repository, &mailmap, mailmap_blob);
|
||||
if (mailmap_file)
|
||||
read_mailmap_file(&mailmap, mailmap_file, 0);
|
||||
|
||||
|
||||
@@ -1155,7 +1155,7 @@ static const char *find_author_by_nickname(const char *name)
|
||||
setup_revisions(ac, av, &revs, NULL);
|
||||
revs.mailmap = xmalloc(sizeof(struct string_list));
|
||||
string_list_init_nodup(revs.mailmap);
|
||||
read_mailmap(revs.mailmap);
|
||||
read_mailmap(the_repository, revs.mailmap);
|
||||
|
||||
if (prepare_revision_walk(&revs))
|
||||
die(_("revision walk setup failed"));
|
||||
|
||||
@@ -336,7 +336,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
|
||||
if (mailmap) {
|
||||
rev->mailmap = xmalloc(sizeof(struct string_list));
|
||||
string_list_init_nodup(rev->mailmap);
|
||||
read_mailmap(rev->mailmap);
|
||||
read_mailmap(the_repository, rev->mailmap);
|
||||
}
|
||||
|
||||
if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
|
||||
|
||||
@@ -357,7 +357,7 @@ void shortlog_init(struct shortlog *log)
|
||||
{
|
||||
memset(log, 0, sizeof(*log));
|
||||
|
||||
read_mailmap(&log->mailmap);
|
||||
read_mailmap(the_repository, &log->mailmap);
|
||||
|
||||
log->list.strdup_strings = 1;
|
||||
log->wrap = DEFAULT_WRAPLEN;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
30
mailmap.c
30
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;
|
||||
@@ -183,7 +181,8 @@ static void read_mailmap_string(struct string_list *map, char *buf)
|
||||
}
|
||||
}
|
||||
|
||||
int read_mailmap_blob(struct string_list *map, const char *name)
|
||||
int read_mailmap_blob(struct repository *repo, struct string_list *map,
|
||||
const char *name)
|
||||
{
|
||||
struct object_id oid;
|
||||
char *buf;
|
||||
@@ -192,10 +191,10 @@ int read_mailmap_blob(struct string_list *map, const char *name)
|
||||
|
||||
if (!name)
|
||||
return 0;
|
||||
if (repo_get_oid(the_repository, name, &oid) < 0)
|
||||
if (repo_get_oid(repo, name, &oid) < 0)
|
||||
return 0;
|
||||
|
||||
buf = odb_read_object(the_repository->objects, &oid, &type, &size);
|
||||
buf = odb_read_object(repo->objects, &oid, &type, &size);
|
||||
if (!buf)
|
||||
return error("unable to read mailmap object at %s", name);
|
||||
if (type != OBJ_BLOB) {
|
||||
@@ -209,23 +208,32 @@ int read_mailmap_blob(struct string_list *map, const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int read_mailmap(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(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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
#ifndef MAILMAP_H
|
||||
#define MAILMAP_H
|
||||
|
||||
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)
|
||||
|
||||
int read_mailmap_file(struct string_list *map, const char *filename,
|
||||
unsigned flags);
|
||||
int read_mailmap_blob(struct string_list *map, const char *name);
|
||||
int read_mailmap_blob(struct repository *repo, struct string_list *map,
|
||||
const char *name);
|
||||
|
||||
int read_mailmap(struct string_list *map);
|
||||
int read_mailmap(struct repository *repo, struct string_list *map);
|
||||
void clear_mailmap(struct string_list *map);
|
||||
|
||||
int map_user(struct string_list *map,
|
||||
|
||||
2
pretty.c
2
pretty.c
@@ -781,7 +781,7 @@ static int mailmap_name(const char **email, size_t *email_len,
|
||||
static struct string_list *mail_map;
|
||||
if (!mail_map) {
|
||||
CALLOC_ARRAY(mail_map, 1);
|
||||
read_mailmap(mail_map);
|
||||
read_mailmap(the_repository, mail_map);
|
||||
}
|
||||
return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
|
||||
}
|
||||
|
||||
@@ -1753,7 +1753,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, void
|
||||
(starts_with(name + wholen, "email") &&
|
||||
(atom->u.email_option.option & EO_MAILMAP))) {
|
||||
if (!mailmap.items)
|
||||
read_mailmap(&mailmap);
|
||||
read_mailmap(the_repository, &mailmap);
|
||||
strbuf_addstr(&mailmap_buf, buf);
|
||||
apply_mailmap_to_header(&mailmap_buf, headers, &mailmap);
|
||||
wholine = find_wholine(who, wholen, mailmap_buf.buf);
|
||||
|
||||
Reference in New Issue
Block a user