Merge branch 'kb/diff-blob-blob-doc'
[gitweb.git] / t / t9001-send-email.sh
index 97d6f4c7de57c54adfd5fed6401dbd168b5f3064..9f46f22ca87be40e217c2ffb199368f0afbf9548 100755 (executable)
@@ -101,7 +101,7 @@ test_expect_success $PREREQ \
 
 test_expect_success $PREREQ 'Send patches with --envelope-sender' '
     clean_fake_sendmail &&
-     git send-email --envelope-sender="Patch Contributer <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
+     git send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
 '
 
 test_expect_success $PREREQ 'setup expect' '
@@ -171,6 +171,81 @@ 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
+
+               cccmd--$1 <$2>
+
+               Cc: $1 <$2>
+               Signed-off-by: $1 <$2>
+       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 '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 '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 \
@@ -787,7 +862,7 @@ test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
        test $ret = "0"
 '
 
-test_expect_success $PREREQ 'confirm doesnt loop forever' '
+test_expect_success $PREREQ 'confirm does not loop forever' '
        CONFIRM=$(git config --get sendemail.confirm) &&
        git config sendemail.confirm auto &&
        GIT_SEND_EMAIL_NOTTY=1 &&
@@ -1003,55 +1078,6 @@ test_expect_success $PREREQ 'threading but no chain-reply-to' '
        grep "In-Reply-To: " stdout
 '
 
-test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' '
-       git send-email \
-       --dry-run \
-       --from="Example <nobody@example.com>" \
-       --to=nobody@example.com \
-       outdir/000?-*.patch 2>errors >out &&
-       grep "no-chain-reply-to" errors
-'
-
-test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' '
-       git send-email \
-       --dry-run \
-       --from="Example <nobody@example.com>" \
-       --to=nobody@example.com \
-       --chain-reply-to \
-       outdir/000?-*.patch 2>errors >out &&
-       ! grep "no-chain-reply-to" errors
-'
-
-test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' '
-       git send-email \
-       --dry-run \
-       --from="Example <nobody@example.com>" \
-       --to=nobody@example.com \
-       --nochain-reply-to \
-       outdir/000?-*.patch 2>errors >out &&
-       ! grep "no-chain-reply-to" errors
-'
-
-test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' '
-       git config sendemail.chainreplyto false &&
-       git send-email \
-       --dry-run \
-       --from="Example <nobody@example.com>" \
-       --to=nobody@example.com \
-       outdir/000?-*.patch 2>errors >out &&
-       ! grep "no-chain-reply-to" errors
-'
-
-test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' '
-       git config sendemail.chainreplyto true &&
-       git send-email \
-       --dry-run \
-       --from="Example <nobody@example.com>" \
-       --to=nobody@example.com \
-       outdir/000?-*.patch 2>errors >out &&
-       ! grep "no-chain-reply-to" errors
-'
-
 test_expect_success $PREREQ 'sendemail.to works' '
        git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
        git send-email \