Пример #1
0
        /// <summary>Compares this abbreviation to a full object id.</summary>
        /// <remarks>Compares this abbreviation to a full object id.</remarks>
        /// <param name="other">the other object id.</param>
        /// <returns>
        /// &lt;0 if this abbreviation names an object that is less than
        /// <code>other</code>; 0 if this abbreviation exactly matches the
        /// first
        /// <see cref="Length()">Length()</see>
        /// digits of <code>other.name()</code>;
        /// &gt;0 if this abbreviation names an object that is after
        /// <code>other</code>.
        /// </returns>
        public int PrefixCompare(AnyObjectId other)
        {
            int cmp;

            cmp = NB.CompareUInt32(w1, Mask(1, other.w1));
            if (cmp != 0)
            {
                return(cmp);
            }
            cmp = NB.CompareUInt32(w2, Mask(2, other.w2));
            if (cmp != 0)
            {
                return(cmp);
            }
            cmp = NB.CompareUInt32(w3, Mask(3, other.w3));
            if (cmp != 0)
            {
                return(cmp);
            }
            cmp = NB.CompareUInt32(w4, Mask(4, other.w4));
            if (cmp != 0)
            {
                return(cmp);
            }
            return(NB.CompareUInt32(w5, Mask(5, other.w5)));
        }
Пример #2
0
        /// <summary>Store an object for future lookup.</summary>
        /// <remarks>
        /// Store an object for future lookup.
        /// <p>
        /// Stores
        /// <code>newValue</code>
        /// , but only if there is not already an object for
        /// the same object name. Callers can tell if the value is new by checking
        /// the return value with reference equality:
        /// <pre>
        /// V obj = ...;
        /// boolean wasNew = map.addIfAbsent(obj) == obj;
        /// </pre>
        /// </remarks>
        /// <param name="newValue">the object to store.</param>
        /// <returns>
        ///
        /// <code>newValue</code>
        /// if stored, or the prior value already stored and
        /// that would have been returned had the caller used
        /// <code>get(newValue)</code>
        /// first.
        /// </returns>
        /// <?></?>
        public virtual V AddIfAbsent <Q>(Q newValue) where Q : V
        {
            int i = ((ObjectId)newValue).w1 & mask;

            V[] tbl = table;
            int end = tbl.Length;
            V   obj;

            while ((obj = tbl[i]) != null)
            {
                if (AnyObjectId.Equals(obj, newValue))
                {
                    return(obj);
                }
                if (++i == end)
                {
                    i = 0;
                }
            }
            if (++size == grow)
            {
                Grow();
                Insert(newValue);
            }
            else
            {
                tbl[i] = newValue;
            }
            return(newValue);
        }
Пример #3
0
        /// <summary>Compare this ObjectId to another and obtain a sort ordering.</summary>
        /// <remarks>Compare this ObjectId to another and obtain a sort ordering.</remarks>
        /// <param name="other">the other id to compare to. Must not be null.</param>
        /// <returns>
        /// &lt; 0 if this id comes before other; 0 if this id is equal to
        /// other; &gt; 0 if this id comes after other.
        /// </returns>
        public int CompareTo(AnyObjectId other)
        {
            if (this == other)
            {
                return(0);
            }
            int cmp;

            cmp = NB.CompareUInt32(w1, other.w1);
            if (cmp != 0)
            {
                return(cmp);
            }
            cmp = NB.CompareUInt32(w2, other.w2);
            if (cmp != 0)
            {
                return(cmp);
            }
            cmp = NB.CompareUInt32(w3, other.w3);
            if (cmp != 0)
            {
                return(cmp);
            }
            cmp = NB.CompareUInt32(w4, other.w4);
            if (cmp != 0)
            {
                return(cmp);
            }
            return(NB.CompareUInt32(w5, other.w5));
        }
 /// <summary>Copy an ObjectId into this mutable buffer.</summary>
 /// <remarks>Copy an ObjectId into this mutable buffer.</remarks>
 /// <param name="src">the source id to copy from.</param>
 public virtual void FromObjectId(AnyObjectId src)
 {
     this.w1 = src.w1;
     this.w2 = src.w2;
     this.w3 = src.w3;
     this.w4 = src.w4;
     this.w5 = src.w5;
 }
Пример #5
0
 /// <summary>Initialize this instance by copying another existing ObjectId.</summary>
 /// <remarks>
 /// Initialize this instance by copying another existing ObjectId.
 /// <p>
 /// This constructor is mostly useful for subclasses who want to extend an
 /// ObjectId with more properties, but initialize from an existing ObjectId
 /// instance acquired by other means.
 /// </remarks>
 /// <param name="src">another already parsed ObjectId to copy the value out of.</param>
 protected internal ObjectId(AnyObjectId src)
 {
     w1 = src.w1;
     w2 = src.w2;
     w3 = src.w3;
     w4 = src.w4;
     w5 = src.w5;
 }
Пример #6
0
        /// <exception cref="System.IO.IOException"></exception>
        internal TrackingRefUpdate(Repository db, string localName, string remoteName, bool
			 forceUpdate, AnyObjectId nv, string msg)
        {
            this.remoteName = remoteName;
            update = db.UpdateRef(localName);
            update.SetForceUpdate(forceUpdate);
            update.SetNewObjectId(nv);
            update.SetRefLogMessage(msg, true);
        }
Пример #7
0
        internal TrackingRefUpdate(bool canForceUpdate, string remoteName, string localName
			, AnyObjectId oldValue, AnyObjectId newValue)
        {
            this.remoteName = remoteName;
            this.localName = localName;
            this.forceUpdate = canForceUpdate;
            this.oldObjectId = oldValue.Copy();
            this.newObjectId = newValue.Copy();
        }
Пример #8
0
		/// <summary>Set the common ancestor tree.</summary>
		/// <remarks>Set the common ancestor tree.</remarks>
		/// <param name="id">
		/// common base treeish; null to automatically compute the common
		/// base from the input commits during
		/// <see cref="Merge(NGit.AnyObjectId[])">Merge(NGit.AnyObjectId[])</see>
		/// .
		/// </param>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException">the object is not a treeish.
		/// 	</exception>
		/// <exception cref="NGit.Errors.MissingObjectException">the object does not exist.</exception>
		/// <exception cref="System.IO.IOException">the object could not be read.</exception>
		public virtual void SetBase(AnyObjectId id)
		{
			if (id != null)
			{
				baseTree = walk.ParseTree(id);
			}
			else
			{
				baseTree = null;
			}
		}
Пример #9
0
 /// <summary>Does the requested object exist in this database?</summary>
 /// <param name="objectId">identity of the object to test for existence of.</param>
 /// <param name="typeHint">
 /// hint about the type of object being requested;
 /// <see cref="OBJ_ANY">OBJ_ANY</see>
 /// if the object type is not known, or does not
 /// matter to the caller.
 /// </param>
 /// <returns>true if the specified object is stored in this database.</returns>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
 /// typeHint was not OBJ_ANY, and the object's actual type does
 /// not match typeHint.
 /// </exception>
 /// <exception cref="System.IO.IOException">the object store cannot be accessed.</exception>
 public virtual bool Has(AnyObjectId objectId, int typeHint)
 {
     try
     {
         Open(objectId, typeHint);
         return(true);
     }
     catch (MissingObjectException)
     {
         return(false);
     }
 }
Пример #10
0
		/// <summary>Parse an object from the unpacked object format.</summary>
		/// <remarks>Parse an object from the unpacked object format.</remarks>
		/// <param name="raw">complete contents of the compressed object.</param>
		/// <param name="id">
		/// expected ObjectId of the object, used only for error reporting
		/// in exceptions.
		/// </param>
		/// <returns>loader to read the inflated contents.</returns>
		/// <exception cref="System.IO.IOException">the object cannot be parsed.</exception>
		public static ObjectLoader Parse(byte[] raw, AnyObjectId id)
		{
			WindowCursor wc = new WindowCursor(null);
			try
			{
				return Open(new ByteArrayInputStream(raw), null, id, wc);
			}
			finally
			{
				wc.Release();
			}
		}
Пример #11
0
 /// <exception cref="NGit.Errors.MissingObjectException"></exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 private static AnyObjectId AsTree(ObjectReader or, AnyObjectId treeish)
 {
     if (treeish is RevTree)
     {
         return(treeish);
     }
     if (treeish is RevCommit && ((RevCommit)treeish).Tree != null)
     {
         return(((RevCommit)treeish).Tree);
     }
     return(new RevWalk(or).ParseTree(treeish).Id);
 }
Пример #12
0
        /// <exception cref="System.IO.IOException"></exception>
        private RefUpdate.Result UpdateImpl(RevWalk walk, RefUpdate.Store store)
        {
            RevObject newObj;
            RevObject oldObj;

            if (GetRefDatabase().IsNameConflicting(GetName()))
            {
                return(RefUpdate.Result.LOCK_FAILURE);
            }
            try
            {
                if (!TryLock(true))
                {
                    return(RefUpdate.Result.LOCK_FAILURE);
                }
                if (expValue != null)
                {
                    ObjectId o;
                    o = oldValue != null ? oldValue : ObjectId.ZeroId;
                    if (!AnyObjectId.Equals(expValue, o))
                    {
                        return(RefUpdate.Result.LOCK_FAILURE);
                    }
                }
                if (oldValue == null)
                {
                    return(store.Execute(RefUpdate.Result.NEW));
                }
                newObj = SafeParse(walk, newValue);
                oldObj = SafeParse(walk, oldValue);
                if (newObj == oldObj && !detachingSymbolicRef)
                {
                    return(store.Execute(RefUpdate.Result.NO_CHANGE));
                }
                if (newObj is RevCommit && oldObj is RevCommit)
                {
                    if (walk.IsMergedInto((RevCommit)oldObj, (RevCommit)newObj))
                    {
                        return(store.Execute(RefUpdate.Result.FAST_FORWARD));
                    }
                }
                if (IsForceUpdate())
                {
                    return(store.Execute(RefUpdate.Result.FORCED));
                }
                return(RefUpdate.Result.REJECTED);
            }
            finally
            {
                Unlock();
            }
        }
Пример #13
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private static byte[] Read(Repository db, AnyObjectId blobId)
        {
            ObjectReader or = db.NewObjectReader();

            try
            {
                return(Read(or, blobId));
            }
            finally
            {
                or.Release();
            }
        }
Пример #14
0
        /// <summary>
        /// Does the requested object exist in this database?
        /// <p>
        /// This is a one-shot call interface which may be faster than allocating a
        /// <see cref="NewReader()">NewReader()</see>
        /// to perform the lookup.
        /// </summary>
        /// <param name="objectId">identity of the object to test for existence of.</param>
        /// <returns>true if the specified object is stored in this database.</returns>
        /// <exception cref="System.IO.IOException">the object store cannot be accessed.</exception>
        public virtual bool Has(AnyObjectId objectId)
        {
            ObjectReader or = NewReader();

            try
            {
                return(or.Has(objectId));
            }
            finally
            {
                or.Release();
            }
        }
Пример #15
0
        /// <summary>Open an object from this database.</summary>
        /// <remarks>
        /// Open an object from this database.
        /// <p>
        /// This is a one-shot call interface which may be faster than allocating a
        /// <see cref="NewReader()">NewReader()</see>
        /// to perform the lookup.
        /// </remarks>
        /// <param name="objectId">identity of the object to open.</param>
        /// <param name="typeHint">
        /// hint about the type of object being requested;
        /// <see cref="ObjectReader.OBJ_ANY">ObjectReader.OBJ_ANY</see>
        /// if the object type is not known,
        /// or does not matter to the caller.
        /// </param>
        /// <returns>
        /// a
        /// <see cref="ObjectLoader">ObjectLoader</see>
        /// for accessing the object.
        /// </returns>
        /// <exception cref="NGit.Errors.MissingObjectException">the object does not exist.</exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
        /// typeHint was not OBJ_ANY, and the object's actual type does
        /// not match typeHint.
        /// </exception>
        /// <exception cref="System.IO.IOException">the object store cannot be accessed.</exception>
        public virtual ObjectLoader Open(AnyObjectId objectId, int typeHint)
        {
            ObjectReader or = NewReader();

            try
            {
                return(or.Open(objectId, typeHint));
            }
            finally
            {
                or.Release();
            }
        }
Пример #16
0
        /// <summary>Lookup an existing mapping.</summary>
        /// <remarks>Lookup an existing mapping.</remarks>
        /// <param name="toFind">the object identifier to find.</param>
        /// <returns>the instance mapped to toFind, or null if no mapping exists.</returns>
        public virtual V Get(AnyObjectId toFind)
        {
            int h   = toFind.w1;
            V   obj = directory[h & mask][(int)(((uint)h) >> SEGMENT_SHIFT)];

            for (; obj != null; obj = (V)obj.next)
            {
                if (Equals(obj, toFind))
                {
                    return(obj);
                }
            }
            return(null);
        }
Пример #17
0
 /// <summary>Add a parent onto the end of the parent list.</summary>
 /// <remarks>Add a parent onto the end of the parent list.</remarks>
 /// <param name="additionalParent">new parent to add onto the end of the current parent list.
 ///     </param>
 public virtual void AddParentId(AnyObjectId additionalParent)
 {
     if (parentIds.Length == 0)
     {
         SetParentId(additionalParent);
     }
     else
     {
         ObjectId[] newParents = new ObjectId[parentIds.Length + 1];
         System.Array.Copy(parentIds, 0, newParents, 0, parentIds.Length);
         newParents[parentIds.Length] = additionalParent.Copy();
         parentIds = newParents;
     }
 }
Пример #18
0
 /// <exception cref="System.IO.IOException"></exception>
 private static RevObject SafeParse(RevWalk rw, AnyObjectId id)
 {
     try
     {
         return(id != null?rw.ParseAny(id) : null);
     }
     catch (MissingObjectException)
     {
         // We can expect some objects to be missing, like if we are
         // trying to force a deletion of a branch and the object it
         // points to has been pruned from the database due to freak
         // corruption accidents (it happens with 'git new-work-dir').
         //
         return(null);
     }
 }
Пример #19
0
 /// <summary>Compare to object identifier byte sequences for equality.</summary>
 /// <remarks>Compare to object identifier byte sequences for equality.</remarks>
 /// <param name="firstObjectId">the first identifier to compare. Must not be null.</param>
 /// <param name="secondObjectId">the second identifier to compare. Must not be null.</param>
 /// <returns>true if the two identifiers are the same.</returns>
 public static bool Equals(AnyObjectId firstObjectId, AnyObjectId secondObjectId)
 {
     if (firstObjectId == secondObjectId)
     {
         return(true);
     }
     // We test word 2 first as odds are someone already used our
     // word 1 as a hash code, and applying that came up with these
     // two instances we are comparing for equality. Therefore the
     // first two words are very likely to be identical. We want to
     // break away from collisions as quickly as possible.
     //
     return(firstObjectId.w2 == secondObjectId.w2 && firstObjectId.w3 == secondObjectId
            .w3 && firstObjectId.w4 == secondObjectId.w4 && firstObjectId.w5 == secondObjectId
            .w5 && firstObjectId.w1 == secondObjectId.w1);
 }
Пример #20
0
		/// <summary>Compare to object identifier byte sequences for equality.</summary>
		/// <remarks>Compare to object identifier byte sequences for equality.</remarks>
		/// <param name="firstObjectId">the first identifier to compare. Must not be null.</param>
		/// <param name="secondObjectId">the second identifier to compare. Must not be null.</param>
		/// <returns>true if the two identifiers are the same.</returns>
		public static bool Equals(AnyObjectId firstObjectId, AnyObjectId secondObjectId)
		{
			if (firstObjectId == secondObjectId)
			{
				return true;
			}
			// We test word 2 first as odds are someone already used our
			// word 1 as a hash code, and applying that came up with these
			// two instances we are comparing for equality. Therefore the
			// first two words are very likely to be identical. We want to
			// break away from collisions as quickly as possible.
			//
			return firstObjectId.w2 == secondObjectId.w2 && firstObjectId.w3 == secondObjectId
				.w3 && firstObjectId.w4 == secondObjectId.w4 && firstObjectId.w5 == secondObjectId
				.w5 && firstObjectId.w1 == secondObjectId.w1;
		}
Пример #21
0
 /// <summary>Add a parent onto the end of the parent list.</summary>
 /// <remarks>Add a parent onto the end of the parent list.</remarks>
 /// <param name="additionalParent">new parent to add onto the end of the current parent list.
 ///     </param>
 public virtual void AddParentId(AnyObjectId additionalParent)
 {
     if (parentIds.Length == 0)
     {
         SetParentId(additionalParent);
     }
     else
     {
         ObjectId[] newParents = new ObjectId[parentIds.Length + 1];
         for (int i = 0; i < parentIds.Length; i++)
         {
             newParents[i] = parentIds[i];
         }
         newParents[parentIds.Length] = additionalParent.Copy();
         parentIds = newParents;
     }
 }
Пример #22
0
		/// <summary>
		/// Create a generator and advance it to the submodule entry at the given
		/// path
		/// </summary>
		/// <param name="repository"></param>
		/// <param name="treeId"></param>
		/// <param name="path"></param>
		/// <returns>generator at given path, null if no submodule at given path</returns>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public static NGit.Submodule.SubmoduleWalk ForPath(Repository repository, AnyObjectId
			 treeId, string path)
		{
			NGit.Submodule.SubmoduleWalk generator = new NGit.Submodule.SubmoduleWalk(repository
				);
			generator.SetTree(treeId);
			PathFilter filter = PathFilter.Create(path);
			generator.SetFilter(filter);
			while (generator.Next())
			{
				if (filter.IsDone(generator.walk))
				{
					return generator;
				}
			}
			return null;
		}
Пример #23
0
        /// <summary>Lookup an existing mapping.</summary>
        /// <remarks>Lookup an existing mapping.</remarks>
        /// <param name="toFind">the object identifier to find.</param>
        /// <returns>the instance mapped to toFind, or null if no mapping exists.</returns>
        public virtual V Get(AnyObjectId toFind)
        {
            int msk = mask;
            int i   = toFind.w1 & msk;

            V[] tbl = table;
            V   obj;

            while ((obj = tbl[i]) != null)
            {
                if (AnyObjectId.Equals(obj, toFind))
                {
                    return(obj);
                }
                i = (i + 1) & msk;
            }
            return(null);
        }
Пример #24
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private static byte[] Read(Repository db, AnyObjectId treeish, string path)
        {
            ObjectReader or = db.NewObjectReader();

            try
            {
                TreeWalk tree = TreeWalk.ForPath(or, path, AsTree(or, treeish));
                if (tree == null)
                {
                    throw new FileNotFoundException(MessageFormat.Format(JGitText.Get().entryNotFoundByPath
                                                                         , path));
                }
                return(Read(or, tree.GetObjectId(0)));
            }
            finally
            {
                or.Release();
            }
        }
Пример #25
0
        /// <summary>Lookup an existing mapping.</summary>
        /// <remarks>Lookup an existing mapping.</remarks>
        /// <param name="toFind">the object identifier to find.</param>
        /// <returns>the instance mapped to toFind, or null if no mapping exists.</returns>
        public virtual V Get(AnyObjectId toFind)
        {
            int i = toFind.w1 & mask;

            V[] tbl = table;
            int end = tbl.Length;
            V   obj;

            while ((obj = tbl[i]) != null)
            {
                if (AnyObjectId.Equals(obj, toFind))
                {
                    return(obj);
                }
                if (++i == end)
                {
                    i = 0;
                }
            }
            return(null);
        }
Пример #26
0
		internal virtual void Add(AnyObjectId objectId)
		{
			UnpackedObjectCache.Table t = table;
			if (t.Add(objectId))
			{
			}
			else
			{
				// The object either already exists in the table, or was
				// successfully added. Either way leave the table alone.
				//
				// The object won't fit into the table. Implement a crude
				// cache removal by just dropping the table away, but double
				// it in size for the next incarnation.
				//
				UnpackedObjectCache.Table n = new UnpackedObjectCache.Table(Math.Min(t.bits + 1, 
					MAX_BITS));
				n.Add(objectId);
				table = n;
			}
		}
Пример #27
0
 /// <summary>Append any entry to the tree.</summary>
 /// <remarks>Append any entry to the tree.</remarks>
 /// <param name="nameBuf">
 /// buffer holding the name of the entry. The name should be UTF-8
 /// encoded, but file name encoding is not a well defined concept
 /// in Git.
 /// </param>
 /// <param name="namePos">
 /// first position within
 /// <code>nameBuf</code>
 /// of the name data.
 /// </param>
 /// <param name="nameLen">
 /// number of bytes from
 /// <code>nameBuf</code>
 /// to use as the name.
 /// </param>
 /// <param name="mode">
 /// mode describing the treatment of
 /// <code>id</code>
 /// .
 /// </param>
 /// <param name="id">the ObjectId to store in this entry.</param>
 public virtual void Append(byte[] nameBuf, int namePos, int nameLen, FileMode mode
                            , AnyObjectId id)
 {
     if (FmtBuf(nameBuf, namePos, nameLen, mode))
     {
         id.CopyRawTo(buf, ptr);
         ptr += Constants.OBJECT_ID_LENGTH;
     }
     else
     {
         try
         {
             FmtOverflowBuffer(nameBuf, namePos, nameLen, mode);
             id.CopyRawTo(overflowBuffer);
         }
         catch (IOException badBuffer)
         {
             // This should never occur.
             throw new RuntimeException(badBuffer);
         }
     }
 }
Пример #28
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="NGit.Errors.CorruptObjectException"></exception>
		private static void CheckValidEndOfStream(InputStream @in, Inflater inf, AnyObjectId
			 id, byte[] buf)
		{
			for (; ; )
			{
				int r;
				try
				{
					r = inf.Inflate(buf);
				}
				catch (SharpZipBaseException)
				{
					throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
				}
				if (r != 0)
				{
					throw new CorruptObjectException(id, JGitText.Get().corruptObjectIncorrectLength);
				}
				if (inf.IsFinished)
				{
					if (inf.RemainingInput != 0 || @in.Read() != -1)
					{
						throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
					}
					break;
				}
				if (!inf.IsNeedingInput)
				{
					throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
				}
				r = @in.Read(buf);
				if (r <= 0)
				{
					throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
				}
				inf.SetInput(buf, 0, r);
			}
		}
Пример #29
0
		/// <exception cref="System.IO.IOException"></exception>
		internal static long GetSize(InputStream @in, AnyObjectId id, WindowCursor wc)
		{
			try
			{
				@in = Buffer(@in);
				@in.Mark(20);
				byte[] hdr = new byte[64];
				IOUtil.ReadFully(@in, hdr, 0, 2);
				if (IsStandardFormat(hdr))
				{
					@in.Reset();
					Inflater inf = wc.Inflater();
					InputStream zIn = Inflate(@in, inf);
					int avail = ReadSome(zIn, hdr, 0, 64);
					if (avail < 5)
					{
						throw new CorruptObjectException(id, JGitText.Get().corruptObjectNoHeader);
					}
					MutableInteger p = new MutableInteger();
					Constants.DecodeTypeString(id, hdr, unchecked((byte)' '), p);
					long size = RawParseUtils.ParseLongBase10(hdr, p.value, p);
					if (size < 0)
					{
						throw new CorruptObjectException(id, JGitText.Get().corruptObjectNegativeSize);
					}
					return size;
				}
				else
				{
					ReadSome(@in, hdr, 2, 18);
					int c = hdr[0] & unchecked((int)(0xff));
					long size = c & 15;
					int shift = 4;
					int p = 1;
					while ((c & unchecked((int)(0x80))) != 0)
					{
						c = hdr[p++] & unchecked((int)(0xff));
						size += (c & unchecked((int)(0x7f))) << shift;
						shift += 7;
					}
					return size;
				}
			}
			catch (SharpZipBaseException)
			{
				throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
			}
		}
Пример #30
0
 /// <summary>Load a configuration file from a blob stored in a specific commit.</summary>
 /// <remarks>Load a configuration file from a blob stored in a specific commit.</remarks>
 /// <param name="base">the base configuration file</param>
 /// <param name="db">the repository containing the objects.</param>
 /// <param name="treeish">the tree (or commit) that contains the object</param>
 /// <param name="path">the path within the tree</param>
 /// <exception cref="System.IO.FileNotFoundException">the path does not exist in the commit's tree.
 ///     </exception>
 /// <exception cref="System.IO.IOException">the tree and/or blob cannot be accessed.</exception>
 /// <exception cref="NGit.Errors.ConfigInvalidException">the blob is not a valid configuration format.
 ///     </exception>
 public BlobBasedConfig(Config @base, Repository db, AnyObjectId treeish, string path
                        ) : this(@base, Read(db, treeish, path))
 {
 }
Пример #31
0
			public SubId(AnyObjectId id) : base(id)
			{
			}
Пример #32
0
 /// <summary>Open an object from this database.</summary>
 /// <remarks>
 /// Open an object from this database.
 /// <p>
 /// This is a one-shot call interface which may be faster than allocating a
 /// <see cref="NewReader()">NewReader()</see>
 /// to perform the lookup.
 /// </remarks>
 /// <param name="objectId">identity of the object to open.</param>
 /// <returns>
 /// a
 /// <see cref="ObjectLoader">ObjectLoader</see>
 /// for accessing the object.
 /// </returns>
 /// <exception cref="NGit.Errors.MissingObjectException">the object does not exist.</exception>
 /// <exception cref="System.IO.IOException">the object store cannot be accessed.</exception>
 public virtual ObjectLoader Open(AnyObjectId objectId)
 {
     return(Open(objectId, ObjectReader.OBJ_ANY));
 }
Пример #33
0
 /// <summary>Returns true if this map contains the specified object.</summary>
 /// <remarks>Returns true if this map contains the specified object.</remarks>
 /// <param name="toFind">object to find.</param>
 /// <returns>true if the mapping exists for this object; false otherwise.</returns>
 public virtual bool Contains(AnyObjectId toFind)
 {
     return(Get(toFind) != null);
 }
Пример #34
0
		/// <exception cref="System.IO.IOException"></exception>
		internal static ObjectLoader Open(InputStream @in, FilePath path, AnyObjectId id, 
			WindowCursor wc)
		{
			try
			{
				@in = Buffer(@in);
				@in.Mark(20);
				byte[] hdr = new byte[64];
				IOUtil.ReadFully(@in, hdr, 0, 2);
				if (IsStandardFormat(hdr))
				{
					@in.Reset();
					Inflater inf = wc.Inflater();
					InputStream zIn = Inflate(@in, inf);
					int avail = ReadSome(zIn, hdr, 0, 64);
					if (avail < 5)
					{
						throw new CorruptObjectException(id, JGitText.Get().corruptObjectNoHeader);
					}
					MutableInteger p = new MutableInteger();
					int type = Constants.DecodeTypeString(id, hdr, unchecked((byte)' '), p);
					long size = RawParseUtils.ParseLongBase10(hdr, p.value, p);
					if (size < 0)
					{
						throw new CorruptObjectException(id, JGitText.Get().corruptObjectNegativeSize);
					}
					if (hdr[p.value++] != 0)
					{
						throw new CorruptObjectException(id, JGitText.Get().corruptObjectGarbageAfterSize
							);
					}
					if (path == null && int.MaxValue < size)
					{
						LargeObjectException.ExceedsByteArrayLimit e;
						e = new LargeObjectException.ExceedsByteArrayLimit();
						e.SetObjectId(id);
						throw e;
					}
					if (size < wc.GetStreamFileThreshold() || path == null)
					{
						byte[] data = new byte[(int)size];
						int n = avail - p.value;
						if (n > 0)
						{
							System.Array.Copy(hdr, p.value, data, 0, n);
						}
						IOUtil.ReadFully(zIn, data, n, data.Length - n);
						CheckValidEndOfStream(@in, inf, id, hdr);
						return new ObjectLoader.SmallObject(type, data);
					}
					return new UnpackedObject.LargeObject(type, size, path, id, wc.db);
				}
				else
				{
					ReadSome(@in, hdr, 2, 18);
					int c = hdr[0] & unchecked((int)(0xff));
					int type = (c >> 4) & 7;
					long size = c & 15;
					int shift = 4;
					int p = 1;
					while ((c & unchecked((int)(0x80))) != 0)
					{
						c = hdr[p++] & unchecked((int)(0xff));
						size += (c & unchecked((int)(0x7f))) << shift;
						shift += 7;
					}
					switch (type)
					{
						case Constants.OBJ_COMMIT:
						case Constants.OBJ_TREE:
						case Constants.OBJ_BLOB:
						case Constants.OBJ_TAG:
						{
							// Acceptable types for a loose object.
							break;
						}

						default:
						{
							throw new CorruptObjectException(id, JGitText.Get().corruptObjectInvalidType);
						}
					}
					if (path == null && int.MaxValue < size)
					{
						LargeObjectException.ExceedsByteArrayLimit e;
						e = new LargeObjectException.ExceedsByteArrayLimit();
						e.SetObjectId(id);
						throw e;
					}
					if (size < wc.GetStreamFileThreshold() || path == null)
					{
						@in.Reset();
						IOUtil.SkipFully(@in, p);
						Inflater inf = wc.Inflater();
						InputStream zIn = Inflate(@in, inf);
						byte[] data = new byte[(int)size];
						IOUtil.ReadFully(zIn, data, 0, data.Length);
						CheckValidEndOfStream(@in, inf, id, hdr);
						return new ObjectLoader.SmallObject(type, data);
					}
					return new UnpackedObject.LargeObject(type, size, path, id, wc.db);
				}
			}
			catch (SharpZipBaseException)
			{
				throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
			}
		}
Пример #35
0
        /// <summary>Reset this parser to walk through the given tree.</summary>
        /// <remarks>Reset this parser to walk through the given tree.</remarks>
        /// <param name="reader">reader to use during repository access.</param>
        /// <param name="id">
        /// identity of the tree being parsed; used only in exception
        /// messages if data corruption is found.
        /// </param>
        /// <returns>the root level parser.</returns>
        /// <exception cref="NGit.Errors.MissingObjectException">the object supplied is not available from the repository.
        /// 	</exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
        /// the object supplied as an argument is not actually a tree and
        /// cannot be parsed as though it were a tree.
        /// </exception>
        /// <exception cref="System.IO.IOException">a loose object or pack file could not be read.
        /// 	</exception>
        public virtual NGit.Treewalk.CanonicalTreeParser ResetRoot(ObjectReader reader, AnyObjectId
			 id)
        {
            NGit.Treewalk.CanonicalTreeParser p = this;
            while (p.parent != null)
            {
                p = (NGit.Treewalk.CanonicalTreeParser)p.parent;
            }
            p.Reset(reader, id);
            return p;
        }
Пример #36
0
        /// <summary>Back door to quickly create a subtree iterator for any subtree.</summary>
        /// <remarks>
        /// Back door to quickly create a subtree iterator for any subtree.
        /// <p/>
        /// Don't use this unless you are ObjectWalk. The method is meant to be
        /// called only once the current entry has been identified as a tree and its
        /// identity has been converted into an ObjectId.
        /// </remarks>
        /// <param name="reader">reader to load the tree data from.</param>
        /// <param name="id">ObjectId of the tree to open.</param>
        /// <returns>a new parser that walks over the current subtree.</returns>
        /// <exception cref="System.IO.IOException">a loose object or pack file could not be read.
        /// 	</exception>
        public NGit.Treewalk.CanonicalTreeParser CreateSubtreeIterator0(ObjectReader reader
			, AnyObjectId id)
        {
            NGit.Treewalk.CanonicalTreeParser p = new NGit.Treewalk.CanonicalTreeParser(this);
            p.Reset(reader, id);
            return p;
        }
Пример #37
0
		/// <summary>Compares this abbreviation to a full object id.</summary>
		/// <remarks>Compares this abbreviation to a full object id.</remarks>
		/// <param name="other">the other object id.</param>
		/// <returns>
		/// &lt;0 if this abbreviation names an object that is less than
		/// <code>other</code>; 0 if this abbreviation exactly matches the
		/// first
		/// <see cref="Length()">Length()</see>
		/// digits of <code>other.name()</code>;
		/// &gt;0 if this abbreviation names an object that is after
		/// <code>other</code>.
		/// </returns>
		public int PrefixCompare(AnyObjectId other)
		{
			int cmp;
			cmp = NB.CompareUInt32(w1, Mask(1, other.w1));
			if (cmp != 0)
			{
				return cmp;
			}
			cmp = NB.CompareUInt32(w2, Mask(2, other.w2));
			if (cmp != 0)
			{
				return cmp;
			}
			cmp = NB.CompareUInt32(w3, Mask(3, other.w3));
			if (cmp != 0)
			{
				return cmp;
			}
			cmp = NB.CompareUInt32(w4, Mask(4, other.w4));
			if (cmp != 0)
			{
				return cmp;
			}
			return NB.CompareUInt32(w5, Mask(5, other.w5));
		}
Пример #38
0
 /// <summary>Append any entry to the tree.</summary>
 /// <remarks>Append any entry to the tree.</remarks>
 /// <param name="name">
 /// name of the entry. The name should be UTF-8 encoded, but file
 /// name encoding is not a well defined concept in Git.
 /// </param>
 /// <param name="mode">
 /// mode describing the treatment of
 /// <code>id</code>
 /// .
 /// </param>
 /// <param name="id">the ObjectId to store in this entry.</param>
 public virtual void Append(byte[] name, FileMode mode, AnyObjectId id)
 {
     Append(name, 0, name.Length, mode, id);
 }
Пример #39
0
 /// <summary>Append any entry to the tree.</summary>
 /// <remarks>Append any entry to the tree.</remarks>
 /// <param name="name">name of the entry.</param>
 /// <param name="mode">
 /// mode describing the treatment of
 /// <code>id</code>
 /// .
 /// </param>
 /// <param name="id">the ObjectId to store in this entry.</param>
 public virtual void Append(string name, FileMode mode, AnyObjectId id)
 {
     Append(Constants.Encode(name), mode, id);
 }
Пример #40
0
			internal LargeObject(int type, long size, FilePath path, AnyObjectId id, FileObjectDatabase
				 db)
			{
				this.type = type;
				this.size = size;
				this.path = path;
				this.id = id.Copy();
				this.source = db;
			}
Пример #41
0
        /// <summary>Parse an encoded type string into a type constant.</summary>
        /// <remarks>Parse an encoded type string into a type constant.</remarks>
        /// <param name="id">
        /// object id this type string came from; may be null if that is
        /// not known at the time the parse is occurring.
        /// </param>
        /// <param name="typeString">string version of the type code.</param>
        /// <param name="endMark">
        /// character immediately following the type string. Usually ' '
        /// (space) or '\n' (line feed).
        /// </param>
        /// <param name="offset">
        /// position within <code>typeString</code> where the parse
        /// should start. Updated with the new position (just past
        /// <code>endMark</code> when the parse is successful.
        /// </param>
        /// <returns>
        /// a type code constant (one of
        /// <see cref="OBJ_BLOB">OBJ_BLOB</see>
        /// ,
        /// <see cref="OBJ_COMMIT">OBJ_COMMIT</see>
        /// ,
        /// <see cref="OBJ_TAG">OBJ_TAG</see>
        /// ,
        /// <see cref="OBJ_TREE">OBJ_TREE</see>
        /// .
        /// </returns>
        /// <exception cref="NGit.Errors.CorruptObjectException">there is no valid type identified by <code>typeString</code>.
        ///     </exception>
        public static int DecodeTypeString(AnyObjectId id, byte[] typeString, byte endMark
                                           , MutableInteger offset)
        {
            try
            {
                int position = offset.value;
                switch (typeString[position])
                {
                case (byte)('b'):
                {
                    if (typeString[position + 1] != 'l' || typeString[position + 2] != 'o' || typeString
                        [position + 3] != 'b' || typeString[position + 4] != endMark)
                    {
                        throw new CorruptObjectException(id, JGitText.Get().corruptObjectInvalidType);
                    }
                    offset.value = position + 5;
                    return(NGit.Constants.OBJ_BLOB);
                }

                case (byte)('c'):
                {
                    if (typeString[position + 1] != 'o' || typeString[position + 2] != 'm' || typeString
                        [position + 3] != 'm' || typeString[position + 4] != 'i' || typeString[position
                                                                                               + 5] != 't' || typeString[position + 6] != endMark)
                    {
                        throw new CorruptObjectException(id, JGitText.Get().corruptObjectInvalidType);
                    }
                    offset.value = position + 7;
                    return(NGit.Constants.OBJ_COMMIT);
                }

                case (byte)('t'):
                {
                    switch (typeString[position + 1])
                    {
                    case (byte)('a'):
                    {
                        if (typeString[position + 2] != 'g' || typeString[position + 3] != endMark)
                        {
                            throw new CorruptObjectException(id, JGitText.Get().corruptObjectInvalidType);
                        }
                        offset.value = position + 4;
                        return(NGit.Constants.OBJ_TAG);
                    }

                    case (byte)('r'):
                    {
                        if (typeString[position + 2] != 'e' || typeString[position + 3] != 'e' || typeString
                            [position + 4] != endMark)
                        {
                            throw new CorruptObjectException(id, JGitText.Get().corruptObjectInvalidType);
                        }
                        offset.value = position + 5;
                        return(NGit.Constants.OBJ_TREE);
                    }

                    default:
                    {
                        throw new CorruptObjectException(id, JGitText.Get().corruptObjectInvalidType);
                    }
                    }
                    goto default;
                }

                default:
                {
                    throw new CorruptObjectException(id, JGitText.Get().corruptObjectInvalidType);
                }
                }
            }
            catch (IndexOutOfRangeException)
            {
                throw new CorruptObjectException(id, JGitText.Get().corruptObjectInvalidType);
            }
        }
Пример #42
0
 /// <summary>Initialize this entry with a specific ObjectId.</summary>
 /// <remarks>Initialize this entry with a specific ObjectId.</remarks>
 /// <param name="id">the id the entry represents.</param>
 protected internal Entry(AnyObjectId id) : base(id)
 {
 }
Пример #43
0
		/// <summary>Create a new structure to remember information about an object.</summary>
		/// <remarks>Create a new structure to remember information about an object.</remarks>
		/// <param name="id">the identity of the object the new instance tracks.</param>
		protected internal PackedObjectInfo(AnyObjectId id) : base(id)
		{
		}
Пример #44
0
		/// <summary>Set the identity of the object, if its not already set.</summary>
		/// <remarks>Set the identity of the object, if its not already set.</remarks>
		/// <param name="id">the id of the object that is too large to process.</param>
		public virtual void SetObjectId(AnyObjectId id)
		{
			if (objectId == null)
			{
				objectId = id.Copy();
			}
		}
Пример #45
0
 private static bool Equals(AnyObjectId firstObjectId, AnyObjectId secondObjectId)
 {
     return(firstObjectId.w2 == secondObjectId.w2 && firstObjectId.w3 == secondObjectId
            .w3 && firstObjectId.w4 == secondObjectId.w4 && firstObjectId.w5 == secondObjectId
            .w5 && firstObjectId.w1 == secondObjectId.w1);
 }
Пример #46
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private static byte[] Read(ObjectReader or, AnyObjectId blobId)
        {
            ObjectLoader loader = or.Open(blobId, Constants.OBJ_BLOB);

            return(loader.GetCachedBytes(int.MaxValue));
        }
Пример #47
0
		internal PackedObjectInfo(long headerOffset, int packedCRC, AnyObjectId id) : base
			(id)
		{
			offset = headerOffset;
			crc = packedCRC;
		}
Пример #48
0
		/// <summary>Event notifying start of a delta referencing its base by ObjectId.</summary>
		/// <remarks>Event notifying start of a delta referencing its base by ObjectId.</remarks>
		/// <param name="deltaStreamPosition">position of this object in the incoming stream.
		/// 	</param>
		/// <param name="baseId">
		/// name of the base object. This object may be later in the
		/// stream, or might not appear at all in the stream (in the case
		/// of a thin-pack).
		/// </param>
		/// <param name="inflatedSize">
		/// size of the delta when fully inflated. The size stored within
		/// the pack may be larger or smaller, and is not yet known.
		/// </param>
		/// <exception cref="System.IO.IOException">the object cannot be recorded.</exception>
		protected internal abstract void OnBeginRefDelta(long deltaStreamPosition, AnyObjectId
			 baseId, long inflatedSize);
Пример #49
0
		/// <summary>Create a large object exception, naming the object that is too big.</summary>
		/// <remarks>Create a large object exception, naming the object that is too big.</remarks>
		/// <param name="id">
		/// identity of the object that is too big to be loaded as a byte
		/// array in this JVM.
		/// </param>
		public LargeObjectException(AnyObjectId id)
		{
			// Do nothing.
			SetObjectId(id);
		}
Пример #50
0
			protected internal DeltaChain(AnyObjectId id) : base(id)
			{
			}
Пример #51
0
		/// <summary>Recursively add an entire tree into this builder.</summary>
		/// <remarks>
		/// Recursively add an entire tree into this builder.
		/// <p>
		/// If pathPrefix is "a/b" and the tree contains file "c" then the resulting
		/// DirCacheEntry will have the path "a/b/c".
		/// <p>
		/// All entries are inserted at stage 0, therefore assuming that the
		/// application will not insert any other paths with the same pathPrefix.
		/// </remarks>
		/// <param name="pathPrefix">
		/// UTF-8 encoded prefix to mount the tree's entries at. If the
		/// path does not end with '/' one will be automatically inserted
		/// as necessary.
		/// </param>
		/// <param name="stage">stage of the entries when adding them.</param>
		/// <param name="reader">
		/// reader the tree(s) will be read from during recursive
		/// traversal. This must be the same repository that the resulting
		/// DirCache would be written out to (or used in) otherwise the
		/// caller is simply asking for deferred MissingObjectExceptions.
		/// Caller is responsible for releasing this reader when done.
		/// </param>
		/// <param name="tree">
		/// the tree to recursively add. This tree's contents will appear
		/// under <code>pathPrefix</code>. The ObjectId must be that of a
		/// tree; the caller is responsible for dereferencing a tag or
		/// commit (if necessary).
		/// </param>
		/// <exception cref="System.IO.IOException">a tree cannot be read to iterate through its entries.
		/// 	</exception>
		public virtual void AddTree(byte[] pathPrefix, int stage, ObjectReader reader, AnyObjectId
			 tree)
		{
			TreeWalk tw = new TreeWalk(reader);
			tw.AddTree(new CanonicalTreeParser(pathPrefix, reader, tree.ToObjectId()));
			tw.Recursive = true;
			if (tw.Next())
			{
				DirCacheEntry newEntry = ToEntry(stage, tw);
				BeforeAdd(newEntry);
				FastAdd(newEntry);
				while (tw.Next())
				{
					FastAdd(ToEntry(stage, tw));
				}
			}
		}
Пример #52
0
		private PackParser.UnresolvedDelta RemoveBaseById(AnyObjectId id)
		{
			PackParser.DeltaChain d = baseById.Get(id);
			return d != null ? d.Remove() : null;
		}
Пример #53
0
		/// <summary>
		/// Convert an AbbreviatedObjectId from an
		/// <see cref="AnyObjectId">AnyObjectId</see>
		/// .
		/// <p>
		/// This method copies over all bits of the Id, and is therefore complete
		/// (see
		/// <see cref="IsComplete()">IsComplete()</see>
		/// ).
		/// </summary>
		/// <param name="id">
		/// the
		/// <see cref="ObjectId">ObjectId</see>
		/// to convert from.
		/// </param>
		/// <returns>the converted object id.</returns>
		public static NGit.AbbreviatedObjectId FromObjectId(AnyObjectId id)
		{
			return new NGit.AbbreviatedObjectId(Constants.OBJECT_ID_STRING_LENGTH, id.w1, id.
				w2, id.w3, id.w4, id.w5);
		}
Пример #54
0
 /// <summary>Load a configuration file from a blob.</summary>
 /// <remarks>Load a configuration file from a blob.</remarks>
 /// <param name="base">the base configuration file</param>
 /// <param name="db">the repository</param>
 /// <param name="objectId">the object identifier</param>
 /// <exception cref="System.IO.IOException">the blob cannot be read from the repository.
 ///     </exception>
 /// <exception cref="NGit.Errors.ConfigInvalidException">the blob is not a valid configuration format.
 ///     </exception>
 public BlobBasedConfig(Config @base, Repository db, AnyObjectId objectId) : this(
         @base, Read(db, objectId))
 {
 }
Пример #55
0
        /// <summary>Create a new parser for a tree appearing in a subset of a repository.</summary>
        /// <remarks>Create a new parser for a tree appearing in a subset of a repository.</remarks>
        /// <param name="prefix">
        /// position of this iterator in the repository tree. The value
        /// may be null or the empty array to indicate the prefix is the
        /// root of the repository. A trailing slash ('/') is
        /// automatically appended if the prefix does not end in '/'.
        /// </param>
        /// <param name="reader">reader to load the tree data from.</param>
        /// <param name="treeId">
        /// identity of the tree being parsed; used only in exception
        /// messages if data corruption is found.
        /// </param>
        /// <exception cref="NGit.Errors.MissingObjectException">the object supplied is not available from the repository.
        /// 	</exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
        /// the object supplied as an argument is not actually a tree and
        /// cannot be parsed as though it were a tree.
        /// </exception>
        /// <exception cref="System.IO.IOException">a loose object or pack file could not be read.
        /// 	</exception>
        public CanonicalTreeParser(byte[] prefix, ObjectReader reader, AnyObjectId treeId
			)
            : base(prefix)
        {
            Reset(reader, treeId);
        }
Пример #56
0
			internal SubclassedId(AnyObjectId src) : base(src)
			{
			}
Пример #57
0
 /// <summary>Reset this parser to walk through the given tree.</summary>
 /// <remarks>Reset this parser to walk through the given tree.</remarks>
 /// <param name="reader">reader to use during repository access.</param>
 /// <param name="id">
 /// identity of the tree being parsed; used only in exception
 /// messages if data corruption is found.
 /// </param>
 /// <exception cref="NGit.Errors.MissingObjectException">the object supplied is not available from the repository.
 /// 	</exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
 /// the object supplied as an argument is not actually a tree and
 /// cannot be parsed as though it were a tree.
 /// </exception>
 /// <exception cref="System.IO.IOException">a loose object or pack file could not be read.
 /// 	</exception>
 public virtual void Reset(ObjectReader reader, AnyObjectId id)
 {
     Reset(reader.Open(id, Constants.OBJ_TREE).GetCachedBytes());
 }
Пример #58
0
		/// <exception cref="System.IO.IOException"></exception>
		private void VerifySafeObject(AnyObjectId id, int type, byte[] data)
		{
			if (objCheck != null)
			{
				try
				{
					objCheck.Check(type, data);
				}
				catch (CorruptObjectException e)
				{
					throw new IOException(MessageFormat.Format(JGitText.Get().invalidObject, Constants
						.TypeString(type), id.Name, e.Message));
				}
			}
			try
			{
				ObjectLoader ldr = readCurs.Open(id, type);
				byte[] existingData = ldr.GetCachedBytes(data.Length);
				if (!Arrays.Equals(data, existingData))
				{
					throw new IOException(MessageFormat.Format(JGitText.Get().collisionOn, id.Name));
				}
			}
			catch (MissingObjectException)
			{
			}
		}
Пример #59
0
		/// <summary>Include an object (and everything reachable from it) in the bundle.</summary>
		/// <remarks>Include an object (and everything reachable from it) in the bundle.</remarks>
		/// <param name="name">
		/// name the recipient can discover this object as from the
		/// bundle's list of advertised refs . The name must be a valid
		/// ref format and must not have already been included in this
		/// bundle writer.
		/// </param>
		/// <param name="id">object to pack. Multiple refs may point to the same object.</param>
		public virtual void Include(string name, AnyObjectId id)
		{
			if (!Repository.IsValidRefName(name))
			{
				throw new ArgumentException(MessageFormat.Format(JGitText.Get().invalidRefName, name
					));
			}
			if (include.ContainsKey(name))
			{
				throw new InvalidOperationException(JGitText.Get().duplicateRef + name);
			}
			include.Put(name, id.ToObjectId());
		}
Пример #60
0
		/// <summary>Construct a PackedObjectInfo instance for this parser.</summary>
		/// <remarks>Construct a PackedObjectInfo instance for this parser.</remarks>
		/// <param name="id">identity of the object to be tracked.</param>
		/// <param name="delta">
		/// if the object was previously an unresolved delta, this is the
		/// delta object that was tracking it. Otherwise null.
		/// </param>
		/// <param name="deltaBase">
		/// if the object was previously an unresolved delta, this is the
		/// ObjectId of the base of the delta. The base may be outside of
		/// the pack stream if the stream was a thin-pack.
		/// </param>
		/// <returns>info object containing this object's data.</returns>
		protected internal virtual PackedObjectInfo NewInfo(AnyObjectId id, PackParser.UnresolvedDelta
			 delta, ObjectId deltaBase)
		{
			PackedObjectInfo oe = new PackedObjectInfo(id);
			if (delta != null)
			{
				oe.SetCRC(delta.crc);
			}
			return oe;
		}