Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 8c38115

Browse files
committed
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 <[email protected]> <[email protected]>", 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 <[email protected]> <[email protected]> without the name. Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 109025b commit 8c38115

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mailmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static char *parse_name_and_email(char *buffer, char **name,
122122
while (nend > nstart && isspace(*nend))
123123
--nend;
124124

125-
*name = (nstart < nend ? nstart : NULL);
125+
*name = (nstart <= nend ? nstart : NULL);
126126
*email = left+1;
127127
*(nend+1) = '\0';
128128
*right++ = '\0';

t/t4203-mailmap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ test_expect_success 'cleanup after mailmap.blob tests' '
247247
rm -f .mailmap
248248
'
249249

250-
test_expect_failure 'single-character name' '
250+
test_expect_success 'single-character name' '
251251
echo " 1 A <[email protected]>" >expect &&
252252
echo " 1 nick1 <[email protected]>" >>expect &&
253253
echo "A <[email protected]>" >.mailmap &&

0 commit comments

Comments
 (0)