Skip to content

Commit

Permalink
Mailmap: Allow empty email addresses to be mapped
Browse files Browse the repository at this point in the history
While it makes no sense to map some email address to an empty one, doing
things the other way around can be useful. For example when using
filter-branch with an env-filter that employs a mailmap to fix up an
import that created such broken commits with empty email addresses.

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Björn Steinbrink authored and Junio C Hamano committed Apr 1, 2009
1 parent 75fd877 commit 5288dd5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mailmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ 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;
Expand All @@ -99,7 +100,7 @@ static char *parse_name_and_email(char *buffer, char **name, char **email)
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 */
Expand Down Expand Up @@ -150,8 +151,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);
Expand Down

0 comments on commit 5288dd5

Please sign in to comment.