t5520: test single-line files by git with test_cmp
In case an invocation of a git command fails within the command substitution, the failure will be masked. Replace the command substitution with a file-redirection and a call to test_cmp. This change was done with the following GNU sed expressions: s/\(\s*\)test \([^ ]*\) = "$(\(git [^)]*\))"/\1echo \2 >expect \&\&\n\1\3 >actual \&\&\n\1test_cmp expect actual/ s/\(\s*\)test "$(\(git [^)]*\))" = \([^ ]*\)/\1echo \3 >expect \&\&\n\1\2 >actual \&\&\n\1test_cmp expect actual/ A future patch will clean up situations where we have multiple duplicate statements within a test case. This is done to keep this patch purely mechanical. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
Nov 12, 2019 at 15:08 UTC
5540ed27bcf30869b2f56e421cb9f52520d2c0a0
1 file changed
+48
-16
t/t5520-pull.sh
+48
-16
@@ -255,7 +255,9 @@ test_expect_success '--rebase' '
255
git tag before-rebase &&
256
git pull --rebase . copy &&
257
test_cmp_rev HEAD^ copy &&
258
- test new = "$(git show HEAD:file2)"
258
+ echo new >expect &&
259
+ git show HEAD:file2 >actual &&
260
+ test_cmp expect actual
261
'
262
263
test_expect_success '--rebase fast forward' '
@@ -330,7 +332,9 @@ test_expect_success '--rebase fails with multiple branches' '
332
test_must_fail git pull --rebase . copy master 2>err &&
333
test_cmp_rev HEAD before-rebase &&
334
test_i18ngrep "Cannot rebase onto multiple branches" err &&
333
- test modified = "$(git show HEAD:file)"
335
+ echo modified >expect &&
336
+ git show HEAD:file >actual &&
337
+ test_cmp expect actual
338
'
339
340
test_expect_success 'pull --rebase succeeds with dirty working directory and rebase.autostash set' '
@@ -381,7 +385,9 @@ test_expect_success 'pull.rebase' '
385
test_config pull.rebase true &&
386
git pull . copy &&
387
test_cmp_rev HEAD^ copy &&
384
- test new = "$(git show HEAD:file2)"
388
+ echo new >expect &&
389
+ git show HEAD:file2 >actual &&
390
+ test_cmp expect actual
391
'
392
393
test_expect_success 'pull --autostash & pull.rebase=true' '
@@ -399,7 +405,9 @@ test_expect_success 'branch.to-rebase.rebase' '
405
test_config branch.to-rebase.rebase true &&
406
git pull . copy &&
407
test_cmp_rev HEAD^ copy &&
402
- test new = "$(git show HEAD:file2)"
408
+ echo new >expect &&
409
+ git show HEAD:file2 >actual &&
410
+ test_cmp expect actual
411
'
412
413
test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
@@ -408,14 +416,18 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
416
test_config branch.to-rebase.rebase false &&
417
git pull . copy &&
418
test_cmp_rev ! HEAD^ copy &&
411
- test new = "$(git show HEAD:file2)"
419
+ echo new >expect &&
420
+ git show HEAD:file2 >actual &&
421
+ test_cmp expect actual
422
'
423
424
test_expect_success 'pull --rebase warns on --verify-signatures' '
425
git reset --hard before-rebase &&
426
git pull --rebase --verify-signatures . copy 2>err &&
427
test_cmp_rev HEAD^ copy &&
418
- test new = "$(git show HEAD:file2)" &&
428
+ echo new >expect &&
429
+ git show HEAD:file2 >actual &&
430
+ test_cmp expect actual &&
431
test_i18ngrep "ignoring --verify-signatures for rebase" err
432
'
433
@@ -423,7 +435,9 @@ test_expect_success 'pull --rebase does not warn on --no-verify-signatures' '
435
git reset --hard before-rebase &&
436
git pull --rebase --no-verify-signatures . copy 2>err &&
437
test_cmp_rev HEAD^ copy &&
426
- test new = "$(git show HEAD:file2)" &&
438
+ echo new >expect &&
439
+ git show HEAD:file2 >actual &&
440
+ test_cmp expect actual &&
441
test_i18ngrep ! "verify-signatures" err
442
'
443
@@ -445,7 +459,9 @@ test_expect_success 'pull.rebase=false create a new merge commit' '
459
git pull . copy &&
460
test_cmp_rev HEAD^1 before-preserve-rebase &&
461
test_cmp_rev HEAD^2 copy &&
448
- test file3 = "$(git show HEAD:file3.t)"
462
+ echo file3 >expect &&
463
+ git show HEAD:file3.t >actual &&
464
+ test_cmp expect actual
465
'
466
467
test_expect_success 'pull.rebase=true flattens keep-merge' '
@@ -453,7 +469,9 @@ test_expect_success 'pull.rebase=true flattens keep-merge' '
469
test_config pull.rebase true &&
470
git pull . copy &&
471
test_cmp_rev HEAD^^ copy &&
456
- test file3 = "$(git show HEAD:file3.t)"
472
+ echo file3 >expect &&
473
+ git show HEAD:file3.t >actual &&
474
+ test_cmp expect actual
475
'
476
477
test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' '
@@ -461,7 +479,9 @@ test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' '
479
test_config pull.rebase 1 &&
480
git pull . copy &&
481
test_cmp_rev HEAD^^ copy &&
464
- test file3 = "$(git show HEAD:file3.t)"
482
+ echo file3 >expect &&
483
+ git show HEAD:file3.t >actual &&
484
+ test_cmp expect actual
485
'
486
487
test_expect_success REBASE_P \
@@ -507,7 +527,9 @@ test_expect_success '--rebase=false create a new merge commit' '
527
git pull --rebase=false . copy &&
528
test_cmp_rev HEAD^1 before-preserve-rebase &&
529
test_cmp_rev HEAD^2 copy &&
510
- test file3 = "$(git show HEAD:file3.t)"
530
+ echo file3 >expect &&
531
+ git show HEAD:file3.t >actual &&
532
+ test_cmp expect actual
533
'
534
535
test_expect_success '--rebase=true rebases and flattens keep-merge' '
@@ -515,7 +537,9 @@ test_expect_success '--rebase=true rebases and flattens keep-merge' '
537
test_config pull.rebase preserve &&
538
git pull --rebase=true . copy &&
539
test_cmp_rev HEAD^^ copy &&
518
- test file3 = "$(git show HEAD:file3.t)"
540
+ echo file3 >expect &&
541
+ git show HEAD:file3.t >actual &&
542
+ test_cmp expect actual
543
'
544
545
test_expect_success REBASE_P \
@@ -537,7 +561,9 @@ test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-m
561
test_config pull.rebase preserve &&
562
git pull --rebase . copy &&
563
test_cmp_rev HEAD^^ copy &&
540
- test file3 = "$(git show HEAD:file3.t)"
564
+ echo file3 >expect &&
565
+ git show HEAD:file3.t >actual &&
566
+ test_cmp expect actual
567
'
568
569
test_expect_success '--rebase with rebased upstream' '
@@ -622,10 +648,16 @@ test_expect_success 'pull --rebase fails on unborn branch with staged changes' '
648
cd empty_repo2 &&
649
echo staged-file >staged-file &&
650
git add staged-file &&
625
- test "$(git ls-files)" = staged-file &&
651
+ echo staged-file >expect &&
652
+ git ls-files >actual &&
653
+ test_cmp expect actual &&
654
test_must_fail git pull --rebase .. master 2>err &&
627
- test "$(git ls-files)" = staged-file &&
628
- test "$(git show :staged-file)" = staged-file &&
655
+ echo staged-file >expect &&
656
+ git ls-files >actual &&
657
+ test_cmp expect actual &&
658
+ echo staged-file >expect &&
659
+ git show :staged-file >actual &&
660
+ test_cmp expect actual &&
661
test_i18ngrep "unborn branch with changes added to the index" err
662
)
663
'