mailmap: drop global config variables
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>main
parent
999b09348d
commit
6aea51bc3b
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
21
mailmap.c
21
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue