Skip to content

Commit f69e836

Browse files
Bryan Donlangitster
authored andcommitted
Fix tests breaking when checkout path contains shell metacharacters
This fixes the remainder of the issues where the test script itself is at fault for failing when the git checkout path contains whitespace or other shell metacharacters. The majority of git svn tests used the idiom test_expect_success "title" "test script using $svnrepo" These were changed to have the test script in single-quotes: test_expect_success "title" 'test script using "$svnrepo"' which unfortunately makes the patch appear larger than it really is. One consequence of this change is that in the verbose test output the value of $svnrepo (and in some cases other variables, too) is no longer expanded, i.e. previously we saw * expecting success: test script using /path/to/git/t/trash/svnrepo but now it is: * expecting success: test script using "$svnrepo" Signed-off-by: Bryan Donlan <bdonlan@fushizen.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 0e46e70 commit f69e836

39 files changed

+475
-469
lines changed

t/t0000-basic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ test_expect_success 'absolute path works as expected' '
305305
file="$dir"/index &&
306306
test "$file" = "$(test-absolute-path $dir2/index)" &&
307307
basename=blub &&
308-
test "$dir/$basename" = $(cd .git && test-absolute-path $basename) &&
308+
test "$dir/$basename" = "$(cd .git && test-absolute-path "$basename")" &&
309309
ln -s ../first/file .git/syml &&
310310
sym="$(cd first; pwd -P)"/file &&
311-
test "$sym" = "$(test-absolute-path $dir2/syml)"
311+
test "$sym" = "$(test-absolute-path "$dir2/syml")"
312312
'
313313

314314
test_expect_success 'very long name in the index handled sanely' '

t/t1020-subdirectory.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LF='
2121
'
2222

2323
test_expect_success 'update-index and ls-files' '
24-
cd $HERE &&
24+
cd "$HERE" &&
2525
git update-index --add one &&
2626
case "`git ls-files`" in
2727
one) echo ok one ;;
@@ -41,7 +41,7 @@ test_expect_success 'update-index and ls-files' '
4141
'
4242

4343
test_expect_success 'cat-file' '
44-
cd $HERE &&
44+
cd "$HERE" &&
4545
two=`git ls-files -s dir/two` &&
4646
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
4747
echo "$two" &&
@@ -54,7 +54,7 @@ test_expect_success 'cat-file' '
5454
rm -f actual dir/actual
5555

5656
test_expect_success 'diff-files' '
57-
cd $HERE &&
57+
cd "$HERE" &&
5858
echo a >>one &&
5959
echo d >>dir/two &&
6060
case "`git diff-files --name-only`" in
@@ -74,7 +74,7 @@ test_expect_success 'diff-files' '
7474
'
7575

7676
test_expect_success 'write-tree' '
77-
cd $HERE &&
77+
cd "$HERE" &&
7878
top=`git write-tree` &&
7979
echo $top &&
8080
cd dir &&
@@ -84,7 +84,7 @@ test_expect_success 'write-tree' '
8484
'
8585

8686
test_expect_success 'checkout-index' '
87-
cd $HERE &&
87+
cd "$HERE" &&
8888
git checkout-index -f -u one &&
8989
cmp one original.one &&
9090
cd dir &&
@@ -93,7 +93,7 @@ test_expect_success 'checkout-index' '
9393
'
9494

9595
test_expect_success 'read-tree' '
96-
cd $HERE &&
96+
cd "$HERE" &&
9797
rm -f one dir/two &&
9898
tree=`git write-tree` &&
9999
git read-tree --reset -u "$tree" &&
@@ -107,27 +107,27 @@ test_expect_success 'read-tree' '
107107
'
108108

109109
test_expect_success 'no file/rev ambiguity check inside .git' '
110-
cd $HERE &&
110+
cd "$HERE" &&
111111
git commit -a -m 1 &&
112-
cd $HERE/.git &&
112+
cd "$HERE"/.git &&
113113
git show -s HEAD
114114
'
115115

116116
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
117-
cd $HERE &&
117+
cd "$HERE" &&
118118
git clone -s --bare .git foo.git &&
119119
cd foo.git && GIT_DIR=. git show -s HEAD
120120
'
121121

122122
# This still does not work as it should...
123123
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
124-
cd $HERE &&
124+
cd "$HERE" &&
125125
git clone -s --bare .git foo.git &&
126126
cd foo.git && git show -s HEAD
127127
'
128128

129129
test_expect_success 'detection should not be fooled by a symlink' '
130-
cd $HERE &&
130+
cd "$HERE" &&
131131
rm -fr foo.git &&
132132
git clone -s .git another &&
133133
ln -s another yetanother &&

t/t3050-subprojects-fetch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_expect_success setup '
2020
'
2121

2222
test_expect_success clone '
23-
git clone file://`pwd`/.git cloned &&
23+
git clone "file://$(pwd)/.git" cloned &&
2424
(git rev-parse HEAD; git ls-files -s) >expected &&
2525
(
2626
cd cloned &&

t/t3404-rebase-interactive.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ for line in $FAKE_LINES; do
9191
done
9292
EOF
9393

94+
test_set_editor "$(pwd)/fake-editor.sh"
9495
chmod a+x fake-editor.sh
95-
VISUAL="$(pwd)/fake-editor.sh"
96-
export VISUAL
9796

9897
test_expect_success 'no changes are a nop' '
9998
git rebase -i F &&

t/t5500-fetch-pack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pull_to_client 2nd "B" $((64*3))
129129

130130
pull_to_client 3rd "A" $((1*3)) # old fails
131131

132-
test_expect_success "clone shallow" "git-clone --depth 2 file://`pwd`/. shallow"
132+
test_expect_success "clone shallow" 'git-clone --depth 2 "file://$(pwd)/." shallow'
133133

134134
(cd shallow; git count-objects -v) > count.shallow
135135

t/t5512-ls-remote.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test_expect_success setup '
1717
git show-ref -d | sed -e "s/ / /"
1818
) >expected.all &&
1919
20-
git remote add self $(pwd)/.git
20+
git remote add self "$(pwd)/.git"
2121
2222
'
2323

t/t5516-fetch-push.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ test_expect_success 'fetch with insteadOf' '
105105
(
106106
TRASH=$(pwd)/ &&
107107
cd testrepo &&
108-
git config url.$TRASH.insteadOf trash/
108+
git config "url.$TRASH.insteadOf" trash/ &&
109109
git config remote.up.url trash/. &&
110110
git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
111111
git fetch up &&
@@ -145,8 +145,8 @@ test_expect_success 'push with wildcard' '
145145

146146
test_expect_success 'push with insteadOf' '
147147
mk_empty &&
148-
TRASH=$(pwd)/ &&
149-
git config url.$TRASH.insteadOf trash/ &&
148+
TRASH="$(pwd)/" &&
149+
git config "url./$TRASH/.insteadOf" trash/ &&
150150
git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
151151
(
152152
cd testrepo &&

t/t5700-clone-reference.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ diff expected current'
5151
cd "$base_dir"
5252

5353
test_expect_success 'cloning with reference (no -l -s)' \
54-
'git clone --reference B file://`pwd`/A D'
54+
'git clone --reference B "file://$(pwd)/A" D'
5555

5656
cd "$base_dir"
5757

t/t5710-info-alternate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ test_valid_repo'
8181
cd "$base_dir"
8282

8383
test_expect_success 'breaking of loops' \
84-
"echo '$base_dir/B/.git/objects' >> '$base_dir'/A/.git/objects/info/alternates&&
84+
'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&&
8585
cd C &&
86-
test_valid_repo"
86+
test_valid_repo'
8787

8888
cd "$base_dir"
8989

t/t7003-filter-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ test_expect_success 'use index-filter to move into a subdirectory' '
125125
"git ls-files -s | sed \"s-\\t-&newsubdir/-\" |
126126
GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
127127
git update-index --index-info &&
128-
mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved &&
128+
mv \"\$GIT_INDEX_FILE.new\" \"\$GIT_INDEX_FILE\"" directorymoved &&
129129
test -z "$(git diff HEAD directorymoved:newsubdir)"'
130130

131131
test_expect_success 'stops when msg filter fails' '

0 commit comments

Comments
 (0)