@@ -1026,4 +1026,92 @@ test_expect_failure 'check submodule modify/modify' '
1026
1026
)
1027
1027
'
1028
1028
1029
+ #
1030
+ # criss-cross with add/add on a submodule:
1031
+ #
1032
+ # B D
1033
+ # o---o
1034
+ # / \ / \
1035
+ # A o X ? F
1036
+ # \ / \ /
1037
+ # o---o
1038
+ # C E
1039
+ #
1040
+ # Commit A: nothing of note
1041
+ # Commit B: introduce submodule repo
1042
+ # Commit C: introduce submodule repo at different commit
1043
+ # Commit D: merge B&C, resolving in favor of B
1044
+ # Commit E: merge B&C, resolving in favor of C
1045
+ #
1046
+ # This is an obvious add/add conflict for the submodule 'repo'. Can
1047
+ # git detect it?
1048
+
1049
+ test_expect_success ' setup submodule add/add' '
1050
+ test_create_repo submodule-add-add &&
1051
+ (
1052
+ cd submodule-add-add &&
1053
+
1054
+ test_create_repo submod &&
1055
+ (
1056
+ cd submod &&
1057
+ touch file-A &&
1058
+ git add file-A &&
1059
+ git commit -m A &&
1060
+ git tag A &&
1061
+
1062
+ git checkout -b B A &&
1063
+ touch file-B &&
1064
+ git add file-B &&
1065
+ git commit -m B &&
1066
+ git tag B &&
1067
+
1068
+ git checkout -b C A &&
1069
+ touch file-C &&
1070
+ git add file-C &&
1071
+ git commit -m C &&
1072
+ git tag C
1073
+ ) &&
1074
+
1075
+ touch irrelevant-file &&
1076
+ git add irrelevant-file &&
1077
+ git commit -m A &&
1078
+ git tag A &&
1079
+
1080
+ git checkout -b B A &&
1081
+ git -C submod reset --hard B &&
1082
+ git add submod &&
1083
+ git commit -m B &&
1084
+
1085
+ git checkout -b C A &&
1086
+ git -C submod reset --hard C &&
1087
+ git add submod &&
1088
+ git commit -m C &&
1089
+
1090
+ git checkout -q B^0 &&
1091
+ git merge -s ours -m D C^0 &&
1092
+ git tag D &&
1093
+
1094
+ git checkout -q C^0 &&
1095
+ git merge -s ours -m E B^0 &&
1096
+ git tag E
1097
+ )
1098
+ '
1099
+
1100
+ test_expect_failure ' check submodule add/add' '
1101
+ (
1102
+ cd submodule-add-add &&
1103
+
1104
+ git checkout D^0 &&
1105
+
1106
+ test_must_fail git merge -s recursive E^0 &&
1107
+
1108
+ git ls-files -s >out &&
1109
+ test_line_count = 3 out &&
1110
+ git ls-files -u >out &&
1111
+ test_line_count = 2 out &&
1112
+ git ls-files -o >out &&
1113
+ test_line_count = 1 out
1114
+ )
1115
+ '
1116
+
1029
1117
test_done
0 commit comments