@@ -1116,4 +1116,66 @@ test_expect_success 'submodule update --filter sets partial clone settings' '
1116
1116
test_cmp_config -C super-filter/submodule blob:none remote.origin.partialclonefilter
1117
1117
'
1118
1118
1119
+ # NEEDSWORK: Clean up the tests so that we can reuse the test setup.
1120
+ # Don't reuse the existing repos because the earlier tests have
1121
+ # intentionally disruptive configurations.
1122
+ test_expect_success ' setup clean recursive superproject' '
1123
+ git init bottom &&
1124
+ test_commit -C bottom "bottom" &&
1125
+ git init middle &&
1126
+ git -C middle submodule add ../bottom bottom &&
1127
+ git -C middle commit -m "middle" &&
1128
+ git init top &&
1129
+ git -C top submodule add ../middle middle &&
1130
+ git -C top commit -m "top" &&
1131
+ git clone --recurse-submodules top top-clean
1132
+ '
1133
+
1134
+ test_expect_success ' submodule update should skip unmerged submodules' '
1135
+ test_when_finished "rm -fr top-cloned" &&
1136
+ cp -r top-clean top-cloned &&
1137
+
1138
+ # Create an upstream commit in each repo, starting with bottom
1139
+ test_commit -C bottom upstream_commit &&
1140
+ # Create middle commit
1141
+ git -C middle/bottom fetch &&
1142
+ git -C middle/bottom checkout -f FETCH_HEAD &&
1143
+ git -C middle add bottom &&
1144
+ git -C middle commit -m "upstream_commit" &&
1145
+ # Create top commit
1146
+ git -C top/middle fetch &&
1147
+ git -C top/middle checkout -f FETCH_HEAD &&
1148
+ git -C top add middle &&
1149
+ git -C top commit -m "upstream_commit" &&
1150
+
1151
+ # Create a downstream conflict
1152
+ test_commit -C top-cloned/middle/bottom downstream_commit &&
1153
+ git -C top-cloned/middle add bottom &&
1154
+ git -C top-cloned/middle commit -m "downstream_commit" &&
1155
+ git -C top-cloned/middle fetch --recurse-submodules origin &&
1156
+ test_must_fail git -C top-cloned/middle merge origin/main &&
1157
+
1158
+ # Make the update of "middle" a no-op, otherwise we error out
1159
+ # because of its unmerged state
1160
+ test_config -C top-cloned submodule.middle.update !true &&
1161
+ git -C top-cloned submodule update --recursive 2>actual.err &&
1162
+ cat >expect.err <<-\EOF &&
1163
+ Skipping unmerged submodule middle//bottom
1164
+ EOF
1165
+ test_cmp expect.err actual.err
1166
+ '
1167
+
1168
+ test_expect_success ' submodule update --recursive skip submodules with strategy=none' '
1169
+ test_when_finished "rm -fr top-cloned" &&
1170
+ cp -r top-clean top-cloned &&
1171
+
1172
+ test_commit -C top-cloned/middle/bottom downstream_commit &&
1173
+ git -C top-cloned/middle config submodule.bottom.update none &&
1174
+ git -C top-cloned submodule update --recursive 2>actual.err &&
1175
+ cat >expect.err <<-\EOF &&
1176
+ Skipping submodule ' \' ' ../middle/' \' '
1177
+ EOF
1178
+ test_cmp expect.err actual.err
1179
+ '
1180
+
1119
1181
test_done
0 commit comments