t1400: use consistent style for test_expect_success calls
Structure calls as test_expect_success 'description' ' body ' Use double quotes for the description if it requires parameter expansion or contains a single quote. Signed-off-by: Kyle Meyer <kyle@kyleam.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kyle Meyer committed
Apr 15, 2017 at 22:31 UTC
1cec9c2db2ca5c0be15e5c3c2223e0baaf3a0e10
1 file changed
+167
-168
t/t1400-update-ref.sh
+167
-168
@@ -35,14 +35,14 @@ test_expect_success setup '
35
cd -
36
'
37
38
-test_expect_success \
39
- "create $m" \
40
- "git update-ref $m $A &&
41
- test $A"' = $(cat .git/'"$m"')'
42
-test_expect_success \
43
- "create $m with oldvalue verification" \
44
- "git update-ref $m $B $A &&
45
- test $B"' = $(cat .git/'"$m"')'
38
+test_expect_success "create $m" '
39
+ git update-ref $m $A &&
40
+ test $A = $(cat .git/$m)
41
+'
42
+test_expect_success "create $m with oldvalue verification" '
43
+ git update-ref $m $B $A &&
44
+ test $B = $(cat .git/$m)
45
+'
46
test_expect_success "fail to delete $m with stale ref" '
47
test_must_fail git update-ref -d $m $A &&
48
test $B = "$(cat .git/$m)"
@@ -67,14 +67,14 @@ test_expect_success "fail to create $n" '
67
test_must_fail git update-ref $n $A
68
'
69
70
-test_expect_success \
71
- "create $m (by HEAD)" \
72
- "git update-ref HEAD $A &&
73
- test $A"' = $(cat .git/'"$m"')'
74
-test_expect_success \
75
- "create $m (by HEAD) with oldvalue verification" \
76
- "git update-ref HEAD $B $A &&
77
- test $B"' = $(cat .git/'"$m"')'
70
+test_expect_success "create $m (by HEAD)" '
71
+ git update-ref HEAD $A &&
72
+ test $A = $(cat .git/$m)
73
+'
74
+test_expect_success "create $m (by HEAD) with oldvalue verification" '
75
+ git update-ref HEAD $B $A &&
76
+ test $B = $(cat .git/$m)
77
+'
78
test_expect_success "fail to delete $m (by HEAD) with stale ref" '
79
test_must_fail git update-ref -d HEAD $A &&
80
test $B = $(cat .git/$m)
@@ -176,17 +176,17 @@ test_expect_success '--no-create-reflog overrides core.logAllRefUpdates=always'
176
test_must_fail git reflog exists $outside
177
'
178
179
-test_expect_success \
180
- "create $m (by HEAD)" \
181
- "git update-ref HEAD $A &&
182
- test $A"' = $(cat .git/'"$m"')'
183
-test_expect_success \
184
- "pack refs" \
185
- "git pack-refs --all"
186
-test_expect_success \
187
- "move $m (by HEAD)" \
188
- "git update-ref HEAD $B $A &&
189
- test $B"' = $(cat .git/'"$m"')'
179
+test_expect_success "create $m (by HEAD)" '
180
+ git update-ref HEAD $A &&
181
+ test $A = $(cat .git/$m)
182
+'
183
+test_expect_success 'pack refs' '
184
+ git pack-refs --all
185
+'
186
+test_expect_success "move $m (by HEAD)" '
187
+ git update-ref HEAD $B $A &&
188
+ test $B = $(cat .git/$m)
189
+'
190
test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" '
191
test_when_finished "rm -f .git/$m" &&
192
git update-ref -d HEAD $B &&
@@ -195,13 +195,13 @@ test_expect_success "delete $m (by HEAD) should remove both packed and loose $m"
195
'
196
197
cp -f .git/HEAD .git/HEAD.orig
198
-test_expect_success "delete symref without dereference" '
198
+test_expect_success 'delete symref without dereference' '
199
test_when_finished "cp -f .git/HEAD.orig .git/HEAD" &&
200
git update-ref --no-deref -d HEAD &&
201
test_path_is_missing .git/HEAD
202
'
203
204
-test_expect_success "delete symref without dereference when the referred ref is packed" '
204
+test_expect_success 'delete symref without dereference when the referred ref is packed' '
205
test_when_finished "cp -f .git/HEAD.orig .git/HEAD" &&
206
echo foo >foo.c &&
207
git add foo.c &&
@@ -239,46 +239,46 @@ test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' '
239
test_path_is_missing .git/refs/heads/ref-to-bad
240
'
241
242
-test_expect_success '(not) create HEAD with old sha1' "
242
+test_expect_success '(not) create HEAD with old sha1' '
243
test_must_fail git update-ref HEAD $A $B
244
-"
244
+'
245
test_expect_success "(not) prior created .git/$m" '
246
test_when_finished "rm -f .git/$m" &&
247
test_path_is_missing .git/$m
248
'
249
250
-test_expect_success \
251
- "create HEAD" \
252
- "git update-ref HEAD $A"
253
-test_expect_success '(not) change HEAD with wrong SHA1' "
250
+test_expect_success 'create HEAD' '
251
+ git update-ref HEAD $A
252
+'
253
+test_expect_success '(not) change HEAD with wrong SHA1' '
254
test_must_fail git update-ref HEAD $B $Z
255
-"
255
+'
256
test_expect_success "(not) changed .git/$m" '
257
test_when_finished "rm -f .git/$m" &&
258
! test $B = $(cat .git/$m)
259
'
260
261
rm -f .git/logs/refs/heads/master
262
-test_expect_success \
263
- "create $m (logged by touch)" \
264
- 'test_config core.logAllRefUpdates false &&
265
- GIT_COMMITTER_DATE="2005-05-26 23:30" \
266
- git update-ref --create-reflog HEAD '"$A"' -m "Initial Creation" &&
267
- test '"$A"' = $(cat .git/'"$m"')'
268
-test_expect_success \
269
- "update $m (logged by touch)" \
270
- 'test_config core.logAllRefUpdates false &&
271
- GIT_COMMITTER_DATE="2005-05-26 23:31" \
272
- git update-ref HEAD'" $B $A "'-m "Switch" &&
273
- test '"$B"' = $(cat .git/'"$m"')'
274
-test_expect_success \
275
- "set $m (logged by touch)" \
276
- 'test_config core.logAllRefUpdates false &&
277
- GIT_COMMITTER_DATE="2005-05-26 23:41" \
278
- git update-ref HEAD'" $A &&
279
- test $A"' = $(cat .git/'"$m"')'
280
-
281
-test_expect_success "empty directory removal" '
262
+test_expect_success "create $m (logged by touch)" '
263
+ test_config core.logAllRefUpdates false &&
264
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
265
+ git update-ref --create-reflog HEAD $A -m "Initial Creation" &&
266
+ test $A = $(cat .git/$m)
267
+'
268
+test_expect_success "update $m (logged by touch)" '
269
+ test_config core.logAllRefUpdates false &&
270
+ GIT_COMMITTER_DATE="2005-05-26 23:31" \
271
+ git update-ref HEAD $B $A -m "Switch" &&
272
+ test $B = $(cat .git/$m)
273
+'
274
+test_expect_success "set $m (logged by touch)" '
275
+ test_config core.logAllRefUpdates false &&
276
+ GIT_COMMITTER_DATE="2005-05-26 23:41" \
277
+ git update-ref HEAD $A &&
278
+ test $A = $(cat .git/$m)
279
+'
280
+
281
+test_expect_success 'empty directory removal' '
282
git branch d1/d2/r1 HEAD &&
283
git branch d1/r2 HEAD &&
284
test_path_is_file .git/refs/heads/d1/d2/r1 &&
@@ -290,7 +290,7 @@ test_expect_success "empty directory removal" '
290
test_path_is_file .git/logs/refs/heads/d1/r2
291
'
292
293
-test_expect_success "symref empty directory removal" '
293
+test_expect_success 'symref empty directory removal' '
294
git branch e1/e2/r1 HEAD &&
295
git branch e1/r2 HEAD &&
296
git checkout e1/e2/r1 &&
@@ -315,34 +315,34 @@ test_expect_success "verifying $m's log (logged by touch)" '
315
test_cmp expect .git/logs/$m
316
'
317
318
-test_expect_success \
319
- "create $m (logged by config)" \
320
- 'test_config core.logAllRefUpdates true &&
321
- GIT_COMMITTER_DATE="2005-05-26 23:32" \
322
- git update-ref HEAD'" $A "'-m "Initial Creation" &&
323
- test '"$A"' = $(cat .git/'"$m"')'
324
-test_expect_success \
325
- "update $m (logged by config)" \
326
- 'test_config core.logAllRefUpdates true &&
327
- GIT_COMMITTER_DATE="2005-05-26 23:33" \
328
- git update-ref HEAD'" $B $A "'-m "Switch" &&
329
- test '"$B"' = $(cat .git/'"$m"')'
330
-test_expect_success \
331
- "set $m (logged by config)" \
332
- 'test_config core.logAllRefUpdates true &&
333
- GIT_COMMITTER_DATE="2005-05-26 23:43" \
334
- git update-ref HEAD '"$A &&
335
- test $A"' = $(cat .git/'"$m"')'
318
+test_expect_success "create $m (logged by config)" '
319
+ test_config core.logAllRefUpdates true &&
320
+ GIT_COMMITTER_DATE="2005-05-26 23:32" \
321
+ git update-ref HEAD $A -m "Initial Creation" &&
322
+ test $A = $(cat .git/$m)
323
+'
324
+test_expect_success "update $m (logged by config)" '
325
+ test_config core.logAllRefUpdates true &&
326
+ GIT_COMMITTER_DATE="2005-05-26 23:33" \
327
+ git update-ref HEAD'" $B $A "'-m "Switch" &&
328
+ test $B = $(cat .git/$m)
329
+'
330
+test_expect_success "set $m (logged by config)" '
331
+ test_config core.logAllRefUpdates true &&
332
+ GIT_COMMITTER_DATE="2005-05-26 23:43" \
333
+ git update-ref HEAD $A &&
334
+ test $A = $(cat .git/$m)
335
+'
336
337
cat >expect <<EOF
338
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 +0000 Initial Creation
339
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch
340
$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000
341
EOF
342
-test_expect_success \
343
- "verifying $m's log (logged by config)" \
344
- 'test_when_finished "rm -f .git/$m .git/logs/$m expect" &&
345
- test_cmp expect .git/logs/$m'
342
+test_expect_success "verifying $m's log (logged by config)" '
343
+ test_when_finished "rm -f .git/$m .git/logs/$m expect" &&
344
+ test_cmp expect .git/logs/$m
345
+'
346
347
git update-ref $m $D
348
cat >.git/logs/$m <<EOF
@@ -356,86 +356,85 @@ EOF
356
ed="Thu, 26 May 2005 18:32:00 -0500"
357
gd="Thu, 26 May 2005 18:33:00 -0500"
358
ld="Thu, 26 May 2005 18:43:00 -0500"
359
-test_expect_success \
360
- 'Query "master@{May 25 2005}" (before history)' \
361
- 'test_when_finished "rm -f o e" &&
362
- git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
363
- test '"$C"' = $(cat o) &&
364
- test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
365
-test_expect_success \
366
- "Query master@{2005-05-25} (before history)" \
367
- 'test_when_finished "rm -f o e" &&
368
- git rev-parse --verify master@{2005-05-25} >o 2>e &&
369
- test '"$C"' = $(cat o) &&
370
- echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
371
-test_expect_success \
372
- 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
373
- 'test_when_finished "rm -f o e" &&
374
- git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
375
- test '"$C"' = $(cat o) &&
376
- test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"'
377
-test_expect_success \
378
- 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
379
- 'test_when_finished "rm -f o e" &&
380
- git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
381
- test '"$C"' = $(cat o) &&
382
- test "" = "$(cat e)"'
383
-test_expect_success \
384
- 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' \
385
- 'test_when_finished "rm -f o e" &&
386
- git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
387
- test '"$A"' = $(cat o) &&
388
- test "" = "$(cat e)"'
389
-test_expect_success \
390
- 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
391
- 'test_when_finished "rm -f o e" &&
392
- git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
393
- test '"$B"' = $(cat o) &&
394
- test "warning: Log for ref '"$m has gap after $gd"'." = "$(cat e)"'
395
-test_expect_success \
396
- 'Query "master@{2005-05-26 23:38:00}" (middle of history)' \
397
- 'test_when_finished "rm -f o e" &&
398
- git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
399
- test '"$Z"' = $(cat o) &&
400
- test "" = "$(cat e)"'
401
-test_expect_success \
402
- 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
403
- 'test_when_finished "rm -f o e" &&
404
- git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
405
- test '"$E"' = $(cat o) &&
406
- test "" = "$(cat e)"'
407
-test_expect_success \
408
- 'Query "master@{2005-05-28}" (past end of history)' \
409
- 'test_when_finished "rm -f o e" &&
410
- git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
411
- test '"$D"' = $(cat o) &&
412
- test "warning: Log for ref '"$m unexpectedly ended on $ld"'." = "$(cat e)"'
413
-
359
+test_expect_success 'Query "master@{May 25 2005}" (before history)' '
360
+ test_when_finished "rm -f o e" &&
361
+ git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
362
+ test $C = $(cat o) &&
363
+ test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
364
+'
365
+test_expect_success 'Query master@{2005-05-25} (before history)' '
366
+ test_when_finished "rm -f o e" &&
367
+ git rev-parse --verify master@{2005-05-25} >o 2>e &&
368
+ test $C = $(cat o) &&
369
+ echo test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
370
+'
371
+test_expect_success 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' '
372
+ test_when_finished "rm -f o e" &&
373
+ git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
374
+ test $C = $(cat o) &&
375
+ test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
376
+'
377
+test_expect_success 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' '
378
+ test_when_finished "rm -f o e" &&
379
+ git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
380
+ test $C = $(cat o) &&
381
+ test "" = "$(cat e)"
382
+'
383
+test_expect_success 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' '
384
+ test_when_finished "rm -f o e" &&
385
+ git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
386
+ test $A = $(cat o) &&
387
+ test "" = "$(cat e)"
388
+'
389
+test_expect_success 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' '
390
+ test_when_finished "rm -f o e" &&
391
+ git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
392
+ test $B = $(cat o) &&
393
+ test "warning: Log for ref $m has gap after $gd." = "$(cat e)"
394
+'
395
+test_expect_success 'Query "master@{2005-05-26 23:38:00}" (middle of history)' '
396
+ test_when_finished "rm -f o e" &&
397
+ git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
398
+ test $Z = $(cat o) &&
399
+ test "" = "$(cat e)"
400
+'
401
+test_expect_success 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' '
402
+ test_when_finished "rm -f o e" &&
403
+ git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
404
+ test $E = $(cat o) &&
405
+ test "" = "$(cat e)"
406
+'
407
+test_expect_success 'Query "master@{2005-05-28}" (past end of history)' '
408
+ test_when_finished "rm -f o e" &&
409
+ git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
410
+ test $D = $(cat o) &&
411
+ test "warning: Log for ref $m unexpectedly ended on $ld." = "$(cat e)"
412
+'
413
414
rm -f .git/$m .git/logs/$m expect
415
417
-test_expect_success \
418
- 'creating initial files' \
419
- 'test_when_finished rm -f M &&
420
- echo TEST >F &&
421
- git add F &&
422
- GIT_AUTHOR_DATE="2005-05-26 23:30" \
423
- GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a &&
424
- h_TEST=$(git rev-parse --verify HEAD) &&
425
- echo The other day this did not work. >M &&
426
- echo And then Bob told me how to fix it. >>M &&
427
- echo OTHER >F &&
428
- GIT_AUTHOR_DATE="2005-05-26 23:41" \
429
- GIT_COMMITTER_DATE="2005-05-26 23:41" git commit -F M -a &&
430
- h_OTHER=$(git rev-parse --verify HEAD) &&
431
- GIT_AUTHOR_DATE="2005-05-26 23:44" \
432
- GIT_COMMITTER_DATE="2005-05-26 23:44" git commit --amend &&
433
- h_FIXED=$(git rev-parse --verify HEAD) &&
434
- echo Merged initial commit and a later commit. >M &&
435
- echo $h_TEST >.git/MERGE_HEAD &&
436
- GIT_AUTHOR_DATE="2005-05-26 23:45" \
437
- GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M &&
438
- h_MERGED=$(git rev-parse --verify HEAD)'
416
+test_expect_success 'creating initial files' '
417
+ test_when_finished rm -f M &&
418
+ echo TEST >F &&
419
+ git add F &&
420
+ GIT_AUTHOR_DATE="2005-05-26 23:30" \
421
+ GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a &&
422
+ h_TEST=$(git rev-parse --verify HEAD) &&
423
+ echo The other day this did not work. >M &&
424
+ echo And then Bob told me how to fix it. >>M &&
425
+ echo OTHER >F &&
426
+ GIT_AUTHOR_DATE="2005-05-26 23:41" \
427
+ GIT_COMMITTER_DATE="2005-05-26 23:41" git commit -F M -a &&
428
+ h_OTHER=$(git rev-parse --verify HEAD) &&
429
+ GIT_AUTHOR_DATE="2005-05-26 23:44" \
430
+ GIT_COMMITTER_DATE="2005-05-26 23:44" git commit --amend &&
431
+ h_FIXED=$(git rev-parse --verify HEAD) &&
432
+ echo Merged initial commit and a later commit. >M &&
433
+ echo $h_TEST >.git/MERGE_HEAD &&
434
+ GIT_AUTHOR_DATE="2005-05-26 23:45" \
435
+ GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M &&
436
+ h_MERGED=$(git rev-parse --verify HEAD)
437
+'
438
439
cat >expect <<EOF
440
$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 commit (initial): add
@@ -443,20 +442,20 @@ $h_TEST $h_OTHER $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 com
442
$h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000 commit (amend): The other day this did not work.
443
$h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit.
444
EOF
446
-test_expect_success \
447
- 'git commit logged updates' \
448
- "test_cmp expect .git/logs/$m"
445
+test_expect_success 'git commit logged updates' '
446
+ test_cmp expect .git/logs/$m
447
+'
448
unset h_TEST h_OTHER h_FIXED h_MERGED
449
451
-test_expect_success \
452
- 'git cat-file blob master:F (expect OTHER)' \
453
- 'test OTHER = $(git cat-file blob master:F)'
454
-test_expect_success \
455
- 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \
456
- 'test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")'
457
-test_expect_success \
458
- 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
459
- 'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")'
450
+test_expect_success 'git cat-file blob master:F (expect OTHER)' '
451
+ test OTHER = $(git cat-file blob master:F)
452
+'
453
+test_expect_success 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' '
454
+ test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")
455
+'
456
+test_expect_success 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' '
457
+ test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")
458
+'
459
460
a=refs/heads/a
461
b=refs/heads/b