t4150-am: refactor am -3 tests

Create a setup for git am -3 in a separate test instead of creating this setup each time. This prepares for the next commit which will use this setup as well. Signed-off-by: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Remi Lespinet committed Jun 4, 2015 at 17:04 UTC 8c8884ce97eed5ab27a8b6f9f54a6f3795eded19
1 file changed +11 -15
t/t4150-am.sh
+11 -15
@@ -274,15 +274,21 @@ test_expect_success 'am --keep-non-patch really keeps the non-patch part' '
274 grep "^\[foo\] third" actual
275 '
276
277 -test_expect_success 'am -3 falls back to 3-way merge' '
277 +test_expect_success 'setup am -3' '
278 rm -fr .git/rebase-apply &&
279 git reset --hard &&
280 - git checkout -b lorem2 master2 &&
280 + git checkout -b base3way master2 &&
281 sed -n -e "3,\$p" msg >file &&
282 head -n 9 msg >>file &&
283 git add file &&
284 test_tick &&
285 - git commit -m "copied stuff" &&
285 + git commit -m "copied stuff"
286 +'
287 +
288 +test_expect_success 'am -3 falls back to 3-way merge' '
289 + rm -fr .git/rebase-apply &&
290 + git reset --hard &&
291 + git checkout -b lorem2 base3way &&
292 git am -3 lorem-move.patch &&
293 test_path_is_missing .git/rebase-apply &&
294 git diff --exit-code lorem
@@ -291,12 +297,7 @@ test_expect_success 'am -3 falls back to 3-way merge' '
297 test_expect_success 'am -3 -p0 can read --no-prefix patch' '
298 rm -fr .git/rebase-apply &&
299 git reset --hard &&
294 - git checkout -b lorem3 master2 &&
295 - sed -n -e "3,\$p" msg >file &&
296 - head -n 9 msg >>file &&
297 - git add file &&
298 - test_tick &&
299 - git commit -m "copied stuff" &&
300 + git checkout -b lorem3 base3way &&
301 git am -3 -p0 lorem-zero.patch &&
302 test_path_is_missing .git/rebase-apply &&
303 git diff --exit-code lorem
@@ -338,12 +339,7 @@ test_expect_success 'am -3 can rename a file after falling back to 3-way merge'
339 test_expect_success 'am -3 -q is quiet' '
340 rm -fr .git/rebase-apply &&
341 git checkout -f lorem2 &&
341 - git reset master2 --hard &&
342 - sed -n -e "3,\$p" msg >file &&
343 - head -n 9 msg >>file &&
344 - git add file &&
345 - test_tick &&
346 - git commit -m "copied stuff" &&
342 + git reset base3way --hard &&
343 git am -3 -q lorem-move.patch >output.out 2>&1 &&
344 ! test -s output.out
345 '