From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 7EF031F8C6 for ; Wed, 15 Sep 2021 17:00:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbhIORBx (ORCPT ); Wed, 15 Sep 2021 13:01:53 -0400 Received: from mout01.posteo.de ([185.67.36.65]:45855 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230024AbhIORBv (ORCPT ); Wed, 15 Sep 2021 13:01:51 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id C4959240027 for ; Wed, 15 Sep 2021 19:00:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1631725229; bh=658/FDCpxdGerlnMJMddesdESAhzOISDHeTvLJRLf9c=; h=Subject:To:Cc:From:Date:From; b=QRopeS1P5+ZpVtrJ/sPTQLjk//f8KPvao1z0zZodSWJ+tho0N5xZcYAnz2gs6RNwM XvjIJgsiMHNykSgji6v7xZi5aU6MTdeaI21nvcpW9OQfTPB5wNWeXvreP4dMAauSA8 GgTjXYVmjZHTkzKlGJVkB5cl0I5+8+zweLbMhjh0NpFXkLDUe4Z8Zr3OLNr64S3x8b gnagfV7taMRjGduTh3iHKQaecQ84WKwgHQikBBHVqtJCHoRuVh3kAAgJ5/7jKqQrP1 OfEbhjEj7vKc0AEP/Acfu6Gki7XoTUkd0xQzRXa+kaRE8xPbqF4vZZKuQYjZOdX3VQ nN9zei5bC87PA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4H8mgH0Qjcz6tmH; Wed, 15 Sep 2021 19:00:27 +0200 (CEST) Subject: Re: [PATCH] send-email: Avoid incorrect header propagation To: git@vger.kernel.org Cc: =?UTF-8?Q?Carlo_Marcelo_Arenas_Bel=c3=b3n?= , Jeff King , Junio C Hamano , Drew DeVault , Simon Ser , xiaoqiang zhao , Jonathan Tan , Christian Ludwig References: <20210830153001.29961-1-mhaeuser@posteo.de> From: =?UTF-8?Q?Marvin_H=c3=a4user?= Message-ID: <0c753ae6-cc2c-2d70-c510-5370a0b4dcf9@posteo.de> Date: Wed, 15 Sep 2021 17:00:26 +0000 MIME-Version: 1.0 In-Reply-To: <20210830153001.29961-1-mhaeuser@posteo.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Ping? :) On 30/08/2021 17:30, Marvin Häuser wrote: > If multiple independent patches are sent with send-email, even if the > "In-Reply-To" and "References" headers are not managed by --thread or > --in-reply-to, their values may be propagated from prior patches to > subsequent patches with no such headers defined. > > To mitigate this and potential future issues, make sure all global > patch-specific variables are always either handled by > command-specific code (e.g. threading), or are reset to their default > values for every iteration. > > Signed-off-by: Jeff King > Signed-off-by: Marvin Häuser > --- > git-send-email.perl | 26 ++++++++++++++++--------- > t/t9001-send-email.sh | 45 +++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 62 insertions(+), 9 deletions(-) > > diff --git a/git-send-email.perl b/git-send-email.perl > index 25be2ebd2a..e411860b18 100755 > --- a/git-send-email.perl > +++ b/git-send-email.perl > @@ -1625,7 +1625,6 @@ sub send_message { > > $in_reply_to = $initial_in_reply_to; > $references = $initial_in_reply_to || ''; > -$subject = $initial_subject; > $message_num = 0; > > # Prepares the email, prompts the user, sends it out > @@ -1648,6 +1647,7 @@ sub process_file { > @xh = (); > my $input_format = undef; > my @header = (); > + $subject = $initial_subject; > $message = ""; > $message_num++; > # First unfold multiline header fields > @@ -1854,15 +1854,23 @@ sub process_file { > } > > # set up for the next message > - if ($thread && $message_was_sent && > - ($chain_reply_to || !defined $in_reply_to || length($in_reply_to) == 0 || > - $message_num == 1)) { > - $in_reply_to = $message_id; > - if (length $references > 0) { > - $references .= "\n $message_id"; > - } else { > - $references = "$message_id"; > + if ($thread) { > + if ($message_was_sent && > + ($chain_reply_to || !defined $in_reply_to || length($in_reply_to) == 0 || > + $message_num == 1)) { > + $in_reply_to = $message_id; > + if (length $references > 0) { > + $references .= "\n $message_id"; > + } else { > + $references = "$message_id"; > + } > } > + } elsif (!defined $initial_in_reply_to) { > + # --thread and --in-reply-to manage the "In-Reply-To" header and by > + # extension the "References" header. If these commands are not used, reset > + # the header values to their defaults. > + $in_reply_to = undef; > + $references = ''; > } > $message_id = undef; > $num_sent++; > diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh > index 3b7540050c..f95177af39 100755 > --- a/t/t9001-send-email.sh > +++ b/t/t9001-send-email.sh > @@ -2167,6 +2167,51 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' ' > test_cmp expected-list actual-list > ' > > +test_expect_success $PREREQ 'set up in-reply-to/references patches' ' > + cat >has-reply.patch <<-\EOF && > + From: A U Thor > + Subject: patch with in-reply-to > + Message-ID: > + In-Reply-To: > + References: > + > + This is the body. > + EOF > + cat >no-reply.patch <<-\EOF > + From: A U Thor > + Subject: patch without in-reply-to > + Message-ID: > + > + This is the body. > + EOF > +' > + > +test_expect_success $PREREQ 'patch reply headers correct with --no-thread' ' > + clean_fake_sendmail && > + git send-email \ > + --no-thread \ > + --to=nobody@example.com \ > + --smtp-server="$(pwd)/fake.sendmail" \ > + has-reply.patch no-reply.patch && > + grep "In-Reply-To: " msgtxt1 && > + grep "References: " msgtxt1 && > + ! grep replied.to@example.com msgtxt2 > +' > + > +test_expect_success $PREREQ 'cmdline in-reply-to used with --no-thread' ' > + clean_fake_sendmail && > + git send-email \ > + --no-thread \ > + --in-reply-to="" \ > + --to=nobody@example.com \ > + --smtp-server="$(pwd)/fake.sendmail" \ > + has-reply.patch no-reply.patch && > + grep "In-Reply-To: " msgtxt1 && > + grep "References: " msgtxt1 && > + grep "In-Reply-To: " msgtxt2 && > + grep "References: " msgtxt2 > +' > + > test_expect_success $PREREQ 'invoke hook' ' > mkdir -p .git/hooks && >