{"thread":{"id":"26373","subject":"[PATCH] git-cvsimport.perl: Bail out right away when reading from the server fails","startedAt":"2011-01-31T19:29:46Z","lastAt":"2011-01-31T19:29:46Z","messageCount":1,"participants":["Fabian Keil"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"160105","messageId":"20110131202946.0a3162b3@r500.local","threadId":"26373","inReplyTo":null,"subject":"[PATCH] git-cvsimport.perl: Bail out right away when reading from the server fails","fromName":"Fabian Keil","fromEmail":"fk@fabiankeil.de","sentAt":"2011-01-31T19:29:46Z","receivedAt":"2011-01-31T19:29:46Z","isPatch":true,"sender":{"key":"fk@fabiankeil.de","avatar":null},"body":"If the CVS server is down, this reduced the git-cvsimport output from:\n\nssh: connect to host ijbswa.cvs.sourceforge.net port 22: Connection refused\nUse of uninitialized value $rep in scalar chomp at /usr/local/libexec/git-core/git-cvsimport line 369.\nUse of uninitialized value $rep in substitution (s///) at /usr/local/libexec/git-core/git-cvsimport line 370.\nExpected Valid-requests from server, but got: <unknown>\n\nto the less noisy:\n\nssh: connect to host ijbswa.cvs.sourceforge.net port 22: Connection refused\nFailed to read from server at /usr/local/libexec/git-core/git-cvsimport line 370.\n\nIn this case a silent exit() instead of the die() would probably do,\nbut I assume that there could be cases where the connection attempt\nsucceeds, but reading from the server fails for other reasons.\n\nSigned-off-by: Fabian Keil <fk@fabiankeil.de>\n---\n git-cvsimport.perl |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\n1d8b7c2be2b7dd281a0799735d00c8111404260f\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8e683e5..2a76d9e 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -366,7 +366,9 @@ sub conn {\n \t$self->{'socketo'}->write(\"valid-requests\\n\");\n \t$self->{'socketo'}->flush();\n \n-\tchomp(my $rep=$self->readline());\n+\tmy $rep=$self->readline();\n+\tdie \"Failed to read from server\" unless defined $rep;\n+\tchomp($rep);\n \tif ($rep !~ s/^Valid-requests\\s*//) {\n \t\t$rep=\"<unknown>\" unless $rep;\n \t\tdie \"Expected Valid-requests from server, but got: $rep\\n\";\n-- \n1.7.3.5\n"}]}