send-email: drop misleading function prototype
The subroutine check_file_rev_conflict() is called from two places, both of which expects to pass a single scalar variable and see if that can be interpreted as a pathname or a revision name. It is defined with a function prototype ($) to force a scalar context while evaluating the arguments at the calling site but it does not help the current calling sites. The only effect it has is to hurt future calling sites that may want to build an argument list in an array variable and call it as check_file_rev_confict(@args). Drop the misleading prototype, as Perlcritic suggests. While at it, rename the function to avoid new call sites unaware of this change arising and add a comment clarifying what this function is for. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
622bc93091
commit
9b39703920
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user