From: Glen Choo <chooglen@xxxxxxxxxx> Refactor builtin/submodule--helper.c:update_submodule() to check if the submodule is up to date using a variable instead of checking the oids directly. In a subsequent commit, we will expand the definition of "up to date" to include checked out branches. Signed-off-by: Glen Choo <chooglen@xxxxxxxxxx> --- builtin/submodule--helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index dd00a0db522..cbf6bda4850 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2455,6 +2455,8 @@ static void update_data_to_args(struct update_data *update_data, struct strvec * static int update_submodule(struct update_data *update_data) { + int submodule_up_to_date; + ensure_core_worktree(update_data->sm_path); update_data->displaypath = get_submodule_displaypath( @@ -2491,7 +2493,8 @@ static int update_submodule(struct update_data *update_data) free(remote_ref); } - if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force) + submodule_up_to_date = oideq(&update_data->oid, &update_data->suboid); + if (!submodule_up_to_date || update_data->force) if (run_update_procedure(update_data)) return 1; -- gitgitgadget