Skip to content

Commit d693345

Browse files
committed
Merge branch 'dl/use-sq-from-test-lib'
Code cleanup. * dl/use-sq-from-test-lib: t: use common $SQ variable
2 parents d8ce144 + bd482d6 commit d693345

11 files changed

+51
-61
lines changed

t/t1300-config.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,26 +1294,25 @@ test_expect_success 'git -c is not confused by empty environment' '
12941294
GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
12951295
'
12961296

1297-
sq="'"
12981297
test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
12991298
cat >expect <<-\EOF &&
13001299
env.one one
13011300
env.two two
13021301
EOF
1303-
GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq} ${sq}env.two=two${sq}" \
1302+
GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ} ${SQ}env.two=two${SQ}" \
13041303
git config --get-regexp "env.*" >actual &&
13051304
test_cmp expect actual &&
13061305
13071306
cat >expect <<-EOF &&
1308-
env.one one${sq}
1307+
env.one one${SQ}
13091308
env.two two
13101309
EOF
1311-
GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq$sq$sq ${sq}env.two=two${sq}" \
1310+
GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ$SQ$SQ ${SQ}env.two=two${SQ}" \
13121311
git config --get-regexp "env.*" >actual &&
13131312
test_cmp expect actual &&
13141313
13151314
test_must_fail env \
1316-
GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq ${sq}env.two=two${sq}" \
1315+
GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ ${SQ}env.two=two${SQ}" \
13171316
git config --get-regexp "env.*"
13181317
'
13191318

t/t1404-update-ref-errors.sh

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ test_update_rejected () {
3232
test_cmp unchanged actual
3333
}
3434

35-
Q="'"
36-
3735
# Test adding and deleting D/F-conflicting references in a single
3836
# transaction.
3937
df_test() {
@@ -93,7 +91,7 @@ df_test() {
9391
delname="$delref"
9492
fi &&
9593
cat >expected-err <<-EOF &&
96-
fatal: cannot lock ref $Q$addname$Q: $Q$delref$Q exists; cannot create $Q$addref$Q
94+
fatal: cannot lock ref $SQ$addname$SQ: $SQ$delref$SQ exists; cannot create $SQ$addref$SQ
9795
EOF
9896
$pack &&
9997
if $add_del
@@ -123,71 +121,71 @@ test_expect_success 'existing loose ref is a simple prefix of new' '
123121
124122
prefix=refs/1l &&
125123
test_update_rejected "a c e" false "b c/x d" \
126-
"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"
124+
"$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x$SQ"
127125
128126
'
129127

130128
test_expect_success 'existing packed ref is a simple prefix of new' '
131129
132130
prefix=refs/1p &&
133131
test_update_rejected "a c e" true "b c/x d" \
134-
"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"
132+
"$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x$SQ"
135133
136134
'
137135

138136
test_expect_success 'existing loose ref is a deeper prefix of new' '
139137
140138
prefix=refs/2l &&
141139
test_update_rejected "a c e" false "b c/x/y d" \
142-
"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"
140+
"$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x/y$SQ"
143141
144142
'
145143

146144
test_expect_success 'existing packed ref is a deeper prefix of new' '
147145
148146
prefix=refs/2p &&
149147
test_update_rejected "a c e" true "b c/x/y d" \
150-
"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"
148+
"$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x/y$SQ"
151149
152150
'
153151

154152
test_expect_success 'new ref is a simple prefix of existing loose' '
155153
156154
prefix=refs/3l &&
157155
test_update_rejected "a c/x e" false "b c d" \
158-
"$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"
156+
"$SQ$prefix/c/x$SQ exists; cannot create $SQ$prefix/c$SQ"
159157
160158
'
161159

162160
test_expect_success 'new ref is a simple prefix of existing packed' '
163161
164162
prefix=refs/3p &&
165163
test_update_rejected "a c/x e" true "b c d" \
166-
"$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"
164+
"$SQ$prefix/c/x$SQ exists; cannot create $SQ$prefix/c$SQ"
167165
168166
'
169167

170168
test_expect_success 'new ref is a deeper prefix of existing loose' '
171169
172170
prefix=refs/4l &&
173171
test_update_rejected "a c/x/y e" false "b c d" \
174-
"$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"
172+
"$SQ$prefix/c/x/y$SQ exists; cannot create $SQ$prefix/c$SQ"
175173
176174
'
177175

178176
test_expect_success 'new ref is a deeper prefix of existing packed' '
179177
180178
prefix=refs/4p &&
181179
test_update_rejected "a c/x/y e" true "b c d" \
182-
"$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"
180+
"$SQ$prefix/c/x/y$SQ exists; cannot create $SQ$prefix/c$SQ"
183181
184182
'
185183

186184
test_expect_success 'one new ref is a simple prefix of another' '
187185
188186
prefix=refs/5 &&
189187
test_update_rejected "a e" false "b c c/x d" \
190-
"cannot process $Q$prefix/c$Q and $Q$prefix/c/x$Q at the same time"
188+
"cannot process $SQ$prefix/c$SQ and $SQ$prefix/c/x$SQ at the same time"
191189
192190
'
193191

@@ -334,7 +332,7 @@ test_expect_success 'D/F conflict prevents indirect delete long packed + indirec
334332
test_expect_success 'missing old value blocks update' '
335333
prefix=refs/missing-update &&
336334
cat >expected <<-EOF &&
337-
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q
335+
fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ
338336
EOF
339337
printf "%s\n" "update $prefix/foo $E $D" |
340338
test_must_fail git update-ref --stdin 2>output.err &&
@@ -345,7 +343,7 @@ test_expect_success 'incorrect old value blocks update' '
345343
prefix=refs/incorrect-update &&
346344
git update-ref $prefix/foo $C &&
347345
cat >expected <<-EOF &&
348-
fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D
346+
fatal: cannot lock ref $SQ$prefix/foo$SQ: is at $C but expected $D
349347
EOF
350348
printf "%s\n" "update $prefix/foo $E $D" |
351349
test_must_fail git update-ref --stdin 2>output.err &&
@@ -356,7 +354,7 @@ test_expect_success 'existing old value blocks create' '
356354
prefix=refs/existing-create &&
357355
git update-ref $prefix/foo $C &&
358356
cat >expected <<-EOF &&
359-
fatal: cannot lock ref $Q$prefix/foo$Q: reference already exists
357+
fatal: cannot lock ref $SQ$prefix/foo$SQ: reference already exists
360358
EOF
361359
printf "%s\n" "create $prefix/foo $E" |
362360
test_must_fail git update-ref --stdin 2>output.err &&
@@ -367,7 +365,7 @@ test_expect_success 'incorrect old value blocks delete' '
367365
prefix=refs/incorrect-delete &&
368366
git update-ref $prefix/foo $C &&
369367
cat >expected <<-EOF &&
370-
fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D
368+
fatal: cannot lock ref $SQ$prefix/foo$SQ: is at $C but expected $D
371369
EOF
372370
printf "%s\n" "delete $prefix/foo $D" |
373371
test_must_fail git update-ref --stdin 2>output.err &&
@@ -378,7 +376,7 @@ test_expect_success 'missing old value blocks indirect update' '
378376
prefix=refs/missing-indirect-update &&
379377
git symbolic-ref $prefix/symref $prefix/foo &&
380378
cat >expected <<-EOF &&
381-
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q
379+
fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ
382380
EOF
383381
printf "%s\n" "update $prefix/symref $E $D" |
384382
test_must_fail git update-ref --stdin 2>output.err &&
@@ -390,7 +388,7 @@ test_expect_success 'incorrect old value blocks indirect update' '
390388
git symbolic-ref $prefix/symref $prefix/foo &&
391389
git update-ref $prefix/foo $C &&
392390
cat >expected <<-EOF &&
393-
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
391+
fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
394392
EOF
395393
printf "%s\n" "update $prefix/symref $E $D" |
396394
test_must_fail git update-ref --stdin 2>output.err &&
@@ -402,7 +400,7 @@ test_expect_success 'existing old value blocks indirect create' '
402400
git symbolic-ref $prefix/symref $prefix/foo &&
403401
git update-ref $prefix/foo $C &&
404402
cat >expected <<-EOF &&
405-
fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists
403+
fatal: cannot lock ref $SQ$prefix/symref$SQ: reference already exists
406404
EOF
407405
printf "%s\n" "create $prefix/symref $E" |
408406
test_must_fail git update-ref --stdin 2>output.err &&
@@ -414,7 +412,7 @@ test_expect_success 'incorrect old value blocks indirect delete' '
414412
git symbolic-ref $prefix/symref $prefix/foo &&
415413
git update-ref $prefix/foo $C &&
416414
cat >expected <<-EOF &&
417-
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
415+
fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
418416
EOF
419417
printf "%s\n" "delete $prefix/symref $D" |
420418
test_must_fail git update-ref --stdin 2>output.err &&
@@ -425,7 +423,7 @@ test_expect_success 'missing old value blocks indirect no-deref update' '
425423
prefix=refs/missing-noderef-update &&
426424
git symbolic-ref $prefix/symref $prefix/foo &&
427425
cat >expected <<-EOF &&
428-
fatal: cannot lock ref $Q$prefix/symref$Q: reference is missing but expected $D
426+
fatal: cannot lock ref $SQ$prefix/symref$SQ: reference is missing but expected $D
429427
EOF
430428
printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
431429
test_must_fail git update-ref --stdin 2>output.err &&
@@ -437,7 +435,7 @@ test_expect_success 'incorrect old value blocks indirect no-deref update' '
437435
git symbolic-ref $prefix/symref $prefix/foo &&
438436
git update-ref $prefix/foo $C &&
439437
cat >expected <<-EOF &&
440-
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
438+
fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
441439
EOF
442440
printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
443441
test_must_fail git update-ref --stdin 2>output.err &&
@@ -449,7 +447,7 @@ test_expect_success 'existing old value blocks indirect no-deref create' '
449447
git symbolic-ref $prefix/symref $prefix/foo &&
450448
git update-ref $prefix/foo $C &&
451449
cat >expected <<-EOF &&
452-
fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists
450+
fatal: cannot lock ref $SQ$prefix/symref$SQ: reference already exists
453451
EOF
454452
printf "%s\n" "option no-deref" "create $prefix/symref $E" |
455453
test_must_fail git update-ref --stdin 2>output.err &&
@@ -461,7 +459,7 @@ test_expect_success 'incorrect old value blocks indirect no-deref delete' '
461459
git symbolic-ref $prefix/symref $prefix/foo &&
462460
git update-ref $prefix/foo $C &&
463461
cat >expected <<-EOF &&
464-
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
462+
fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
465463
EOF
466464
printf "%s\n" "option no-deref" "delete $prefix/symref $D" |
467465
test_must_fail git update-ref --stdin 2>output.err &&
@@ -474,13 +472,13 @@ test_expect_success 'non-empty directory blocks create' '
474472
: >.git/$prefix/foo/bar/baz.lock &&
475473
test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&
476474
cat >expected <<-EOF &&
477-
fatal: cannot lock ref $Q$prefix/foo$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q
475+
fatal: cannot lock ref $SQ$prefix/foo$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ
478476
EOF
479477
printf "%s\n" "update $prefix/foo $C" |
480478
test_must_fail git update-ref --stdin 2>output.err &&
481479
test_cmp expected output.err &&
482480
cat >expected <<-EOF &&
483-
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q
481+
fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ
484482
EOF
485483
printf "%s\n" "update $prefix/foo $D $C" |
486484
test_must_fail git update-ref --stdin 2>output.err &&
@@ -493,13 +491,13 @@ test_expect_success 'broken reference blocks create' '
493491
echo "gobbledigook" >.git/$prefix/foo &&
494492
test_when_finished "rm -f .git/$prefix/foo" &&
495493
cat >expected <<-EOF &&
496-
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
494+
fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
497495
EOF
498496
printf "%s\n" "update $prefix/foo $C" |
499497
test_must_fail git update-ref --stdin 2>output.err &&
500498
test_cmp expected output.err &&
501499
cat >expected <<-EOF &&
502-
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
500+
fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
503501
EOF
504502
printf "%s\n" "update $prefix/foo $D $C" |
505503
test_must_fail git update-ref --stdin 2>output.err &&
@@ -513,13 +511,13 @@ test_expect_success 'non-empty directory blocks indirect create' '
513511
: >.git/$prefix/foo/bar/baz.lock &&
514512
test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&
515513
cat >expected <<-EOF &&
516-
fatal: cannot lock ref $Q$prefix/symref$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q
514+
fatal: cannot lock ref $SQ$prefix/symref$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ
517515
EOF
518516
printf "%s\n" "update $prefix/symref $C" |
519517
test_must_fail git update-ref --stdin 2>output.err &&
520518
test_cmp expected output.err &&
521519
cat >expected <<-EOF &&
522-
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q
520+
fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ
523521
EOF
524522
printf "%s\n" "update $prefix/symref $D $C" |
525523
test_must_fail git update-ref --stdin 2>output.err &&
@@ -532,13 +530,13 @@ test_expect_success 'broken reference blocks indirect create' '
532530
echo "gobbledigook" >.git/$prefix/foo &&
533531
test_when_finished "rm -f .git/$prefix/foo" &&
534532
cat >expected <<-EOF &&
535-
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
533+
fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
536534
EOF
537535
printf "%s\n" "update $prefix/symref $C" |
538536
test_must_fail git update-ref --stdin 2>output.err &&
539537
test_cmp expected output.err &&
540538
cat >expected <<-EOF &&
541-
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
539+
fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
542540
EOF
543541
printf "%s\n" "update $prefix/symref $D $C" |
544542
test_must_fail git update-ref --stdin 2>output.err &&
@@ -614,7 +612,7 @@ test_expect_success 'delete fails cleanly if packed-refs file is locked' '
614612
test_when_finished "rm -f .git/packed-refs.lock" &&
615613
test_must_fail git update-ref -d $prefix/foo >out 2>err &&
616614
git for-each-ref $prefix >actual &&
617-
test_i18ngrep "Unable to create $Q.*packed-refs.lock$Q: " err &&
615+
test_i18ngrep "Unable to create $SQ.*packed-refs.lock$SQ: " err &&
618616
test_cmp unchanged actual
619617
'
620618

t/t1414-reflog-walk.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ do_walk () {
1818
git log -g --format="%gd %gs" "$@"
1919
}
2020

21-
sq="'"
2221
test_expect_success 'set up expected reflog' '
2322
cat >expect.all <<-EOF
24-
HEAD@{0} commit (merge): Merge branch ${sq}master${sq} into side
23+
HEAD@{0} commit (merge): Merge branch ${SQ}master${SQ} into side
2524
HEAD@{1} commit: three
2625
HEAD@{2} checkout: moving from master to side
2726
HEAD@{3} commit: two

t/t1506-rev-parse-diagnosis.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ exec </dev/null
88

99
test_did_you_mean ()
1010
{
11-
sq="'" &&
1211
cat >expected <<-EOF &&
13-
fatal: Path '$2$3' $4, but not ${5:-$sq$3$sq}.
14-
Did you mean '$1:$2$3'${2:+ aka $sq$1:./$3$sq}?
12+
fatal: Path '$2$3' $4, but not ${5:-$SQ$3$SQ}.
13+
Did you mean '$1:$2$3'${2:+ aka $SQ$1:./$3$SQ}?
1514
EOF
1615
test_cmp expected error
1716
}

t/t1507-rev-parse-upstream.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ test_expect_success 'setup' '
2828
)
2929
'
3030

31-
sq="'"
32-
3331
full_name () {
3432
(cd clone &&
3533
git rev-parse --symbolic-full-name "$@")
@@ -129,7 +127,7 @@ test_expect_success 'merge my-side@{u} records the correct name' '
129127
git branch -t new my-side@{u} &&
130128
git merge -s ours new@{u} &&
131129
git show -s --pretty=tformat:%s >actual &&
132-
echo "Merge remote-tracking branch ${sq}origin/side${sq}" >expect &&
130+
echo "Merge remote-tracking branch ${SQ}origin/side${SQ}" >expect &&
133131
test_cmp expect actual
134132
)
135133
'
@@ -156,23 +154,23 @@ test_expect_success 'branch@{u} works when tracking a local branch' '
156154

157155
test_expect_success 'branch@{u} error message when no upstream' '
158156
cat >expect <<-EOF &&
159-
fatal: no upstream configured for branch ${sq}non-tracking${sq}
157+
fatal: no upstream configured for branch ${SQ}non-tracking${SQ}
160158
EOF
161159
error_message non-tracking@{u} &&
162160
test_i18ncmp expect error
163161
'
164162

165163
test_expect_success '@{u} error message when no upstream' '
166164
cat >expect <<-EOF &&
167-
fatal: no upstream configured for branch ${sq}master${sq}
165+
fatal: no upstream configured for branch ${SQ}master${SQ}
168166
EOF
169167
test_must_fail git rev-parse --verify @{u} 2>actual &&
170168
test_i18ncmp expect actual
171169
'
172170

173171
test_expect_success 'branch@{u} error message with misspelt branch' '
174172
cat >expect <<-EOF &&
175-
fatal: no such branch: ${sq}no-such-branch${sq}
173+
fatal: no such branch: ${SQ}no-such-branch${SQ}
176174
EOF
177175
error_message no-such-branch@{u} &&
178176
test_i18ncmp expect error
@@ -189,7 +187,7 @@ test_expect_success '@{u} error message when not on a branch' '
189187

190188
test_expect_success 'branch@{u} error message if upstream branch not fetched' '
191189
cat >expect <<-EOF &&
192-
fatal: upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
190+
fatal: upstream branch ${SQ}refs/heads/side${SQ} not stored as a remote-tracking branch
193191
EOF
194192
error_message bad-upstream@{u} &&
195193
test_i18ncmp expect error

0 commit comments

Comments
 (0)