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>

Ramkumar Ramachandra committed Mar 31, 2013 at 18:40 UTC 9b39703920b2d64985abcc1348b169d8fa658c24
1 file changed +6 -4
git-send-email.perl
+6 -4
@@ -512,8 +512,9 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
512
513 ($sender) = expand_aliases($sender) if defined $sender;
514
515 -# returns 1 if the conflict must be solved using it as a format-patch argument
516 -sub check_file_rev_conflict($) {
515 +# is_format_patch_arg($f) returns 0 if $f names a patch, or 1 if
516 +# $f is a revision list specification to be passed to format-patch.
517 +sub is_format_patch_arg {
518 return unless $repo;
519 my $f = shift;
520 try {
@@ -529,6 +530,7 @@ to produce patches for. Please disambiguate by...
530 * Giving --format-patch option if you mean a range.
531 EOF
532 } catch Git::Error::Command with {
533 + # Not a valid revision. Treat it as a filename.
534 return 0;
535 }
536 }
@@ -540,14 +542,14 @@ while (defined(my $f = shift @ARGV)) {
542 if ($f eq "--") {
543 push @rev_list_opts, "--", @ARGV;
544 @ARGV = ();
543 - } elsif (-d $f and !check_file_rev_conflict($f)) {
545 + } elsif (-d $f and !is_format_patch_arg($f)) {
546 opendir my $dh, $f
547 or die "Failed to opendir $f: $!";
548
549 push @files, grep { -f $_ } map { catfile($f, $_) }
550 sort readdir $dh;
551 closedir $dh;
550 - } elsif ((-f $f or -p $f) and !check_file_rev_conflict($f)) {
552 + } elsif ((-f $f or -p $f) and !is_format_patch_arg($f)) {
553 push @files, $f;
554 } else {
555 push @rev_list_opts, $f;