Skip to content

Commit dca05bb

Browse files
committed
Merge branch 'jk/test-z-n-unquoted'
t9xxx series has been updated primarily for readability, while fixing small bugs in it. A few scripted Porcelains have also been updated to fix possible bugs around their use of "test -z" and "test -n". * jk/test-z-n-unquoted: always quote shell arguments to test -z/-n t9103: modernize test style t9107: switch inverted single/double quotes in test t9107: use "return 1" instead of "exit 1" t9100,t3419: enclose all test code in single-quotes t/lib-git-svn: drop $remote_git_svn and $git_svn_id
2 parents 53c4b3e + 268ef4d commit dca05bb

15 files changed

+125
-115
lines changed

git-rebase--interactive.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,12 +867,12 @@ add_exec_commands () {
867867
# $3: the input filename
868868
check_commit_sha () {
869869
badsha=0
870-
if test -z $1
870+
if test -z "$1"
871871
then
872872
badsha=1
873873
else
874874
sha1_verif="$(git rev-parse --verify --quiet $1^{commit})"
875-
if test -z $sha1_verif
875+
if test -z "$sha1_verif"
876876
then
877877
badsha=1
878878
fi

git-stash.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ store_stash () {
185185

186186
git update-ref --create-reflog -m "$stash_msg" $ref_stash $w_commit
187187
ret=$?
188-
test $ret != 0 && test -z $quiet &&
188+
test $ret != 0 && test -z "$quiet" &&
189189
die "$(eval_gettext "Cannot update \$ref_stash with \$w_commit")"
190190
return $ret
191191
}
@@ -277,7 +277,7 @@ save_stash () {
277277
git clean --force --quiet -d $CLEAN_X_OPTION
278278
fi
279279

280-
if test "$keep_index" = "t" && test -n $i_tree
280+
if test "$keep_index" = "t" && test -n "$i_tree"
281281
then
282282
git read-tree --reset -u $i_tree
283283
fi

t/lib-git-svn.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
. ./test-lib.sh
22

3-
remotes_git_svn=remotes/git""-svn
4-
git_svn_id=git""-svn-id
5-
63
if test -n "$NO_SVN_TESTS"
74
then
85
skip_all='skipping git svn tests, NO_SVN_TESTS defined'

t/t3419-rebase-patch-id.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,25 @@ do_tests () {
7373
run git format-patch --stdout --ignore-if-in-upstream master
7474
"
7575

76-
test_expect_success $pr 'detect upstream patch' "
76+
test_expect_success $pr 'detect upstream patch' '
7777
git checkout -q master &&
7878
scramble file &&
7979
git add file &&
80-
git commit -q -m 'change big file again' &&
80+
git commit -q -m "change big file again" &&
8181
git checkout -q other^{} &&
8282
git rebase master &&
83-
test_must_fail test -n \"\$(git rev-list master...HEAD~)\"
84-
"
83+
test_must_fail test -n "$(git rev-list master...HEAD~)"
84+
'
8585

86-
test_expect_success $pr 'do not drop patch' "
86+
test_expect_success $pr 'do not drop patch' '
8787
git branch -f squashed master &&
8888
git checkout -q -f squashed &&
8989
git reset -q --soft HEAD~2 &&
9090
git commit -q -m squashed &&
9191
git checkout -q other^{} &&
9292
test_must_fail git rebase squashed &&
9393
rm -rf .git/rebase-apply
94-
"
94+
'
9595
}
9696

9797
do_tests 500

t/t9100-git-svn-basic.sh

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ test_expect_success "checkout from svn" 'svn co "$svnrepo" "$SVN_TREE"'
4545

4646
name='try a deep --rmdir with a commit'
4747
test_expect_success "$name" '
48-
git checkout -f -b mybranch ${remotes_git_svn} &&
48+
git checkout -f -b mybranch remotes/git-svn &&
4949
mv dir/a/b/c/d/e/file dir/file &&
5050
cp dir/file file &&
5151
git update-index --add --remove dir/a/b/c/d/e/file dir/file file &&
5252
git commit -m "$name" &&
5353
git svn set-tree --find-copies-harder --rmdir \
54-
${remotes_git_svn}..mybranch &&
54+
remotes/git-svn..mybranch &&
5555
svn_cmd up "$SVN_TREE" &&
5656
test -d "$SVN_TREE"/dir && test ! -d "$SVN_TREE"/dir/a'
5757

@@ -65,37 +65,37 @@ test_expect_success "$name" "
6565
git update-index --add dir/file/file &&
6666
git commit -m '$name' &&
6767
test_must_fail git svn set-tree --find-copies-harder --rmdir \
68-
${remotes_git_svn}..mybranch
68+
remotes/git-svn..mybranch
6969
"
7070

7171

7272
name='detect node change from directory to file #1'
7373
test_expect_success "$name" '
7474
rm -rf dir "$GIT_DIR"/index &&
75-
git checkout -f -b mybranch2 ${remotes_git_svn} &&
75+
git checkout -f -b mybranch2 remotes/git-svn &&
7676
mv bar/zzz zzz &&
7777
rm -rf bar &&
7878
mv zzz bar &&
7979
git update-index --remove -- bar/zzz &&
8080
git update-index --add -- bar &&
8181
git commit -m "$name" &&
8282
test_must_fail git svn set-tree --find-copies-harder --rmdir \
83-
${remotes_git_svn}..mybranch2
83+
remotes/git-svn..mybranch2
8484
'
8585

8686

8787
name='detect node change from file to directory #2'
8888
test_expect_success "$name" '
8989
rm -f "$GIT_DIR"/index &&
90-
git checkout -f -b mybranch3 ${remotes_git_svn} &&
90+
git checkout -f -b mybranch3 remotes/git-svn &&
9191
rm bar/zzz &&
9292
git update-index --remove bar/zzz &&
9393
mkdir bar/zzz &&
9494
echo yyy > bar/zzz/yyy &&
9595
git update-index --add bar/zzz/yyy &&
9696
git commit -m "$name" &&
9797
git svn set-tree --find-copies-harder --rmdir \
98-
${remotes_git_svn}..mybranch3 &&
98+
remotes/git-svn..mybranch3 &&
9999
svn_cmd up "$SVN_TREE" &&
100100
test -d "$SVN_TREE"/bar/zzz &&
101101
test -e "$SVN_TREE"/bar/zzz/yyy
@@ -104,27 +104,27 @@ test_expect_success "$name" '
104104
name='detect node change from directory to file #2'
105105
test_expect_success "$name" '
106106
rm -f "$GIT_DIR"/index &&
107-
git checkout -f -b mybranch4 ${remotes_git_svn} &&
107+
git checkout -f -b mybranch4 remotes/git-svn &&
108108
rm -rf dir &&
109109
git update-index --remove -- dir/file &&
110110
touch dir &&
111111
echo asdf > dir &&
112112
git update-index --add -- dir &&
113113
git commit -m "$name" &&
114114
test_must_fail git svn set-tree --find-copies-harder --rmdir \
115-
${remotes_git_svn}..mybranch4
115+
remotes/git-svn..mybranch4
116116
'
117117

118118

119119
name='remove executable bit from a file'
120120
test_expect_success POSIXPERM "$name" '
121121
rm -f "$GIT_DIR"/index &&
122-
git checkout -f -b mybranch5 ${remotes_git_svn} &&
122+
git checkout -f -b mybranch5 remotes/git-svn &&
123123
chmod -x exec.sh &&
124124
git update-index exec.sh &&
125125
git commit -m "$name" &&
126126
git svn set-tree --find-copies-harder --rmdir \
127-
${remotes_git_svn}..mybranch5 &&
127+
remotes/git-svn..mybranch5 &&
128128
svn_cmd up "$SVN_TREE" &&
129129
test ! -x "$SVN_TREE"/exec.sh'
130130

@@ -135,7 +135,7 @@ test_expect_success POSIXPERM "$name" '
135135
git update-index exec.sh &&
136136
git commit -m "$name" &&
137137
git svn set-tree --find-copies-harder --rmdir \
138-
${remotes_git_svn}..mybranch5 &&
138+
remotes/git-svn..mybranch5 &&
139139
svn_cmd up "$SVN_TREE" &&
140140
test -x "$SVN_TREE"/exec.sh'
141141

@@ -147,7 +147,7 @@ test_expect_success SYMLINKS "$name" '
147147
git update-index exec.sh &&
148148
git commit -m "$name" &&
149149
git svn set-tree --find-copies-harder --rmdir \
150-
${remotes_git_svn}..mybranch5 &&
150+
remotes/git-svn..mybranch5 &&
151151
svn_cmd up "$SVN_TREE" &&
152152
test -h "$SVN_TREE"/exec.sh'
153153

@@ -159,7 +159,7 @@ test_expect_success POSIXPERM,SYMLINKS "$name" '
159159
git update-index --add file exec-2.sh &&
160160
git commit -m "$name" &&
161161
git svn set-tree --find-copies-harder --rmdir \
162-
${remotes_git_svn}..mybranch5 &&
162+
remotes/git-svn..mybranch5 &&
163163
svn_cmd up "$SVN_TREE" &&
164164
test -x "$SVN_TREE"/file &&
165165
test -h "$SVN_TREE"/exec-2.sh'
@@ -172,7 +172,7 @@ test_expect_success POSIXPERM,SYMLINKS "$name" '
172172
git update-index exec-2.sh &&
173173
git commit -m "$name" &&
174174
git svn set-tree --find-copies-harder --rmdir \
175-
${remotes_git_svn}..mybranch5 &&
175+
remotes/git-svn..mybranch5 &&
176176
svn_cmd up "$SVN_TREE" &&
177177
test -f "$SVN_TREE"/exec-2.sh &&
178178
test ! -h "$SVN_TREE"/exec-2.sh &&
@@ -194,7 +194,7 @@ GIT_SVN_ID=alt
194194
export GIT_SVN_ID
195195
test_expect_success "$name" \
196196
'git svn init "$svnrepo" && git svn fetch &&
197-
git rev-list --pretty=raw ${remotes_git_svn} | grep ^tree | uniq > a &&
197+
git rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
198198
git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
199199
test_cmp a b'
200200

@@ -217,17 +217,17 @@ EOF
217217

218218
test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp a expected"
219219

220-
test_expect_success 'exit if remote refs are ambigious' "
220+
test_expect_success 'exit if remote refs are ambigious' '
221221
git config --add svn-remote.svn.fetch \
222-
bar:refs/${remotes_git_svn} &&
222+
bar:refs/remotes/git-svn &&
223223
test_must_fail git svn migrate
224-
"
224+
'
225225

226226
test_expect_success 'exit if init-ing a would clobber a URL' '
227227
svnadmin create "${PWD}/svnrepo2" &&
228228
svn mkdir -m "mkdir bar" "${svnrepo}2/bar" &&
229229
git config --unset svn-remote.svn.fetch \
230-
"^bar:refs/${remotes_git_svn}$" &&
230+
"^bar:refs/remotes/git-svn$" &&
231231
test_must_fail git svn init "${svnrepo}2/bar"
232232
'
233233

@@ -237,7 +237,7 @@ test_expect_success \
237237
git config --get svn-remote.svn.fetch \
238238
"^bar:refs/remotes/bar$" &&
239239
git config --get svn-remote.svn.fetch \
240-
"^:refs/${remotes_git_svn}$"
240+
"^:refs/remotes/git-svn$"
241241
'
242242

243243
test_expect_success 'dcommit $rev does not clobber current branch' '
@@ -259,26 +259,26 @@ test_expect_success 'dcommit $rev does not clobber current branch' '
259259
git branch -D my-bar
260260
'
261261

262-
test_expect_success 'able to dcommit to a subdirectory' "
262+
test_expect_success 'able to dcommit to a subdirectory' '
263263
git svn fetch -i bar &&
264264
git checkout -b my-bar refs/remotes/bar &&
265265
echo abc > d &&
266266
git update-index --add d &&
267-
git commit -m '/bar/d should be in the log' &&
267+
git commit -m "/bar/d should be in the log" &&
268268
git svn dcommit -i bar &&
269-
test -z \"\$(git diff refs/heads/my-bar refs/remotes/bar)\" &&
269+
test -z "$(git diff refs/heads/my-bar refs/remotes/bar)" &&
270270
mkdir newdir &&
271271
echo new > newdir/dir &&
272272
git update-index --add newdir/dir &&
273-
git commit -m 'add a new directory' &&
273+
git commit -m "add a new directory" &&
274274
git svn dcommit -i bar &&
275-
test -z \"\$(git diff refs/heads/my-bar refs/remotes/bar)\" &&
275+
test -z "$(git diff refs/heads/my-bar refs/remotes/bar)" &&
276276
echo foo >> newdir/dir &&
277277
git update-index newdir/dir &&
278-
git commit -m 'modify a file in new directory' &&
278+
git commit -m "modify a file in new directory" &&
279279
git svn dcommit -i bar &&
280-
test -z \"\$(git diff refs/heads/my-bar refs/remotes/bar)\"
281-
"
280+
test -z "$(git diff refs/heads/my-bar refs/remotes/bar)"
281+
'
282282

283283
test_expect_success 'dcommit should not fail with a touched file' '
284284
test_commit "commit-new-file-foo2" foo2 &&
@@ -291,13 +291,13 @@ test_expect_success 'rebase should not fail with a touched file' '
291291
git svn rebase
292292
'
293293

294-
test_expect_success 'able to set-tree to a subdirectory' "
294+
test_expect_success 'able to set-tree to a subdirectory' '
295295
echo cba > d &&
296296
git update-index d &&
297-
git commit -m 'update /bar/d' &&
297+
git commit -m "update /bar/d" &&
298298
git svn set-tree -i bar HEAD &&
299-
test -z \"\$(git diff refs/heads/my-bar refs/remotes/bar)\"
300-
"
299+
test -z "$(git diff refs/heads/my-bar refs/remotes/bar)"
300+
'
301301

302302
test_expect_success 'git-svn works in a bare repository' '
303303
mkdir bare-repo &&

t/t9101-git-svn-props.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ test_expect_success 'fetch revisions from svn' 'git svn fetch'
7373

7474
name='test svn:keywords ignoring'
7575
test_expect_success "$name" \
76-
'git checkout -b mybranch ${remotes_git_svn} &&
76+
'git checkout -b mybranch remotes/git-svn &&
7777
echo Hi again >> kw.c &&
7878
git commit -a -m "test keywords ignoring" &&
79-
git svn set-tree ${remotes_git_svn}..mybranch &&
80-
git pull . ${remotes_git_svn}'
79+
git svn set-tree remotes/git-svn..mybranch &&
80+
git pull . remotes/git-svn'
8181

8282
expect='/* $Id$ */'
8383
got="$(sed -ne 2p kw.c)"
@@ -95,7 +95,7 @@ test_expect_success "propset CR on crlf files" '
9595

9696
test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
9797
'git svn fetch &&
98-
git pull . ${remotes_git_svn} &&
98+
git pull . remotes/git-svn &&
9999
svn_cmd co "$svnrepo" new_wc'
100100

101101
for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf
@@ -117,7 +117,7 @@ cd test_wc
117117
svn_cmd commit -m "propset CRLF on cr files"'
118118
cd ..
119119
test_expect_success 'fetch and pull latest from svn' \
120-
'git svn fetch && git pull . ${remotes_git_svn}'
120+
'git svn fetch && git pull . remotes/git-svn'
121121

122122
b_cr="$(git hash-object cr)"
123123
b_ne_cr="$(git hash-object ne_cr)"
@@ -168,7 +168,7 @@ cat >create-ignore-index.expect <<\EOF
168168
EOF
169169

170170
test_expect_success 'test create-ignore' "
171-
git svn fetch && git pull . ${remotes_git_svn} &&
171+
git svn fetch && git pull . remotes/git-svn &&
172172
git svn create-ignore &&
173173
cmp ./.gitignore create-ignore.expect &&
174174
cmp ./deeply/.gitignore create-ignore.expect &&

t/t9102-git-svn-deep-rmdir.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test_expect_success 'initialize repo' '
1717
test_expect_success 'mirror via git svn' '
1818
git svn init "$svnrepo" &&
1919
git svn fetch &&
20-
git checkout -f -b test-rmdir ${remotes_git_svn}
20+
git checkout -f -b test-rmdir remotes/git-svn
2121
'
2222

2323
test_expect_success 'Try a commit on rmdir' '

t/t9103-git-svn-tracked-directory-removed.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ test_expect_success 'make history for tracking' '
2323

2424
test_expect_success 'clone repo with git' '
2525
git svn clone -s "$svnrepo" x &&
26-
test -f x/FOLLOWME &&
27-
test ! -f x/README
26+
test_path_is_file x/FOLLOWME &&
27+
test_path_is_missing x/README
2828
'
2929

30-
test_expect_success 'make sure r2 still has old file' "
31-
cd x &&
32-
test -n \"\$(git svn find-rev r1)\" &&
33-
git reset --hard \$(git svn find-rev r1) &&
34-
test -f README &&
35-
test ! -f FOLLOWME &&
36-
test x\$(git svn find-rev r2) = x
37-
"
30+
test_expect_success 'make sure r2 still has old file' '
31+
(
32+
cd x &&
33+
test -n "$(git svn find-rev r1)" &&
34+
git reset --hard "$(git svn find-rev r1)" &&
35+
test_path_is_file README &&
36+
test_path_is_missing FOLLOWME &&
37+
test -z "$(git svn find-rev r2)"
38+
)
39+
'
3840

3941
test_done

0 commit comments

Comments
 (0)