mailmap: do not lose single-letter names
authorJunio C Hamano <gitster@pobox.com>
Mon, 15 Jul 2013 06:54:06 +0000 (02:54 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jul 2013 15:16:00 +0000 (08:16 -0700)
In parse_name_and_email() function, there is this line:

*name = (nstart < nend ? nstart : NULL);

When the function is given a buffer "A <A@example.org> <old@x.z>",
nstart scans from the beginning of the buffer, skipping whitespaces
(there isn't any, so nstart points at the buffer), while nend starts
from one byte before the first '<' and skips whitespaces backwards
and stops at the first non-whitespace (i.e. it hits "A" at the
beginning of the buffer). nstart == nend in this case for a
single-letter name, and an off-by-one error makes it fail to pick up
the name, which makes the entry equivalent to

<A@example.org> <old@x.z>

without the name.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mailmap.c
t/t4203-mailmap.sh
index 2a7b36628cb5623eb0ffb95bfb54e52a6dd300f4..418081e6130885780249e7daef1a3e3a86181d58 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -122,7 +122,7 @@ static char *parse_name_and_email(char *buffer, char **name,
        while (nend > nstart && isspace(*nend))
                --nend;
 
-       *name = (nstart < nend ? nstart : NULL);
+       *name = (nstart <= nend ? nstart : NULL);
        *email = left+1;
        *(nend+1) = '\0';
        *right++ = '\0';
index 27f8f86ea759b52b69b78c6a16a151f0e57cb6ec..8583724375134253c1054f3d8e683bfaba7c6275 100755 (executable)
@@ -247,7 +247,7 @@ test_expect_success 'cleanup after mailmap.blob tests' '
        rm -f .mailmap
 '
 
-test_expect_failure 'single-character name' '
+test_expect_success 'single-character name' '
        echo "     1    A <author@example.com>" >expect &&
        echo "     1    nick1 <bugs@company.xx>" >>expect &&
        echo "A <author@example.com>" >.mailmap &&