@@ -540,26 +540,10 @@ test_expect_success 'make sure exactly the right set of files ends up in the sub
540
540
git fetch .. subproj-br &&
541
541
git merge FETCH_HEAD &&
542
542
543
- chks="sub1
544
- sub2
545
- sub3
546
- sub4" &&
547
- chks_sub=$(cat <<TXT | sed ' \' ' s,^,sub dir/,' \' '
548
- $chks
549
- TXT
550
- ) &&
551
- chkms="main-sub1
552
- main-sub2
553
- main-sub3
554
- main-sub4" &&
555
- chkms_sub=$(cat <<TXT | sed ' \' ' s,^,sub dir/,' \' '
556
- $chkms
557
- TXT
558
- ) &&
559
-
560
- subfiles=$(git ls-files) &&
561
- check_equal "$subfiles" "$chkms
562
- $chks"
543
+ test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 \
544
+ sub1 sub2 sub3 sub4 >expect &&
545
+ git ls-files >actual &&
546
+ test_cmp expect actual
563
547
)
564
548
'
565
549
@@ -606,25 +590,11 @@ test_expect_success 'make sure the subproj *only* contains commits that affect t
606
590
git fetch .. subproj-br &&
607
591
git merge FETCH_HEAD &&
608
592
609
- chks="sub1
610
- sub2
611
- sub3
612
- sub4" &&
613
- chks_sub=$(cat <<TXT | sed ' \' ' s,^,sub dir/,' \' '
614
- $chks
615
- TXT
616
- ) &&
617
- chkms="main-sub1
618
- main-sub2
619
- main-sub3
620
- main-sub4" &&
621
- chkms_sub=$(cat <<TXT | sed ' \' ' s,^,sub dir/,' \' '
622
- $chkms
623
- TXT
624
- ) &&
625
- allchanges=$(git log --name-only --pretty=format:"" | sort | sed "/^$/d") &&
626
- check_equal "$allchanges" "$chkms
627
- $chks"
593
+ test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 \
594
+ sub1 sub2 sub3 sub4 >expect &&
595
+ git log --name-only --pretty=format:"" >log &&
596
+ sort <log | sed "/^\$/ d" >actual &&
597
+ test_cmp expect actual
628
598
)
629
599
'
630
600
@@ -675,29 +645,16 @@ test_expect_success 'make sure exactly the right set of files ends up in the mai
675
645
cd "$subtree_test_count" &&
676
646
git subtree pull --prefix="sub dir" ./"sub proj" master &&
677
647
678
- chkm="main1
679
- main2" &&
680
- chks="sub1
681
- sub2
682
- sub3
683
- sub4" &&
684
- chks_sub=$(cat <<TXT | sed ' \' ' s,^,sub dir/,' \' '
685
- $chks
686
- TXT
687
- ) &&
688
- chkms="main-sub1
689
- main-sub2
690
- main-sub3
691
- main-sub4" &&
692
- chkms_sub=$(cat <<TXT | sed ' \' ' s,^,sub dir/,' \' '
693
- $chkms
694
- TXT
695
- ) &&
696
- mainfiles=$(git ls-files) &&
697
- check_equal "$mainfiles" "$chkm
698
- $chkms_sub
699
- $chks_sub"
700
- )
648
+ test_write_lines main1 main2 >chkm &&
649
+ test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 >chkms &&
650
+ sed "s,^,sub dir/," chkms >chkms_sub &&
651
+ test_write_lines sub1 sub2 sub3 sub4 >chks &&
652
+ sed "s,^,sub dir/," chks >chks_sub &&
653
+
654
+ cat chkm chkms_sub chks_sub >expect &&
655
+ git ls-files >actual &&
656
+ test_cmp expect actual
657
+ )
701
658
'
702
659
703
660
next_test
@@ -708,7 +665,7 @@ test_expect_success 'make sure each filename changed exactly once in the entire
708
665
test_create_commit "$subtree_test_count/sub proj" sub1 &&
709
666
(
710
667
cd "$subtree_test_count" &&
711
- git config log.date relative
668
+ git config log.date relative &&
712
669
git fetch ./"sub proj" master &&
713
670
git subtree add --prefix="sub dir" FETCH_HEAD
714
671
) &&
@@ -748,37 +705,21 @@ test_expect_success 'make sure each filename changed exactly once in the entire
748
705
cd "$subtree_test_count" &&
749
706
git subtree pull --prefix="sub dir" ./"sub proj" master &&
750
707
751
- chkm="main1
752
- main2" &&
753
- chks="sub1
754
- sub2
755
- sub3
756
- sub4" &&
757
- chks_sub=$(cat <<TXT | sed ' \' ' s,^,sub dir/,' \' '
758
- $chks
759
- TXT
760
- ) &&
761
- chkms="main-sub1
762
- main-sub2
763
- main-sub3
764
- main-sub4" &&
765
- chkms_sub=$(cat <<TXT | sed ' \' ' s,^,sub dir/,' \' '
766
- $chkms
767
- TXT
768
- ) &&
708
+ test_write_lines main1 main2 >chkm &&
709
+ test_write_lines sub1 sub2 sub3 sub4 >chks &&
710
+ test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 >chkms &&
711
+ sed "s,^,sub dir/," chkms >chkms_sub &&
769
712
770
713
# main-sub?? and /"sub dir"/main-sub?? both change, because those are the
771
714
# changes that were split into their own history. And "sub dir"/sub?? never
772
715
# change, since they were *only* changed in the subtree branch.
773
- allchanges=$(git log --name-only --pretty=format:"" | sort | sed "/^$/d") &&
774
- expected=' ' "$(cat <<TXT | sort
775
- $chkms
776
- $chkm
777
- $chks
778
- $chkms_sub
779
- TXT
780
- )"' ' &&
781
- check_equal "$allchanges" "$expected"
716
+ git log --name-only --pretty=format:"" >log &&
717
+ sort <log >sorted-log &&
718
+ sed "/^$/ d" sorted-log >actual &&
719
+
720
+ cat chkms chkm chks chkms_sub >expect-unsorted &&
721
+ sort expect-unsorted >expect &&
722
+ test_cmp expect actual
782
723
)
783
724
'
784
725
0 commit comments