From 5adcf2c69989884ad6c51df0f9ad5e68f6a3f650 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 30 May 2013 10:11:13 +0300 Subject: t/send-email.sh: add test for suppress-cc=self This adds a basic test for --suppress-cc=self option of git send-email. Signed-off-by: Michael S. Tsirkin Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 't') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index ebd5c5db45..f4745ce742 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -171,6 +171,49 @@ Result: OK EOF " +test_suppress_self () { + test_commit $3 && + test_when_finished "git reset --hard HEAD^" && + + write_script cccmd-sed <<-EOF && + sed -n -e s/^cccmd--//p "\$1" + EOF + + git commit --amend --author="$1 <$2>" -F - && + clean_fake_sendmail && + git format-patch --stdout -1 >"suppress-self-$3.patch" && + + git send-email --from="$1 <$2>" \ + --to=nobody@example.com \ + --cc-cmd=./cccmd-sed \ + --suppress-cc=self \ + --smtp-server="$(pwd)/fake.sendmail" \ + suppress-self-$3.patch && + + mv msgtxt1 msgtxt1-$3 && + sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" && + >"expected-no-cc-$3" && + + (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3"; + test_cmp expected-no-cc-$3 actual-no-cc-$3) +} + +test_suppress_self_unquoted () { + test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF + test suppress-cc.self unquoted-$3 with name $1 email $2 + + unquoted-$3 + + Cc: $1 <$2> + Signed-off-by: $1 <$2> + EOF +} + +test_expect_success $PREREQ 'self name is suppressed' " + test_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \ + 'self_name_suppressed' +" + test_expect_success $PREREQ 'Show all headers' ' git send-email \ --dry-run \ -- cgit v1.2.3 From d6ee44568c876f7644f23d7f4319f7689348de76 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 5 Jun 2013 21:10:57 +0300 Subject: t/send-email: test suppress-cc=self on cccmd Check that suppress-cc=self works when applied to output of cccmd. Signed-off-by: Michael S. Tsirkin Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index f4745ce742..d7797c5e3f 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -204,13 +204,15 @@ test_suppress_self_unquoted () { unquoted-$3 + cccmd--$1 <$2> + Cc: $1 <$2> Signed-off-by: $1 <$2> EOF } test_expect_success $PREREQ 'self name is suppressed' " - test_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \ + test_suppress_self_unquoted 'A U Thor' 'author@example.com' \ 'self_name_suppressed' " -- cgit v1.2.3 From dd29f0b4dcc4e5411adeb310d6cd14a5a626b22c Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 5 Jun 2013 21:11:02 +0300 Subject: t/send-email: add test with quoted sender add test where sender address needs to be quoted. Make sure --suppress-cc=self works well in this case. Signed-off-by: Michael S. Tsirkin Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 't') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index d7797c5e3f..39d82f46e4 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -211,11 +211,31 @@ test_suppress_self_unquoted () { EOF } +test_suppress_self_quoted () { + test_suppress_self "$1" "$2" "quoted-$3" <<-EOF + test suppress-cc.self quoted-$3 with name $1 email $2 + + quoted-$3 + + cccmd--"$1" <$2> + + Cc: $1 <$2> + Cc: "$1" <$2> + Signed-off-by: $1 <$2> + Signed-off-by: "$1" <$2> + EOF +} + test_expect_success $PREREQ 'self name is suppressed' " test_suppress_self_unquoted 'A U Thor' 'author@example.com' \ 'self_name_suppressed' " +test_expect_success $PREREQ 'self name with dot is suppressed' " + test_suppress_self_quoted 'A U. Thor' 'author@example.com' \ + 'self_name_dot_suppressed' +" + test_expect_success $PREREQ 'Show all headers' ' git send-email \ --dry-run \ -- cgit v1.2.3 From 4b45bcf7b141baf49c7290925b4fa5a40e47b610 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 5 Jun 2013 21:11:04 +0300 Subject: t/send-email: test suppress-cc=self with non-ascii test suppress-cc=self when sender is non-acsii Signed-off-by: Michael S. Tsirkin Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 't') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 39d82f46e4..e4b3514d73 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -236,6 +236,11 @@ test_expect_success $PREREQ 'self name with dot is suppressed' " 'self_name_dot_suppressed' " +test_expect_success $PREREQ 'non-ascii self name is suppressed' " + test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \ + 'non_ascii_self_suppressed' +" + test_expect_success $PREREQ 'Show all headers' ' git send-email \ --dry-run \ -- cgit v1.2.3 From 14952666d18e5256e1796633e5a927891e77a8de Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 5 Jun 2013 21:11:08 +0300 Subject: test-send-email: test for pre-sanitized self name Users can sanitize from address manually. Verify that these are suppressed properly. Signed-off-by: Michael S. Tsirkin Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 't') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index e4b3514d73..ebcb60a050 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -241,6 +241,11 @@ test_expect_success $PREREQ 'non-ascii self name is suppressed' " 'non_ascii_self_suppressed' " +test_expect_success $PREREQ 'sanitized self name is suppressed' " + test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \ + 'self_name_sanitized_suppressed' +" + test_expect_success $PREREQ 'Show all headers' ' git send-email \ --dry-run \ -- cgit v1.2.3 From f07075c297d8a9b58b693176b6ae73dbabcdb103 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Tue, 18 Jun 2013 15:49:29 +0300 Subject: send-email: add test for duplicate utf8 name Verify that author name is not duplicated if it matches sender, even if it is in utf8 (the test expects a failure that will be fixed in the next patch). Signed-off-by: Michael S. Tsirkin Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index ebcb60a050..2a6f444bf8 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -956,6 +956,20 @@ test_expect_success $PREREQ 'utf8 author is correctly passed on' ' grep "^From: Füñný Nâmé " msgtxt1 ' +test_expect_failure $PREREQ 'utf8 sender is not duplicated' ' + clean_fake_sendmail && + test_commit weird_sender && + test_when_finished "git reset --hard HEAD^" && + git commit --amend --author "Füñný Nâmé " && + git format-patch --stdout -1 >funny_name.patch && + git send-email --from="Füñný Nâmé " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + funny_name.patch && + grep "^From: " msgtxt1 >msgfrom && + test_line_count = 1 msgfrom +' + test_expect_success $PREREQ 'sendemail.composeencoding works' ' clean_fake_sendmail && git config sendemail.composeencoding iso-8859-1 && -- cgit v1.2.3 From 4cb46bddeb7d21241f8ac5e46eb3d1cee468ea14 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Tue, 18 Jun 2013 15:49:26 +0300 Subject: send-email: sanitize author when writing From line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sender is now sanitized, but we didn't sanitize author when checking whether From: line is needed in the message body. As a result git started writing duplicate From: lines when author matched sender and has utf8 characters. Reported-by: SZEDER Gábor Signed-off-by: Michael S. Tsirkin Tested-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 2a6f444bf8..d6f0271866 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -956,7 +956,7 @@ test_expect_success $PREREQ 'utf8 author is correctly passed on' ' grep "^From: Füñný Nâmé " msgtxt1 ' -test_expect_failure $PREREQ 'utf8 sender is not duplicated' ' +test_expect_success $PREREQ 'utf8 sender is not duplicated' ' clean_fake_sendmail && test_commit weird_sender && test_when_finished "git reset --hard HEAD^" && -- cgit v1.2.3