diff --git a/Documentation/git-check-mailmap.txt b/Documentation/git-check-mailmap.txt index 02f4418323..7747e38e25 100644 --- a/Documentation/git-check-mailmap.txt +++ b/Documentation/git-check-mailmap.txt @@ -15,10 +15,10 @@ SYNOPSIS DESCRIPTION ----------- -For each ``Name $$$$'' or ``$$$$'' from the command-line -or standard input (when using `--stdin`), look up the person's canonical name -and email address (see "Mapping Authors" below). If found, print them; -otherwise print the input as-is. +For each ``Name $$$$'', ``$$$$'', or ``$$user@host$$'' +from the command-line or standard input (when using `--stdin`), look up the +person's canonical name and email address (see "Mapping Authors" below). If +found, print them; otherwise print the input as-is. OPTIONS diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c index b8a05b8e07..6b7fb53494 100644 --- a/builtin/check-mailmap.c +++ b/builtin/check-mailmap.c @@ -25,13 +25,17 @@ static void check_mailmap(struct string_list *mailmap, const char *contact) size_t namelen, maillen; struct ident_split ident; - if (split_ident_line(&ident, contact, strlen(contact))) - die(_("unable to parse contact: %s"), contact); - - name = ident.name_begin; - namelen = ident.name_end - ident.name_begin; - mail = ident.mail_begin; - maillen = ident.mail_end - ident.mail_begin; + if (!split_ident_line(&ident, contact, strlen(contact))) { + name = ident.name_begin; + namelen = ident.name_end - ident.name_begin; + mail = ident.mail_begin; + maillen = ident.mail_end - ident.mail_begin; + } else { + name = NULL; + namelen = 0; + mail = contact; + maillen = strlen(contact); + } map_user(mailmap, &mail, &maillen, &name, &namelen); diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 8a88dd7900..2421491931 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -71,12 +71,46 @@ test_expect_success 'check-mailmap --stdin arguments: mapping' ' test_cmp expect actual ' -test_expect_success 'check-mailmap bogus contact' ' - test_must_fail git check-mailmap bogus +test_expect_success 'check-mailmap simple address: mapping' ' + test_when_finished "rm .mailmap" && + cat >.mailmap <<-EOF && + New Name <$GIT_AUTHOR_EMAIL> + EOF + cat .mailmap >expect && + git check-mailmap "$GIT_AUTHOR_EMAIL" >actual && + test_cmp expect actual ' -test_expect_success 'check-mailmap bogus contact --stdin' ' - test_must_fail git check-mailmap --stdin bogus .mailmap <<-EOF && + New Name <$GIT_AUTHOR_EMAIL> + EOF + cat >stdin <<-EOF && + $GIT_AUTHOR_EMAIL + EOF + cat .mailmap >expect && + git check-mailmap --stdin actual && + test_cmp expect actual +' + +test_expect_success 'check-mailmap simple address: no mapping' ' + cat >expect <<-EOF && + + EOF + git check-mailmap "bugs@company.xx" >actual && + test_cmp expect actual +' + +test_expect_success 'check-mailmap --stdin simple address: no mapping' ' + cat >expect <<-EOF && + + EOF + cat >stdin <<-EOF && + bugs@company.xx + EOF + git check-mailmap --stdin actual && + test_cmp expect actual ' test_expect_success 'No mailmap' '