Skip to content

Commit fc99da1

Browse files
peffgitster
authored andcommitted
t9001: drop save_confirm helper
The idea of this helper is that we want to save the current value of a config variable and then restore it again after the test completes. However, there's no point in actually saving the value; it should always be restored to the string "never" (which you can confirm by instrumenting save_confirm to print the value it finds). Let's just replace it with a single test_when_finished call. Suggested-by: SZEDER Gábor <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent be86fb3 commit fc99da1

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

t/t9001-send-email.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -817,25 +817,20 @@ test_expect_success $PREREQ '--confirm=compose' '
817817
test_confirm --confirm=compose --compose
818818
'
819819

820-
save_confirm () {
821-
CONFIRM=$(git config --get sendemail.confirm) &&
822-
test_when_finished "git config sendemail.confirm ${CONFIRM:-never}"
823-
}
824-
825820
test_expect_success $PREREQ 'confirm by default (due to cc)' '
826-
save_confirm &&
821+
test_when_finished git config sendemail.confirm never &&
827822
git config --unset sendemail.confirm &&
828823
test_confirm
829824
'
830825

831826
test_expect_success $PREREQ 'confirm by default (due to --compose)' '
832-
save_confirm &&
827+
test_when_finished git config sendemail.confirm never &&
833828
git config --unset sendemail.confirm &&
834829
test_confirm --suppress-cc=all --compose
835830
'
836831

837832
test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
838-
save_confirm &&
833+
test_when_finished git config sendemail.confirm never &&
839834
git config --unset sendemail.confirm &&
840835
rm -fr outdir &&
841836
git format-patch -2 -o outdir &&
@@ -848,7 +843,7 @@ test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
848843
'
849844

850845
test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
851-
save_confirm &&
846+
test_when_finished git config sendemail.confirm never &&
852847
git config sendemail.confirm auto &&
853848
GIT_SEND_EMAIL_NOTTY=1 &&
854849
export GIT_SEND_EMAIL_NOTTY &&
@@ -860,7 +855,7 @@ test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
860855
'
861856

862857
test_expect_success $PREREQ 'confirm does not loop forever' '
863-
save_confirm &&
858+
test_when_finished git config sendemail.confirm never &&
864859
git config sendemail.confirm auto &&
865860
GIT_SEND_EMAIL_NOTTY=1 &&
866861
export GIT_SEND_EMAIL_NOTTY &&

0 commit comments

Comments
 (0)