summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorPhilippe Blain <levraiphilippeblain@gmail.com>2022-10-21 15:13:31 +0000
committerJunio C Hamano <gitster@pobox.com>2022-10-21 13:51:05 -0700
commit455f0adf5709e24712bff725005ff1a59508a054 (patch)
tree72fa2399e8575852f0f066a8d675711a597c657d /t/test-lib-functions.sh
parent1fc3c0ad407008c2f71dd9ae1241d8b75f8ef886 (diff)
downloadgit-455f0adf5709e24712bff725005ff1a59508a054.tar.gz
test-lib-functions: mark 'test_commit' variables as 'local'
Some variables in 'test_commit' have names that are common enough that it is very likely that test authors might use them in a test. If they do so and use 'test_commit' between setting such a variable and using it, the variable value from 'test_commit' will leak back into the test and most likely break it. Prevent that by marking all variables in 'test_commit' as 'local'. This allow a subsequent commit to use a 'tag' variable. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 527a714500..adc0fb6330 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -273,13 +273,13 @@ debug () {
# <file>, <contents>, and <tag> all default to <message>.
test_commit () {
- notick= &&
- echo=echo &&
- append= &&
- author= &&
- signoff= &&
- indir= &&
- tag=light &&
+ local notick= &&
+ local echo=echo &&
+ local append= &&
+ local author= &&
+ local signoff= &&
+ local indir= &&
+ local tag=light &&
while test $# != 0
do
case "$1" in
@@ -322,7 +322,7 @@ test_commit () {
shift
done &&
indir=${indir:+"$indir"/} &&
- file=${2:-"$1.t"} &&
+ local file=${2:-"$1.t"} &&
if test -n "$append"
then
$echo "${3-$1}" >>"$indir$file"