Skip to content

Commit

Permalink
git-cvsimport.perl: Bail out right away when reading from the server …
Browse files Browse the repository at this point in the history
…fails

If the CVS server is down, this reduced the git-cvsimport output from:

ssh: connect to host ijbswa.cvs.sourceforge.net port 22: Connection refused
Use of uninitialized value $rep in scalar chomp at /usr/local/libexec/git-core/git-cvsimport line 369.
Use of uninitialized value $rep in substitution (s///) at /usr/local/libexec/git-core/git-cvsimport line 370.
Expected Valid-requests from server, but got: <unknown>

to the less noisy:

ssh: connect to host ijbswa.cvs.sourceforge.net port 22: Connection refused
Failed to read from server at /usr/local/libexec/git-core/git-cvsimport line 370.

In this case a silent exit() instead of the die() would probably do,
but I assume that there could be cases where the connection attempt
succeeds, but reading from the server fails for other reasons.

Signed-off-by: Fabian Keil <fk@fabiankeil.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Fabian Keil authored and Junio C Hamano committed Feb 27, 2011
1 parent 62270f6 commit e7cad3c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion git-cvsimport.perl
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ sub conn {
$self->{'socketo'}->write("valid-requests\n");
$self->{'socketo'}->flush();

chomp(my $rep=$self->readline());
my $rep=$self->readline();
die "Failed to read from server" unless defined $rep;
chomp($rep);
if ($rep !~ s/^Valid-requests\s*//) {
$rep="<unknown>" unless $rep;
die "Expected Valid-requests from server, but got: $rep\n";
Expand Down

0 comments on commit e7cad3c

Please sign in to comment.