Skip to content

Commit

Permalink
mailmap: do not lose single-letter names
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jul 15, 2013
1 parent 109025b commit 8c38115
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mailmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion t/t4203-mailmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 8c38115

Please sign in to comment.