Skip to content

Commit d905d44

Browse files
avargitster
authored andcommitted
submodule--helper: libify "must_die_on_failure" code paths
In preceding commits the codepaths around update_submodules() were changed from using exit() or die() to ferrying up a "must_die_on_failure" in the cases where we'd exit(), and in most cases where we'd die(). We needed to do this this to ensure that we'd early exit or otherwise abort the update_submodules() processing before it was completed. Now that those preceding changes have shown that we've converted those paths, we can remove the remaining "ret == 128" special-cases, leaving the only such special-case in update_submodules(). I.e. we now know after having gone through the various codepaths that we were only returning 128 if we meant to early abort. In update_submodules() we'll for now set any non-zero non-128 exit codes to "1", but will start ferrying up the exit code as-is in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Reviewed-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 484f915 commit d905d44

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

builtin/submodule--helper.c

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,8 +2129,7 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet,
21292129
return run_command(&cp);
21302130
}
21312131

2132-
static int run_update_command(const struct update_data *ud, int subforce,
2133-
int *must_die_on_failure)
2132+
static int run_update_command(const struct update_data *ud, int subforce)
21342133
{
21352134
struct child_process cp = CHILD_PROCESS_INIT;
21362135
char *oid = oid_to_hex(&ud->oid);
@@ -2193,8 +2192,6 @@ static int run_update_command(const struct update_data *ud, int subforce,
21932192
ud->update_strategy.type);
21942193
}
21952194

2196-
if (ret == 128)
2197-
*must_die_on_failure = 1;
21982195
return ret;
21992196
}
22002197

@@ -2226,8 +2223,7 @@ static int run_update_command(const struct update_data *ud, int subforce,
22262223
return 0;
22272224
}
22282225

2229-
static int run_update_procedure(const struct update_data *ud,
2230-
int *must_die_on_failure)
2226+
static int run_update_procedure(const struct update_data *ud)
22312227
{
22322228
int subforce = is_null_oid(&ud->suboid) || ud->force;
22332229

@@ -2254,7 +2250,7 @@ static int run_update_procedure(const struct update_data *ud,
22542250
ud->displaypath, oid_to_hex(&ud->oid));
22552251
}
22562252

2257-
return run_update_command(ud, subforce, must_die_on_failure);
2253+
return run_update_command(ud, subforce);
22582254
}
22592255

22602256
static const char *remote_submodule_branch(const char *path)
@@ -2391,8 +2387,7 @@ static void update_data_to_args(const struct update_data *update_data,
23912387
"--no-single-branch");
23922388
}
23932389

2394-
static int update_submodule(struct update_data *update_data,
2395-
int *must_die_on_failure)
2390+
static int update_submodule(struct update_data *update_data)
23962391
{
23972392
int ret;
23982393

@@ -2406,10 +2401,8 @@ static int update_submodule(struct update_data *update_data,
24062401
update_data->sm_path,
24072402
update_data->update_default,
24082403
&update_data->update_strategy);
2409-
if (ret) {
2410-
*must_die_on_failure = 1;
2404+
if (ret)
24112405
return ret;
2412-
}
24132406

24142407
if (update_data->just_cloned)
24152408
oidcpy(&update_data->suboid, null_oid());
@@ -2437,11 +2430,9 @@ static int update_submodule(struct update_data *update_data,
24372430
}
24382431

24392432
if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force) {
2440-
ret = run_update_procedure(update_data, must_die_on_failure);
2441-
if (*must_die_on_failure)
2442-
return ret;
2433+
ret = run_update_procedure(update_data);
24432434
if (ret)
2444-
return 1;
2435+
return ret;
24452436
}
24462437

24472438
if (update_data->recursive) {
@@ -2458,12 +2449,9 @@ static int update_submodule(struct update_data *update_data,
24582449
update_data_to_args(&next, &cp.args);
24592450

24602451
ret = run_command(&cp);
2461-
if (!ret)
2462-
return 0;
2463-
die_message(_("Failed to recurse into submodule path '%s'"),
2464-
update_data->displaypath);
2465-
if (ret == 128)
2466-
*must_die_on_failure = 1;
2452+
if (ret)
2453+
die_message(_("Failed to recurse into submodule path '%s'"),
2454+
update_data->displaypath);
24672455
return ret;
24682456
}
24692457

@@ -2496,20 +2484,19 @@ static int update_submodules(struct update_data *update_data)
24962484

24972485
for (i = 0; i < suc.update_clone_nr; i++) {
24982486
struct update_clone_data ucd = suc.update_clone[i];
2499-
int must_die_on_failure = 0;
25002487
int code;
25012488

25022489
oidcpy(&update_data->oid, &ucd.oid);
25032490
update_data->just_cloned = ucd.just_cloned;
25042491
update_data->sm_path = ucd.sub->path;
25052492

2506-
code = update_submodule(update_data, &must_die_on_failure);
2507-
if (code)
2508-
ret = code;
2509-
if (must_die_on_failure)
2493+
code = update_submodule(update_data);
2494+
if (!code)
2495+
continue;
2496+
ret = code;
2497+
if (ret == 128)
25102498
goto cleanup;
2511-
else if (code)
2512-
ret = 1;
2499+
ret = 1;
25132500
}
25142501

25152502
cleanup:

0 commit comments

Comments
 (0)