mailmap: do not lose single-letter names

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>

Junio C Hamano committed Jul 15, 2013 at 02:54 UTC 8c3811510e2a90f765edbb6dc7f81b0737592c0a
2 files changed +2 -2
mailmap.c
+1 -1
@@ -122,7 +122,7 @@ static char *parse_name_and_email(char *buffer, char **name,
122 while (nend > nstart && isspace(*nend))
123 --nend;
124
125 - *name = (nstart < nend ? nstart : NULL);
125 + *name = (nstart <= nend ? nstart : NULL);
126 *email = left+1;
127 *(nend+1) = '\0';
128 *right++ = '\0';
t/t4203-mailmap.sh
+1 -1
@@ -247,7 +247,7 @@ test_expect_success 'cleanup after mailmap.blob tests' '
247 rm -f .mailmap
248 '
249
250 -test_expect_failure 'single-character name' '
250 +test_expect_success 'single-character name' '
251 echo " 1 A <author@example.com>" >expect &&
252 echo " 1 nick1 <bugs@company.xx>" >>expect &&
253 echo "A <author@example.com>" >.mailmap &&