Skip to content

Commit 455f0ad

Browse files
phil-blaingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fc3c0a commit 455f0ad

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

t/test-lib-functions.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,13 @@ debug () {
273273
# <file>, <contents>, and <tag> all default to <message>.
274274

275275
test_commit () {
276-
notick= &&
277-
echo=echo &&
278-
append= &&
279-
author= &&
280-
signoff= &&
281-
indir= &&
282-
tag=light &&
276+
local notick= &&
277+
local echo=echo &&
278+
local append= &&
279+
local author= &&
280+
local signoff= &&
281+
local indir= &&
282+
local tag=light &&
283283
while test $# != 0
284284
do
285285
case "$1" in
@@ -322,7 +322,7 @@ test_commit () {
322322
shift
323323
done &&
324324
indir=${indir:+"$indir"/} &&
325-
file=${2:-"$1.t"} &&
325+
local file=${2:-"$1.t"} &&
326326
if test -n "$append"
327327
then
328328
$echo "${3-$1}" >>"$indir$file"

0 commit comments

Comments
 (0)