t: fix some trivial cases of ignored exit codes in loops
[gitweb.git] / t / t9001-send-email.sh
index af6a3e8904ab1d953b359707de1e0c9a09b3ce1f..c9f54d5a5ea47a32f71ad7a34d9f6024280c5da0 100755 (executable)
@@ -392,7 +392,7 @@ test_expect_success $PREREQ 'allow long lines with --no-validate' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --smtp-server="$(pwd)/fake.sendmail" \
-               --novalidate \
+               --no-validate \
                $patches longline.patch \
                2>errors
 '
@@ -426,7 +426,7 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
        git send-email \
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
-               --nochain-reply-to \
+               --no-chain-reply-to \
                --in-reply-to="$(cat expect)" \
                --smtp-server="$(pwd)/fake.sendmail" \
                $patches $patches $patches \
@@ -817,26 +817,25 @@ test_expect_success $PREREQ '--confirm=compose' '
        test_confirm --confirm=compose --compose
 '
 
-test_expect_success $PREREQ 'confirm by default (due to cc)' '
+save_confirm () {
        CONFIRM=$(git config --get sendemail.confirm) &&
+       test_when_finished "git config sendemail.confirm ${CONFIRM:-never}"
+}
+
+test_expect_success $PREREQ 'confirm by default (due to cc)' '
+       save_confirm &&
        git config --unset sendemail.confirm &&
        test_confirm
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       save_confirm &&
        git config --unset sendemail.confirm &&
        test_confirm --suppress-cc=all --compose
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       save_confirm &&
        git config --unset sendemail.confirm &&
        rm -fr outdir &&
        git format-patch -2 -o outdir &&
@@ -846,13 +845,10 @@ test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/fake.sendmail" \
                        outdir/*.patch </dev/null
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       save_confirm &&
        git config sendemail.confirm auto &&
        GIT_SEND_EMAIL_NOTTY=1 &&
        export GIT_SEND_EMAIL_NOTTY &&
@@ -861,13 +857,10 @@ test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/fake.sendmail" \
                        $patches </dev/null
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'confirm does not loop forever' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       save_confirm &&
        git config sendemail.confirm auto &&
        GIT_SEND_EMAIL_NOTTY=1 &&
        export GIT_SEND_EMAIL_NOTTY &&
@@ -876,9 +869,6 @@ test_expect_success $PREREQ 'confirm does not loop forever' '
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/fake.sendmail" \
                        $patches
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
@@ -1067,7 +1057,7 @@ test_expect_success $PREREQ 'in-reply-to but no threading' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --in-reply-to="<in-reply-id@example.com>" \
-               --nothread \
+               --no-thread \
                $patches |
        grep "In-Reply-To: <in-reply-id@example.com>"
 '
@@ -1077,7 +1067,7 @@ test_expect_success $PREREQ 'no in-reply-to and no threading' '
                --dry-run \
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
-               --nothread \
+               --no-thread \
                $patches $patches >stdout &&
        ! grep "In-Reply-To: " stdout
 '
@@ -1088,7 +1078,7 @@ test_expect_success $PREREQ 'threading but no chain-reply-to' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --thread \
-               --nochain-reply-to \
+               --no-chain-reply-to \
                $patches $patches >stdout &&
        grep "In-Reply-To: " stdout
 '
@@ -1325,7 +1315,7 @@ test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data'
 
 test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
        clean_fake_sendmail &&
-       git config sendemail.transferEncoding 8bit
+       git config sendemail.transferEncoding 8bit &&
        test_must_fail git send-email \
                --transfer-encoding=7bit \
                --smtp-server="$(pwd)/fake.sendmail" \