From: Glen Choo <chooglen@google.com>
To: git@vger.kernel.org
Cc: "Glen Choo" <chooglen@google.com>,
"Junio C Hamano" <gitster@pobox.com>,
"Atharva Raykar" <raykar.ath@gmail.com>,
"Emily Shaffer" <emilyshaffer@google.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 2/7] submodule update: use die_message()
Date: Tue, 15 Mar 2022 14:09:20 -0700 [thread overview]
Message-ID: <20220315210925.79289-3-chooglen@google.com> (raw)
In-Reply-To: <20220315210925.79289-1-chooglen@google.com>
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 <avarab@gmail.com>
Signed-off-by: Glen Choo <chooglen@google.com>
---
This was spun out of
https://lore.kernel.org/git/patch-v5-9.9-e8e57606ee9-20220128T125206Z-avarab@gmail.com
builtin/submodule--helper.c | 33 ++++++++++++++-------------------
git-submodule.sh | 9 +++++----
2 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 95ef113d16..af1d90af7c 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2366,40 +2366,35 @@ static int run_update_command(struct update_data *ud, int subforce)
if (run_command(&cp)) {
switch (ud->update_strategy.type) {
case SM_UPDATE_CHECKOUT:
- printf(_("Unable to checkout '%s' in submodule path '%s'"),
- oid, ud->displaypath);
+ die_message(_("Unable to checkout '%s' in submodule path '%s'"),
+ oid, ud->displaypath);
break;
case SM_UPDATE_REBASE:
- printf(_("Unable to rebase '%s' in submodule path '%s'"),
- oid, ud->displaypath);
+ die_message(_("Unable to rebase '%s' in submodule path '%s'"),
+ oid, ud->displaypath);
break;
case SM_UPDATE_MERGE:
- printf(_("Unable to merge '%s' in submodule path '%s'"),
- oid, ud->displaypath);
+ die_message(_("Unable to merge '%s' in submodule path '%s'"),
+ oid, ud->displaypath);
break;
case SM_UPDATE_COMMAND:
- printf(_("Execution of '%s %s' failed in submodule path '%s'"),
- ud->update_strategy.command, oid, ud->displaypath);
+ die_message(_("Execution of '%s %s' failed in submodule path '%s'"),
+ ud->update_strategy.command, oid, ud->displaypath);
break;
default:
BUG("unexpected update strategy type: %s",
submodule_strategy_to_string(&ud->update_strategy));
}
- /*
- * NEEDSWORK: We are currently printing to stdout with error
- * return so that the shell caller handles the error output
- * properly. Once we start handling the error messages within
- * C, we should use die() instead.
- */
if (must_die_on_failure)
- return 2;
- /*
- * This signifies to the caller in shell that the command
- * failed without dying
- */
+ exit(128);
+
+ /* the command failed, but update must continue */
return 1;
}
+ if (ud->quiet)
+ return 0;
+
switch (ud->update_strategy.type) {
case SM_UPDATE_CHECKOUT:
printf(_("Submodule path '%s': checked out '%s'\n"),
diff --git a/git-submodule.sh b/git-submodule.sh
index aa8bdfca9d..a84143daab 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -404,7 +404,7 @@ cmd_update()
# exit codes for run-update-procedure:
# 0: update was successful, say command output
# 1: update procedure failed, but should not die
- # 2 or 128: subcommand died during execution
+ # 128: subcommand died during execution
# 3: no update procedure was run
res="$?"
case $res in
@@ -412,11 +412,12 @@ cmd_update()
say "$out"
;;
1)
- err="${err};fatal: $out"
+ err="${err};$out"
continue
;;
- 2|128)
- die_with_status $res "fatal: $out"
+ 128)
+ printf >&2 "$out"
+ exit $res
;;
esac
--
2.33.GIT
next prev parent reply other threads:[~2022-03-15 21:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-15 21:09 [PATCH 0/7] Finish converting "submodule update" to C Glen Choo
2022-03-15 21:09 ` [PATCH 1/7] submodule--helper: run update using child process struct Glen Choo
2022-03-15 21:09 ` Glen Choo [this message]
2022-03-15 21:09 ` [PATCH 3/7] builtin/submodule--helper.c: rename option struct to "opt" Glen Choo
2022-03-15 21:09 ` [PATCH 4/7] submodule--helper: teach update_data more options Glen Choo
2022-03-15 21:09 ` [PATCH 5/7] submodule--helper: reduce logic in run_update_procedure() Glen Choo
2022-03-15 21:09 ` [PATCH 6/7] submodule: move core cmd_update() logic to C Glen Choo
2022-03-15 21:09 ` [PATCH 7/7] submodule--helper: remove forward declaration Glen Choo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220315210925.79289-3-chooglen@google.com \
--to=chooglen@google.com \
--cc=avarab@gmail.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=raykar.ath@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).