git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luben Tuikov <luben.tuikov@amd.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Strawbridge, Michael" <Michael.Strawbridge@amd.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH v6 2/2] send-email: expose header information to git-send-email's sendemail-validate hook
Date: Wed, 18 Jan 2023 11:35:19 -0500	[thread overview]
Message-ID: <fa9b1371-0a61-147f-637e-cb09f775fe22@amd.com> (raw)
In-Reply-To: <xmqqv8l34xkp.fsf@gitster.g>

On 2023-01-18 11:27, Junio C Hamano wrote:
> Luben Tuikov <luben.tuikov@amd.com> writes:
> 
>> On 2023-01-17 02:31, Junio C Hamano wrote:
>>> Luben Tuikov <luben.tuikov@amd.com> writes:
>>>
>>>>> +test_expect_success $PREREQ "--validate hook supports header argument" '
>>>>> +	write_script my-hooks/sendemail-validate <<-\EOF &&
>>>>> +	if test -s "$2"
>>>>> +	then
>>>>> +		cat "$2" >actual
>>>>> +		exit 1
>>>>> +	fi
>>>>> +	EOF
>>>
>>> If "$2" is not given, or an empty "$2" is given, is that an error?
>>> I am wondering if the lack of "else" clause (and the hook exits with
>>> success when "$2" is an empty file) here is intentional.
>>
>> I think we'll always have a $2, since it is the SMTP envelope and headers.
> 
> We write our tests to verify _that_ assumption you have.  A future
> developer mistakenly drops the code to append the file to the
> command line that invokes the hook, and we want our test to catch
> such a mistake.
> 
> Do we really feed envelope?  E.g. if the --envelope-sender=<who> is
> used, does $2 have the "From:" from the header and "MAIL TO" from
> the envelope separately?

I'm not sure--I thought we did, but yes, we should _test_ that we indeed
1) have/get $2, as a non-empty string,
2) it is a non-empty, readable file,
3) contains the test header we included in git-format-patch in the test.

This is what I meant when I wrote "we'll always have $2 ...", not having it
is failure of some kind and yes we should test for it.
-- 
Regards,
Luben


  reply	other threads:[~2023-01-18 16:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17  1:39 [PATCH v6 0/2] send-email: expose header information to git-send-email's sendemail-validate hook Strawbridge, Michael
2023-01-17  1:39 ` [PATCH v6 1/2] send-email: refactor header generation functions Strawbridge, Michael
2023-01-17  3:38   ` Luben Tuikov
2023-01-17  4:13   ` Luben Tuikov
2023-01-17  1:39 ` [PATCH v6 2/2] send-email: expose header information to git-send-email's sendemail-validate hook Strawbridge, Michael
2023-01-17  4:35   ` Luben Tuikov
2023-01-17  5:06   ` Luben Tuikov
2023-01-17  7:31     ` Junio C Hamano
2023-01-18  8:31       ` Luben Tuikov
2023-01-18 16:27         ` Junio C Hamano
2023-01-18 16:35           ` Luben Tuikov [this message]
2023-01-18 20:44             ` Michael Strawbridge

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=fa9b1371-0a61-147f-637e-cb09f775fe22@amd.com \
    --to=luben.tuikov@amd.com \
    --cc=Michael.Strawbridge@amd.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).