Skip to content

Commit 75df9df

Browse files
chooglengitster
authored andcommitted
submodule--helper: reduce logic in run_update_procedure()
A later commit will combine the "update-clone" and "run-update-procedure" commands, so run_update_procedure() will be removed. Prepare for this by moving as much logic as possible out of run_update_procedure() and into update_submodule2(). Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c9911c9 commit 75df9df

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

builtin/submodule--helper.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,6 @@ static int update_clone(int argc, const char **argv, const char *prefix)
26112611

26122612
static int run_update_procedure(int argc, const char **argv, const char *prefix)
26132613
{
2614-
char *prefixed_path;
26152614
struct update_data update_data = UPDATE_DATA_INIT;
26162615

26172616
struct option options[] = {
@@ -2653,18 +2652,6 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix)
26532652

26542653
update_data.sm_path = argv[0];
26552654

2656-
if (update_data.recursive_prefix)
2657-
prefixed_path = xstrfmt("%s%s", update_data.recursive_prefix, update_data.sm_path);
2658-
else
2659-
prefixed_path = xstrdup(update_data.sm_path);
2660-
2661-
update_data.displaypath = get_submodule_displaypath(prefixed_path, prefix);
2662-
2663-
determine_submodule_update_strategy(the_repository, update_data.just_cloned,
2664-
update_data.sm_path, update_data.update_default,
2665-
&update_data.update_strategy);
2666-
2667-
free(prefixed_path);
26682655
return update_submodule2(&update_data);
26692656
}
26702657

@@ -3044,7 +3031,24 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)
30443031
/* NEEDSWORK: this is a temporary name until we delete update_submodule() */
30453032
static int update_submodule2(struct update_data *update_data)
30463033
{
3034+
char *prefixed_path;
3035+
30473036
ensure_core_worktree(update_data->sm_path);
3037+
3038+
if (update_data->recursive_prefix)
3039+
prefixed_path = xstrfmt("%s%s", update_data->recursive_prefix,
3040+
update_data->sm_path);
3041+
else
3042+
prefixed_path = xstrdup(update_data->sm_path);
3043+
3044+
update_data->displaypath = get_submodule_displaypath(prefixed_path,
3045+
update_data->prefix);
3046+
free(prefixed_path);
3047+
3048+
determine_submodule_update_strategy(the_repository, update_data->just_cloned,
3049+
update_data->sm_path, update_data->update_default,
3050+
&update_data->update_strategy);
3051+
30483052
if (update_data->just_cloned)
30493053
oidcpy(&update_data->suboid, null_oid());
30503054
else if (resolve_gitlink_ref(update_data->sm_path, "HEAD", &update_data->suboid))

0 commit comments

Comments
 (0)