Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectLoader


          return objItr.next();
        if (!lItr.next())
          return null;

        ObjectId id = lItr.getObjectId();
        ObjectLoader ldr = lItr.open();
        RevObject r = objects.get(id);
        if (r == null)
          r = parseNew(id, ldr);
        else if (r instanceof RevCommit) {
          byte[] raw = ldr.getCachedBytes();
          ((RevCommit) r).parseCanonical(RevWalk.this, raw);
        } else if (r instanceof RevTag) {
          byte[] raw = ldr.getCachedBytes();
          ((RevTag) r).parseCanonical(RevWalk.this, raw);
        } else
          r.flags |= PARSED;
        return r;
      }
View Full Code Here


    // The loose format is going to be faster to access than a
    // delta applied on top of a base. Use that whenever we can.
    //
    final ObjectId myId = getObjectId();
    final WindowCursor wc = new WindowCursor(db);
    ObjectLoader ldr = db.openObject2(wc, myId.name(), myId);
    if (ldr != null)
      return ldr.openStream();

    InputStream in = open(wc);
    in = new BufferedInputStream(in, 8192);

    // While we inflate the object, also deflate it back as a loose
View Full Code Here

      //
      return wc.open(getObjectId()).openStream();
    }
    delta = new InflaterInputStream(delta);

    final ObjectLoader base = pack.load(wc, baseOffset);
    DeltaStream ds = new DeltaStream(delta) {
      private long baseSize = SIZE_UNKNOWN;

      @Override
      protected InputStream openBase() throws IOException {
        InputStream in;
        if (base instanceof LargePackedDeltaObject)
          in = ((LargePackedDeltaObject) base).open(wc);
        else
          in = base.openStream();
        if (baseSize == SIZE_UNKNOWN) {
          if (in instanceof DeltaStream)
            baseSize = ((DeltaStream) in).getSize();
          else if (in instanceof ObjectStream)
            baseSize = ((ObjectStream) in).getSize();
        }
        return in;
      }

      @Override
      protected long getBaseSize() throws IOException {
        if (baseSize == SIZE_UNKNOWN) {
          // This code path should never be used as DeltaStream
          // is supposed to open the stream first, which would
          // initialize the size for us directly from the stream.
          baseSize = base.getSize();
        }
        return baseSize;
      }
    };
    if (type == Constants.OBJ_BAD) {
      if (!(base instanceof LargePackedDeltaObject))
        type = base.getType();
    }
    if (size == SIZE_UNKNOWN)
      size = ds.getSize();
    return ds;
  }
View Full Code Here

   *         object, or null if the object does not exist.
   * @throws IOException
   */
  ObjectLoader openObject(final WindowCursor curs, final AnyObjectId objectId)
      throws IOException {
    ObjectLoader ldr;

    ldr = openObjectImpl1(curs, objectId);
    if (ldr != null)
      return ldr;

View Full Code Here

    return null;
  }

  final ObjectLoader openObjectImpl1(final WindowCursor curs,
      final AnyObjectId objectId) throws IOException {
    ObjectLoader ldr;

    ldr = openObject1(curs, objectId);
    if (ldr != null)
      return ldr;
View Full Code Here

  }

  final ObjectLoader openObjectImpl2(final WindowCursor curs,
      final String objectName, final AnyObjectId objectId)
      throws IOException {
    ObjectLoader ldr;

    ldr = openObject2(curs, objectName, objectId);
    if (ldr != null)
      return ldr;
View Full Code Here

  }

  ObjectLoader openObject1(final WindowCursor curs,
      final AnyObjectId objectId) throws IOException {
    if (unpackedObjectCache.isUnpacked(objectId)) {
      ObjectLoader ldr = openObject2(curs, objectId.name(), objectId);
      if (ldr != null)
        return ldr;
      else
        unpackedObjectCache.remove(objectId);
    }

    PackList pList = packList.get();
    SEARCH: for (;;) {
      for (final PackFile p : pList.packs) {
        try {
          final ObjectLoader ldr = p.get(curs, objectId);
          if (ldr != null)
            return ldr;
        } catch (PackMismatchException e) {
          // Pack was modified; refresh the entire pack list.
          //
View Full Code Here

    }
  }

  private void verifyAndInsertLooseObject(final AnyObjectId id,
      final byte[] compressed) throws IOException {
    final ObjectLoader uol;
    try {
      uol = UnpackedObject.parse(compressed, id);
    } 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.
      //
      final FileNotFoundException e;
      e = new FileNotFoundException(id.name());
      e.initCause(parsingError);
      throw e;
    }

    final int type = uol.getType();
    final byte[] raw = uol.getCachedBytes();
    if (objCheck != null) {
      try {
        objCheck.check(type, raw);
      } catch (CorruptObjectException e) {
        throw new TransportException(MessageFormat.format(JGitText.get().transportExceptionInvalid
View Full Code Here

  }

  private void writeWholeObjectDeflate(PackOutputStream out,
      final ObjectToPack otp) throws IOException {
    final Deflater deflater = deflater();
    final ObjectLoader ldr = reader.open(otp, otp.getType());

    out.writeHeader(otp, ldr.getSize());

    deflater.reset();
    DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater);
    ldr.copyTo(dst);
    dst.finish();
  }
View Full Code Here

      IncorrectObjectTypeException, IOException {
    TreeWithData tree = treeCache.get(id);
    if (tree != null)
      return tree.buf;

    ObjectLoader ldr = reader.open(id, OBJ_TREE);
    byte[] buf = ldr.getCachedBytes(Integer.MAX_VALUE);
    treeCache.add(new TreeWithData(id, buf));
    return buf;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.ObjectLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.