From 109025b4e1c836fb62752f69f24e8f11403760d5 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Mon, 15 Jul 2013 02:54:05 -0400 Subject: t4203: demonstrate loss of single-character name in mailmap entry A bug in mailmap.c:parse_name_and_email() causes it to overlook the single-character name in "A " and parse it only as "". Demonstrate this problem. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/t4203-mailmap.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 't') diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 842b7549ec..27f8f86ea7 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -247,6 +247,15 @@ test_expect_success 'cleanup after mailmap.blob tests' ' rm -f .mailmap ' +test_expect_failure 'single-character name' ' + echo " 1 A " >expect && + echo " 1 nick1 " >>expect && + echo "A " >.mailmap && + test_when_finished "rm .mailmap" && + git shortlog -es HEAD >actual && + test_cmp expect actual +' + # Extended mailmap configurations should give us the following output for shortlog cat >expect <<\EOF A U Thor (1): -- cgit v1.2.3 From 8c3811510e2a90f765edbb6dc7f81b0737592c0a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 15 Jul 2013 02:54:06 -0400 Subject: 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 ", 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 without the name. Signed-off-by: Junio C Hamano Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/t4203-mailmap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 27f8f86ea7..8583724375 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -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 " >expect && echo " 1 nick1 " >>expect && echo "A " >.mailmap && -- cgit v1.2.3 From 3aff56ddbebfdb314f123e9a076403459d6a0767 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Mon, 15 Jul 2013 02:54:07 -0400 Subject: t4203: demonstrate loss of uppercase characters in canonical email The email addresses read from .mailmap are downcased before being inserted into the mailmap data structure, which undesirably loses information. It is impossible, for instance, to map to . Demonstrate this problem. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/t4203-mailmap.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 't') diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 8583724375..ffe6a11ac0 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -256,6 +256,15 @@ test_expect_success 'single-character name' ' test_cmp expect actual ' +test_expect_failure 'preserve canonical email case' ' + echo " 1 A U Thor " >expect && + echo " 1 nick1 " >>expect && + echo " " >.mailmap && + test_when_finished "rm .mailmap" && + git shortlog -es HEAD >actual && + test_cmp expect actual +' + # Extended mailmap configurations should give us the following output for shortlog cat >expect <<\EOF A U Thor (1): -- cgit v1.2.3 From 97e751be7928d17c177b2fe65fb9bacf6ee35643 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 15 Jul 2013 02:54:08 -0400 Subject: mailmap: do not downcase mailmap entries The email addresses in the records read from the .mailmap file are downcased very early, and then used to match against e-mail addresses in the input. Because we do use case insensitive version of string list to manage these entries, there is no need to do this, and worse yet, downcasing the rewritten/canonical e-mail read from the .mailmap file loses information. Stop doing that, and also make the string list used to keep multiple names for an mailmap entry case insensitive (the code that uses the list, lookup_prefix(), expects a case insensitive match). Signed-off-by: Junio C Hamano Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/t4203-mailmap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index ffe6a11ac0..c32df80f14 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -256,7 +256,7 @@ test_expect_success 'single-character name' ' test_cmp expect actual ' -test_expect_failure 'preserve canonical email case' ' +test_expect_success 'preserve canonical email case' ' echo " 1 A U Thor " >expect && echo " 1 nick1 " >>expect && echo " " >.mailmap && -- cgit v1.2.3