GitSharp.Core.Transport.TransportGitSsh.Exec C# (CSharp) Method

Exec() private method

private Exec ( string exe ) : ChannelExec
exe string
return Tamir.SharpSsh.jsch.ChannelExec
        private ChannelExec Exec(string exe)
        {
            InitSession();

            try
            {
                var channel = (ChannelExec)Sock.openChannel("exec");
                string path = Uri.Path;
                if (Uri.Scheme != null && Uri.Path.StartsWith("/~"))
                {
                    path = (Uri.Path.Substring(1));
                }

                var cmd = new StringBuilder();
                int gitspace = exe.IndexOf("git ");
                if (gitspace >= 0)
                {
                    SqMinimal(cmd, exe.Slice(0, gitspace + 3));
                    cmd.Append(' ');
                    SqMinimal(cmd, exe.Substring(gitspace + 4));
                }
                else
                {
                    SqMinimal(cmd, exe);
                }

                cmd.Append(' ');
                SqAlways(cmd, path);
                channel.setCommand(cmd.ToString());
                _errStream = CreateErrorStream();
                channel.setErrStream(_errStream);
                channel.connect();
                return channel;
            }
            catch (JSchException e)
            {
                throw new TransportException(Uri, e.Message, e);
            }
        }

Usage Example

            public SshPushConnection(TransportGitSsh instance)
                : base(instance)
            {
                try
                {
                    _channel = instance.Exec(instance.OptionReceivePack);

                    if (_channel.isConnected())
                    {
                        init(_channel.getInputStream(), _channel.getOutputStream());
                    }
                    else
                    {
                        throw new TransportException(uri, instance._errStream.ToString());
                    }
                }
                catch (TransportException)
                {
                    Close();
                    throw;
                }
                catch (SocketException err)
                {
                    Close();
                    throw new TransportException(uri, "remote hung up unexpectedly", err);
                }

                try
                {
                    readAdvertisedRefs();
                }
                catch (NoRemoteRepositoryException notFound)
                {
                    Close();
                    instance.checkExecFailure(_exitStatus, instance.OptionReceivePack);
                    throw instance.cleanNotFound(notFound);
                }
            }
All Usage Examples Of GitSharp.Core.Transport.TransportGitSsh::Exec