Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectLoader$SmallObject


  @Override
  ObjectLoader openLooseObject(WindowCursor curs, AnyObjectId id)
      throws IOException {
    if (unpackedObjects.contains(id)) {
      ObjectLoader ldr = wrapped.openLooseObject(curs, id);
      if (ldr != null)
        return ldr;
      unpackedObjects = scanLoose();
    }
    return null;
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

   * @throws IOException
   *             the repository cannot be read.
   */
  public BlameGenerator push(String description, AnyObjectId id)
      throws IOException {
    ObjectLoader ldr = reader.open(id);
    if (ldr.getType() == OBJ_BLOB) {
      if (description == null)
        description = JGitText.get().blameNotCommittedYet;
      BlobCandidate c = new BlobCandidate(description, resultPath);
      c.sourceBlob = id.toObjectId();
      c.sourceText = new RawText(ldr.getCachedBytes(Integer.MAX_VALUE));
      c.regionList = new Region(0, 0, c.sourceText.size());
      remaining = c.sourceText.size();
      push(c);
      return this;
    }
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

      return ours;

    if (ours.getData().equals(theirs.getData()))
      return ours;

    ObjectLoader lo = reader.open(ours.getData());
    ObjectLoader lt = reader.open(theirs.getData());
    UnionInputStream union = new UnionInputStream(lo.openStream(),
        lt.openStream());
    try {
      ObjectId noteData = inserter.insert(Constants.OBJ_BLOB,
          lo.getSize() + lt.getSize(), union);
      return new Note(ours, noteData);
    } finally {
      union.close();
    }
  }
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());

    crc32.reset();
    otp.setOffset(out.length());
    out.writeHeader(otp, ldr.getSize());

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

    RevBlob id = tr.blob(data);
    tr.branch("master").commit().add("A", id).create();
    tr.packAndPrune();
    assertTrue("has blob", wc.has(id));

    ObjectLoader ol = wc.open(id);
    assertNotNull("created loader", ol);
    assertEquals(type, ol.getType());
    assertEquals(data.length, ol.getSize());
    assertFalse("is not large", ol.isLarge());
    assertTrue("same content", Arrays.equals(data, ol.getCachedBytes()));

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
    assertEquals(type, in.getType());
    assertEquals(data.length, in.getSize());
    byte[] data2 = new byte[data.length];
    IO.readFully(in, data2, 0, data.length);
View Full Code Here

    RevBlob id = tr.blob(data);
    tr.branch("master").commit().add("A", id).create();
    tr.packAndPrune();
    assertTrue("has blob", wc.has(id));

    ObjectLoader ol = wc.open(id);
    assertNotNull("created loader", ol);
    assertEquals(type, ol.getType());
    assertEquals(data.length, ol.getSize());
    assertTrue("is large", ol.isLarge());
    try {
      ol.getCachedBytes();
      fail("Should have thrown LargeObjectException");
    } catch (LargeObjectException tooBig) {
      assertEquals(MessageFormat.format(
          JGitText.get().largeObjectException, id.name()), tooBig
          .getMessage());
    }

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
    assertEquals(type, in.getType());
    assertEquals(data.length, in.getSize());
    byte[] data2 = new byte[data.length];
    IO.readFully(in, data2, 0, data.length);
View Full Code Here

    ip.setAllowThin(true);
    ip.parse(NullProgressMonitor.INSTANCE);

    assertTrue("has blob", wc.has(id3));

    ObjectLoader ol = wc.open(id3);
    assertNotNull("created loader", ol);
    assertEquals(Constants.OBJ_BLOB, ol.getType());
    assertEquals(data3.length, ol.getSize());
    assertFalse("is large", ol.isLarge());
    assertNotNull(ol.getCachedBytes());
    assertArrayEquals(data3, ol.getCachedBytes());

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
    assertEquals(Constants.OBJ_BLOB, in.getType());
    assertEquals(data3.length, in.getSize());
    byte[] act = new byte[data3.length];
    IO.readFully(in, act, 0, data3.length);
View Full Code Here

  }

  @Test
  public void test004_lookupDeltifiedObject() throws IOException {
    final ObjectId id;
    final ObjectLoader or;

    id = ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259");
    or = db.open(id);
    assertNotNull(or);
    assertEquals(Constants.OBJ_BLOB, or.getType());
    assertEquals(18009, or.getSize());
  }
View Full Code Here

TOP

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

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.