unpack-trees: don't respect submodule.update

The 'submodule.update' config was historically used and respected by the 'submodule update' command because update handled a variety of different ways it updated a submodule. As we begin teaching other commands about submodules it makes more sense for the different settings of 'submodule.update' to be handled by the individual commands themselves (checkout, rebase, merge, etc) so it shouldn't be respected by the native checkout command. Also remove the overlaying of the repository's config (via using 'submodule_config()') from the commands which use the unpack-trees logic (checkout, read-tree, reset). Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed Aug 3, 2017 at 11:19 UTC 7463e2ec3e932707b70b5d5c82df51bfbb6aa77d
3 files changed +9 -32
builtin/checkout.c
+1 -1
@@ -858,7 +858,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
858 }
859
860 if (starts_with(var, "submodule."))
861 - return submodule_config(var, value, NULL);
861 + return git_default_submodule_config(var, value, NULL);
862
863 return git_xmerge_config(var, value, NULL);
864 }
submodule.c
-1
@@ -235,7 +235,6 @@ void load_submodule_cache(void)
235 return;
236
237 gitmodules_config();
238 - git_config(submodule_config, NULL);
238 }
239
240 static int gitmodules_cb(const char *var, const char *value, void *data)
unpack-trees.c
+8 -30
@@ -255,28 +255,17 @@ static int check_submodule_move_head(const struct cache_entry *ce,
255 {
256 unsigned flags = SUBMODULE_MOVE_HEAD_DRY_RUN;
257 const struct submodule *sub = submodule_from_ce(ce);
258 +
259 if (!sub)
260 return 0;
261
262 if (o->reset)
263 flags |= SUBMODULE_MOVE_HEAD_FORCE;
264
264 - switch (sub->update_strategy.type) {
265 - case SM_UPDATE_UNSPECIFIED:
266 - case SM_UPDATE_CHECKOUT:
267 - if (submodule_move_head(ce->name, old_id, new_id, flags))
268 - return o->gently ? -1 :
269 - add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name);
270 - return 0;
271 - case SM_UPDATE_NONE:
272 - return 0;
273 - case SM_UPDATE_REBASE:
274 - case SM_UPDATE_MERGE:
275 - case SM_UPDATE_COMMAND:
276 - default:
277 - warning(_("submodule update strategy not supported for submodule '%s'"), ce->name);
278 - return -1;
279 - }
265 + if (submodule_move_head(ce->name, old_id, new_id, flags))
266 + return o->gently ? -1 :
267 + add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name);
268 + return 0;
269 }
270
271 static void reload_gitmodules_file(struct index_state *index,
@@ -293,7 +282,6 @@ static void reload_gitmodules_file(struct index_state *index,
282 submodule_free();
283 checkout_entry(ce, state, NULL);
284 gitmodules_config();
296 - git_config(submodule_config, NULL);
285 } else
286 break;
287 }
@@ -308,19 +296,9 @@ static void unlink_entry(const struct cache_entry *ce)
296 {
297 const struct submodule *sub = submodule_from_ce(ce);
298 if (sub) {
311 - switch (sub->update_strategy.type) {
312 - case SM_UPDATE_UNSPECIFIED:
313 - case SM_UPDATE_CHECKOUT:
314 - case SM_UPDATE_REBASE:
315 - case SM_UPDATE_MERGE:
316 - /* state.force is set at the caller. */
317 - submodule_move_head(ce->name, "HEAD", NULL,
318 - SUBMODULE_MOVE_HEAD_FORCE);
319 - break;
320 - case SM_UPDATE_NONE:
321 - case SM_UPDATE_COMMAND:
322 - return; /* Do not touch the submodule. */
323 - }
299 + /* state.force is set at the caller. */
300 + submodule_move_head(ce->name, "HEAD", NULL,
301 + SUBMODULE_MOVE_HEAD_FORCE);
302 }
303 if (!check_leading_path(ce->name, ce_namelen(ce)))
304 return;