t4014: cleanups in a few tests

Arrange things we are going to create to be removed at end, and then start creating them. That way, we will clean them up even if we fail after creating some but before the end of the command. Signed-off-by: Rubén Justo <rjusto@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rubén Justo committed Jun 7, 2024 at 22:55 UTC bc665cdab70ac2aab59575902f8b1d4abe994060
1 file changed +5 -5
t/t4014-format-patch.sh
+5 -5
@@ -820,8 +820,8 @@ test_expect_success 'format-patch --notes --signoff' '
820 '
821
822 test_expect_success 'format-patch notes output control' '
823 + test_when_finished "git notes remove HEAD || :" &&
824 git notes add -m "notes config message" HEAD &&
824 - test_when_finished git notes remove HEAD &&
825
826 git format-patch -1 --stdout >out &&
827 ! grep "notes config message" out &&
@@ -848,10 +848,10 @@ test_expect_success 'format-patch notes output control' '
848 '
849
850 test_expect_success 'format-patch with multiple notes refs' '
851 + test_when_finished "git notes --ref note1 remove HEAD;
852 + git notes --ref note2 remove HEAD || :" &&
853 git notes --ref note1 add -m "this is note 1" HEAD &&
852 - test_when_finished git notes --ref note1 remove HEAD &&
854 git notes --ref note2 add -m "this is note 2" HEAD &&
854 - test_when_finished git notes --ref note2 remove HEAD &&
855
856 git format-patch -1 --stdout >out &&
857 ! grep "this is note 1" out &&
@@ -892,10 +892,10 @@ test_expect_success 'format-patch with multiple notes refs' '
892 test_expect_success 'format-patch with multiple notes refs in config' '
893 test_when_finished "test_unconfig format.notes" &&
894
895 + test_when_finished "git notes --ref note1 remove HEAD;
896 + git notes --ref note2 remove HEAD || :" &&
897 git notes --ref note1 add -m "this is note 1" HEAD &&
896 - test_when_finished git notes --ref note1 remove HEAD &&
898 git notes --ref note2 add -m "this is note 2" HEAD &&
898 - test_when_finished git notes --ref note2 remove HEAD &&
899
900 git config format.notes note1 &&
901 git format-patch -1 --stdout >out &&