Ejemplo n.º 1
0
        public void testGetRefs_PackedWithPeeled()
        {
            IDictionary <string, global::GitSharp.Core.Ref> all;

            writePackedRefs("# pack-refs with: peeled \n" +   //
                            A.Name + " refs/heads/master\n" + //
                            B.Name + " refs/heads/other\n" +  //
                            v1_0.Name + " refs/tags/v1.0\n" + //
                            "^" + v1_0.getObject().Name + "\n");
            all = refdir.getRefs(RefDatabase.ALL);

            Assert.AreEqual(4, all.size());
            global::GitSharp.Core.Ref head   = all.get(Constants.HEAD);
            global::GitSharp.Core.Ref master = all.get("refs/heads/master");
            global::GitSharp.Core.Ref other  = all.get("refs/heads/other");
            global::GitSharp.Core.Ref tag    = all.get("refs/tags/v1.0");

            Assert.AreEqual(A, master.getObjectId());
            Assert.IsTrue(master.isPeeled());
            Assert.IsNull(master.getPeeledObjectId());

            Assert.AreEqual(B, other.getObjectId());
            Assert.IsTrue(other.isPeeled());
            Assert.IsNull(other.getPeeledObjectId());

            Assert.AreSame(master, head.getTarget());
            Assert.AreEqual(A, head.getObjectId());
            Assert.IsTrue(head.isPeeled());
            Assert.IsNull(head.getPeeledObjectId());

            Assert.AreEqual(v1_0, tag.getObjectId());
            Assert.IsTrue(tag.isPeeled());
            Assert.AreEqual(v1_0.getObject(), tag.getPeeledObjectId());
        }
Ejemplo n.º 2
0
        public void testGetRef_PackedNotPeeled_WrongSort()
        {
            writePackedRefs("" +                              //
                            v1_0.Name + " refs/tags/v1.0\n" + //
                            B.Name + " refs/heads/other\n" +  //
                            A.Name + " refs/heads/master\n");

            global::GitSharp.Core.Ref head   = refdir.getRef(Constants.HEAD);
            global::GitSharp.Core.Ref master = refdir.getRef("refs/heads/master");
            global::GitSharp.Core.Ref other  = refdir.getRef("refs/heads/other");
            global::GitSharp.Core.Ref tag    = refdir.getRef("refs/tags/v1.0");

            Assert.AreEqual(A, master.getObjectId());
            Assert.IsFalse(master.isPeeled());
            Assert.IsNull(master.getPeeledObjectId());

            Assert.AreEqual(B, other.getObjectId());
            Assert.IsFalse(other.isPeeled());
            Assert.IsNull(other.getPeeledObjectId());

            Assert.AreSame(master, head.getTarget());
            Assert.AreEqual(A, head.getObjectId());
            Assert.IsFalse(head.isPeeled());
            Assert.IsNull(head.getPeeledObjectId());

            Assert.AreEqual(v1_0, tag.getObjectId());
            Assert.IsFalse(tag.isPeeled());
            Assert.IsNull(tag.getPeeledObjectId());
        }
Ejemplo n.º 3
0
 public virtual void testReadSymRefToPacked()
 {
     writeSymref("HEAD", "refs/heads/b");
     global::GitSharp.Core.Ref @ref = db.getRef("HEAD");
     Assert.AreEqual(Storage.Loose, @ref.StorageFormat);
     Assert.IsTrue(@ref.isSymbolic(), "is symref");
     @ref = @ref.getTarget();
     Assert.AreEqual("refs/heads/b", @ref.Name);
     Assert.AreEqual(Storage.Packed, @ref.StorageFormat);
 }
Ejemplo n.º 4
0
        public void testResolvedNamesSymRef()
        {
            global::GitSharp.Core.Ref @ref = db.getRef(Constants.HEAD);
            Assert.AreEqual(Constants.HEAD, @ref.Name);
            Assert.IsTrue(@ref.isSymbolic(), "is symbolic ref");
            Assert.AreSame(Storage.Loose, @ref.StorageFormat);

            global::GitSharp.Core.Ref dst = @ref.getTarget();
            Assert.IsNotNull(dst, "has target");
            Assert.AreEqual("refs/heads/master", dst.Name);

            Assert.AreSame(dst.ObjectId, @ref.ObjectId);
            Assert.AreSame(dst.PeeledObjectId, @ref.PeeledObjectId);
            Assert.AreEqual(dst.IsPeeled, @ref.IsPeeled);
        }
Ejemplo n.º 5
0
        public void testPeelLooseTag()
        {
            writeLooseRef("refs/tags/v1_0", v1_0);
            writeLooseRef("refs/tags/current", "ref: refs/tags/v1_0\n");

            global::GitSharp.Core.Ref tag = refdir.getRef("refs/tags/v1_0");
            global::GitSharp.Core.Ref cur = refdir.getRef("refs/tags/current");

            Assert.AreEqual(v1_0, tag.getObjectId());
            Assert.IsFalse(tag.isSymbolic());
            Assert.IsFalse(tag.isPeeled());
            Assert.IsNull(tag.getPeeledObjectId());

            Assert.AreEqual(v1_0, cur.getObjectId());
            Assert.IsTrue(cur.isSymbolic());
            Assert.IsFalse(cur.isPeeled());
            Assert.IsNull(cur.getPeeledObjectId());

            global::GitSharp.Core.Ref tag_p = refdir.peel(tag);
            global::GitSharp.Core.Ref cur_p = refdir.peel(cur);

            Assert.AreNotSame(tag, tag_p);
            Assert.IsFalse(tag_p.isSymbolic());
            Assert.IsTrue(tag_p.isPeeled());
            Assert.AreEqual(v1_0, tag_p.getObjectId());
            Assert.AreEqual(v1_0.getObject(), tag_p.getPeeledObjectId());
            Assert.AreSame(tag_p, refdir.peel(tag_p));

            Assert.AreNotSame(cur, cur_p);
            Assert.AreEqual("refs/tags/current", cur_p.getName());
            Assert.IsTrue(cur_p.isSymbolic());
            Assert.AreEqual("refs/tags/v1_0", cur_p.getTarget().getName());
            Assert.IsTrue(cur_p.isPeeled());
            Assert.AreEqual(v1_0, cur_p.getObjectId());
            Assert.AreEqual(v1_0.getObject(), cur_p.getPeeledObjectId());

            // reuses cached peeling later, but not immediately due to
            // the implementation so we have to fetch it once.
            global::GitSharp.Core.Ref tag_p2 = refdir.getRef("refs/tags/v1_0");
            Assert.IsFalse(tag_p2.isSymbolic());
            Assert.IsTrue(tag_p2.isPeeled());
            Assert.AreEqual(v1_0, tag_p2.getObjectId());
            Assert.AreEqual(v1_0.getObject(), tag_p2.getPeeledObjectId());

            Assert.AreSame(tag_p2, refdir.getRef("refs/tags/v1_0"));
            Assert.AreSame(tag_p2, refdir.getRef("refs/tags/current").getTarget());
            Assert.AreSame(tag_p2, refdir.peel(tag_p2));
        }
Ejemplo n.º 6
0
        public void testReadSymRefToLoosePacked()
        {
            ObjectId  pid       = db.Resolve("refs/heads/master^");
            RefUpdate updateRef = db.UpdateRef("refs/heads/master");

            updateRef.setNewObjectId(pid);
            updateRef.setForceUpdate(true);
            RefUpdate.RefUpdateResult update = updateRef.update();
            Assert.AreEqual(RefUpdate.RefUpdateResult.FORCED, update); // internal

            writeSymref("HEAD", "refs/heads/master");
            global::GitSharp.Core.Ref @ref = db.getRef("HEAD");
            Assert.AreEqual(Storage.Loose, @ref.StorageFormat);
            @ref = @ref.getTarget();
            Assert.AreEqual("refs/heads/master", @ref.Name);
            Assert.AreEqual(Storage.Loose, @ref.StorageFormat);
        }