public virtual void TestConstructor_Peeled()
        {
            ObjectIdRef r;

            r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, name, ID_A);
            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(r, r.GetLeaf(), "leaf is this");
            NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this");
            NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic");
            r = new ObjectIdRef.PeeledNonTag(RefStorage.LOOSE, name, ID_A);
            NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled");
            NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
            r = new ObjectIdRef.PeeledTag(RefStorage.LOOSE, name, ID_A, ID_B);
            NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled");
            NUnit.Framework.Assert.AreSame(ID_B, r.GetPeeledObjectId());
        }
		/// <exception cref="System.IO.IOException"></exception>
		private void ReadPackedRefsImpl(IDictionary<string, Ref> avail, BufferedReader br
			)
		{
			Ref last = null;
			bool peeled = false;
			for (; ; )
			{
				string line = br.ReadLine();
				if (line == null)
				{
					break;
				}
				if (line[0] == '#')
				{
					if (line.StartsWith(RefDirectory.PACKED_REFS_HEADER))
					{
						line = Sharpen.Runtime.Substring(line, RefDirectory.PACKED_REFS_HEADER.Length);
						peeled = line.Contains(RefDirectory.PACKED_REFS_PEELED);
					}
					continue;
				}
				if (line[0] == '^')
				{
					if (last == null)
					{
						throw new TransportException(JGitText.Get().peeledLineBeforeRef);
					}
					ObjectId id = ObjectId.FromString(Sharpen.Runtime.Substring(line, 1));
					last = new ObjectIdRef.PeeledTag(RefStorage.PACKED, last.GetName(), last.GetObjectId
						(), id);
					avail.Put(last.GetName(), last);
					continue;
				}
				int sp = line.IndexOf(' ');
				if (sp < 0)
				{
					throw new TransportException(MessageFormat.Format(JGitText.Get().unrecognizedRef, 
						line));
				}
				ObjectId id_1 = ObjectId.FromString(Sharpen.Runtime.Substring(line, 0, sp));
				string name = Sharpen.Runtime.Substring(line, sp + 1);
				if (peeled)
				{
					last = new ObjectIdRef.PeeledNonTag(RefStorage.PACKED, name, id_1);
				}
				else
				{
					last = new ObjectIdRef.Unpeeled(RefStorage.PACKED, name, id_1);
				}
				avail.Put(last.GetName(), last);
			}
		}
Esempio n. 3
0
		public virtual void TestConstructor_Peeled()
		{
			ObjectIdRef r;
			r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, name, ID_A);
			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(r, r.GetLeaf(), "leaf is this");
			NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this");
			NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic");
			r = new ObjectIdRef.PeeledNonTag(RefStorage.LOOSE, name, ID_A);
			NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled");
			NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
			r = new ObjectIdRef.PeeledTag(RefStorage.LOOSE, name, ID_A, ID_B);
			NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled");
			NUnit.Framework.Assert.AreSame(ID_B, r.GetPeeledObjectId());
		}