예제 #1
0
 /// <summary>
 /// Gets the <see cref="ObjectId"/> of the current entry.
 /// </summary>
 /// <param name="objectId">buffer to copy the object id into.</param>
 public virtual void getEntryObjectId(MutableObjectId objectId)
 {
     if (objectId == null)
     {
         throw new ArgumentNullException("objectId");
     }
     objectId.FromRaw(idBuffer(), idOffset());
 }
예제 #2
0
 public new CanonicalTreeParser createSubtreeIterator(Repository repo, MutableObjectId idBuffer, WindowCursor curs)
 {
     idBuffer.FromRaw(this.idBuffer(), idOffset());
     if (FileMode.Tree != EntryFileMode)
     {
         ObjectId me = idBuffer.ToObjectId();
         throw new IncorrectObjectTypeException(me, Constants.TYPE_TREE);
     }
     return(createSubtreeIterator0(repo, idBuffer, curs));
 }
예제 #3
0
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public override AbstractTreeIterator CreateSubtreeIterator(ObjectReader reader, MutableObjectId
                                                            idBuffer)
 {
     idBuffer.FromRaw(IdBuffer, IdOffset);
     if (!FileMode.TREE.Equals(mode))
     {
         ObjectId me = idBuffer.ToObjectId();
         throw new IncorrectObjectTypeException(me, Constants.TYPE_TREE);
     }
     return(CreateSubtreeIterator0(reader, idBuffer));
 }
        private void VerifyLooseObject(AnyObjectId id, byte[] compressed)
        {
            UnpackedObjectLoader uol;

            try
            {
                uol = new UnpackedObjectLoader(compressed);
            }
            catch (CorruptObjectException parsingError)
            {
                // Some HTTP servers send back a "200 OK" status with an HTML
                // page that explains the requested file could not be found.
                // These servers are most certainly misconfigured, but many
                // of them exist in the world, and many of those are hosting
                // Git repositories.
                //
                // Since an HTML page is unlikely to hash to one of our loose
                // objects we treat this condition as a FileNotFoundException
                // and attempt to recover by getting the object from another
                // source.
                //
                var e = new FileNotFoundException(id.Name, parsingError);
                throw e;
            }

            _objectDigest.Reset();
            _objectDigest.Update(Constants.encodedTypeString(uol.Type));
            _objectDigest.Update((byte)' ');
            _objectDigest.Update(Constants.encodeASCII(uol.Size));
            _objectDigest.Update(0);
            _objectDigest.Update(uol.CachedBytes);
            _idBuffer.FromRaw(_objectDigest.Digest(), 0);

            if (!AnyObjectId.equals(id, _idBuffer))
            {
                throw new TransportException("Incorrect hash for " + id.Name + "; computed " + _idBuffer.Name + " as a " +
                                             Constants.typeString(uol.Type) + " from " + compressed.Length +
                                             " bytes.");
            }
            if (_objCheck != null)
            {
                try
                {
                    _objCheck.check(uol.Type, uol.CachedBytes);
                }
                catch (CorruptObjectException e)
                {
                    throw new TransportException("Invalid " + Constants.typeString(uol.Type) + " " + id.Name + ": " + e.Message);
                }
            }
        }
예제 #5
0
        private void VerifyLooseObject(AnyObjectId id, byte[] compressed)
        {
            UnpackedObjectLoader uol;

            try
            {
                uol = new UnpackedObjectLoader(compressed);
            }
            catch (CorruptObjectException parsingError)
            {
                var e = new FileNotFoundException(id.Name, parsingError);
                throw e;
            }

            _objectDigest.Reset();
            _objectDigest.Update(Constants.encodedTypeString(uol.Type));
            _objectDigest.Update((byte)' ');
            _objectDigest.Update(Constants.encodeASCII(uol.Size));
            _objectDigest.Update(0);
            _objectDigest.Update(uol.CachedBytes);
            _idBuffer.FromRaw(_objectDigest.Digest(), 0);

            if (!id.Equals(_idBuffer))
            {
                throw new TransportException("Incorrect hash for " + id.Name + "; computed " + _idBuffer.Name + " as a " +
                                             Constants.typeString(uol.Type) + " from " + compressed.Length +
                                             " bytes.");
            }
            if (_objCheck != null)
            {
                try
                {
                    _objCheck.check(uol.Type, uol.CachedBytes);
                }
                catch (CorruptObjectException e)
                {
                    throw new TransportException("Invalid " + Constants.typeString(uol.Type) + " " + id.Name + ": " + e.Message);
                }
            }
        }
예제 #6
0
 public new CanonicalTreeParser createSubtreeIterator(Repository repo, MutableObjectId idBuffer, WindowCursor curs)
 {
     idBuffer.FromRaw(this.idBuffer(), this.idOffset());
     if (!FileMode.Tree.Equals(mode))
     {
         ObjectId me = idBuffer.ToObjectId();
         throw new IncorrectObjectTypeException(me, Constants.TYPE_TREE);
     }
     return createSubtreeIterator0(repo, idBuffer, curs);
 }
예제 #7
0
 /**
  * Obtain the ObjectId for the current entry.
  *
  * @param out
  *            buffer to copy the object id into.
  */
 public virtual void getEntryObjectId(MutableObjectId @out)
 {
     @out.FromRaw(idBuffer(), idOffset());
 }
 /// <summary>
 /// Gets the <see cref="ObjectId"/> of the current entry.
 /// </summary>
 /// <param name="objectId">buffer to copy the object id into.</param>
 public virtual void getEntryObjectId(MutableObjectId objectId)
 {
     if (objectId == null)
         throw new ArgumentNullException ("objectId");
     objectId.FromRaw(idBuffer(), idOffset());
 }
예제 #9
0
 /// <summary>
 /// Gets the <see cref="ObjectId"/> of the current entry.
 /// </summary>
 /// <param name="objectId">buffer to copy the object id into.</param>
 public virtual void getEntryObjectId(MutableObjectId objectId)
 {
     objectId.FromRaw(idBuffer(), idOffset());
 }
예제 #10
0
 /// <summary>Obtain the ObjectId for the current entry.</summary>
 /// <remarks>Obtain the ObjectId for the current entry.</remarks>
 /// <param name="out">buffer to copy the object id into.</param>
 public virtual void GetEntryObjectId(MutableObjectId @out)
 {
     @out.FromRaw(IdBuffer, IdOffset);
 }
예제 #11
0
 public new CanonicalTreeParser createSubtreeIterator(Repository repo, MutableObjectId idBuffer, WindowCursor curs)
 {
     if (idBuffer == null)
         throw new ArgumentNullException("idBuffer");
     idBuffer.FromRaw(this.idBuffer(), idOffset());
     if (FileMode.Tree != EntryFileMode)
     {
         ObjectId me = idBuffer.ToObjectId();
         throw new IncorrectObjectTypeException(me, Constants.TYPE_TREE);
     }
     return createSubtreeIterator0(repo, idBuffer, curs);
 }
예제 #12
0
 /// <summary>
 /// Gets the <see cref="ObjectId"/> of the current entry.
 /// </summary>
 /// <param name="objectId">buffer to copy the object id into.</param>
 public virtual void getEntryObjectId(MutableObjectId objectId)
 {
     objectId.FromRaw(idBuffer(), idOffset());
 }