diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-01-12 21:17:59 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-01-12 23:04:41 +0100 |
commit | 3373518cc8bd0916581ccfd4a2ee9682d61a8874 (patch) | |
tree | 1f46d5bf80a14ada0b15aeb6911376f62060cd62 /t/test-lib-functions.sh | |
parent | test-lib functions: add --author support to test_commit (diff) | |
download | git-3373518cc8bd0916581ccfd4a2ee9682d61a8874.tar.xz git-3373518cc8bd0916581ccfd4a2ee9682d61a8874.zip |
test-lib functions: add an --append option to test_commit
Add an --append option to test_commit to append <contents> to the
<file> we're writing to. This simplifies a lot of test setup, as shown
in some of the tests being changed here.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r-- | t/test-lib-functions.sh | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 529f6264fe..b0a5d74dc7 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -183,6 +183,9 @@ debug () { # Run all git commands in directory <dir> # --notick # Do not call test_tick before making a commit +# --append +# Use "echo >>" instead of "echo >" when writing "<contents>" to +# "<file>" # --signoff # Invoke "git commit" with --signoff # --author=<author> @@ -195,6 +198,7 @@ debug () { test_commit () { notick= && + append= && author= && signoff= && indir= && @@ -204,6 +208,9 @@ test_commit () { --notick) notick=yes ;; + --append) + append=yes + ;; --author) author="$2" shift @@ -223,7 +230,12 @@ test_commit () { done && indir=${indir:+"$indir"/} && file=${2:-"$1.t"} && - echo "${3-$1}" > "$indir$file" && + if test -n "$append" + then + echo "${3-$1}" >>"$indir$file" + else + echo "${3-$1}" >"$indir$file" + fi && git ${indir:+ -C "$indir"} add "$file" && if test -z "$notick" then |