@@ -421,8 +421,8 @@ test_confirm () {
421421 --from=" Example <nobody@example.com>" \
422422 --to=nobody@example.com \
423423 --smtp-server=" $( pwd) /fake.sendmail" \
424- $@ \
425- $patches | grep " Send this email"
424+ $@ $patches > stdout &&
425+ grep " Send this email" stdout
426426}
427427
428428test_expect_success ' --confirm=always' '
@@ -444,8 +444,10 @@ test_expect_success '--confirm=compose' '
444444test_expect_success ' confirm by default (due to cc)' '
445445 CONFIRM=$(git config --get sendemail.confirm) &&
446446 git config --unset sendemail.confirm &&
447- test_confirm &&
448- git config sendemail.confirm $CONFIRM
447+ test_confirm
448+ ret="$?"
449+ git config sendemail.confirm ${CONFIRM:-never}
450+ test $ret = "0"
449451'
450452
451453test_expect_success ' confirm by default (due to --compose)' '
@@ -457,6 +459,48 @@ test_expect_success 'confirm by default (due to --compose)' '
457459 test $ret = "0"
458460'
459461
462+ test_expect_success ' confirm detects EOF (inform assumes y)' '
463+ CONFIRM=$(git config --get sendemail.confirm) &&
464+ git config --unset sendemail.confirm &&
465+ GIT_SEND_EMAIL_NOTTY=1 \
466+ git send-email \
467+ --from="Example <nobody@example.com>" \
468+ --to=nobody@example.com \
469+ --smtp-server="$(pwd)/fake.sendmail" \
470+ $patches < /dev/null
471+ ret="$?"
472+ git config sendemail.confirm ${CONFIRM:-never}
473+ test $ret = "0"
474+ '
475+
476+ test_expect_success ' confirm detects EOF (auto causes failure)' '
477+ CONFIRM=$(git config --get sendemail.confirm) &&
478+ git config sendemail.confirm auto &&
479+ GIT_SEND_EMAIL_NOTTY=1 \
480+ test_must_fail git send-email \
481+ --from="Example <nobody@example.com>" \
482+ --to=nobody@example.com \
483+ --smtp-server="$(pwd)/fake.sendmail" \
484+ $patches < /dev/null
485+ ret="$?"
486+ git config sendemail.confirm ${CONFIRM:-never}
487+ test $ret = "0"
488+ '
489+
490+ test_expect_success ' confirm doesnt loop forever' '
491+ CONFIRM=$(git config --get sendemail.confirm) &&
492+ git config sendemail.confirm auto &&
493+ yes "bogus" | GIT_SEND_EMAIL_NOTTY=1 \
494+ test_must_fail git send-email \
495+ --from="Example <nobody@example.com>" \
496+ --to=nobody@example.com \
497+ --smtp-server="$(pwd)/fake.sendmail" \
498+ $patches
499+ ret="$?"
500+ git config sendemail.confirm ${CONFIRM:-never}
501+ test $ret = "0"
502+ '
503+
460504test_expect_success ' --compose adds MIME for utf8 body' '
461505 clean_fake_sendmail &&
462506 (echo "#!$SHELL_PATH" &&
0 commit comments