Merge branch 'rr/send-email-perl-critique' into maint
* rr/send-email-perl-critique: send-email: use the three-arg form of open in recipients_cmd send-email: drop misleading function prototype send-email: use "return;" not "return undef;" on error codepaths
This commit is contained in:
commit
b5581e6ac9
@ -512,8 +512,9 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
|
|||||||
|
|
||||||
($sender) = expand_aliases($sender) if defined $sender;
|
($sender) = expand_aliases($sender) if defined $sender;
|
||||||
|
|
||||||
# returns 1 if the conflict must be solved using it as a format-patch argument
|
# is_format_patch_arg($f) returns 0 if $f names a patch, or 1 if
|
||||||
sub check_file_rev_conflict($) {
|
# $f is a revision list specification to be passed to format-patch.
|
||||||
|
sub is_format_patch_arg {
|
||||||
return unless $repo;
|
return unless $repo;
|
||||||
my $f = shift;
|
my $f = shift;
|
||||||
try {
|
try {
|
||||||
@ -529,6 +530,7 @@ to produce patches for. Please disambiguate by...
|
|||||||
* Giving --format-patch option if you mean a range.
|
* Giving --format-patch option if you mean a range.
|
||||||
EOF
|
EOF
|
||||||
} catch Git::Error::Command with {
|
} catch Git::Error::Command with {
|
||||||
|
# Not a valid revision. Treat it as a filename.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,14 +542,14 @@ while (defined(my $f = shift @ARGV)) {
|
|||||||
if ($f eq "--") {
|
if ($f eq "--") {
|
||||||
push @rev_list_opts, "--", @ARGV;
|
push @rev_list_opts, "--", @ARGV;
|
||||||
@ARGV = ();
|
@ARGV = ();
|
||||||
} elsif (-d $f and !check_file_rev_conflict($f)) {
|
} elsif (-d $f and !is_format_patch_arg($f)) {
|
||||||
opendir my $dh, $f
|
opendir my $dh, $f
|
||||||
or die "Failed to opendir $f: $!";
|
or die "Failed to opendir $f: $!";
|
||||||
|
|
||||||
push @files, grep { -f $_ } map { catfile($f, $_) }
|
push @files, grep { -f $_ } map { catfile($f, $_) }
|
||||||
sort readdir $dh;
|
sort readdir $dh;
|
||||||
closedir $dh;
|
closedir $dh;
|
||||||
} elsif ((-f $f or -p $f) and !check_file_rev_conflict($f)) {
|
} elsif ((-f $f or -p $f) and !is_format_patch_arg($f)) {
|
||||||
push @files, $f;
|
push @files, $f;
|
||||||
} else {
|
} else {
|
||||||
push @rev_list_opts, $f;
|
push @rev_list_opts, $f;
|
||||||
@ -711,7 +713,7 @@ sub ask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undef;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my %broken_encoding;
|
my %broken_encoding;
|
||||||
@ -833,7 +835,7 @@ sub extract_valid_address {
|
|||||||
# less robust/correct than the monster regexp in Email::Valid,
|
# less robust/correct than the monster regexp in Email::Valid,
|
||||||
# but still does a 99% job, and one less dependency
|
# but still does a 99% job, and one less dependency
|
||||||
return $1 if $address =~ /($local_part_regexp\@$domain_regexp)/;
|
return $1 if $address =~ /($local_part_regexp\@$domain_regexp)/;
|
||||||
return undef;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub extract_valid_address_or_die {
|
sub extract_valid_address_or_die {
|
||||||
@ -1438,7 +1440,7 @@ sub recipients_cmd {
|
|||||||
|
|
||||||
my $sanitized_sender = sanitize_address($sender);
|
my $sanitized_sender = sanitize_address($sender);
|
||||||
my @addresses = ();
|
my @addresses = ();
|
||||||
open my $fh, "$cmd \Q$file\E |"
|
open my $fh, "-|", "$cmd \Q$file\E"
|
||||||
or die "($prefix) Could not execute '$cmd'";
|
or die "($prefix) Could not execute '$cmd'";
|
||||||
while (my $address = <$fh>) {
|
while (my $address = <$fh>) {
|
||||||
$address =~ s/^\s*//g;
|
$address =~ s/^\s*//g;
|
||||||
@ -1484,7 +1486,7 @@ sub validate_patch {
|
|||||||
return "$.: patch contains a line longer than 998 characters";
|
return "$.: patch contains a line longer than 998 characters";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undef;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub file_has_nonascii {
|
sub file_has_nonascii {
|
||||||
|
Loading…
Reference in New Issue
Block a user