@@ -361,7 +361,6 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
361
361
rm -f sm1 &&
362
362
test_create_repo sm1 &&
363
363
head6=$( add_file sm1 foo6 foo7)
364
- fullhead6=$( cd sm1; git rev-parse --verify HEAD)
365
364
test_expect_success ' nonexistent commit' '
366
365
git diff-index -p --submodule=diff HEAD >actual &&
367
366
cat >expected <<-EOF &&
@@ -704,10 +703,26 @@ test_expect_success 'path filter' '
704
703
diff_cmp expected actual
705
704
'
706
705
707
- commit_file sm2
706
+ cat > .gitmodules << -EOF
707
+ [submodule "sm2"]
708
+ path = sm2
709
+ url = bogus_url
710
+ EOF
711
+ git add .gitmodules
712
+ commit_file sm2 .gitmodules
713
+
708
714
test_expect_success ' given commit' '
709
715
git diff-index -p --submodule=diff HEAD^ >actual &&
710
716
cat >expected <<-EOF &&
717
+ diff --git a/.gitmodules b/.gitmodules
718
+ new file mode 100644
719
+ index 1234567..89abcde
720
+ --- /dev/null
721
+ +++ b/.gitmodules
722
+ @@ -0,0 +1,3 @@
723
+ +[submodule "sm2"]
724
+ +path = sm2
725
+ +url = bogus_url
711
726
Submodule sm1 $head7...0000000 (submodule deleted)
712
727
Submodule sm2 0000000...$head9 (new submodule)
713
728
diff --git a/sm2/foo8 b/sm2/foo8
@@ -729,15 +744,21 @@ test_expect_success 'given commit' '
729
744
'
730
745
731
746
test_expect_success ' setup .git file for sm2' '
732
- (cd sm2 &&
733
- REAL="$(pwd)/../.real" &&
734
- mv .git "$REAL" &&
735
- echo "gitdir: $REAL" >.git)
747
+ git submodule absorbgitdirs sm2
736
748
'
737
749
738
750
test_expect_success ' diff --submodule=diff with .git file' '
739
751
git diff --submodule=diff HEAD^ >actual &&
740
752
cat >expected <<-EOF &&
753
+ diff --git a/.gitmodules b/.gitmodules
754
+ new file mode 100644
755
+ index 1234567..89abcde
756
+ --- /dev/null
757
+ +++ b/.gitmodules
758
+ @@ -0,0 +1,3 @@
759
+ +[submodule "sm2"]
760
+ +path = sm2
761
+ +url = bogus_url
741
762
Submodule sm1 $head7...0000000 (submodule deleted)
742
763
Submodule sm2 0000000...$head9 (new submodule)
743
764
diff --git a/sm2/foo8 b/sm2/foo8
@@ -758,9 +779,67 @@ test_expect_success 'diff --submodule=diff with .git file' '
758
779
diff_cmp expected actual
759
780
'
760
781
782
+ mv sm2 sm2-bak
783
+
784
+ test_expect_success ' deleted submodule with .git file' '
785
+ git diff-index -p --submodule=diff HEAD >actual &&
786
+ cat >expected <<-EOF &&
787
+ Submodule sm1 $head7...0000000 (submodule deleted)
788
+ Submodule sm2 $head9...0000000 (submodule deleted)
789
+ diff --git a/sm2/foo8 b/sm2/foo8
790
+ deleted file mode 100644
791
+ index 1234567..89abcde
792
+ --- a/sm2/foo8
793
+ +++ /dev/null
794
+ @@ -1 +0,0 @@
795
+ -foo8
796
+ diff --git a/sm2/foo9 b/sm2/foo9
797
+ deleted file mode 100644
798
+ index 1234567..89abcde
799
+ --- a/sm2/foo9
800
+ +++ /dev/null
801
+ @@ -1 +0,0 @@
802
+ -foo9
803
+ EOF
804
+ diff_cmp expected actual
805
+ '
806
+
807
+ echo submodule-to-blob> sm2
808
+
809
+ test_expect_success ' typechanged(submodule->blob) submodule with .git file' '
810
+ git diff-index -p --submodule=diff HEAD >actual &&
811
+ cat >expected <<-EOF &&
812
+ Submodule sm1 $head7...0000000 (submodule deleted)
813
+ Submodule sm2 $head9...0000000 (submodule deleted)
814
+ diff --git a/sm2/foo8 b/sm2/foo8
815
+ deleted file mode 100644
816
+ index 1234567..89abcde
817
+ --- a/sm2/foo8
818
+ +++ /dev/null
819
+ @@ -1 +0,0 @@
820
+ -foo8
821
+ diff --git a/sm2/foo9 b/sm2/foo9
822
+ deleted file mode 100644
823
+ index 1234567..89abcde
824
+ --- a/sm2/foo9
825
+ +++ /dev/null
826
+ @@ -1 +0,0 @@
827
+ -foo9
828
+ diff --git a/sm2 b/sm2
829
+ new file mode 100644
830
+ index 1234567..89abcde
831
+ --- /dev/null
832
+ +++ b/sm2
833
+ @@ -0,0 +1 @@
834
+ +submodule-to-blob
835
+ EOF
836
+ diff_cmp expected actual
837
+ '
838
+
839
+ rm sm2
840
+ mv sm2-bak sm2
841
+
761
842
test_expect_success ' setup nested submodule' '
762
- git submodule add -f ./sm2 &&
763
- git commit -a -m "add sm2" &&
764
843
git -C sm2 submodule add ../sm2 nested &&
765
844
git -C sm2 commit -a -m "nested sub" &&
766
845
head10=$(git -C sm2 rev-parse --short --verify HEAD)
@@ -791,6 +870,7 @@ test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' '
791
870
792
871
test_expect_success ' diff --submodule=diff recurses into nested submodules' '
793
872
cat >expected <<-EOF &&
873
+ Submodule sm1 $head7...0000000 (submodule deleted)
794
874
Submodule sm2 contains modified content
795
875
Submodule sm2 $head9..$head10:
796
876
diff --git a/sm2/.gitmodules b/sm2/.gitmodules
@@ -830,4 +910,67 @@ test_expect_success 'diff --submodule=diff recurses into nested submodules' '
830
910
diff_cmp expected actual
831
911
'
832
912
913
+ (cd sm2; commit_file nested)
914
+ commit_file sm2
915
+ head12=$( cd sm2; git rev-parse --short --verify HEAD)
916
+
917
+ mv sm2 sm2-bak
918
+
919
+ test_expect_success ' diff --submodule=diff recurses into deleted nested submodules' '
920
+ cat >expected <<-EOF &&
921
+ Submodule sm1 $head7...0000000 (submodule deleted)
922
+ Submodule sm2 $head12...0000000 (submodule deleted)
923
+ diff --git a/sm2/.gitmodules b/sm2/.gitmodules
924
+ deleted file mode 100644
925
+ index 3a816b8..0000000
926
+ --- a/sm2/.gitmodules
927
+ +++ /dev/null
928
+ @@ -1,3 +0,0 @@
929
+ -[submodule "nested"]
930
+ - path = nested
931
+ - url = ../sm2
932
+ diff --git a/sm2/foo8 b/sm2/foo8
933
+ deleted file mode 100644
934
+ index db9916b..0000000
935
+ --- a/sm2/foo8
936
+ +++ /dev/null
937
+ @@ -1 +0,0 @@
938
+ -foo8
939
+ diff --git a/sm2/foo9 b/sm2/foo9
940
+ deleted file mode 100644
941
+ index 9c3b4f6..0000000
942
+ --- a/sm2/foo9
943
+ +++ /dev/null
944
+ @@ -1 +0,0 @@
945
+ -foo9
946
+ Submodule nested $head11...0000000 (submodule deleted)
947
+ diff --git a/sm2/nested/file b/sm2/nested/file
948
+ deleted file mode 100644
949
+ index ca281f5..0000000
950
+ --- a/sm2/nested/file
951
+ +++ /dev/null
952
+ @@ -1 +0,0 @@
953
+ -nested content
954
+ diff --git a/sm2/nested/foo8 b/sm2/nested/foo8
955
+ deleted file mode 100644
956
+ index db9916b..0000000
957
+ --- a/sm2/nested/foo8
958
+ +++ /dev/null
959
+ @@ -1 +0,0 @@
960
+ -foo8
961
+ diff --git a/sm2/nested/foo9 b/sm2/nested/foo9
962
+ deleted file mode 100644
963
+ index 9c3b4f6..0000000
964
+ --- a/sm2/nested/foo9
965
+ +++ /dev/null
966
+ @@ -1 +0,0 @@
967
+ -foo9
968
+ EOF
969
+ git diff --submodule=diff >actual 2>err &&
970
+ test_must_be_empty err &&
971
+ diff_cmp expected actual
972
+ '
973
+
974
+ mv sm2-bak sm2
975
+
833
976
test_done
0 commit comments