]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: refactor a few tests to use "test_commit --append"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 12 Jan 2021 20:18:00 +0000 (21:18 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Jan 2021 22:04:41 +0000 (14:04 -0800)
Refactor a few more tests to use the new "--append" option to
"test_commit". I added it for use in the mailmap tests, but this
demonstrates how useful it is in general.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1412-reflog-loop.sh
t/t2012-checkout-last.sh
t/t7810-grep.sh

index 3acd895afb7fde7f02a446b7508966e20734c4c5..977603f7f1ca9efb781c5743f1e730246e6d1963 100755 (executable)
@@ -4,11 +4,8 @@ test_description='reflog walk shows repeated commits again'
 . ./test-lib.sh
 
 test_expect_success 'setup commits' '
-       test_tick &&
-       echo content >file && git add file && git commit -m one &&
-       git tag one &&
-       echo content >>file && git add file && git commit -m two &&
-       git tag two
+       test_commit one file content &&
+       test_commit --append two file content
 '
 
 test_expect_success 'setup reflog with alternating commits' '
index e7ba8c505f579ab5cd53ee713eaf6ca894e471a1..c95aa3e78fdc747f3703acbfe257f9cab9156038 100755 (executable)
@@ -5,13 +5,9 @@ test_description='checkout can switch to last branch and merge base'
 . ./test-lib.sh
 
 test_expect_success 'setup' '
-       echo hello >world &&
-       git add world &&
-       git commit -m initial &&
+       test_commit initial world hello &&
        git branch other &&
-       echo "hello again" >>world &&
-       git add world &&
-       git commit -m second
+       test_commit --append second world "hello again"
 '
 
 test_expect_success '"checkout -" does not work initially' '
@@ -93,9 +89,7 @@ test_expect_success 'switch to twelfth from the last' '
 
 test_expect_success 'merge base test setup' '
        git checkout -b another other &&
-       echo "hello again" >>world &&
-       git add world &&
-       git commit -m third
+       test_commit --append third world "hello again"
 '
 
 test_expect_success 'another...master' '
index 991d5bd9c03f525d536770908269209d716f39c1..312e0f8cb4980a82ef1f9e73aff8e1f109404ce1 100755 (executable)
@@ -687,21 +687,9 @@ test_expect_success 'grep -C1 hunk mark between files' '
 '
 
 test_expect_success 'log grep setup' '
-       echo a >>file &&
-       test_tick &&
-       GIT_AUTHOR_NAME="With * Asterisk" \
-       GIT_AUTHOR_EMAIL="xyzzy@frotz.com" \
-       git commit -a -m "second" &&
-
-       echo a >>file &&
-       test_tick &&
-       git commit -a -m "third" &&
-
-       echo a >>file &&
-       test_tick &&
-       GIT_AUTHOR_NAME="Night Fall" \
-       GIT_AUTHOR_EMAIL="nitfol@frobozz.com" \
-       git commit -a -m "fourth"
+       test_commit --append --author "With * Asterisk <xyzzy@frotz.com>" second file a &&
+       test_commit --append third file a &&
+       test_commit --append --author "Night Fall <nitfol@frobozz.com>" fourth file a
 '
 
 test_expect_success 'log grep (1)' '