Skip to content

Commit

Permalink
send-email: detect invocation errors earlier
Browse files Browse the repository at this point in the history
We never even look at the command line arguments until after
we have prompted the user for some information. So running
"git send-email" without arguments would prompt for "from"
and "to" headers, only to then die with "No patch files
specified." Instead, let's try to do as much error checking
as possible before getting user input.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jan 18, 2008
1 parent 5a7b1b5 commit aa54892
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,33 @@ sub read_config {

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

# Now that all the defaults are set, process the rest of the command line
# arguments and collect up the files that need to be processed.
for my $f (@ARGV) {
if (-d $f) {
opendir(DH,$f)
or die "Failed to opendir $f: $!";

push @files, grep { -f $_ } map { +$f . "/" . $_ }
sort readdir(DH);

} elsif (-f $f) {
push @files, $f;

} else {
print STDERR "Skipping $f - not found.\n";
}
}

if (@files) {
unless ($quiet) {
print $_,"\n" for (@files);
}
} else {
print STDERR "\nNo patch files specified!\n\n";
usage();
}

my $prompting = 0;
if (!defined $sender) {
$sender = $repoauthor || $repocommitter;
Expand Down Expand Up @@ -427,34 +454,6 @@ sub expand_aliases {
@files = ($compose_filename . ".final");
}


# Now that all the defaults are set, process the rest of the command line
# arguments and collect up the files that need to be processed.
for my $f (@ARGV) {
if (-d $f) {
opendir(DH,$f)
or die "Failed to opendir $f: $!";

push @files, grep { -f $_ } map { +$f . "/" . $_ }
sort readdir(DH);

} elsif (-f $f) {
push @files, $f;

} else {
print STDERR "Skipping $f - not found.\n";
}
}

if (@files) {
unless ($quiet) {
print $_,"\n" for (@files);
}
} else {
print STDERR "\nNo patch files specified!\n\n";
usage();
}

# Variables we set as part of the loop over files
our ($message_id, %mail, $subject, $reply_to, $references, $message);

Expand Down

0 comments on commit aa54892

Please sign in to comment.