{"thread":{"id":"59620","subject":"[PATCH v10 0/2] Expose header information to git-send-email's sendemail-validate hook","startedAt":"2023-04-19T20:27:37Z","lastAt":"2023-05-02T18:56:28Z","messageCount":7,"participants":["Michael Strawbridge","Luben Tuikov","Junio C Hamano"],"isPatch":true,"patchVersion":10,"patchTotal":2},"messages":[{"id":"475713","messageId":"20230419202703.2911836-1-michael.strawbridge@amd.com","threadId":"59620","inReplyTo":null,"subject":"[PATCH v10 0/2] Expose header information to git-send-email's sendemail-validate hook","fromName":"Michael Strawbridge","fromEmail":"michael.strawbridge@amd.com","sentAt":"2023-04-19T20:27:01Z","receivedAt":"2023-04-19T20:27:37Z","isPatch":true,"sender":{"key":"michael.strawbridge@amd.com","avatar":null},"body":"My appologies for taking a while to get back to this.  Here is a reroll\nwith the latest suggestions from Luben.\n\nMichael Strawbridge (2):\n  send-email: refactor header generation functions\n  send-email: expose header information to git-send-email's\n    sendemail-validate hook\n\n Documentation/githooks.txt | 27 +++++++++--\n git-send-email.perl        | 97 +++++++++++++++++++++++---------------\n t/t9001-send-email.sh      | 27 ++++++++++-\n 3 files changed, 108 insertions(+), 43 deletions(-)\n\n-- \n2.34.1\n\n"},{"id":"475714","messageId":"20230419202703.2911836-2-michael.strawbridge@amd.com","threadId":"59620","inReplyTo":"20230419202703.2911836-1-michael.strawbridge@amd.com","subject":"[PATCH v10 1/2] send-email: refactor header generation functions","fromName":"Michael Strawbridge","fromEmail":"michael.strawbridge@amd.com","sentAt":"2023-04-19T20:27:02Z","receivedAt":"2023-04-19T20:27:47Z","isPatch":true,"sender":{"key":"michael.strawbridge@amd.com","avatar":null},"body":"Split process_file and send_message into easier to use functions.\nMaking SMTP header information widely available.\n\nCc: Luben Tuikov <luben.tuikov@amd.com>\nCc: Junio C Hamano <gitster@pobox.com>\nCc: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nAcked-by: Luben Tuikov <luben.tuikov@amd.com>\nSigned-off-by: Michael Strawbridge <michael.strawbridge@amd.com>\n---\n git-send-email.perl | 49 ++++++++++++++++++++++++++++-----------------\n 1 file changed, 31 insertions(+), 18 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 07f2a0cbea..0a44c0e5cb 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1502,16 +1502,7 @@ sub file_name_is_absolute {\n \treturn File::Spec::Functions::file_name_is_absolute($path);\n }\n \n-# Prepares the email, then asks the user what to do.\n-#\n-# If the user chooses to send the email, it's sent and 1 is returned.\n-# If the user chooses not to send the email, 0 is returned.\n-# If the user decides they want to make further edits, -1 is returned and the\n-# caller is expected to call send_message again after the edits are performed.\n-#\n-# If an error occurs sending the email, this just dies.\n-\n-sub send_message {\n+sub gen_header {\n \tmy @recipients = unique_email_list(@to);\n \t@cc = (grep { my $cc = extract_valid_address_or_die($_);\n \t\t      not grep { $cc eq $_ || $_ =~ /<\\Q${cc}\\E>$/ } @recipients\n@@ -1553,6 +1544,22 @@ sub send_message {\n \tif (@xh) {\n \t\t$header .= join(\"\\n\", @xh) . \"\\n\";\n \t}\n+\tmy $recipients_ref = \\@recipients;\n+\treturn ($recipients_ref, $to, $date, $gitversion, $cc, $ccline, $header);\n+}\n+\n+# Prepares the email, then asks the user what to do.\n+#\n+# If the user chooses to send the email, it's sent and 1 is returned.\n+# If the user chooses not to send the email, 0 is returned.\n+# If the user decides they want to make further edits, -1 is returned and the\n+# caller is expected to call send_message again after the edits are performed.\n+#\n+# If an error occurs sending the email, this just dies.\n+\n+sub send_message {\n+\tmy ($recipients_ref, $to, $date, $gitversion, $cc, $ccline, $header) = gen_header();\n+\tmy @recipients = @$recipients_ref;\n \n \tmy @sendmail_parameters = ('-i', @recipients);\n \tmy $raw_from = $sender;\n@@ -1742,11 +1749,8 @@ sub send_message {\n $references = $initial_in_reply_to || '';\n $message_num = 0;\n \n-# Prepares the email, prompts the user, sends it out\n-# Returns 0 if an edit was done and the function should be called again, or 1\n-# otherwise.\n-sub process_file {\n-\tmy ($t) = @_;\n+sub pre_process_file {\n+\tmy ($t, $quiet) = @_;\n \n \topen my $fh, \"<\", $t or die sprintf(__(\"can't open file %s\"), $t);\n \n@@ -1900,9 +1904,9 @@ sub process_file {\n \t}\n \tclose $fh;\n \n-\tpush @to, recipients_cmd(\"to-cmd\", \"to\", $to_cmd, $t)\n+\tpush @to, recipients_cmd(\"to-cmd\", \"to\", $to_cmd, $t, $quiet)\n \t\tif defined $to_cmd;\n-\tpush @cc, recipients_cmd(\"cc-cmd\", \"cc\", $cc_cmd, $t)\n+\tpush @cc, recipients_cmd(\"cc-cmd\", \"cc\", $cc_cmd, $t, $quiet)\n \t\tif defined $cc_cmd && !$suppress_cc{'cccmd'};\n \n \tif ($broken_encoding{$t} && !$has_content_type) {\n@@ -1961,6 +1965,15 @@ sub process_file {\n \t\t\t@initial_to = @to;\n \t\t}\n \t}\n+}\n+\n+# Prepares the email, prompts the user, and sends it out\n+# Returns 0 if an edit was done and the function should be called again, or 1\n+# on the email being successfully sent out.\n+sub process_file {\n+\tmy ($t) = @_;\n+\n+        pre_process_file($t, $quiet);\n \n \tmy $message_was_sent = send_message();\n \tif ($message_was_sent == -1) {\n@@ -2009,7 +2022,7 @@ sub process_file {\n # Execute a command (e.g. $to_cmd) to get a list of email addresses\n # and return a results array\n sub recipients_cmd {\n-\tmy ($prefix, $what, $cmd, $file) = @_;\n+\tmy ($prefix, $what, $cmd, $file, $quiet) = @_;\n \n \tmy @addresses = ();\n \topen my $fh, \"-|\", \"$cmd \\Q$file\\E\"\n-- \n2.34.1\n\n"},{"id":"475715","messageId":"20230419202703.2911836-3-michael.strawbridge@amd.com","threadId":"59620","inReplyTo":"20230419202703.2911836-1-michael.strawbridge@amd.com","subject":"[PATCH v10 2/2] send-email: expose header information to git-send-email's sendemail-validate hook","fromName":"Michael Strawbridge","fromEmail":"michael.strawbridge@amd.com","sentAt":"2023-04-19T20:27:03Z","receivedAt":"2023-04-19T20:27:59Z","isPatch":true,"sender":{"key":"michael.strawbridge@amd.com","avatar":null},"body":"To allow further flexibility in the Git hook, the SMTP header\ninformation of the email which git-send-email intends to send, is now\npassed as the 2nd argument to the sendemail-validate hook.\n\nAs an example, this can be useful for acting upon keywords in the\nsubject or specific email addresses.\n\nCc: Luben Tuikov <luben.tuikov@amd.com>\nCc: Junio C Hamano <gitster@pobox.com>\nCc: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nAcked-by: Luben Tuikov <luben.tuikov@amd.com>\nSigned-off-by: Michael Strawbridge <michael.strawbridge@amd.com>\n---\n Documentation/githooks.txt | 27 +++++++++++++++++----\n git-send-email.perl        | 48 +++++++++++++++++++++++---------------\n t/t9001-send-email.sh      | 27 +++++++++++++++++++--\n 3 files changed, 77 insertions(+), 25 deletions(-)\n\ndiff --git a/Documentation/githooks.txt b/Documentation/githooks.txt\nindex 62908602e7..9896ffafaf 100644\n--- a/Documentation/githooks.txt\n+++ b/Documentation/githooks.txt\n@@ -595,10 +595,29 @@ processed by rebase.\n sendemail-validate\n ~~~~~~~~~~~~~~~~~~\n \n-This hook is invoked by linkgit:git-send-email[1].  It takes a single parameter,\n-the name of the file that holds the e-mail to be sent.  Exiting with a\n-non-zero status causes `git send-email` to abort before sending any\n-e-mails.\n+This hook is invoked by linkgit:git-send-email[1].\n+\n+It takes these command line arguments. They are,\n+1. the name of the file which holds the contents of the email to be sent.\n+2. The name of the file which holds the SMTP headers of the email.\n+\n+The SMTP headers are passed in the exact same way as they are passed to the\n+user's Mail Transport Agent (MTA). In effect, the email given to the user's\n+MTA, is the contents of $2 followed by the contents of $1.\n+\n+An example of a few common headers is shown below. Take notice of the\n+capitalization and multi-line tab structure.\n+\n+  From: Example <from@example.com>\n+  To: to@example.com\n+  Cc: cc@example.com,\n+\t  A <author@example.com>,\n+\t  One <one@example.com>,\n+\t  two@example.com\n+  Subject: PATCH-STRING\n+\n+Exiting with a non-zero status causes `git send-email` to abort\n+before sending any e-mails.\n \n fsmonitor-watchman\n ~~~~~~~~~~~~~~~~~~\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 0a44c0e5cb..a3bc7b33d4 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -792,16 +792,31 @@ sub is_format_patch_arg {\n \t\t\t\t    @rev_list_opts);\n }\n \n-@files = handle_backup_files(@files);\n+if (defined $sender) {\n+\t$sender =~ s/^\\s+|\\s+$//g;\n+\t($sender) = expand_aliases($sender);\n+} else {\n+\t$sender = $repoauthor->() || $repocommitter->() || '';\n+}\n+\n+# $sender could be an already sanitized address\n+# (e.g. sendemail.from could be manually sanitized by user).\n+# But it's a no-op to run sanitize_address on an already sanitized address.\n+$sender = sanitize_address($sender);\n+\n+$time = time - scalar $#files;\n \n if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\n+\t\t        pre_process_file($f, 1);\n \t\t\tvalidate_patch($f, $target_xfer_encoding);\n \t\t}\n \t}\n }\n \n+@files = handle_backup_files(@files);\n+\n if (@files) {\n \tunless ($quiet) {\n \t\tprint $_,\"\\n\" for (@files);\n@@ -1050,18 +1065,6 @@ sub file_declares_8bit_cte {\n \t}\n }\n \n-if (defined $sender) {\n-\t$sender =~ s/^\\s+|\\s+$//g;\n-\t($sender) = expand_aliases($sender);\n-} else {\n-\t$sender = $repoauthor->() || $repocommitter->() || '';\n-}\n-\n-# $sender could be an already sanitized address\n-# (e.g. sendemail.from could be manually sanitized by user).\n-# But it's a no-op to run sanitize_address on an already sanitized address.\n-$sender = sanitize_address($sender);\n-\n my $to_whom = __(\"To whom should the emails be sent (if anyone)?\");\n my $prompting = 0;\n if (!@initial_to && !defined $to_cmd) {\n@@ -1221,10 +1224,6 @@ sub make_message_id {\n \t#print \"new message id = $message_id\\n\"; # Was useful for debugging\n }\n \n-\n-\n-$time = time - scalar $#files;\n-\n sub unquote_rfc2047 {\n \tlocal ($_) = @_;\n \tmy $charset;\n@@ -2108,10 +2107,21 @@ sub validate_patch {\n \t\t\tchdir($repo->wc_path() or $repo->repo_path())\n \t\t\t\tor die(\"chdir: $!\");\n \t\t\tlocal $ENV{\"GIT_DIR\"} = $repo->repo_path();\n+\n+\t\t\tmy ($recipients_ref, $to, $date, $gitversion, $cc, $ccline, $header) = gen_header();\n+\n+\t\t\trequire File::Temp;\n+\t\t\tmy ($header_filehandle, $header_filename) = File::Temp::tempfile(\n+                            TEMPLATE => \".gitsendemail.header.XXXXXX\",\n+                            DIR => $repo->repo_path(),\n+                            UNLINK => 1,\n+                        );\n+\t\t\tprint $header_filehandle $header;\n+\n \t\t\tmy @cmd = (\"git\", \"hook\", \"run\", \"--ignore-missing\",\n \t\t\t\t    $hook_name, \"--\");\n-\t\t\tmy @cmd_msg = (@cmd, \"<patch>\");\n-\t\t\tmy @cmd_run = (@cmd, $target);\n+\t\t\tmy @cmd_msg = (@cmd, \"<patch>\", \"<header>\");\n+\t\t\tmy @cmd_run = (@cmd, $target, $header_filename);\n \t\t\t$hook_error = system_or_msg(\\@cmd_run, undef, \"@cmd_msg\");\n \t\t\tchdir($cwd_save) or die(\"chdir: $!\");\n \t\t}\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 323952a572..e8c96d0d4e 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -540,7 +540,7 @@ test_expect_success $PREREQ \"--validate respects relative core.hooksPath path\" '\n \ttest_path_is_file my-hooks.ran &&\n \tcat >expect <<-EOF &&\n \tfatal: longline.patch: rejected by sendemail-validate hook\n-\tfatal: command '\"'\"'git hook run --ignore-missing sendemail-validate -- <patch>'\"'\"' died with exit code 1\n+\tfatal: command '\"'\"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'\"'\"' died with exit code 1\n \twarning: no patches were sent\n \tEOF\n \ttest_cmp expect actual\n@@ -559,12 +559,35 @@ test_expect_success $PREREQ \"--validate respects absolute core.hooksPath path\" '\n \ttest_path_is_file my-hooks.ran &&\n \tcat >expect <<-EOF &&\n \tfatal: longline.patch: rejected by sendemail-validate hook\n-\tfatal: command '\"'\"'git hook run --ignore-missing sendemail-validate -- <patch>'\"'\"' died with exit code 1\n+\tfatal: command '\"'\"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'\"'\"' died with exit code 1\n \twarning: no patches were sent\n \tEOF\n \ttest_cmp expect actual\n '\n \n+test_expect_success $PREREQ \"--validate hook supports header argument\" '\n+\twrite_script my-hooks/sendemail-validate <<-\\EOF &&\n+\tif test \"$#\" -ge 2\n+\tthen\n+\t\tgrep \"X-test-header: v1.0\" \"$2\"\n+\telse\n+\t\techo \"No header arg passed\"\n+\t\texit 1\n+\tfi\n+\tEOF\n+\ttest_config core.hooksPath \"my-hooks\" &&\n+\trm -fr outdir &&\n+\tgit format-patch \\\n+\t\t--add-header=\"X-test-header: v1.0\" \\\n+\t\t-n HEAD^1 -o outdir &&\n+\tgit send-email \\\n+\t\t--dry-run \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--validate \\\n+\t\toutdir/000?-*.patch\n+'\n+\n for enc in 7bit 8bit quoted-printable base64\n do\n \ttest_expect_success $PREREQ \"--transfer-encoding=$enc produces correct header\" '\n-- \n2.34.1\n\n"},{"id":"475781","messageId":"4da10b6c-a1ce-c0f7-4b54-3a032b437e54@amd.com","threadId":"59620","inReplyTo":"20230419202703.2911836-3-michael.strawbridge@amd.com","subject":"Re: [PATCH v10 2/2] send-email: expose header information to git-send-email's sendemail-validate hook","fromName":"Luben Tuikov","fromEmail":"luben.tuikov@amd.com","sentAt":"2023-04-21T05:27:45Z","receivedAt":"2023-04-21T05:27:56Z","isPatch":true,"sender":{"key":"luben.tuikov@amd.com","avatar":null},"body":"On 2023-04-19 16:27, Michael Strawbridge wrote:\n> To allow further flexibility in the Git hook, the SMTP header\n> information of the email which git-send-email intends to send, is now\n> passed as the 2nd argument to the sendemail-validate hook.\n> \n> As an example, this can be useful for acting upon keywords in the\n> subject or specific email addresses.\n> \n> Cc: Luben Tuikov <luben.tuikov@amd.com>\n> Cc: Junio C Hamano <gitster@pobox.com>\n> Cc: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Acked-by: Luben Tuikov <luben.tuikov@amd.com>\n> Signed-off-by: Michael Strawbridge <michael.strawbridge@amd.com>\n\nThanks for posting this Michael. Perhaps this should be pushed now.\n\nRegards,\nLuben\n\n> ---\n>  Documentation/githooks.txt | 27 +++++++++++++++++----\n>  git-send-email.perl        | 48 +++++++++++++++++++++++---------------\n>  t/t9001-send-email.sh      | 27 +++++++++++++++++++--\n>  3 files changed, 77 insertions(+), 25 deletions(-)\n> \n> diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt\n> index 62908602e7..9896ffafaf 100644\n> --- a/Documentation/githooks.txt\n> +++ b/Documentation/githooks.txt\n> @@ -595,10 +595,29 @@ processed by rebase.\n>  sendemail-validate\n>  ~~~~~~~~~~~~~~~~~~\n>  \n> -This hook is invoked by linkgit:git-send-email[1].  It takes a single parameter,\n> -the name of the file that holds the e-mail to be sent.  Exiting with a\n> -non-zero status causes `git send-email` to abort before sending any\n> -e-mails.\n> +This hook is invoked by linkgit:git-send-email[1].\n> +\n> +It takes these command line arguments. They are,\n> +1. the name of the file which holds the contents of the email to be sent.\n> +2. The name of the file which holds the SMTP headers of the email.\n> +\n> +The SMTP headers are passed in the exact same way as they are passed to the\n> +user's Mail Transport Agent (MTA). In effect, the email given to the user's\n> +MTA, is the contents of $2 followed by the contents of $1.\n> +\n> +An example of a few common headers is shown below. Take notice of the\n> +capitalization and multi-line tab structure.\n> +\n> +  From: Example <from@example.com>\n> +  To: to@example.com\n> +  Cc: cc@example.com,\n> +\t  A <author@example.com>,\n> +\t  One <one@example.com>,\n> +\t  two@example.com\n> +  Subject: PATCH-STRING\n> +\n> +Exiting with a non-zero status causes `git send-email` to abort\n> +before sending any e-mails.\n>  \n>  fsmonitor-watchman\n>  ~~~~~~~~~~~~~~~~~~\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 0a44c0e5cb..a3bc7b33d4 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -792,16 +792,31 @@ sub is_format_patch_arg {\n>  \t\t\t\t    @rev_list_opts);\n>  }\n>  \n> -@files = handle_backup_files(@files);\n> +if (defined $sender) {\n> +\t$sender =~ s/^\\s+|\\s+$//g;\n> +\t($sender) = expand_aliases($sender);\n> +} else {\n> +\t$sender = $repoauthor->() || $repocommitter->() || '';\n> +}\n> +\n> +# $sender could be an already sanitized address\n> +# (e.g. sendemail.from could be manually sanitized by user).\n> +# But it's a no-op to run sanitize_address on an already sanitized address.\n> +$sender = sanitize_address($sender);\n> +\n> +$time = time - scalar $#files;\n>  \n>  if ($validate) {\n>  \tforeach my $f (@files) {\n>  \t\tunless (-p $f) {\n> +\t\t        pre_process_file($f, 1);\n>  \t\t\tvalidate_patch($f, $target_xfer_encoding);\n>  \t\t}\n>  \t}\n>  }\n>  \n> +@files = handle_backup_files(@files);\n> +\n>  if (@files) {\n>  \tunless ($quiet) {\n>  \t\tprint $_,\"\\n\" for (@files);\n> @@ -1050,18 +1065,6 @@ sub file_declares_8bit_cte {\n>  \t}\n>  }\n>  \n> -if (defined $sender) {\n> -\t$sender =~ s/^\\s+|\\s+$//g;\n> -\t($sender) = expand_aliases($sender);\n> -} else {\n> -\t$sender = $repoauthor->() || $repocommitter->() || '';\n> -}\n> -\n> -# $sender could be an already sanitized address\n> -# (e.g. sendemail.from could be manually sanitized by user).\n> -# But it's a no-op to run sanitize_address on an already sanitized address.\n> -$sender = sanitize_address($sender);\n> -\n>  my $to_whom = __(\"To whom should the emails be sent (if anyone)?\");\n>  my $prompting = 0;\n>  if (!@initial_to && !defined $to_cmd) {\n> @@ -1221,10 +1224,6 @@ sub make_message_id {\n>  \t#print \"new message id = $message_id\\n\"; # Was useful for debugging\n>  }\n>  \n> -\n> -\n> -$time = time - scalar $#files;\n> -\n>  sub unquote_rfc2047 {\n>  \tlocal ($_) = @_;\n>  \tmy $charset;\n> @@ -2108,10 +2107,21 @@ sub validate_patch {\n>  \t\t\tchdir($repo->wc_path() or $repo->repo_path())\n>  \t\t\t\tor die(\"chdir: $!\");\n>  \t\t\tlocal $ENV{\"GIT_DIR\"} = $repo->repo_path();\n> +\n> +\t\t\tmy ($recipients_ref, $to, $date, $gitversion, $cc, $ccline, $header) = gen_header();\n> +\n> +\t\t\trequire File::Temp;\n> +\t\t\tmy ($header_filehandle, $header_filename) = File::Temp::tempfile(\n> +                            TEMPLATE => \".gitsendemail.header.XXXXXX\",\n> +                            DIR => $repo->repo_path(),\n> +                            UNLINK => 1,\n> +                        );\n> +\t\t\tprint $header_filehandle $header;\n> +\n>  \t\t\tmy @cmd = (\"git\", \"hook\", \"run\", \"--ignore-missing\",\n>  \t\t\t\t    $hook_name, \"--\");\n> -\t\t\tmy @cmd_msg = (@cmd, \"<patch>\");\n> -\t\t\tmy @cmd_run = (@cmd, $target);\n> +\t\t\tmy @cmd_msg = (@cmd, \"<patch>\", \"<header>\");\n> +\t\t\tmy @cmd_run = (@cmd, $target, $header_filename);\n>  \t\t\t$hook_error = system_or_msg(\\@cmd_run, undef, \"@cmd_msg\");\n>  \t\t\tchdir($cwd_save) or die(\"chdir: $!\");\n>  \t\t}\n> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\n> index 323952a572..e8c96d0d4e 100755\n> --- a/t/t9001-send-email.sh\n> +++ b/t/t9001-send-email.sh\n> @@ -540,7 +540,7 @@ test_expect_success $PREREQ \"--validate respects relative core.hooksPath path\" '\n>  \ttest_path_is_file my-hooks.ran &&\n>  \tcat >expect <<-EOF &&\n>  \tfatal: longline.patch: rejected by sendemail-validate hook\n> -\tfatal: command '\"'\"'git hook run --ignore-missing sendemail-validate -- <patch>'\"'\"' died with exit code 1\n> +\tfatal: command '\"'\"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'\"'\"' died with exit code 1\n>  \twarning: no patches were sent\n>  \tEOF\n>  \ttest_cmp expect actual\n> @@ -559,12 +559,35 @@ test_expect_success $PREREQ \"--validate respects absolute core.hooksPath path\" '\n>  \ttest_path_is_file my-hooks.ran &&\n>  \tcat >expect <<-EOF &&\n>  \tfatal: longline.patch: rejected by sendemail-validate hook\n> -\tfatal: command '\"'\"'git hook run --ignore-missing sendemail-validate -- <patch>'\"'\"' died with exit code 1\n> +\tfatal: command '\"'\"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'\"'\"' died with exit code 1\n>  \twarning: no patches were sent\n>  \tEOF\n>  \ttest_cmp expect actual\n>  '\n>  \n> +test_expect_success $PREREQ \"--validate hook supports header argument\" '\n> +\twrite_script my-hooks/sendemail-validate <<-\\EOF &&\n> +\tif test \"$#\" -ge 2\n> +\tthen\n> +\t\tgrep \"X-test-header: v1.0\" \"$2\"\n> +\telse\n> +\t\techo \"No header arg passed\"\n> +\t\texit 1\n> +\tfi\n> +\tEOF\n> +\ttest_config core.hooksPath \"my-hooks\" &&\n> +\trm -fr outdir &&\n> +\tgit format-patch \\\n> +\t\t--add-header=\"X-test-header: v1.0\" \\\n> +\t\t-n HEAD^1 -o outdir &&\n> +\tgit send-email \\\n> +\t\t--dry-run \\\n> +\t\t--to=nobody@example.com \\\n> +\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n> +\t\t--validate \\\n> +\t\toutdir/000?-*.patch\n> +'\n> +\n>  for enc in 7bit 8bit quoted-printable base64\n>  do\n>  \ttest_expect_success $PREREQ \"--transfer-encoding=$enc produces correct header\" '\n\n"},{"id":"476384","messageId":"xmqq354f4sts.fsf@gitster.g","threadId":"59620","inReplyTo":"20230419202703.2911836-1-michael.strawbridge@amd.com","subject":"Re: [PATCH v10 0/2] Expose header information to git-send-email's sendemail-validate hook","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-05-01T21:58:39Z","receivedAt":"2023-05-01T21:58:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Strawbridge <michael.strawbridge@amd.com> writes:\n\n> My appologies for taking a while to get back to this.  Here is a reroll\n> with the latest suggestions from Luben.\n>\n> Michael Strawbridge (2):\n>   send-email: refactor header generation functions\n>   send-email: expose header information to git-send-email's\n>     sendemail-validate hook\n\nThis round did not see any further comments.  Is everybody happy to\nsee us declare victory on this front and merge it down to 'next'?\n\nThe topic does not make itself a reply to previous iterations, and\nthe cover letter does not CC: anybody who gave reviews to earlier\nrounds, so it is a bit hard to answer the above question myself,\nunfortunately.  I manually picked off a few names after finding v9\nand v8 from the list archive and added them to Cc: of this message.\n\nThanks.\n"},{"id":"476395","messageId":"fae69ed7-5b5b-0920-73f2-a0e72795c032@amd.com","threadId":"59620","inReplyTo":"41F7913A-E91B-4442-9531-5EE8EC2CAA9E@yahoo.com","subject":"Re: Fwd: [PATCH v10 0/2] Expose header information to git-send-email's sendemail-validate hook","fromName":"Luben Tuikov","fromEmail":"luben.tuikov@amd.com","sentAt":"2023-05-02T01:05:29Z","receivedAt":"2023-05-02T01:06:51Z","isPatch":true,"sender":{"key":"luben.tuikov@amd.com","avatar":null},"body":"On 2023-05-01 21:01, Luben Tuikov wrote:\n> Begin forwarded message:\n> \n>> *From:* Junio C Hamano <gitster@pobox.com>\n>> *Date:* May 1, 2023 at 17:58:41 EDT\n>> *To:* Michael Strawbridge <michael.strawbridge@amd.com>\n>> *Cc:* git@vger.kernel.org, Luben Tuikov <ltuikov@yahoo.com>, Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> *Subject:* *Re: [PATCH v10 0/2] Expose header information to git-send-email's sendemail-validate hook*\n>>\n>> ﻿Michael Strawbridge <michael.strawbridge@amd.com> writes:\n>>\n>>> My appologies for taking a while to get back to this.  Here is a reroll\n>>> with the latest suggestions from Luben.\n>>>\n>>> Michael Strawbridge (2):\n>>>  send-email: refactor header generation functions\n>>>  send-email: expose header information to git-send-email's\n>>>    sendemail-validate hook\n>>\n>> This round did not see any further comments.  Is everybody happy to\n>> see us declare victory on this front and merge it down to 'next'?\n>>\n>> The topic does not make itself a reply to previous iterations, and\n>> the cover letter does not CC: anybody who gave reviews to earlier\n>> rounds, so it is a bit hard to answer the above question myself,\n>> unfortunately.  I manually picked off a few names after finding v9\n>> and v8 from the list archive and added them to Cc: of this message.\n>>\n>> Thanks.\n\nSounds good to me.\n-- \nRegards,\nLuben\n\n"},{"id":"476449","messageId":"b82443ad-36e5-291d-3335-2f69fed7fa74@amd.com","threadId":"59620","inReplyTo":"fae69ed7-5b5b-0920-73f2-a0e72795c032@amd.com","subject":"Re: Fwd: [PATCH v10 0/2] Expose header information to git-send-email's sendemail-validate hook","fromName":"Michael Strawbridge","fromEmail":"michael.strawbridge@amd.com","sentAt":"2023-05-02T18:56:18Z","receivedAt":"2023-05-02T18:56:28Z","isPatch":true,"sender":{"key":"michael.strawbridge@amd.com","avatar":null},"body":"Thanks.  I will do that in the future.\n\nOn 2023-05-01 21:05, Luben Tuikov wrote:\n> On 2023-05-01 21:01, Luben Tuikov wrote:\n>> Begin forwarded message:\n>>\n>>> *From:* Junio C Hamano <gitster@pobox.com>\n>>> *Date:* May 1, 2023 at 17:58:41 EDT\n>>> *To:* Michael Strawbridge <michael.strawbridge@amd.com>\n>>> *Cc:* git@vger.kernel.org, Luben Tuikov <ltuikov@yahoo.com>, Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>>> *Subject:* *Re: [PATCH v10 0/2] Expose header information to git-send-email's sendemail-validate hook*\n>>>\n>>> ﻿Michael Strawbridge <michael.strawbridge@amd.com> writes:\n>>>\n>>>> My appologies for taking a while to get back to this.  Here is a reroll\n>>>> with the latest suggestions from Luben.\n>>>>\n>>>> Michael Strawbridge (2):\n>>>>  send-email: refactor header generation functions\n>>>>  send-email: expose header information to git-send-email's\n>>>>    sendemail-validate hook\n>>> This round did not see any further comments.  Is everybody happy to\n>>> see us declare victory on this front and merge it down to 'next'?\n>>>\n>>> The topic does not make itself a reply to previous iterations, and\n>>> the cover letter does not CC: anybody who gave reviews to earlier\n>>> rounds, so it is a bit hard to answer the above question myself,\n>>> unfortunately.  I manually picked off a few names after finding v9\n>>> and v8 from the list archive and added them to Cc: of this message.\n>>>\n>>> Thanks.\n> Sounds good to me.\n"}]}