public virtual void TestLeaf()
        {
            Ref         a;
            SymbolicRef b;
            SymbolicRef c;
            SymbolicRef d;

            a = new ObjectIdRef.PeeledTag(RefStorage.PACKED, targetName, ID_A, ID_B);
            b = new SymbolicRef("B", a);
            c = new SymbolicRef("C", b);
            d = new SymbolicRef("D", c);
            NUnit.Framework.Assert.AreSame(c, d.GetTarget());
            NUnit.Framework.Assert.AreSame(b, c.GetTarget());
            NUnit.Framework.Assert.AreSame(a, b.GetTarget());
            NUnit.Framework.Assert.AreSame(a, d.GetLeaf());
            NUnit.Framework.Assert.AreSame(a, c.GetLeaf());
            NUnit.Framework.Assert.AreSame(a, b.GetLeaf());
            NUnit.Framework.Assert.AreSame(a, a.GetLeaf());
            NUnit.Framework.Assert.AreSame(ID_A, d.GetObjectId());
            NUnit.Framework.Assert.AreSame(ID_A, c.GetObjectId());
            NUnit.Framework.Assert.AreSame(ID_A, b.GetObjectId());
            NUnit.Framework.Assert.IsTrue(d.IsPeeled());
            NUnit.Framework.Assert.IsTrue(c.IsPeeled());
            NUnit.Framework.Assert.IsTrue(b.IsPeeled());
            NUnit.Framework.Assert.AreSame(ID_B, d.GetPeeledObjectId());
            NUnit.Framework.Assert.AreSame(ID_B, c.GetPeeledObjectId());
            NUnit.Framework.Assert.AreSame(ID_B, b.GetPeeledObjectId());
        }
Example #2
0
		public virtual void TestConstructor()
		{
			Ref t;
			SymbolicRef r;
			t = new ObjectIdRef.Unpeeled(RefStorage.NEW, targetName, null);
			r = new SymbolicRef(name, t);
			NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage());
			NUnit.Framework.Assert.AreSame(name, r.GetName());
			NUnit.Framework.Assert.IsNull(r.GetObjectId(), "no id on new ref");
			NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled");
			NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
			NUnit.Framework.Assert.AreSame(t, r.GetLeaf(), "leaf is t");
			NUnit.Framework.Assert.AreSame(t, r.GetTarget(), "target is t");
			NUnit.Framework.Assert.IsTrue(r.IsSymbolic(), "is symbolic");
			t = new ObjectIdRef.Unpeeled(RefStorage.PACKED, targetName, ID_A);
			r = new SymbolicRef(name, t);
			NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage());
			NUnit.Framework.Assert.AreSame(name, r.GetName());
			NUnit.Framework.Assert.AreSame(ID_A, r.GetObjectId());
			NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled");
			NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
			NUnit.Framework.Assert.AreSame(t, r.GetLeaf(), "leaf is t");
			NUnit.Framework.Assert.AreSame(t, r.GetTarget(), "target is t");
			NUnit.Framework.Assert.IsTrue(r.IsSymbolic(), "is symbolic");
		}
        public virtual void TestConstructor()
        {
            Ref         t;
            SymbolicRef r;

            t = new ObjectIdRef.Unpeeled(RefStorage.NEW, targetName, null);
            r = new SymbolicRef(name, t);
            NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage());
            NUnit.Framework.Assert.AreSame(name, r.GetName());
            NUnit.Framework.Assert.IsNull(r.GetObjectId(), "no id on new ref");
            NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled");
            NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
            NUnit.Framework.Assert.AreSame(t, r.GetLeaf(), "leaf is t");
            NUnit.Framework.Assert.AreSame(t, r.GetTarget(), "target is t");
            NUnit.Framework.Assert.IsTrue(r.IsSymbolic(), "is symbolic");
            t = new ObjectIdRef.Unpeeled(RefStorage.PACKED, targetName, ID_A);
            r = new SymbolicRef(name, t);
            NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage());
            NUnit.Framework.Assert.AreSame(name, r.GetName());
            NUnit.Framework.Assert.AreSame(ID_A, r.GetObjectId());
            NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled");
            NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
            NUnit.Framework.Assert.AreSame(t, r.GetLeaf(), "leaf is t");
            NUnit.Framework.Assert.AreSame(t, r.GetTarget(), "target is t");
            NUnit.Framework.Assert.IsTrue(r.IsSymbolic(), "is symbolic");
        }
        public virtual void TestToString()
        {
            Ref         a;
            SymbolicRef b;
            SymbolicRef c;
            SymbolicRef d;

            a = new ObjectIdRef.PeeledTag(RefStorage.PACKED, targetName, ID_A, ID_B);
            b = new SymbolicRef("B", a);
            c = new SymbolicRef("C", b);
            d = new SymbolicRef("D", c);
            NUnit.Framework.Assert.AreEqual("SymbolicRef[D -> C -> B -> " + targetName + "="
                                            + ID_A.Name + "]", d.ToString());
        }
			/// <exception cref="NGit.Errors.TransportException"></exception>
			private Ref ReadRef(SortedDictionary<string, Ref> avail, string rn)
			{
				string s;
				string @ref = WalkRemoteObjectDatabase.ROOT_DIR + rn;
				try
				{
					BufferedReader br = this.OpenReader(@ref);
					try
					{
						s = br.ReadLine();
					}
					finally
					{
						br.Close();
					}
				}
				catch (FileNotFoundException)
				{
					return null;
				}
				catch (IOException err)
				{
					throw new TransportException(this.GetURI(), MessageFormat.Format(JGitText.Get().transportExceptionReadRef
						, @ref), err);
				}
				if (s == null)
				{
					throw new TransportException(this.GetURI(), MessageFormat.Format(JGitText.Get().transportExceptionEmptyRef
						, rn));
				}
				if (s.StartsWith("ref: "))
				{
					string target = Sharpen.Runtime.Substring(s, "ref: ".Length);
					Ref r = avail.Get(target);
					if (r == null)
					{
						r = this.ReadRef(avail, target);
					}
					if (r == null)
					{
						r = new ObjectIdRef.Unpeeled(RefStorage.NEW, target, null);
					}
					r = new SymbolicRef(rn, r);
					avail.Put(r.GetName(), r);
					return r;
				}
				if (ObjectId.IsId(s))
				{
					Ref r = new ObjectIdRef.Unpeeled(this.Loose(avail.Get(rn)), rn, ObjectId.FromString
						(s));
					avail.Put(r.GetName(), r);
					return r;
				}
				throw new TransportException(this.GetURI(), MessageFormat.Format(JGitText.Get().transportExceptionBadRef
					, rn, s));
			}
Example #6
0
		public virtual void TestIntoSymbolicRefHeadPointingToMaster()
		{
			Ref a = db.GetRef("refs/heads/a");
			Ref master = db.GetRef("refs/heads/master");
			SymbolicRef head = new SymbolicRef("HEAD", master);
			string message = formatter.Format(Arrays.AsList(a), head);
			NUnit.Framework.Assert.AreEqual("Merge branch 'a'", message);
		}
Example #7
0
		public virtual void TestIntoHeadOtherThanMaster()
		{
			Ref a = db.GetRef("refs/heads/a");
			Ref b = db.GetRef("refs/heads/b");
			SymbolicRef head = new SymbolicRef("HEAD", b);
			string message = formatter.Format(Arrays.AsList(a), head);
			NUnit.Framework.Assert.AreEqual("Merge branch 'a' into b", message);
		}
Example #8
0
		public virtual void TestLeaf()
		{
			Ref a;
			SymbolicRef b;
			SymbolicRef c;
			SymbolicRef d;
			a = new ObjectIdRef.PeeledTag(RefStorage.PACKED, targetName, ID_A, ID_B);
			b = new SymbolicRef("B", a);
			c = new SymbolicRef("C", b);
			d = new SymbolicRef("D", c);
			NUnit.Framework.Assert.AreSame(c, d.GetTarget());
			NUnit.Framework.Assert.AreSame(b, c.GetTarget());
			NUnit.Framework.Assert.AreSame(a, b.GetTarget());
			NUnit.Framework.Assert.AreSame(a, d.GetLeaf());
			NUnit.Framework.Assert.AreSame(a, c.GetLeaf());
			NUnit.Framework.Assert.AreSame(a, b.GetLeaf());
			NUnit.Framework.Assert.AreSame(a, a.GetLeaf());
			NUnit.Framework.Assert.AreSame(ID_A, d.GetObjectId());
			NUnit.Framework.Assert.AreSame(ID_A, c.GetObjectId());
			NUnit.Framework.Assert.AreSame(ID_A, b.GetObjectId());
			NUnit.Framework.Assert.IsTrue(d.IsPeeled());
			NUnit.Framework.Assert.IsTrue(c.IsPeeled());
			NUnit.Framework.Assert.IsTrue(b.IsPeeled());
			NUnit.Framework.Assert.AreSame(ID_B, d.GetPeeledObjectId());
			NUnit.Framework.Assert.AreSame(ID_B, c.GetPeeledObjectId());
			NUnit.Framework.Assert.AreSame(ID_B, b.GetPeeledObjectId());
		}
Example #9
0
		public virtual void TestToString()
		{
			Ref a;
			SymbolicRef b;
			SymbolicRef c;
			SymbolicRef d;
			a = new ObjectIdRef.PeeledTag(RefStorage.PACKED, targetName, ID_A, ID_B);
			b = new SymbolicRef("B", a);
			c = new SymbolicRef("C", b);
			d = new SymbolicRef("D", c);
			NUnit.Framework.Assert.AreEqual("SymbolicRef[D -> C -> B -> " + targetName + "=" 
				+ ID_A.Name + "]", d.ToString());
		}