diff mbox series

[5/6] submodule--helper: refactor up-to-date criterion

Message ID 513d18e56d3b60d1b522af212fb8b7be232992d4.1661806456.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series clone, submodule update: check out submodule branches | expand

Commit Message

Glen Choo Aug. 29, 2022, 8:54 p.m. UTC
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 mbox series

Patch

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;