Skip to content

Commit 55b3f12

Browse files
chooglengitster
authored andcommitted
submodule update: use die_message()
Use die_message() to print the "fatal: " prefix instead of doing it in git-submodule.sh and remove a now-unnecessary exit code from "git submodule--helper run-update-procedure". Also, since die_message() adds the newline for us, replace an invocation of die_with_status() with printf + exit invocations that do not add a newline, but are otherwise identical to die_with_status(). Helped-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c3558f commit 55b3f12

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

builtin/submodule--helper.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,40 +2366,35 @@ static int run_update_command(struct update_data *ud, int subforce)
23662366
if (run_command(&cp)) {
23672367
switch (ud->update_strategy.type) {
23682368
case SM_UPDATE_CHECKOUT:
2369-
printf(_("Unable to checkout '%s' in submodule path '%s'"),
2370-
oid, ud->displaypath);
2369+
die_message(_("Unable to checkout '%s' in submodule path '%s'"),
2370+
oid, ud->displaypath);
23712371
break;
23722372
case SM_UPDATE_REBASE:
2373-
printf(_("Unable to rebase '%s' in submodule path '%s'"),
2374-
oid, ud->displaypath);
2373+
die_message(_("Unable to rebase '%s' in submodule path '%s'"),
2374+
oid, ud->displaypath);
23752375
break;
23762376
case SM_UPDATE_MERGE:
2377-
printf(_("Unable to merge '%s' in submodule path '%s'"),
2378-
oid, ud->displaypath);
2377+
die_message(_("Unable to merge '%s' in submodule path '%s'"),
2378+
oid, ud->displaypath);
23792379
break;
23802380
case SM_UPDATE_COMMAND:
2381-
printf(_("Execution of '%s %s' failed in submodule path '%s'"),
2382-
ud->update_strategy.command, oid, ud->displaypath);
2381+
die_message(_("Execution of '%s %s' failed in submodule path '%s'"),
2382+
ud->update_strategy.command, oid, ud->displaypath);
23832383
break;
23842384
default:
23852385
BUG("unexpected update strategy type: %s",
23862386
submodule_strategy_to_string(&ud->update_strategy));
23872387
}
2388-
/*
2389-
* NEEDSWORK: We are currently printing to stdout with error
2390-
* return so that the shell caller handles the error output
2391-
* properly. Once we start handling the error messages within
2392-
* C, we should use die() instead.
2393-
*/
23942388
if (must_die_on_failure)
2395-
return 2;
2396-
/*
2397-
* This signifies to the caller in shell that the command
2398-
* failed without dying
2399-
*/
2389+
exit(128);
2390+
2391+
/* the command failed, but update must continue */
24002392
return 1;
24012393
}
24022394

2395+
if (ud->quiet)
2396+
return 0;
2397+
24032398
switch (ud->update_strategy.type) {
24042399
case SM_UPDATE_CHECKOUT:
24052400
printf(_("Submodule path '%s': checked out '%s'\n"),

git-submodule.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,20 @@ cmd_update()
404404
# exit codes for run-update-procedure:
405405
# 0: update was successful, say command output
406406
# 1: update procedure failed, but should not die
407-
# 2 or 128: subcommand died during execution
407+
# 128: subcommand died during execution
408408
# 3: no update procedure was run
409409
res="$?"
410410
case $res in
411411
0)
412412
say "$out"
413413
;;
414414
1)
415-
err="${err};fatal: $out"
415+
err="${err};$out"
416416
continue
417417
;;
418-
2|128)
419-
die_with_status $res "fatal: $out"
418+
128)
419+
printf >&2 "$out"
420+
exit $res
420421
;;
421422
esac
422423

0 commit comments

Comments
 (0)