Skip to content

Commit 53cb210

Browse files
committed
Merge branch 'ab/send-email-validate-errors-fix'
* ab/send-email-validate-errors-fix: send-email: fix missing error message regression
2 parents de88ac7 + 5b719b7 commit 53cb210

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

git-send-email.perl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,18 @@ sub system_or_msg {
219219
my $exit_code = $? >> 8;
220220
return unless $signalled or $exit_code;
221221

222+
my @sprintf_args = ($args->[0], $exit_code);
223+
if (defined $msg) {
224+
# Quiet the 'redundant' warning category, except we
225+
# need to support down to Perl 5.8, so we can't do a
226+
# "no warnings 'redundant'", since that category was
227+
# introduced in perl 5.22, and asking for it will die
228+
# on older perls.
229+
no warnings;
230+
return sprintf($msg, @sprintf_args);
231+
}
222232
return sprintf(__("fatal: command '%s' died with exit code %d"),
223-
$args->[0], $exit_code);
233+
@sprintf_args);
224234
}
225235

226236
sub system_or_die {

t/t9001-send-email.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,14 +644,33 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
644644
test_cmp expect actual
645645
'
646646

647+
test_set_editor "$(pwd)/fake-editor"
648+
649+
test_expect_success $PREREQ 'setup erroring fake editor' '
650+
write_script fake-editor <<-\EOF
651+
echo >&2 "I am about to error"
652+
exit 1
653+
EOF
654+
'
655+
656+
test_expect_success $PREREQ 'fake editor dies with error' '
657+
clean_fake_sendmail &&
658+
test_must_fail git send-email \
659+
--compose --subject foo \
660+
--from="Example <[email protected]>" \
661+
662+
--smtp-server="$(pwd)/fake.sendmail" \
663+
$patches 2>err &&
664+
grep "I am about to error" err &&
665+
grep "the editor exited uncleanly, aborting everything" err
666+
'
667+
647668
test_expect_success $PREREQ 'setup fake editor' '
648669
write_script fake-editor <<-\EOF
649670
echo fake edit >>"$1"
650671
EOF
651672
'
652673

653-
test_set_editor "$(pwd)/fake-editor"
654-
655674
test_expect_success $PREREQ '--compose works' '
656675
clean_fake_sendmail &&
657676
git send-email \

0 commit comments

Comments
 (0)