Skip to content

Commit 9b39703

Browse files
artagnongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 622bc93 commit 9b39703

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

git-send-email.perl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,9 @@ sub split_addrs {
512512

513513
($sender) = expand_aliases($sender) if defined $sender;
514514

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 {
517518
return unless $repo;
518519
my $f = shift;
519520
try {
@@ -529,6 +530,7 @@ ($)
529530
* Giving --format-patch option if you mean a range.
530531
EOF
531532
} catch Git::Error::Command with {
533+
# Not a valid revision. Treat it as a filename.
532534
return 0;
533535
}
534536
}
@@ -540,14 +542,14 @@ ($)
540542
if ($f eq "--") {
541543
push @rev_list_opts, "--", @ARGV;
542544
@ARGV = ();
543-
} elsif (-d $f and !check_file_rev_conflict($f)) {
545+
} elsif (-d $f and !is_format_patch_arg($f)) {
544546
opendir my $dh, $f
545547
or die "Failed to opendir $f: $!";
546548

547549
push @files, grep { -f $_ } map { catfile($f, $_) }
548550
sort readdir $dh;
549551
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)) {
551553
push @files, $f;
552554
} else {
553555
push @rev_list_opts, $f;

0 commit comments

Comments
 (0)