From ec6141a0f290ba5a0cea2d15820be0223467e656 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 3 Aug 2017 11:19:50 -0700 Subject: submodule--helper: don't overlay config in update-clone Don't rely on overlaying the repository's config on top of the submodule-config, instead query the repository's config directly for the url and the update strategy configuration. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- submodule.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'submodule.c') diff --git a/submodule.c b/submodule.c index 19bd13bb2..8a9b964ce 100644 --- a/submodule.c +++ b/submodule.c @@ -398,24 +398,38 @@ void die_path_inside_submodule(const struct index_state *istate, } } -int parse_submodule_update_strategy(const char *value, - struct submodule_update_strategy *dst) +enum submodule_update_type parse_submodule_update_type(const char *value) { - free((void*)dst->command); - dst->command = NULL; if (!strcmp(value, "none")) - dst->type = SM_UPDATE_NONE; + return SM_UPDATE_NONE; else if (!strcmp(value, "checkout")) - dst->type = SM_UPDATE_CHECKOUT; + return SM_UPDATE_CHECKOUT; else if (!strcmp(value, "rebase")) - dst->type = SM_UPDATE_REBASE; + return SM_UPDATE_REBASE; else if (!strcmp(value, "merge")) - dst->type = SM_UPDATE_MERGE; - else if (skip_prefix(value, "!", &value)) { - dst->type = SM_UPDATE_COMMAND; - dst->command = xstrdup(value); - } else + return SM_UPDATE_MERGE; + else if (*value == '!') + return SM_UPDATE_COMMAND; + else + return SM_UPDATE_UNSPECIFIED; +} + +int parse_submodule_update_strategy(const char *value, + struct submodule_update_strategy *dst) +{ + enum submodule_update_type type; + + free((void*)dst->command); + dst->command = NULL; + + type = parse_submodule_update_type(value); + if (type == SM_UPDATE_UNSPECIFIED) return -1; + + dst->type = type; + if (type == SM_UPDATE_COMMAND) + dst->command = xstrdup(value + 1); + return 0; } -- cgit v1.2.1