Skip to content

Commit e7cad3c

Browse files
fabiankeilgitster
authored andcommitted
git-cvsimport.perl: Bail out right away when reading from the server 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 62270f6 commit e7cad3c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

git-cvsimport.perl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ sub conn {
366366
$self->{'socketo'}->write("valid-requests\n");
367367
$self->{'socketo'}->flush();
368368

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

0 commit comments

Comments
 (0)