aboutsummaryrefslogtreecommitdiff
path: root/mailmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mailmap.c')
-rw-r--r--mailmap.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/mailmap.c b/mailmap.c
index 6be91b60d..b68c1fec9 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -99,16 +99,17 @@ static void add_mapping(struct string_list *map,
old_name, old_email, new_name, new_email);
}
-static char *parse_name_and_email(char *buffer, char **name, char **email)
+static char *parse_name_and_email(char *buffer, char **name,
+ char **email, int allow_empty_email)
{
char *left, *right, *nstart, *nend;
- *name = *email = 0;
+ *name = *email = NULL;
if ((left = strchr(buffer, '<')) == NULL)
return NULL;
if ((right = strchr(left+1, '>')) == NULL)
return NULL;
- if (left+1 == right)
+ if (!allow_empty_email && (left+1 == right))
return NULL;
/* remove whitespace from beginning and end of name */
@@ -135,7 +136,7 @@ static int read_single_mailmap(struct string_list *map, const char *filename, ch
if (f == NULL)
return 1;
while (fgets(buffer, sizeof(buffer), f) != NULL) {
- char *name1 = 0, *email1 = 0, *name2 = 0, *email2 = 0;
+ char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
if (buffer[0] == '#') {
static const char abbrev[] = "# repo-abbrev:";
int abblen = sizeof(abbrev) - 1;
@@ -159,8 +160,8 @@ static int read_single_mailmap(struct string_list *map, const char *filename, ch
}
continue;
}
- if ((name2 = parse_name_and_email(buffer, &name1, &email1)) != NULL)
- parse_name_and_email(name2, &name2, &email2);
+ if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
+ parse_name_and_email(name2, &name2, &email2, 1);
if (email1)
add_mapping(map, name1, email1, name2, email2);
@@ -199,7 +200,7 @@ int map_user(struct string_list *map,
if (!p) {
/* email passed in might not be wrapped in <>, but end with a \0 */
p = memchr(email, '\0', maxlen_email);
- if (p == 0)
+ if (!p)
return 0;
}
if (p - email + 1 < sizeof(buf))
@@ -242,8 +243,3 @@ int map_user(struct string_list *map,
debug_mm("map_user: --\n");
return 0;
}
-
-int map_email(struct string_list *map, const char *email, char *name, int maxlen)
-{
- return map_user(map, (char *)email, 0, name, maxlen);
-}