@ -147,17 +147,25 @@ public class TransportGitSsh extends SshTransport implements PackTransport {
ChannelExec exec ( final String exe ) throws TransportException {
ChannelExec exec ( final String exe ) throws TransportException {
initSession ( ) ;
initSession ( ) ;
final int tms = getTimeout ( ) > 0 ? getTimeout ( ) * 1000 : 0 ;
try {
try {
final ChannelExec channel = ( ChannelExec ) sock . openChannel ( "exec" ) ;
final ChannelExec channel = ( ChannelExec ) sock . openChannel ( "exec" ) ;
channel . setCommand ( commandFor ( exe ) ) ;
channel . setCommand ( commandFor ( exe ) ) ;
channel . connect ( tms ) ;
return channel ;
return channel ;
} catch ( JSchException je ) {
} catch ( JSchException je ) {
throw new TransportException ( uri , je . getMessage ( ) , je ) ;
throw new TransportException ( uri , je . getMessage ( ) , je ) ;
}
}
}
}
private void connect ( ChannelExec channel ) throws TransportException {
try {
channel . connect ( getTimeout ( ) > 0 ? getTimeout ( ) * 1000 : 0 ) ;
if ( ! channel . isConnected ( ) )
throw new TransportException ( uri , "connection failed" ) ;
} catch ( JSchException e ) {
throw new TransportException ( uri , e . getMessage ( ) , e ) ;
}
}
void checkExecFailure ( int status , String exe , String why )
void checkExecFailure ( int status , String exe , String why )
throws TransportException {
throws TransportException {
if ( status = = 127 ) {
if ( status = = 127 ) {
@ -235,14 +243,13 @@ public class TransportGitSsh extends SshTransport implements PackTransport {
setMessageWriter ( msg ) ;
setMessageWriter ( msg ) ;
channel = exec ( getOptionUploadPack ( ) ) ;
channel = exec ( getOptionUploadPack ( ) ) ;
if ( ! channel . isConnected ( ) )
throw new TransportException ( uri , "connection failed" ) ;
final InputStream upErr = channel . getErrStream ( ) ;
final InputStream upErr = channel . getErrStream ( ) ;
errorThread = new StreamCopyThread ( upErr , msg . getRawStream ( ) ) ;
errorThread = new StreamCopyThread ( upErr , msg . getRawStream ( ) ) ;
errorThread . start ( ) ;
errorThread . start ( ) ;
init ( channel . getInputStream ( ) , outputStream ( channel ) ) ;
init ( channel . getInputStream ( ) , outputStream ( channel ) ) ;
connect ( channel ) ;
} catch ( TransportException err ) {
} catch ( TransportException err ) {
close ( ) ;
close ( ) ;
@ -304,14 +311,13 @@ public class TransportGitSsh extends SshTransport implements PackTransport {
setMessageWriter ( msg ) ;
setMessageWriter ( msg ) ;
channel = exec ( getOptionReceivePack ( ) ) ;
channel = exec ( getOptionReceivePack ( ) ) ;
if ( ! channel . isConnected ( ) )
throw new TransportException ( uri , "connection failed" ) ;
final InputStream rpErr = channel . getErrStream ( ) ;
final InputStream rpErr = channel . getErrStream ( ) ;
errorThread = new StreamCopyThread ( rpErr , msg . getRawStream ( ) ) ;
errorThread = new StreamCopyThread ( rpErr , msg . getRawStream ( ) ) ;
errorThread . start ( ) ;
errorThread . start ( ) ;
init ( channel . getInputStream ( ) , outputStream ( channel ) ) ;
init ( channel . getInputStream ( ) , outputStream ( channel ) ) ;
connect ( channel ) ;
} catch ( TransportException err ) {
} catch ( TransportException err ) {
close ( ) ;
close ( ) ;