[PATCH 5/6] submodule--helper: refactor up-to-date criterion
- From
Glen Choo via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Aug 29, 2022, 20:54 UTC
- Message-ID
- <513d18e56d3b60d1b522af212fb8b7be232992d4.1661806456.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1321.git.git.1661806456.gitgitgadget@gmail.com>
From: Glen Choo <chooglen@google.com>
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@google.com> --- 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