summaryrefslogtreecommitdiff
path: root/mailmap.c
diff options
context:
space:
mode:
authorMarius Storm-Olsen <marius@trolltech.com>2009-02-08 15:34:27 +0100
committerJunio C Hamano <gitster@pobox.com>2009-02-08 12:36:26 -0800
commitd551a488169aeb2ac09dba781f2ffbecf3425996 (patch)
tree04a6e379953fbabdbe17dddd8732f778b20cec84 /mailmap.c
parent88ccb9f9745ff1f44bff7c6d6c17ad4b46870706 (diff)
downloadgit-d551a488169aeb2ac09dba781f2ffbecf3425996.tar.gz
Add mailmap.file as configurational option for mailmap location
This allows us to augment the repo mailmap file, and to use mailmap files elsewhere than the repository root. Meaning that the entries in mailmap.file will override the entries in "./.mailmap", should they match. Signed-off-by: Marius Storm-Olsen <marius@trolltech.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mailmap.c')
-rw-r--r--mailmap.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/mailmap.c b/mailmap.c
index 88fc6f3946..d006dad673 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -2,10 +2,11 @@
#include "string-list.h"
#include "mailmap.h"
-int read_mailmap(struct string_list *map, const char *filename, char **repo_abbrev)
+const char *git_mailmap_file;
+static int read_single_mailmap(struct string_list *map, const char *filename, char **repo_abbrev)
{
char buffer[1024];
- FILE *f = fopen(filename, "r");
+ FILE *f = (filename == NULL ? NULL : fopen(filename, "r"));
if (f == NULL)
return 1;
@@ -60,6 +61,13 @@ int read_mailmap(struct string_list *map, const char *filename, char **repo_abbr
return 0;
}
+int read_mailmap(struct string_list *map, char **repo_abbrev)
+{
+ /* each failure returns 1, so >1 means both calls failed */
+ return read_single_mailmap(map, ".mailmap", repo_abbrev) +
+ read_single_mailmap(map, git_mailmap_file, repo_abbrev) > 1;
+}
+
int map_email(struct string_list *map, const char *email, char *name, int maxlen)
{
char *p;