summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-02-13 06:43:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-02-13 06:43:39 (GMT)
commitb95ffc143fee155e9ef7ef5e4def38c58febf2ee (patch)
treecd6a845e8fe90138345a9272ce62972e68d4eb6c
parent974e978b09fdabba009c18f99db54cc36baf9c36 (diff)
parentf026358ef20e0c252388a41fcc8eff125b00927c (diff)
downloadgit-b95ffc143fee155e9ef7ef5e4def38c58febf2ee.zip
git-b95ffc143fee155e9ef7ef5e4def38c58febf2ee.tar.gz
git-b95ffc143fee155e9ef7ef5e4def38c58febf2ee.tar.bz2
Merge branch 'jc/maint-mailmap-output'
* jc/maint-mailmap-output: mailmap: always return a plain mail address from map_user()
-rw-r--r--mailmap.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/mailmap.c b/mailmap.c
index 8c3196c..47aa419 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -190,27 +190,27 @@ void clear_mailmap(struct string_list *map)
int map_user(struct string_list *map,
char *email, int maxlen_email, char *name, int maxlen_name)
{
- char *p;
+ char *end_of_email;
struct string_list_item *item;
struct mailmap_entry *me;
char buf[1024], *mailbuf;
int i;
/* figure out space requirement for email */
- p = strchr(email, '>');
- if (!p) {
+ end_of_email = strchr(email, '>');
+ if (!end_of_email) {
/* email passed in might not be wrapped in <>, but end with a \0 */
- p = memchr(email, '\0', maxlen_email);
- if (!p)
+ end_of_email = memchr(email, '\0', maxlen_email);
+ if (!end_of_email)
return 0;
}
- if (p - email + 1 < sizeof(buf))
+ if (end_of_email - email + 1 < sizeof(buf))
mailbuf = buf;
else
- mailbuf = xmalloc(p - email + 1);
+ mailbuf = xmalloc(end_of_email - email + 1);
/* downcase the email address */
- for (i = 0; i < p - email; i++)
+ for (i = 0; i < end_of_email - email; i++)
mailbuf[i] = tolower(email[i]);
mailbuf[i] = 0;
@@ -236,6 +236,8 @@ int map_user(struct string_list *map,
}
if (maxlen_email && mi->email)
strlcpy(email, mi->email, maxlen_email);
+ else
+ *end_of_email = '\0';
if (maxlen_name && mi->name)
strlcpy(name, mi->name, maxlen_name);
debug_mm("map_user: to '%s' <%s>\n", name, mi->email ? mi->email : "");