mirror of
https://github.com/git/git.git
synced 2024-05-06 18:06:13 +02:00
Merge branch 'ms/send-email-validate-fix'
"git send-email" did not have certain pieces of data computed yet when it tried to validate the outging messages and its recipient addresses, which has been sorted out. * ms/send-email-validate-fix: send-email: move validation code below process_address_list
This commit is contained in:
commit
00f372e2a4
|
@ -799,30 +799,6 @@ sub is_format_patch_arg {
|
|||
|
||||
$time = time - scalar $#files;
|
||||
|
||||
if ($validate) {
|
||||
# FIFOs can only be read once, exclude them from validation.
|
||||
my @real_files = ();
|
||||
foreach my $f (@files) {
|
||||
unless (-p $f) {
|
||||
push(@real_files, $f);
|
||||
}
|
||||
}
|
||||
|
||||
# Run the loop once again to avoid gaps in the counter due to FIFO
|
||||
# arguments provided by the user.
|
||||
my $num = 1;
|
||||
my $num_files = scalar @real_files;
|
||||
$ENV{GIT_SENDEMAIL_FILE_TOTAL} = "$num_files";
|
||||
foreach my $r (@real_files) {
|
||||
$ENV{GIT_SENDEMAIL_FILE_COUNTER} = "$num";
|
||||
pre_process_file($r, 1);
|
||||
validate_patch($r, $target_xfer_encoding);
|
||||
$num += 1;
|
||||
}
|
||||
delete $ENV{GIT_SENDEMAIL_FILE_COUNTER};
|
||||
delete $ENV{GIT_SENDEMAIL_FILE_TOTAL};
|
||||
}
|
||||
|
||||
@files = handle_backup_files(@files);
|
||||
|
||||
if (@files) {
|
||||
|
@ -1726,10 +1702,6 @@ sub send_message {
|
|||
return 1;
|
||||
}
|
||||
|
||||
$in_reply_to = $initial_in_reply_to;
|
||||
$references = $initial_in_reply_to || '';
|
||||
$message_num = 0;
|
||||
|
||||
sub pre_process_file {
|
||||
my ($t, $quiet) = @_;
|
||||
|
||||
|
@ -1995,6 +1967,38 @@ sub process_file {
|
|||
return 1;
|
||||
}
|
||||
|
||||
sub initialize_modified_loop_vars {
|
||||
$in_reply_to = $initial_in_reply_to;
|
||||
$references = $initial_in_reply_to || '';
|
||||
$message_num = 0;
|
||||
}
|
||||
|
||||
if ($validate) {
|
||||
# FIFOs can only be read once, exclude them from validation.
|
||||
my @real_files = ();
|
||||
foreach my $f (@files) {
|
||||
unless (-p $f) {
|
||||
push(@real_files, $f);
|
||||
}
|
||||
}
|
||||
|
||||
# Run the loop once again to avoid gaps in the counter due to FIFO
|
||||
# arguments provided by the user.
|
||||
my $num = 1;
|
||||
my $num_files = scalar @real_files;
|
||||
$ENV{GIT_SENDEMAIL_FILE_TOTAL} = "$num_files";
|
||||
initialize_modified_loop_vars();
|
||||
foreach my $r (@real_files) {
|
||||
$ENV{GIT_SENDEMAIL_FILE_COUNTER} = "$num";
|
||||
pre_process_file($r, 1);
|
||||
validate_patch($r, $target_xfer_encoding);
|
||||
$num += 1;
|
||||
}
|
||||
delete $ENV{GIT_SENDEMAIL_FILE_COUNTER};
|
||||
delete $ENV{GIT_SENDEMAIL_FILE_TOTAL};
|
||||
}
|
||||
|
||||
initialize_modified_loop_vars();
|
||||
foreach my $t (@files) {
|
||||
while (!process_file($t)) {
|
||||
# user edited the file
|
||||
|
|
|
@ -633,6 +633,25 @@ test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
|
|||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ "--validate hook supports multiple addresses in arguments" '
|
||||
hooks_path="$(pwd)/my-hooks" &&
|
||||
test_config core.hooksPath "$hooks_path" &&
|
||||
test_when_finished "rm my-hooks.ran" &&
|
||||
test_must_fail git send-email \
|
||||
--from="Example <nobody@example.com>" \
|
||||
--to=nobody@example.com,abc@example.com \
|
||||
--smtp-server="$(pwd)/fake.sendmail" \
|
||||
--validate \
|
||||
longline.patch 2>actual &&
|
||||
test_path_is_file my-hooks.ran &&
|
||||
cat >expect <<-EOF &&
|
||||
fatal: longline.patch: rejected by sendemail-validate hook
|
||||
fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1
|
||||
warning: no patches were sent
|
||||
EOF
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ "--validate hook supports header argument" '
|
||||
write_script my-hooks/sendemail-validate <<-\EOF &&
|
||||
if test "$#" -ge 2
|
||||
|
|
Loading…
Reference in New Issue