Inheritance: Transport, IPackTransport
示例#1
0
            public ForkLocalPushConnection(TransportLocal transport)
                : base(transport)
            {
                receivePack = transport.Spawn(transport.OptionReceivePack);

                Stream rpIn  = new BufferedStream(receivePack.StandardInput.BaseStream);
                Stream rpOut = new BufferedStream(receivePack.StandardOutput.BaseStream);

                init(rpIn, rpOut);
                readAdvertisedRefs();
            }
示例#2
0
            public ForkLocalFetchConnection(TransportLocal transport)
                : base(transport)
            {
                uploadPack = transport.Spawn(transport.OptionUploadPack);

                Stream upIn  = new BufferedStream(uploadPack.StandardInput.BaseStream);
                Stream upOut = new BufferedStream(uploadPack.StandardOutput.BaseStream);

                init(upIn, upOut);
                readAdvertisedRefs();
            }
示例#3
0
        /// <summary>
        /// Open a new transport instance to connect two repositories.
        /// </summary>
        /// <param name="local">existing local repository.</param>
        /// <param name="remote">location of the remote repository.</param>
        /// <returns>the new transport instance. Never null.</returns>
        public static Transport open(Repository local, URIish remote)
        {
            if (TransportGitSsh.canHandle(remote))
            {
                return(new TransportGitSsh(local, remote));
            }

            if (TransportHttp.canHandle(remote))
            {
                return(new TransportHttp(local, remote));
            }

            if (TransportSftp.canHandle(remote))
            {
                return(new TransportSftp(local, remote));
            }

            if (TransportGitAnon.canHandle(remote))
            {
                return(new TransportGitAnon(local, remote));
            }

            if (TransportAmazonS3.canHandle(remote))
            {
                return(new TransportAmazonS3(local, remote));
            }

            if (TransportBundleFile.canHandle(remote))
            {
                return(new TransportBundleFile(local, remote));
            }

            if (TransportLocal.canHandle(remote))
            {
                return(new TransportLocal(local, remote));
            }

            throw new NotSupportedException("URI not supported: " + remote);
        }
示例#4
0
            public InternalLocalPushConnection(TransportLocal transport)
                : base(transport)
            {
                Repository dst;
                try
                {
                    dst = new Repository(transport.remoteGitDir);
                }
                catch (IOException)
                {
                    throw new TransportException(uri, "Not a Git directory");
                }

                PipedInputStream in_r;
                PipedOutputStream in_w;

                PipedInputStream out_r;
                PipedOutputStream out_w;
                try
                {
                    in_r = new PipedInputStream();
                    in_w = new PipedOutputStream(in_r);

                    out_r = new PipedInputStream();
                    out_w = new PipedOutputStream(out_r);
                }
                catch (IOException ex)
                {
                    dst.Close();
                    throw new TransportException(uri, "Cannot connect pipes", ex);
                }

                worker = new Thread(() =>
                {
                    try
                    {
                        ReceivePack rp = new ReceivePack(dst);
                        rp.receive(out_r, in_w, null);
                    }
                    catch (IOException)
                    {
                        // Client side of the pipes should report the problem.
                    }
                    catch (Exception)
                    {
                        // Clients side will notice we went away, and report.
                    }
                    finally
                    {
                        try
                        {
                            out_r.close();
                        }
                        catch (IOException)
                        {
                            // Ignore close failure, we probably crashed above.
                        }

                        try
                        {
                            in_w.close();
                        }
                        catch (IOException)
                        {
                            // Ignore close failure, we probably crashed above.
                        }

                        dst.Close();
                    }
                });
                worker.Name = "JGit-Receive-Pack";
                worker.Start();

                init(in_r, out_w);
                readAdvertisedRefs();
            }
示例#5
0
            public ForkLocalPushConnection( TransportLocal transport)
                : base(transport)
            {
                receivePack = transport.Spawn(transport.OptionReceivePack);

                Stream rpIn = new BufferedStream(receivePack.StandardInput.BaseStream);
                Stream rpOut = new BufferedStream(receivePack.StandardOutput.BaseStream);

                init(rpIn, rpOut);
                readAdvertisedRefs();
            }
示例#6
0
            public ForkLocalFetchConnection( TransportLocal transport)
                : base(transport)
            {
                uploadPack = transport.Spawn(transport.OptionUploadPack);

                Stream upIn = new BufferedStream(uploadPack.StandardInput.BaseStream);
                Stream upOut = new BufferedStream(uploadPack.StandardOutput.BaseStream);

                init(upIn, upOut);
                readAdvertisedRefs();
            }
示例#7
0
            public InternalLocalPushConnection(TransportLocal transport)
                : base(transport)
            {
                Repository dst;

                try
                {
                    dst = new Repository(transport.remoteGitDir);
                }
                catch (IOException)
                {
                    throw new TransportException(uri, "Not a Git directory");
                }

                PipedInputStream  in_r;
                PipedOutputStream in_w;

                PipedInputStream  out_r;
                PipedOutputStream out_w;

                try
                {
                    in_r = new PipedInputStream();
                    in_w = new PipedOutputStream(in_r);

                    out_r = new PipedInputStream();
                    out_w = new PipedOutputStream(out_r);
                }
                catch (IOException ex)
                {
                    dst.Close();
                    throw new TransportException(uri, "Cannot connect pipes", ex);
                }

                worker = new Thread(() =>
                {
                    try
                    {
                        ReceivePack rp = new ReceivePack(dst);
                        rp.receive(out_r, in_w, null);
                    }
                    catch (IOException)
                    {
                        // Client side of the pipes should report the problem.
                    }
                    catch (Exception)
                    {
                        // Clients side will notice we went away, and report.
                    }
                    finally
                    {
                        try
                        {
                            out_r.close();
                        }
                        catch (IOException)
                        {
                            // Ignore close failure, we probably crashed above.
                        }

                        try
                        {
                            in_w.close();
                        }
                        catch (IOException)
                        {
                            // Ignore close failure, we probably crashed above.
                        }

                        dst.Close();
                    }
                });
                worker.Name = "JGit-Receive-Pack";
                worker.Start();

                init(in_r, out_w);
                readAdvertisedRefs();
            }