Skip to content

Commit 7463e2e

Browse files
bmwillgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fdfa9e9 commit 7463e2e

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
858858
}
859859

860860
if (starts_with(var, "submodule."))
861-
return submodule_config(var, value, NULL);
861+
return git_default_submodule_config(var, value, NULL);
862862

863863
return git_xmerge_config(var, value, NULL);
864864
}

submodule.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ void load_submodule_cache(void)
235235
return;
236236

237237
gitmodules_config();
238-
git_config(submodule_config, NULL);
239238
}
240239

241240
static int gitmodules_cb(const char *var, const char *value, void *data)

unpack-trees.c

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -255,28 +255,17 @@ static int check_submodule_move_head(const struct cache_entry *ce,
255255
{
256256
unsigned flags = SUBMODULE_MOVE_HEAD_DRY_RUN;
257257
const struct submodule *sub = submodule_from_ce(ce);
258+
258259
if (!sub)
259260
return 0;
260261

261262
if (o->reset)
262263
flags |= SUBMODULE_MOVE_HEAD_FORCE;
263264

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;
280269
}
281270

282271
static void reload_gitmodules_file(struct index_state *index,
@@ -293,7 +282,6 @@ static void reload_gitmodules_file(struct index_state *index,
293282
submodule_free();
294283
checkout_entry(ce, state, NULL);
295284
gitmodules_config();
296-
git_config(submodule_config, NULL);
297285
} else
298286
break;
299287
}
@@ -308,19 +296,9 @@ static void unlink_entry(const struct cache_entry *ce)
308296
{
309297
const struct submodule *sub = submodule_from_ce(ce);
310298
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);
324302
}
325303
if (!check_leading_path(ce->name, ce_namelen(ce)))
326304
return;

0 commit comments

Comments
 (0)