Skip to content

Commit 1a0b78c

Browse files
chooglengitster
authored andcommitted
submodule--helper: reorganize code for sh to C conversion
Introduce a function, update_submodule2(), that will implement the functionality of run-update-procedure and its surrounding shell code in submodule.sh. This name is temporary; it will replace update_submodule() when the sh to C conversion is complete. Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f7bdb32 commit 1a0b78c

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

builtin/submodule--helper.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,16 @@ static int do_run_update_procedure(struct update_data *ud)
24522452
return run_update_command(ud, subforce);
24532453
}
24542454

2455+
/*
2456+
* NEEDSWORK: As we convert "git submodule update" to C,
2457+
* update_submodule2() will invoke more and more functions, making it
2458+
* difficult to preserve the function ordering without forward
2459+
* declarations.
2460+
*
2461+
* When the conversion is complete, this forward declaration will be
2462+
* unnecessary and should be removed.
2463+
*/
2464+
static int update_submodule2(struct update_data *update_data);
24552465
static void update_submodule(struct update_clone_data *ucd)
24562466
{
24572467
fprintf(stdout, "dummy %s %d\t%s\n",
@@ -2618,11 +2628,7 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix)
26182628
&update_data.update_strategy);
26192629

26202630
free(prefixed_path);
2621-
2622-
if (!oideq(&update_data.oid, &update_data.suboid) || update_data.force)
2623-
return do_run_update_procedure(&update_data);
2624-
2625-
return 3;
2631+
return update_submodule2(&update_data);
26262632
}
26272633

26282634
static int resolve_relative_path(int argc, const char **argv, const char *prefix)
@@ -3022,6 +3028,16 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)
30223028
force, reflog, quiet, track, dry_run);
30233029
return 0;
30243030
}
3031+
3032+
/* NEEDSWORK: this is a temporary name until we delete update_submodule() */
3033+
static int update_submodule2(struct update_data *update_data)
3034+
{
3035+
if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force)
3036+
return do_run_update_procedure(update_data);
3037+
3038+
return 3;
3039+
}
3040+
30253041
struct add_data {
30263042
const char *prefix;
30273043
const char *branch;

0 commit comments

Comments
 (0)