示例#1
0
        public virtual void Test000_openrepo_alternate_index_file_and_objdirs()
        {
            FilePath   repo1Parent  = new FilePath(trash.GetParentFile(), "r1");
            FilePath   indexFile    = new FilePath(trash, "idx");
            FilePath   objDir       = new FilePath(trash, "../obj");
            FilePath   altObjDir    = ((ObjectDirectory)db.ObjectDatabase).GetDirectory();
            Repository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants.
                                                                      DOT_GIT));

            repo1initial.Create();
            repo1initial.Close();
            FilePath       theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
            FileRepository r      = new FileRepositoryBuilder().SetGitDir(theDir).SetObjectDirectory
                                        (objDir).AddAlternateObjectDirectory(altObjDir).SetIndexFile(indexFile).Build();

            //
            //
            //
            //
            AssertEqualsPath(theDir, r.Directory);
            AssertEqualsPath(theDir.GetParentFile(), r.WorkTree);
            AssertEqualsPath(indexFile, r.GetIndexFile());
            AssertEqualsPath(objDir, ((ObjectDirectory)r.ObjectDatabase).GetDirectory());
            NUnit.Framework.Assert.IsNotNull(r.Open(ObjectId.FromString("6db9c2ebf75590eef973081736730a9ea169a0c4"
                                                                        )));
            // Must close or the default repo pack files created by this test gets
            // locked via the alternate object directories on Windows.
            r.Close();
        }
示例#2
0
        public virtual void Test000_openrepo_default_workDirSet()
        {
            FilePath   repo1Parent  = new FilePath(trash.GetParentFile(), "r1");
            Repository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants.
                                                                      DOT_GIT));

            repo1initial.Create();
            repo1initial.Close();
            FilePath       theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
            FileRepository r      = new FileRepositoryBuilder().SetWorkTree(repo1Parent).Build();

            AssertEqualsPath(theDir, r.Directory);
            AssertEqualsPath(repo1Parent, r.WorkTree);
            AssertEqualsPath(new FilePath(theDir, "index"), r.GetIndexFile());
            AssertEqualsPath(new FilePath(theDir, "objects"), ((ObjectDirectory)r.ObjectDatabase
                                                               ).GetDirectory());
        }
示例#3
0
        public virtual void Test000_openrepo_default_relative_workdirconfig()
        {
            FilePath repo1Parent = new FilePath(trash.GetParentFile(), "r1");
            FilePath workdir     = new FilePath(trash.GetParentFile(), "rw");

            FileUtils.Mkdir(workdir);
            FileRepository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants
                                                                          .DOT_GIT));

            repo1initial.Create();
            FileBasedConfig cfg = ((FileBasedConfig)repo1initial.GetConfig());

            cfg.SetString("core", null, "worktree", "../../rw");
            cfg.Save();
            repo1initial.Close();
            FilePath       theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
            FileRepository r      = new FileRepositoryBuilder().SetGitDir(theDir).Build();

            AssertEqualsPath(theDir, r.Directory);
            AssertEqualsPath(workdir, r.WorkTree);
            AssertEqualsPath(new FilePath(theDir, "index"), r.GetIndexFile());
            AssertEqualsPath(new FilePath(theDir, "objects"), ((ObjectDirectory)r.ObjectDatabase
                                                               ).GetDirectory());
        }
示例#4
0
 public virtual void Test000_openrepo_alternate_index_file_and_objdirs()
 {
     FilePath repo1Parent = new FilePath(trash.GetParentFile(), "r1");
     FilePath indexFile = new FilePath(trash, "idx");
     FilePath objDir = new FilePath(trash, "../obj");
     FilePath altObjDir = ((ObjectDirectory)db.ObjectDatabase).GetDirectory();
     Repository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants.
         DOT_GIT));
     repo1initial.Create();
     repo1initial.Close();
     FilePath theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
     FileRepository r = new FileRepositoryBuilder().SetGitDir(theDir).SetObjectDirectory
         (objDir).AddAlternateObjectDirectory(altObjDir).SetIndexFile(indexFile).Build();
     //
     //
     //
     //
     AssertEqualsPath(theDir, r.Directory);
     AssertEqualsPath(theDir.GetParentFile(), r.WorkTree);
     AssertEqualsPath(indexFile, r.GetIndexFile());
     AssertEqualsPath(objDir, ((ObjectDirectory)r.ObjectDatabase).GetDirectory());
     NUnit.Framework.Assert.IsNotNull(r.Open(ObjectId.FromString("6db9c2ebf75590eef973081736730a9ea169a0c4"
         )));
     // Must close or the default repo pack files created by this test gets
     // locked via the alternate object directories on Windows.
     r.Close();
 }
示例#5
0
 public virtual void Test000_openrepo_default_workDirSet()
 {
     FilePath repo1Parent = new FilePath(trash.GetParentFile(), "r1");
     Repository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants.
         DOT_GIT));
     repo1initial.Create();
     repo1initial.Close();
     FilePath theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
     FileRepository r = new FileRepositoryBuilder().SetWorkTree(repo1Parent).Build();
     AssertEqualsPath(theDir, r.Directory);
     AssertEqualsPath(repo1Parent, r.WorkTree);
     AssertEqualsPath(new FilePath(theDir, "index"), r.GetIndexFile());
     AssertEqualsPath(new FilePath(theDir, "objects"), ((ObjectDirectory)r.ObjectDatabase
         ).GetDirectory());
 }
示例#6
0
 public virtual void Test000_openrepo_default_relative_workdirconfig()
 {
     FilePath repo1Parent = new FilePath(trash.GetParentFile(), "r1");
     FilePath workdir = new FilePath(trash.GetParentFile(), "rw");
     FileUtils.Mkdir(workdir);
     FileRepository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants
         .DOT_GIT));
     repo1initial.Create();
     FileBasedConfig cfg = ((FileBasedConfig)repo1initial.GetConfig());
     cfg.SetString("core", null, "worktree", "../../rw");
     cfg.Save();
     repo1initial.Close();
     FilePath theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
     FileRepository r = new FileRepositoryBuilder().SetGitDir(theDir).Build();
     AssertEqualsPath(theDir, r.Directory);
     AssertEqualsPath(workdir, r.WorkTree);
     AssertEqualsPath(new FilePath(theDir, "index"), r.GetIndexFile());
     AssertEqualsPath(new FilePath(theDir, "objects"), ((ObjectDirectory)r.ObjectDatabase
         ).GetDirectory());
 }
示例#7
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public InternalLocalPushConnection(TransportLocal _enclosing)
     : base(_enclosing)
 {
     this._enclosing = _enclosing;
     Repository dst;
     try
     {
         dst = new FileRepository(this._enclosing.remoteGitDir);
     }
     catch (IOException)
     {
         throw new TransportException(this.uri, JGitText.Get().notAGitDirectory);
     }
     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 err)
     {
         dst.Close();
         throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err);
     }
     this.worker = new _Thread_365(this, dst, out_r, in_w, "JGit-Receive-Pack");
     // Client side of the pipes should report the problem.
     // Clients side will notice we went away, and report.
     // Ignore close failure, we probably crashed above.
     // Ignore close failure, we probably crashed above.
     this.worker.Start();
     this.Init(in_r, out_w);
     this.ReadAdvertisedRefs();
 }
示例#8
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public InternalLocalFetchConnection(TransportLocal _enclosing)
     : base(_enclosing)
 {
     this._enclosing = _enclosing;
     Repository dst;
     try
     {
         dst = new FileRepository(this._enclosing.remoteGitDir);
     }
     catch (IOException)
     {
         throw new TransportException(this.uri, JGitText.Get().notAGitDirectory);
     }
     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_218();
         // The client (BasePackFetchConnection) can write
         // a huge burst before it reads again. We need to
         // force the buffer to be big enough, otherwise it
         // will deadlock both threads.
         out_w = new PipedOutputStream(out_r);
     }
     catch (IOException err)
     {
         dst.Close();
         throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err);
     }
     this.worker = new _Thread_233(this, dst, out_r, in_w, "JGit-Upload-Pack");
     // Client side of the pipes should report the problem.
     // Clients side will notice we went away, and report.
     // Ignore close failure, we probably crashed above.
     // Ignore close failure, we probably crashed above.
     this.worker.Start();
     this.Init(in_r, out_w);
     this.ReadAdvertisedRefs();
 }
示例#9
0
 internal override void Close()
 {
     repository.Close();
 }