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 void testGetRef_AnyHeadWithGarbage()
        {
            write(PathUtil.CombineFilePath(diskRepo.Directory, "refs/heads/A"), A.Name
                  + "012345 . this is not a standard reference\n"
                  + "#and even more junk\n");

            global::GitSharp.Core.Ref r = refdir.getRef("refs/heads/A");
            Assert.IsFalse(r.isSymbolic());
            Assert.AreEqual(A, r.getObjectId());
            Assert.AreEqual("refs/heads/A", r.getName());
            Assert.IsFalse(r.isPeeled());
            Assert.IsNull(r.getPeeledObjectId());
        }
Ejemplo n.º 4
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.º 5
0
        public void testGetRef_FetchHead()
        {
            // This is an odd special case where we need to make sure we read
            // exactly the first 40 bytes of the file and nothing further on
            // that line, or the remainder of the file.
            write(PathUtil.CombineFilePath(diskRepo.Directory, "FETCH_HEAD"), A.Name
                  + "\tnot-for-merge"
                  + "\tbranch 'master' of git://egit.eclipse.org/jgit\n");

            global::GitSharp.Core.Ref r = refdir.getRef("FETCH_HEAD");
            Assert.IsFalse(r.isSymbolic());
            Assert.AreEqual(A, r.getObjectId());
            Assert.AreEqual("FETCH_HEAD", r.getName());
            Assert.IsFalse(r.isPeeled());
            Assert.IsNull(r.getPeeledObjectId());
        }
Ejemplo n.º 6
0
        public void testPeelCommit()
        {
            writeLooseRef("refs/heads/master", A);

            global::GitSharp.Core.Ref master = refdir.getRef("refs/heads/master");
            Assert.AreEqual(A, master.getObjectId());
            Assert.IsFalse(master.isPeeled());
            Assert.IsNull(master.getPeeledObjectId());

            global::GitSharp.Core.Ref master_p = refdir.peel(master);
            Assert.AreNotSame(master, master_p);
            Assert.AreEqual(A, master_p.getObjectId());
            Assert.IsTrue(master_p.isPeeled());
            Assert.IsNull(master_p.getPeeledObjectId());

            // reuses cached peeling later, but not immediately due to
            // the implementation so we have to fetch it once.
            global::GitSharp.Core.Ref master_p2 = refdir.getRef("refs/heads/master");
            Assert.AreNotSame(master, master_p2);
            Assert.AreEqual(A, master_p2.getObjectId());
            Assert.IsTrue(master_p2.isPeeled());
            Assert.IsNull(master_p2.getPeeledObjectId());
            Assert.AreSame(master_p2, refdir.peel(master_p2));
        }