Skip to content

Commit b04671b

Browse files
committed
Merge branch 'jc/send-email-pre-process-fix'
When "git send-email" that uses the validate hook is fed a message without and then with Message-ID, it failed to auto-assign a unique Message-ID to the former and instead reused the Message-ID from the latter, which has been corrected. This was a fix for a recent regression caught before the release, so no need to mention it in the release notes. * jc/send-email-pre-process-fix: t9001: mark the script as no longer leak checker clean send-email: clear the $message_id after validation
2 parents 75ab1fa + 20bd08a commit b04671b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

git-send-email.perl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,7 @@ sub pre_process_file {
17881788
$subject = $initial_subject;
17891789
$message = "";
17901790
$message_num++;
1791+
undef $message_id;
17911792
# Retrieve and unfold header fields.
17921793
my @header_lines = ();
17931794
while(<$fh>) {

t/t9001-send-email.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test_description='git send-email'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7-
TEST_PASSES_SANITIZE_LEAK=true
7+
# no longer TEST_PASSES_SANITIZE_LEAK=true - format-patch --thread leaks
88
. ./test-lib.sh
99

1010
# May be altered later in the test
@@ -47,7 +47,7 @@ clean_fake_sendmail () {
4747

4848
test_expect_success $PREREQ 'Extract patches' '
4949
patches=$(git format-patch -s --cc="One <[email protected]>" [email protected] -n HEAD^1) &&
50-
threaded_patches=$(git format-patch -o threaded -s --in-reply-to="format" HEAD^1)
50+
threaded_patches=$(git format-patch -o threaded --thread=shallow -s --in-reply-to="format" HEAD^1)
5151
'
5252

5353
# Test no confirm early to ensure remaining tests will not hang
@@ -655,6 +655,21 @@ test_expect_success $PREREQ "--validate hook supports header argument" '
655655
outdir/000?-*.patch
656656
'
657657

658+
test_expect_success $PREREQ 'clear message-id before parsing a new message' '
659+
clean_fake_sendmail &&
660+
echo true | write_script my-hooks/sendemail-validate &&
661+
test_config core.hooksPath my-hooks &&
662+
GIT_SEND_EMAIL_NOTTY=1 \
663+
git send-email --validate [email protected] \
664+
--smtp-server="$(pwd)/fake.sendmail" \
665+
$patches $threaded_patches &&
666+
id0=$(grep "^Message-ID: " $threaded_patches) &&
667+
id1=$(grep "^Message-ID: " msgtxt1) &&
668+
id2=$(grep "^Message-ID: " msgtxt2) &&
669+
test "z$id0" = "z$id2" &&
670+
test "z$id1" != "z$id2"
671+
'
672+
658673
for enc in 7bit 8bit quoted-printable base64
659674
do
660675
test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '

0 commit comments

Comments
 (0)