All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Johannes Sixt" <j6t@kdbg.org>,
	"Johannes Schindelin" <johannes.schindelin@gmx.de>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Robert Foss" <robert.foss@linaro.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 1/2] send-email: fix missing error message regression
Date: Tue, 25 May 2021 01:14:24 +0200	[thread overview]
Message-ID: <patch-1.2-df3a2b8562d-20210524T231047Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-0.2-00000000000-20210524T231047Z-avarab@gmail.com>

Fix a regression with the "the editor exited uncleanly, aborting
everything" error message going missing after my
d21616c0394 (git-send-email: refactor duplicate $? checks into a
function, 2021-04-06).

I introduced a $msg variable, but did not actually use it. This caused
us to miss the optional error message supplied by the "do_edit"
codepath. Fix that, and add tests to check that this works.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 git-send-email.perl   | 12 +++++++++++-
 t/t9001-send-email.sh | 23 +++++++++++++++++++++--
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 175da07d946..170f42fe210 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -219,8 +219,18 @@ sub system_or_msg {
 	my $exit_code = $? >> 8;
 	return unless $signalled or $exit_code;
 
+	my @sprintf_args = ($args->[0], $exit_code);
+	if (defined $msg) {
+		# Quiet the 'redundant' warning category, except we
+		# need to support down to Perl 5.8, so we can't do a
+		# "no warnings 'redundant'", since that category was
+		# introduced in perl 5.22, and asking for it will die
+		# on older perls.
+		no warnings;
+		return sprintf($msg, @sprintf_args);
+	}
 	return sprintf(__("fatal: command '%s' died with exit code %d"),
-		       $args->[0], $exit_code);
+		       @sprintf_args);
 }
 
 sub system_or_die {
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 65b30353719..2acf389837c 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -644,14 +644,33 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
 	test_cmp expect actual
 '
 
+test_set_editor "$(pwd)/fake-editor"
+
+test_expect_success $PREREQ 'setup erroring fake editor' '
+	write_script fake-editor <<-\EOF
+	echo >&2 "I am about to error"
+	exit 1
+	EOF
+'
+
+test_expect_success $PREREQ 'fake editor dies with error' '
+	clean_fake_sendmail &&
+	test_must_fail git send-email \
+		--compose --subject foo \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		$patches 2>err &&
+	grep "I am about to error" err &&
+	grep "the editor exited uncleanly, aborting everything" err
+'
+
 test_expect_success $PREREQ 'setup fake editor' '
 	write_script fake-editor <<-\EOF
 	echo fake edit >>"$1"
 	EOF
 '
 
-test_set_editor "$(pwd)/fake-editor"
-
 test_expect_success $PREREQ '--compose works' '
 	clean_fake_sendmail &&
 	git send-email \
-- 
2.32.0.rc1.385.g9db524b96f7


  reply	other threads:[~2021-05-24 23:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 19:38 [PATCH] t9001-send-email.sh: fix expected absolute paths on Windows Johannes Sixt
2021-05-24 20:26 ` Jonathan Nieder
2021-05-24 22:15 ` Ævar Arnfjörð Bjarmason
2021-05-24 23:15   ` Ævar Arnfjörð Bjarmason
2021-05-24 23:14 ` [PATCH 0/2] send-email: pre-release fixes for v2.32.0 Ævar Arnfjörð Bjarmason
2021-05-24 23:14   ` Ævar Arnfjörð Bjarmason [this message]
2021-05-24 23:14   ` [PATCH 2/2] send-email: don't needlessly abs_path() the core.hooksPath Ævar Arnfjörð Bjarmason
2021-05-25  1:03     ` Junio C Hamano
2021-05-25  5:57       ` Ævar Arnfjörð Bjarmason
2021-05-25  6:13         ` Ævar Arnfjörð Bjarmason
2021-05-25  6:21           ` Robert Foss
2021-05-25  6:21         ` Junio C Hamano
2021-05-25 12:09           ` Ævar Arnfjörð Bjarmason
2021-05-25 19:28             ` Junio C Hamano
2021-05-26 11:21               ` [PATCH v2 0/2] " Ævar Arnfjörð Bjarmason
2021-05-26 11:21                 ` [PATCH v2 1/2] " Ævar Arnfjörð Bjarmason
2021-05-26 11:21                 ` [PATCH v2 2/2] send-email: move "hooks_path" invocation to git-send-email.perl Ævar Arnfjörð Bjarmason
2021-05-26  1:22         ` [PATCH 2/2] send-email: don't needlessly abs_path() the core.hooksPath Felipe Contreras
2021-05-25  6:10       ` Robert Foss
2021-06-02 11:40 ` [PATCH] t9001-send-email.sh: fix expected absolute paths on Windows Johannes Schindelin

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=patch-1.2-df3a2b8562d-20210524T231047Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=jrnieder@gmail.com \
    --cc=robert.foss@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.