unpack-trees: don't respect submodule.update
authorBrandon Williams <bmwill@google.com>
Thu, 3 Aug 2017 18:19:53 +0000 (11:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Aug 2017 20:11:01 +0000 (13:11 -0700)
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>
builtin/checkout.c
submodule.c
unpack-trees.c
index 9661e1bcba31ffa4f7b8a2fb1a9d2060cb8efda7..246e0cd166b7fc888f9aa70736a02e5bf153b028 100644 (file)
@@ -858,7 +858,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
        }
 
        if (starts_with(var, "submodule."))
        }
 
        if (starts_with(var, "submodule."))
-               return submodule_config(var, value, NULL);
+               return git_default_submodule_config(var, value, NULL);
 
        return git_xmerge_config(var, value, NULL);
 }
 
        return git_xmerge_config(var, value, NULL);
 }
index a32043893bd294f8ecd02c58d0ac6dfbfb356273..f913c234151cd69920c28b8edb0c3f8884fb27ab 100644 (file)
@@ -235,7 +235,6 @@ void load_submodule_cache(void)
                return;
 
        gitmodules_config();
                return;
 
        gitmodules_config();
-       git_config(submodule_config, NULL);
 }
 
 static int gitmodules_cb(const char *var, const char *value, void *data)
 }
 
 static int gitmodules_cb(const char *var, const char *value, void *data)
index 05335fe5bf285f575878440397d641137a8abbd7..5dce7ff7d41aa32d28a7d6b4314746896944d1de 100644 (file)
@@ -255,28 +255,17 @@ static int check_submodule_move_head(const struct cache_entry *ce,
 {
        unsigned flags = SUBMODULE_MOVE_HEAD_DRY_RUN;
        const struct submodule *sub = submodule_from_ce(ce);
 {
        unsigned flags = SUBMODULE_MOVE_HEAD_DRY_RUN;
        const struct submodule *sub = submodule_from_ce(ce);
+
        if (!sub)
                return 0;
 
        if (o->reset)
                flags |= SUBMODULE_MOVE_HEAD_FORCE;
 
        if (!sub)
                return 0;
 
        if (o->reset)
                flags |= SUBMODULE_MOVE_HEAD_FORCE;
 
-       switch (sub->update_strategy.type) {
-       case SM_UPDATE_UNSPECIFIED:
-       case SM_UPDATE_CHECKOUT:
-               if (submodule_move_head(ce->name, old_id, new_id, flags))
-                       return o->gently ? -1 :
-                               add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name);
-               return 0;
-       case SM_UPDATE_NONE:
-               return 0;
-       case SM_UPDATE_REBASE:
-       case SM_UPDATE_MERGE:
-       case SM_UPDATE_COMMAND:
-       default:
-               warning(_("submodule update strategy not supported for submodule '%s'"), ce->name);
-               return -1;
-       }
+       if (submodule_move_head(ce->name, old_id, new_id, flags))
+               return o->gently ? -1 :
+                                  add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name);
+       return 0;
 }
 
 static void reload_gitmodules_file(struct index_state *index,
 }
 
 static void reload_gitmodules_file(struct index_state *index,
@@ -293,7 +282,6 @@ static void reload_gitmodules_file(struct index_state *index,
                                submodule_free();
                                checkout_entry(ce, state, NULL);
                                gitmodules_config();
                                submodule_free();
                                checkout_entry(ce, state, NULL);
                                gitmodules_config();
-                               git_config(submodule_config, NULL);
                        } else
                                break;
                }
                        } else
                                break;
                }
@@ -308,19 +296,9 @@ static void unlink_entry(const struct cache_entry *ce)
 {
        const struct submodule *sub = submodule_from_ce(ce);
        if (sub) {
 {
        const struct submodule *sub = submodule_from_ce(ce);
        if (sub) {
-               switch (sub->update_strategy.type) {
-               case SM_UPDATE_UNSPECIFIED:
-               case SM_UPDATE_CHECKOUT:
-               case SM_UPDATE_REBASE:
-               case SM_UPDATE_MERGE:
-                       /* state.force is set at the caller. */
-                       submodule_move_head(ce->name, "HEAD", NULL,
-                                           SUBMODULE_MOVE_HEAD_FORCE);
-                       break;
-               case SM_UPDATE_NONE:
-               case SM_UPDATE_COMMAND:
-                       return; /* Do not touch the submodule. */
-               }
+               /* state.force is set at the caller. */
+               submodule_move_head(ce->name, "HEAD", NULL,
+                                   SUBMODULE_MOVE_HEAD_FORCE);
        }
        if (!check_leading_path(ce->name, ce_namelen(ce)))
                return;
        }
        if (!check_leading_path(ce->name, ce_namelen(ce)))
                return;