submodule--helper update: don't override 'checkout' exit code
When "git submodule update" runs it might call "checkout", "merge", "rebase", or a custom command. Ever since run_update_command() was added inc51f8f94e5
(submodule--helper: run update procedures from C, 2021-08-24) we'd either exit immediately if the "submodule.<name>.update" method failed, or in the case of "checkout" continue trying to update other submodules. This code used to use the magical "2" return code, but in55b3f12cb5
(submodule update: use die_message(), 2022-03-15) it was made to exit(128), which in preceding commits has been changed to return that 128 code to the top-level. Let's "libify" this code even more by not having it arbitrarily override the return code. In practice this doesn't change anything as the code "git checkout" would return on any normal failure is "1", but we'll now in principle properly abort the operation if "git checkout" were to exit with 128. It would make sense to follow-up this change with a change to allow the "submodule.<name>.update = !..." (SM_UPDATE_COMMAND) method the same liberties as "checkout", and perhaps to do the same with a failed "merge" or "rebase". But let's leave that for now. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d905d4432f
commit
a03c01de2f
@ -2133,6 +2133,7 @@ static int run_update_command(const struct update_data *ud, int subforce)
|
||||
{
|
||||
struct child_process cp = CHILD_PROCESS_INIT;
|
||||
char *oid = oid_to_hex(&ud->oid);
|
||||
int ret;
|
||||
|
||||
switch (ud->update_strategy.type) {
|
||||
case SM_UPDATE_CHECKOUT:
|
||||
@ -2165,15 +2166,12 @@ static int run_update_command(const struct update_data *ud, int subforce)
|
||||
|
||||
cp.dir = xstrdup(ud->sm_path);
|
||||
prepare_submodule_repo_env(&cp.env);
|
||||
if (run_command(&cp)) {
|
||||
int ret;
|
||||
|
||||
if ((ret = run_command(&cp))) {
|
||||
switch (ud->update_strategy.type) {
|
||||
case SM_UPDATE_CHECKOUT:
|
||||
die_message(_("Unable to checkout '%s' in submodule path '%s'"),
|
||||
oid, ud->displaypath);
|
||||
/* the command failed, but update must continue */
|
||||
ret = 1;
|
||||
/* No "ret" assignment, use "git checkout"'s */
|
||||
break;
|
||||
case SM_UPDATE_REBASE:
|
||||
ret = die_message(_("Unable to rebase '%s' in submodule path '%s'"),
|
||||
@ -2496,7 +2494,6 @@ static int update_submodules(struct update_data *update_data)
|
||||
ret = code;
|
||||
if (ret == 128)
|
||||
goto cleanup;
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
Loading…
Reference in New Issue
Block a user