t6036: add a failed conflict detection case with conflicting types

Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jun 30, 2018 at 21:11 UTC 451a3abc262575e5ed325b71547d345c55cc7d1d
1 file changed +75
t/t6036-recursive-corner-cases.sh
+75
@@ -1114,4 +1114,79 @@ test_expect_failure 'check submodule add/add' '
1114 )
1115 '
1116
1117 +#
1118 +# criss-cross with conflicting entry types:
1119 +#
1120 +# B D
1121 +# o---o
1122 +# / \ / \
1123 +# A o X ? F
1124 +# \ / \ /
1125 +# o---o
1126 +# C E
1127 +#
1128 +# Commit A: nothing of note
1129 +# Commit B: introduce submodule 'path'
1130 +# Commit C: introduce symlink 'path'
1131 +# Commit D: merge B&C, resolving in favor of B
1132 +# Commit E: merge B&C, resolving in favor of C
1133 +#
1134 +# This is an obvious add/add conflict for 'path'. Can git detect it?
1135 +
1136 +test_expect_success 'setup conflicting entry types (submodule vs symlink)' '
1137 + test_create_repo submodule-symlink-add-add &&
1138 + (
1139 + cd submodule-symlink-add-add &&
1140 +
1141 + test_create_repo path &&
1142 + (
1143 + cd path &&
1144 + touch file-B &&
1145 + git add file-B &&
1146 + git commit -m B &&
1147 + git tag B
1148 + ) &&
1149 +
1150 + touch irrelevant-file &&
1151 + git add irrelevant-file &&
1152 + git commit -m A &&
1153 + git tag A &&
1154 +
1155 + git checkout -b B A &&
1156 + git -C path reset --hard B &&
1157 + git add path &&
1158 + git commit -m B &&
1159 +
1160 + git checkout -b C A &&
1161 + rm -rf path/ &&
1162 + test_ln_s_add irrelevant-file path &&
1163 + git commit -m C &&
1164 +
1165 + git checkout -q B^0 &&
1166 + git merge -s ours -m D C^0 &&
1167 + git tag D &&
1168 +
1169 + git checkout -q C^0 &&
1170 + git merge -s ours -m E B^0 &&
1171 + git tag E
1172 + )
1173 +'
1174 +
1175 +test_expect_failure 'check conflicting entry types (submodule vs symlink)' '
1176 + (
1177 + cd submodule-symlink-add-add &&
1178 +
1179 + git checkout D^0 &&
1180 +
1181 + test_must_fail git merge -s recursive E^0 &&
1182 +
1183 + git ls-files -s >out &&
1184 + test_line_count = 3 out &&
1185 + git ls-files -u >out &&
1186 + test_line_count = 2 out &&
1187 + git ls-files -o >out &&
1188 + test_line_count = 1 out
1189 + )
1190 +'
1191 +
1192 test_done