t7610: run 'git reset --hard' after each test to clean up

Use test_when_finished to run 'git reset --hard' after each test so that the repository is left in a saner state for the next test. This is a step toward making the tests more independent so that if one test fails it doesn't cause subsequent tests to fail. Signed-off-by: Richard Hansen <hansenr@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Richard Hansen committed Jan 10, 2017 at 15:41 UTC c3ad3126b8113e9ed90ec8639a2ef266e9190565
1 file changed +8
t/t7610-mergetool.sh
+8
@@ -127,6 +127,7 @@ test_expect_success 'setup' '
127 '
128
129 test_expect_success 'custom mergetool' '
130 + test_when_finished "git reset --hard" &&
131 git checkout -b test$test_count branch1 &&
132 git submodule update -N &&
133 test_must_fail git merge master >/dev/null 2>&1 &&
@@ -170,6 +171,7 @@ test_expect_success 'mergetool crlf' '
171 '
172
173 test_expect_success 'mergetool in subdir' '
174 + test_when_finished "git reset --hard" &&
175 git checkout -b test$test_count branch1 &&
176 git submodule update -N &&
177 (
@@ -181,6 +183,7 @@ test_expect_success 'mergetool in subdir' '
183 '
184
185 test_expect_success 'mergetool on file in parent dir' '
186 + test_when_finished "git reset --hard" &&
187 git reset --hard &&
188 git submodule update -N &&
189 (
@@ -214,6 +217,7 @@ test_expect_success 'mergetool skips autoresolved' '
217 '
218
219 test_expect_success 'mergetool merges all from subdir' '
220 + test_when_finished "git reset --hard" &&
221 test_config rerere.enabled false &&
222 (
223 cd subdir &&
@@ -244,6 +248,7 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' '
248 '
249
250 test_expect_success 'conflicted stash sets up rerere' '
251 + test_when_finished "git reset --hard" &&
252 test_config rerere.enabled true &&
253 git checkout stash1 &&
254 echo "Conflicting stash content" >file11 &&
@@ -403,6 +408,7 @@ test_expect_success 'deleted vs modified submodule' '
408 '
409
410 test_expect_success 'file vs modified submodule' '
411 + test_when_finished "git reset --hard" &&
412 git checkout -b test$test_count branch1 &&
413 git submodule update -N &&
414 mv submod submod-movedaside &&
@@ -474,6 +480,7 @@ test_expect_success 'file vs modified submodule' '
480 '
481
482 test_expect_success 'submodule in subdirectory' '
483 + test_when_finished "git reset --hard" &&
484 git checkout -b test$test_count branch1 &&
485 git submodule update -N &&
486 (
@@ -535,6 +542,7 @@ test_expect_success 'submodule in subdirectory' '
542 '
543
544 test_expect_success 'directory vs modified submodule' '
545 + test_when_finished "git reset --hard" &&
546 git checkout -b test$test_count branch1 &&
547 mv submod submod-movedaside &&
548 git rm --cached submod &&