Skip to content

Commit 1fb4a11

Browse files
committed
Merge branch 'sb/t3600-cleanup' into maint
Code cleanup. * sb/t3600-cleanup: t3600: slightly modernize style t3600: remove useless redirect
2 parents bc7547f + 9e189f1 commit 1fb4a11

File tree

1 file changed

+51
-73
lines changed

1 file changed

+51
-73
lines changed

t/t3600-rm.sh

Lines changed: 51 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,21 @@ test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
111111
'
112112

113113
test_expect_success '"rm" command printed' '
114-
echo frotz > test-file &&
114+
echo frotz >test-file &&
115115
git add test-file &&
116116
git commit -m "add file for rm test" &&
117-
git rm test-file > rm-output &&
117+
git rm test-file >rm-output &&
118118
test $(grep "^rm " rm-output | wc -l) = 1 &&
119119
rm -f test-file rm-output &&
120120
git commit -m "remove file from rm test"
121121
'
122122

123123
test_expect_success '"rm" command suppressed with --quiet' '
124-
echo frotz > test-file &&
124+
echo frotz >test-file &&
125125
git add test-file &&
126126
git commit -m "add file for rm --quiet test" &&
127-
git rm --quiet test-file > rm-output &&
128-
test $(wc -l < rm-output) = 0 &&
127+
git rm --quiet test-file >rm-output &&
128+
test_must_be_empty rm-output &&
129129
rm -f test-file rm-output &&
130130
git commit -m "remove file from rm --quiet test"
131131
'
@@ -221,7 +221,7 @@ test_expect_success 'Call "rm" from outside the work tree' '
221221
mkdir repo &&
222222
(cd repo &&
223223
git init &&
224-
echo something > somefile &&
224+
echo something >somefile &&
225225
git add somefile &&
226226
git commit -m "add a file" &&
227227
(cd .. &&
@@ -287,7 +287,7 @@ test_expect_success 'rm removes empty submodules from work tree' '
287287
git commit -m "add submodule" &&
288288
git rm submod &&
289289
test ! -e submod &&
290-
git status -s -uno --ignore-submodules=none > actual &&
290+
git status -s -uno --ignore-submodules=none >actual &&
291291
test_cmp expect actual &&
292292
test_must_fail git config -f .gitmodules submodule.sub.url &&
293293
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -298,7 +298,7 @@ test_expect_success 'rm removes removed submodule from index and .gitmodules' '
298298
git submodule update &&
299299
rm -rf submod &&
300300
git rm submod &&
301-
git status -s -uno --ignore-submodules=none > actual &&
301+
git status -s -uno --ignore-submodules=none >actual &&
302302
test_cmp expect actual &&
303303
test_must_fail git config -f .gitmodules submodule.sub.url &&
304304
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -309,7 +309,7 @@ test_expect_success 'rm removes work tree of unmodified submodules' '
309309
git submodule update &&
310310
git rm submod &&
311311
test ! -d submod &&
312-
git status -s -uno --ignore-submodules=none > actual &&
312+
git status -s -uno --ignore-submodules=none >actual &&
313313
test_cmp expect actual &&
314314
test_must_fail git config -f .gitmodules submodule.sub.url &&
315315
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -320,7 +320,7 @@ test_expect_success 'rm removes a submodule with a trailing /' '
320320
git submodule update &&
321321
git rm submod/ &&
322322
test ! -d submod &&
323-
git status -s -uno --ignore-submodules=none > actual &&
323+
git status -s -uno --ignore-submodules=none >actual &&
324324
test_cmp expect actual
325325
'
326326

@@ -335,17 +335,15 @@ test_expect_success 'rm succeeds when given a directory with a trailing /' '
335335
test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' '
336336
git reset --hard &&
337337
git submodule update &&
338-
(cd submod &&
339-
git checkout HEAD^
340-
) &&
338+
git -C submod checkout HEAD^ &&
341339
test_must_fail git rm submod &&
342340
test -d submod &&
343341
test -f submod/.git &&
344-
git status -s -uno --ignore-submodules=none > actual &&
342+
git status -s -uno --ignore-submodules=none >actual &&
345343
test_cmp expect.modified actual &&
346344
git rm -f submod &&
347345
test ! -d submod &&
348-
git status -s -uno --ignore-submodules=none > actual &&
346+
git status -s -uno --ignore-submodules=none >actual &&
349347
test_cmp expect actual &&
350348
test_must_fail git config -f .gitmodules submodule.sub.url &&
351349
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -418,34 +416,30 @@ test_expect_success 'rm issues a warning when section is not found in .gitmodule
418416
test_expect_success 'rm of a populated submodule with modifications fails unless forced' '
419417
git reset --hard &&
420418
git submodule update &&
421-
(cd submod &&
422-
echo X >empty
423-
) &&
419+
echo X >submod/empty &&
424420
test_must_fail git rm submod &&
425421
test -d submod &&
426422
test -f submod/.git &&
427-
git status -s -uno --ignore-submodules=none > actual &&
423+
git status -s -uno --ignore-submodules=none >actual &&
428424
test_cmp expect.modified actual &&
429425
git rm -f submod &&
430426
test ! -d submod &&
431-
git status -s -uno --ignore-submodules=none > actual &&
427+
git status -s -uno --ignore-submodules=none >actual &&
432428
test_cmp expect actual
433429
'
434430

435431
test_expect_success 'rm of a populated submodule with untracked files fails unless forced' '
436432
git reset --hard &&
437433
git submodule update &&
438-
(cd submod &&
439-
echo X >untracked
440-
) &&
434+
echo X >submod/untracked &&
441435
test_must_fail git rm submod &&
442436
test -d submod &&
443437
test -f submod/.git &&
444-
git status -s -uno --ignore-submodules=none > actual &&
438+
git status -s -uno --ignore-submodules=none >actual &&
445439
test_cmp expect.modified actual &&
446440
git rm -f submod &&
447441
test ! -d submod &&
448-
git status -s -uno --ignore-submodules=none > actual &&
442+
git status -s -uno --ignore-submodules=none >actual &&
449443
test_cmp expect actual
450444
'
451445

@@ -461,16 +455,12 @@ test_expect_success 'setup submodule conflict' '
461455
git add nitfol &&
462456
git commit -m "added nitfol 2" &&
463457
git checkout -b conflict1 master &&
464-
(cd submod &&
465-
git fetch &&
466-
git checkout branch1
467-
) &&
458+
git -C submod fetch &&
459+
git -C submod checkout branch1 &&
468460
git add submod &&
469461
git commit -m "submod 1" &&
470462
git checkout -b conflict2 master &&
471-
(cd submod &&
472-
git checkout branch2
473-
) &&
463+
git -C submod checkout branch2 &&
474464
git add submod &&
475465
git commit -m "submod 2"
476466
'
@@ -486,26 +476,24 @@ test_expect_success 'rm removes work tree of unmodified conflicted submodule' '
486476
test_must_fail git merge conflict2 &&
487477
git rm submod &&
488478
test ! -d submod &&
489-
git status -s -uno --ignore-submodules=none > actual &&
479+
git status -s -uno --ignore-submodules=none >actual &&
490480
test_cmp expect actual
491481
'
492482

493483
test_expect_success 'rm of a conflicted populated submodule with different HEAD fails unless forced' '
494484
git checkout conflict1 &&
495485
git reset --hard &&
496486
git submodule update &&
497-
(cd submod &&
498-
git checkout HEAD^
499-
) &&
487+
git -C submod checkout HEAD^ &&
500488
test_must_fail git merge conflict2 &&
501489
test_must_fail git rm submod &&
502490
test -d submod &&
503491
test -f submod/.git &&
504-
git status -s -uno --ignore-submodules=none > actual &&
492+
git status -s -uno --ignore-submodules=none >actual &&
505493
test_cmp expect.conflict actual &&
506494
git rm -f submod &&
507495
test ! -d submod &&
508-
git status -s -uno --ignore-submodules=none > actual &&
496+
git status -s -uno --ignore-submodules=none >actual &&
509497
test_cmp expect actual &&
510498
test_must_fail git config -f .gitmodules submodule.sub.url &&
511499
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -515,18 +503,16 @@ test_expect_success 'rm of a conflicted populated submodule with modifications f
515503
git checkout conflict1 &&
516504
git reset --hard &&
517505
git submodule update &&
518-
(cd submod &&
519-
echo X >empty
520-
) &&
506+
echo X >submod/empty &&
521507
test_must_fail git merge conflict2 &&
522508
test_must_fail git rm submod &&
523509
test -d submod &&
524510
test -f submod/.git &&
525-
git status -s -uno --ignore-submodules=none > actual &&
511+
git status -s -uno --ignore-submodules=none >actual &&
526512
test_cmp expect.conflict actual &&
527513
git rm -f submod &&
528514
test ! -d submod &&
529-
git status -s -uno --ignore-submodules=none > actual &&
515+
git status -s -uno --ignore-submodules=none >actual &&
530516
test_cmp expect actual &&
531517
test_must_fail git config -f .gitmodules submodule.sub.url &&
532518
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -536,18 +522,16 @@ test_expect_success 'rm of a conflicted populated submodule with untracked files
536522
git checkout conflict1 &&
537523
git reset --hard &&
538524
git submodule update &&
539-
(cd submod &&
540-
echo X >untracked
541-
) &&
525+
echo X >submod/untracked &&
542526
test_must_fail git merge conflict2 &&
543527
test_must_fail git rm submod &&
544528
test -d submod &&
545529
test -f submod/.git &&
546-
git status -s -uno --ignore-submodules=none > actual &&
530+
git status -s -uno --ignore-submodules=none >actual &&
547531
test_cmp expect.conflict actual &&
548532
git rm -f submod &&
549533
test ! -d submod &&
550-
git status -s -uno --ignore-submodules=none > actual &&
534+
git status -s -uno --ignore-submodules=none >actual &&
551535
test_cmp expect actual
552536
'
553537

@@ -564,12 +548,12 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
564548
test_must_fail git rm submod &&
565549
test -d submod &&
566550
test -d submod/.git &&
567-
git status -s -uno --ignore-submodules=none > actual &&
551+
git status -s -uno --ignore-submodules=none >actual &&
568552
test_cmp expect.conflict actual &&
569553
test_must_fail git rm -f submod &&
570554
test -d submod &&
571555
test -d submod/.git &&
572-
git status -s -uno --ignore-submodules=none > actual &&
556+
git status -s -uno --ignore-submodules=none >actual &&
573557
test_cmp expect.conflict actual &&
574558
git merge --abort &&
575559
rm -rf submod
@@ -581,7 +565,7 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' '
581565
test_must_fail git merge conflict2 &&
582566
git rm submod &&
583567
test ! -d submod &&
584-
git status -s -uno --ignore-submodules=none > actual &&
568+
git status -s -uno --ignore-submodules=none >actual &&
585569
test_cmp expect actual
586570
'
587571

@@ -597,12 +581,12 @@ test_expect_success 'rm of a populated submodule with a .git directory fails eve
597581
test_must_fail git rm submod &&
598582
test -d submod &&
599583
test -d submod/.git &&
600-
git status -s -uno --ignore-submodules=none > actual &&
584+
git status -s -uno --ignore-submodules=none >actual &&
601585
! test -s actual &&
602586
test_must_fail git rm -f submod &&
603587
test -d submod &&
604588
test -d submod/.git &&
605-
git status -s -uno --ignore-submodules=none > actual &&
589+
git status -s -uno --ignore-submodules=none >actual &&
606590
! test -s actual &&
607591
rm -rf submod
608592
'
@@ -629,58 +613,52 @@ test_expect_success 'setup subsubmodule' '
629613
test_expect_success 'rm recursively removes work tree of unmodified submodules' '
630614
git rm submod &&
631615
test ! -d submod &&
632-
git status -s -uno --ignore-submodules=none > actual &&
616+
git status -s -uno --ignore-submodules=none >actual &&
633617
test_cmp expect actual
634618
'
635619

636620
test_expect_success 'rm of a populated nested submodule with different nested HEAD fails unless forced' '
637621
git reset --hard &&
638622
git submodule update --recursive &&
639-
(cd submod/subsubmod &&
640-
git checkout HEAD^
641-
) &&
623+
git -C submod/subsubmod checkout HEAD^ &&
642624
test_must_fail git rm submod &&
643625
test -d submod &&
644626
test -f submod/.git &&
645-
git status -s -uno --ignore-submodules=none > actual &&
627+
git status -s -uno --ignore-submodules=none >actual &&
646628
test_cmp expect.modified actual &&
647629
git rm -f submod &&
648630
test ! -d submod &&
649-
git status -s -uno --ignore-submodules=none > actual &&
631+
git status -s -uno --ignore-submodules=none >actual &&
650632
test_cmp expect actual
651633
'
652634

653635
test_expect_success 'rm of a populated nested submodule with nested modifications fails unless forced' '
654636
git reset --hard &&
655637
git submodule update --recursive &&
656-
(cd submod/subsubmod &&
657-
echo X >empty
658-
) &&
638+
echo X >submod/subsubmod/empty &&
659639
test_must_fail git rm submod &&
660640
test -d submod &&
661641
test -f submod/.git &&
662-
git status -s -uno --ignore-submodules=none > actual &&
642+
git status -s -uno --ignore-submodules=none >actual &&
663643
test_cmp expect.modified actual &&
664644
git rm -f submod &&
665645
test ! -d submod &&
666-
git status -s -uno --ignore-submodules=none > actual &&
646+
git status -s -uno --ignore-submodules=none >actual &&
667647
test_cmp expect actual
668648
'
669649

670650
test_expect_success 'rm of a populated nested submodule with nested untracked files fails unless forced' '
671651
git reset --hard &&
672652
git submodule update --recursive &&
673-
(cd submod/subsubmod &&
674-
echo X >untracked
675-
) &&
653+
echo X >submod/subsubmod/untracked &&
676654
test_must_fail git rm submod &&
677655
test -d submod &&
678656
test -f submod/.git &&
679-
git status -s -uno --ignore-submodules=none > actual &&
657+
git status -s -uno --ignore-submodules=none >actual &&
680658
test_cmp expect.modified actual &&
681659
git rm -f submod &&
682660
test ! -d submod &&
683-
git status -s -uno --ignore-submodules=none > actual &&
661+
git status -s -uno --ignore-submodules=none >actual &&
684662
test_cmp expect actual
685663
'
686664

@@ -695,12 +673,12 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
695673
test_must_fail git rm submod &&
696674
test -d submod &&
697675
test -d submod/subsubmod/.git &&
698-
git status -s -uno --ignore-submodules=none > actual &&
676+
git status -s -uno --ignore-submodules=none >actual &&
699677
! test -s actual &&
700678
test_must_fail git rm -f submod &&
701679
test -d submod &&
702680
test -d submod/subsubmod/.git &&
703-
git status -s -uno --ignore-submodules=none > actual &&
681+
git status -s -uno --ignore-submodules=none >actual &&
704682
! test -s actual &&
705683
rm -rf submod
706684
'
@@ -709,14 +687,14 @@ test_expect_success 'checking out a commit after submodule removal needs manual
709687
git commit -m "submodule removal" submod &&
710688
git checkout HEAD^ &&
711689
git submodule update &&
712-
git checkout -q HEAD^ 2>actual &&
690+
git checkout -q HEAD^ &&
713691
git checkout -q master 2>actual &&
714692
test_i18ngrep "^warning: unable to rmdir submod:" actual &&
715693
git status -s submod >actual &&
716694
echo "?? submod/" >expected &&
717695
test_cmp expected actual &&
718696
rm -rf submod &&
719-
git status -s -uno --ignore-submodules=none > actual &&
697+
git status -s -uno --ignore-submodules=none >actual &&
720698
! test -s actual
721699
'
722700

0 commit comments

Comments
 (0)