From 3ece9bf0f9e24909b090cf348d89e8920bd4f82f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 May 2023 14:10:39 -0700 Subject: send-email: clear the $message_id after validation Recently git-send-email started parsing the same message twice, once to validate _all_ the message before sending even the first one, and then after the validation hook is happy and each message gets sent, to read the contents to find out where to send to etc. Unfortunately, the effect of reading the messages for validation lingered even after the validation is done. Namely $message_id gets assigned if exists in the input files but the variable is global, and it is not cleared before pre_process_file runs. This causes reading a message without a message-id followed by reading a message with a message-id to misbehave---the sub reports as if the message had the same id as the previously written one. Clear the variable before starting to read the headers in pre_process_file. Tested-by: Douglas Anderson Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 10c450ef68..37dfd4b8c5 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -1768,6 +1768,8 @@ sub pre_process_file { $subject = $initial_subject; $message = ""; $message_num++; + undef $message_id; + # First unfold multiline header fields while(<$fh>) { last if /^\s*$/; -- cgit v1.2.3