100
printf "%s\n" "delete $delname" "create $addname $D"
101
fi >commands &&
102
test_must_fail git update-ref --stdin <commands 2>output.err &&
103
- grep -E "fatal:( cannot lock ref $SQ$addname$SQ:)? $SQ$delref$SQ exists; cannot create $SQ$addref$SQ" output.err &&
103
+ grep -E "fatal:( cannot lock ref '$addname':)? '$delref' exists; cannot create '$addref'" output.err &&
104
printf "%s\n" "$C $delref" >expected-refs &&
105
git for-each-ref --format="%(objectname) %(refname)" $prefix/r >actual-refs &&
106
test_cmp expected-refs actual-refs
107
}
108
109
-test_expect_success 'setup' '
109
+test_expect_success 'setup' - <<\EOT
110
111
git commit --allow-empty -m Initial &&
112
C=$(git rev-parse HEAD) &&
114
D=$(git rev-parse HEAD) &&
115
git commit --allow-empty -m Third &&
116
E=$(git rev-parse HEAD)
117
-'
117
+EOT
118
119
-test_expect_success 'existing loose ref is a simple prefix of new' '
119
+test_expect_success 'existing loose ref is a simple prefix of new' - <<\EOT
120
121
prefix=refs/1l &&
122
test_update_rejected "a c e" false "b c/x d" \
123
- "$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x$SQ"
123
+ "'$prefix/c' exists; cannot create '$prefix/c/x'"
124
125
-'
125
+EOT
126
127
-test_expect_success 'existing packed ref is a simple prefix of new' '
127
+test_expect_success 'existing packed ref is a simple prefix of new' - <<\EOT
128
129
prefix=refs/1p &&
130
test_update_rejected "a c e" true "b c/x d" \
131
- "$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x$SQ"
131
+ "'$prefix/c' exists; cannot create '$prefix/c/x'"
132
133
-'
133
+EOT
134
135
-test_expect_success 'existing loose ref is a deeper prefix of new' '
135
+test_expect_success 'existing loose ref is a deeper prefix of new' - <<\EOT
136
137
prefix=refs/2l &&
138
test_update_rejected "a c e" false "b c/x/y d" \
139
- "$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x/y$SQ"
139
+ "'$prefix/c' exists; cannot create '$prefix/c/x/y'"
140
141
-'
141
+EOT
142
143
-test_expect_success 'existing packed ref is a deeper prefix of new' '
143
+test_expect_success 'existing packed ref is a deeper prefix of new' - <<\EOT
144
145
prefix=refs/2p &&
146
test_update_rejected "a c e" true "b c/x/y d" \
147
- "$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x/y$SQ"
147
+ "'$prefix/c' exists; cannot create '$prefix/c/x/y'"
148
149
-'
149
+EOT
150
151
-test_expect_success 'new ref is a simple prefix of existing loose' '
151
+test_expect_success 'new ref is a simple prefix of existing loose' - <<\EOT
152
153
prefix=refs/3l &&
154
test_update_rejected "a c/x e" false "b c d" \
155
- "$SQ$prefix/c/x$SQ exists; cannot create $SQ$prefix/c$SQ"
155
+ "'$prefix/c/x' exists; cannot create '$prefix/c'"
156
157
-'
157
+EOT
158
159
-test_expect_success 'new ref is a simple prefix of existing packed' '
159
+test_expect_success 'new ref is a simple prefix of existing packed' - <<\EOT
160
161
prefix=refs/3p &&
162
test_update_rejected "a c/x e" true "b c d" \
163
- "$SQ$prefix/c/x$SQ exists; cannot create $SQ$prefix/c$SQ"
163
+ "'$prefix/c/x' exists; cannot create '$prefix/c'"
164
165
-'
165
+EOT
166
167
-test_expect_success 'new ref is a deeper prefix of existing loose' '
167
+test_expect_success 'new ref is a deeper prefix of existing loose' - <<\EOT
168
169
prefix=refs/4l &&
170
test_update_rejected "a c/x/y e" false "b c d" \
171
- "$SQ$prefix/c/x/y$SQ exists; cannot create $SQ$prefix/c$SQ"
171
+ "'$prefix/c/x/y' exists; cannot create '$prefix/c'"
172
173
-'
173
+EOT
174
175
-test_expect_success 'new ref is a deeper prefix of existing packed' '
175
+test_expect_success 'new ref is a deeper prefix of existing packed' - <<\EOT
176
177
prefix=refs/4p &&
178
test_update_rejected "a c/x/y e" true "b c d" \
179
- "$SQ$prefix/c/x/y$SQ exists; cannot create $SQ$prefix/c$SQ"
179
+ "'$prefix/c/x/y' exists; cannot create '$prefix/c'"
180
181
-'
181
+EOT
182
183
-test_expect_success 'one new ref is a simple prefix of another' '
183
+test_expect_success 'one new ref is a simple prefix of another' - <<\EOT
184
185
prefix=refs/5 &&
186
test_update_rejected "a e" false "b c c/x d" \
187
- "cannot process $SQ$prefix/c$SQ and $SQ$prefix/c/x$SQ at the same time"
187
+ "cannot process '$prefix/c' and '$prefix/c/x' at the same time"
188
189
-'
189
+EOT
190
191
-test_expect_success 'D/F conflict prevents add long + delete short' '
191
+test_expect_success 'D/F conflict prevents add long + delete short' - <<\EOT
192
df_test refs/df-al-ds --add-del foo/bar foo
193
-'
193
+EOT
194
195
-test_expect_success 'D/F conflict prevents add short + delete long' '
195
+test_expect_success 'D/F conflict prevents add short + delete long' - <<\EOT
196
df_test refs/df-as-dl --add-del foo foo/bar
197
-'
197
+EOT
198
199
-test_expect_success 'D/F conflict prevents delete long + add short' '
199
+test_expect_success 'D/F conflict prevents delete long + add short' - <<\EOT
200
df_test refs/df-dl-as --del-add foo/bar foo
201
-'
201
+EOT
202
203
-test_expect_success 'D/F conflict prevents delete short + add long' '
203
+test_expect_success 'D/F conflict prevents delete short + add long' - <<\EOT
204
df_test refs/df-ds-al --del-add foo foo/bar
205
-'
205
+EOT
206
207
-test_expect_success 'D/F conflict prevents add long + delete short packed' '
207
+test_expect_success 'D/F conflict prevents add long + delete short packed' - <<\EOT
208
df_test refs/df-al-dsp --pack --add-del foo/bar foo
209
-'
209
+EOT
210
211
-test_expect_success 'D/F conflict prevents add short + delete long packed' '
211
+test_expect_success 'D/F conflict prevents add short + delete long packed' - <<\EOT
212
df_test refs/df-as-dlp --pack --add-del foo foo/bar
213
-'
213
+EOT
214
215
-test_expect_success 'D/F conflict prevents delete long packed + add short' '
215
+test_expect_success 'D/F conflict prevents delete long packed + add short' - <<\EOT
216
df_test refs/df-dlp-as --pack --del-add foo/bar foo
217
-'
217
+EOT
218
219
-test_expect_success 'D/F conflict prevents delete short packed + add long' '
219
+test_expect_success 'D/F conflict prevents delete short packed + add long' - <<\EOT
220
df_test refs/df-dsp-al --pack --del-add foo foo/bar
221
-'
221
+EOT
222
223
# Try some combinations involving symbolic refs...
224
225
-test_expect_success 'D/F conflict prevents indirect add long + delete short' '
225
+test_expect_success 'D/F conflict prevents indirect add long + delete short' - <<\EOT
226
df_test refs/df-ial-ds --sym-add --add-del foo/bar foo
227
-'
227
+EOT
228
229
-test_expect_success 'D/F conflict prevents indirect add long + indirect delete short' '
229
+test_expect_success 'D/F conflict prevents indirect add long + indirect delete short' - <<\EOT
230
df_test refs/df-ial-ids --sym-add --sym-del --add-del foo/bar foo
231
-'
231
+EOT
232
233
-test_expect_success 'D/F conflict prevents indirect add short + indirect delete long' '
233
+test_expect_success 'D/F conflict prevents indirect add short + indirect delete long' - <<\EOT
234
df_test refs/df-ias-idl --sym-add --sym-del --add-del foo foo/bar
235
-'
235
+EOT
236
237
-test_expect_success 'D/F conflict prevents indirect delete long + indirect add short' '
237
+test_expect_success 'D/F conflict prevents indirect delete long + indirect add short' - <<\EOT
238
df_test refs/df-idl-ias --sym-add --sym-del --del-add foo/bar foo
239
-'
239
+EOT
240
241
-test_expect_success 'D/F conflict prevents indirect add long + delete short packed' '
241
+test_expect_success 'D/F conflict prevents indirect add long + delete short packed' - <<\EOT
242
df_test refs/df-ial-dsp --sym-add --pack --add-del foo/bar foo
243
-'
243
+EOT
244
245
-test_expect_success 'D/F conflict prevents indirect add long + indirect delete short packed' '
245
+test_expect_success 'D/F conflict prevents indirect add long + indirect delete short packed' - <<\EOT
246
df_test refs/df-ial-idsp --sym-add --sym-del --pack --add-del foo/bar foo
247
-'
247
+EOT
248
249
-test_expect_success 'D/F conflict prevents add long + indirect delete short packed' '
249
+test_expect_success 'D/F conflict prevents add long + indirect delete short packed' - <<\EOT
250
df_test refs/df-al-idsp --sym-del --pack --add-del foo/bar foo
251
-'
251
+EOT
252
253
-test_expect_success 'D/F conflict prevents indirect delete long packed + indirect add short' '
253
+test_expect_success 'D/F conflict prevents indirect delete long packed + indirect add short' - <<\EOT
254
df_test refs/df-idlp-ias --sym-add --sym-del --pack --del-add foo/bar foo
255
-'
255
+EOT
256
257
# Test various errors when reading the old values of references...
258
259
-test_expect_success 'missing old value blocks update' '
259
+test_expect_success 'missing old value blocks update' - <<\EOT
260
prefix=refs/missing-update &&
261
cat >expected <<-EOF &&
262
- fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ
262
+ fatal: cannot lock ref '$prefix/foo': unable to resolve reference '$prefix/foo'
263
EOF
264
printf "%s\n" "update $prefix/foo $E $D" |
265
test_must_fail git update-ref --stdin 2>output.err &&
266
test_cmp expected output.err
267
-'
267
+EOT
268
269
-test_expect_success 'incorrect old value blocks update' '
269
+test_expect_success 'incorrect old value blocks update' - <<\EOT
270
prefix=refs/incorrect-update &&
271
git update-ref $prefix/foo $C &&
272
cat >expected <<-EOF &&
273
- fatal: cannot lock ref $SQ$prefix/foo$SQ: is at $C but expected $D
273
+ fatal: cannot lock ref '$prefix/foo': is at $C but expected $D
274
EOF
275
printf "%s\n" "update $prefix/foo $E $D" |
276
test_must_fail git update-ref --stdin 2>output.err &&
277
test_cmp expected output.err
278
-'
278
+EOT
279
280
-test_expect_success 'existing old value blocks create' '
280
+test_expect_success 'existing old value blocks create' - <<\EOT
281
prefix=refs/existing-create &&
282
git update-ref $prefix/foo $C &&
283
cat >expected <<-EOF &&
284
- fatal: cannot lock ref $SQ$prefix/foo$SQ: reference already exists
284
+ fatal: cannot lock ref '$prefix/foo': reference already exists
285
EOF
286
printf "%s\n" "create $prefix/foo $E" |
287
test_must_fail git update-ref --stdin 2>output.err &&
288
test_cmp expected output.err
289
-'
289
+EOT
290
291
-test_expect_success 'incorrect old value blocks delete' '
291
+test_expect_success 'incorrect old value blocks delete' - <<\EOT
292
prefix=refs/incorrect-delete &&
293
git update-ref $prefix/foo $C &&
294
cat >expected <<-EOF &&
295
- fatal: cannot lock ref $SQ$prefix/foo$SQ: is at $C but expected $D
295
+ fatal: cannot lock ref '$prefix/foo': is at $C but expected $D
296
EOF
297
printf "%s\n" "delete $prefix/foo $D" |
298
test_must_fail git update-ref --stdin 2>output.err &&
299
test_cmp expected output.err
300
-'
300
+EOT
301
302
-test_expect_success 'missing old value blocks indirect update' '
302
+test_expect_success 'missing old value blocks indirect update' - <<\EOT
303
prefix=refs/missing-indirect-update &&
304
git symbolic-ref $prefix/symref $prefix/foo &&
305
cat >expected <<-EOF &&
306
- fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ
306
+ fatal: cannot lock ref '$prefix/symref': unable to resolve reference '$prefix/foo'
307
EOF
308
printf "%s\n" "update $prefix/symref $E $D" |
309
test_must_fail git update-ref --stdin 2>output.err &&
310
test_cmp expected output.err
311
-'
311
+EOT
312
313
-test_expect_success 'incorrect old value blocks indirect update' '
313
+test_expect_success 'incorrect old value blocks indirect update' - <<\EOT
314
prefix=refs/incorrect-indirect-update &&
315
git symbolic-ref $prefix/symref $prefix/foo &&
316
git update-ref $prefix/foo $C &&
317
cat >expected <<-EOF &&
318
- fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
318
+ fatal: cannot lock ref '$prefix/symref': is at $C but expected $D
319
EOF
320
printf "%s\n" "update $prefix/symref $E $D" |
321
test_must_fail git update-ref --stdin 2>output.err &&
322
test_cmp expected output.err
323
-'
323
+EOT
324
325
-test_expect_success 'existing old value blocks indirect create' '
325
+test_expect_success 'existing old value blocks indirect create' - <<\EOT
326
prefix=refs/existing-indirect-create &&
327
git symbolic-ref $prefix/symref $prefix/foo &&
328
git update-ref $prefix/foo $C &&
329
cat >expected <<-EOF &&
330
- fatal: cannot lock ref $SQ$prefix/symref$SQ: reference already exists
330
+ fatal: cannot lock ref '$prefix/symref': reference already exists
331
EOF
332
printf "%s\n" "create $prefix/symref $E" |
333
test_must_fail git update-ref --stdin 2>output.err &&
334
test_cmp expected output.err
335
-'
335
+EOT
336
337
-test_expect_success 'incorrect old value blocks indirect delete' '
337
+test_expect_success 'incorrect old value blocks indirect delete' - <<\EOT
338
prefix=refs/incorrect-indirect-delete &&
339
git symbolic-ref $prefix/symref $prefix/foo &&
340
git update-ref $prefix/foo $C &&
341
cat >expected <<-EOF &&
342
- fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
342
+ fatal: cannot lock ref '$prefix/symref': is at $C but expected $D
343
EOF
344
printf "%s\n" "delete $prefix/symref $D" |
345
test_must_fail git update-ref --stdin 2>output.err &&
346
test_cmp expected output.err
347
-'
347
+EOT
348
349
-test_expect_success 'missing old value blocks indirect no-deref update' '
349
+test_expect_success 'missing old value blocks indirect no-deref update' - <<\EOT
350
prefix=refs/missing-noderef-update &&
351
git symbolic-ref $prefix/symref $prefix/foo &&
352
cat >expected <<-EOF &&
353
- fatal: cannot lock ref $SQ$prefix/symref$SQ: reference is missing but expected $D
353
+ fatal: cannot lock ref '$prefix/symref': reference is missing but expected $D
354
EOF
355
printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
356
test_must_fail git update-ref --stdin 2>output.err &&
357
test_cmp expected output.err
358
-'
358
+EOT
359
360
-test_expect_success 'incorrect old value blocks indirect no-deref update' '
360
+test_expect_success 'incorrect old value blocks indirect no-deref update' - <<\EOT
361
prefix=refs/incorrect-noderef-update &&
362
git symbolic-ref $prefix/symref $prefix/foo &&
363
git update-ref $prefix/foo $C &&
364
cat >expected <<-EOF &&
365
- fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
365
+ fatal: cannot lock ref '$prefix/symref': is at $C but expected $D
366
EOF
367
printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
368
test_must_fail git update-ref --stdin 2>output.err &&
369
test_cmp expected output.err
370
-'
370
+EOT
371
372
-test_expect_success 'existing old value blocks indirect no-deref create' '
372
+test_expect_success 'existing old value blocks indirect no-deref create' - <<\EOT
373
prefix=refs/existing-noderef-create &&
374
git symbolic-ref $prefix/symref $prefix/foo &&
375
git update-ref $prefix/foo $C &&
376
cat >expected <<-EOF &&
377
- fatal: cannot lock ref $SQ$prefix/symref$SQ: reference already exists
377
+ fatal: cannot lock ref '$prefix/symref': reference already exists
378
EOF
379
printf "%s\n" "option no-deref" "create $prefix/symref $E" |
380
test_must_fail git update-ref --stdin 2>output.err &&
381
test_cmp expected output.err
382
-'
382
+EOT
383
384
-test_expect_success 'incorrect old value blocks indirect no-deref delete' '
384
+test_expect_success 'incorrect old value blocks indirect no-deref delete' - <<\EOT
385
prefix=refs/incorrect-noderef-delete &&
386
git symbolic-ref $prefix/symref $prefix/foo &&
387
git update-ref $prefix/foo $C &&
388
cat >expected <<-EOF &&
389
- fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
389
+ fatal: cannot lock ref '$prefix/symref': is at $C but expected $D
390
EOF
391
printf "%s\n" "option no-deref" "delete $prefix/symref $D" |
392
test_must_fail git update-ref --stdin 2>output.err &&
393
test_cmp expected output.err
394
-'
394
+EOT
395
396
test_done