Package org.eclipse.jgit.lib

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


        entry.setComment(commit.getName());
        entry.setUnixMode(mode.getBits());
        entry.setTime(modified);
        zos.putArchiveEntry(entry);

        ObjectLoader ldr = repository.open(id);
        ldr.copyTo(zos);
        zos.closeArchiveEntry();
      }
      zos.finish();
      success = true;
    } catch (IOException e) {
View Full Code Here


        if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
          continue;
        }
        tw.getObjectId(id, 0);

        ObjectLoader loader = repository.open(id);
        if (FileMode.SYMLINK == mode) {
          TarArchiveEntry entry = new TarArchiveEntry(tw.getPathString(),TarArchiveEntry.LF_SYMLINK);
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          loader.copyTo(bos);
          entry.setLinkName(bos.toString());
          entry.setModTime(modified);
          tos.putArchiveEntry(entry);
          tos.closeArchiveEntry();
        } else {
          TarArchiveEntry entry = new TarArchiveEntry(tw.getPathString());
          entry.setMode(mode.getBits());
          entry.setModTime(modified);
          entry.setSize(loader.getSize());
          tos.putArchiveEntry(entry);
          loader.copyTo(tos);
          tos.closeArchiveEntry();
        }
      }
      tos.finish();
      tos.close();
View Full Code Here

              ext = name.substring(name.lastIndexOf('.') + 1);
            }

            // index the blob content
            if (StringUtils.isEmpty(ext) || !excludedExtensions.contains(ext)) {
              ObjectLoader ldr = repository.open(blobId, Constants.OBJ_BLOB);
              InputStream in = ldr.openStream();
              int n;
              while ((n = in.read(tmp)) > 0) {
                os.write(tmp, 0, n);
              }
              in.close();
View Full Code Here

    Repository repo = new FileRepository(testRepo) {

      public ObjectLoader open(AnyObjectId objectId, int typeHint)
          throws MissingObjectException,
          IncorrectObjectTypeException, IOException {
        final ObjectLoader loader = super.open(objectId, typeHint);
        return new ObjectLoader() {

          public ObjectStream openStream()
              throws MissingObjectException, IOException {
            return loader.openStream();
          }

          public int getType() {
            return loader.getType();
          }

          public long getSize() {
            return loader.getSize();
          }

          public byte[] getCachedBytes() throws LargeObjectException {
            throw new LargeObjectException();
          }
View Full Code Here

    assertEquals(a, rw.next());
  }

  private String readFile(String path, RevCommit commit) throws IOException {
    TreeWalk walk = TreeWalk.forPath(db, path, commit.getTree());
    ObjectLoader loader = db.open(walk.getObjectId(0), Constants.OBJ_BLOB);
    String result = RawParseUtils.decode(loader.getCachedBytes());
    walk.release();
    return result;
  }
View Full Code Here

    r.renameScore = renameScore;
    return r;
  }

  void loadText(ObjectReader reader) throws IOException {
    ObjectLoader ldr = reader.open(sourceBlob, Constants.OBJ_BLOB);
    sourceText = new RawText(ldr.getCachedBytes(Integer.MAX_VALUE));
  }
View Full Code Here

  @Override
  public ObjectLoader open(AnyObjectId objectId, int typeHint)
      throws MissingObjectException, IncorrectObjectTypeException,
      IOException {
    if (last != null) {
      ObjectLoader ldr = last.get(this, objectId);
      if (ldr != null)
        return ldr;
    }

    boolean noGarbage = avoidUnreachable;
    for (DfsPackFile pack : db.getPacks()) {
      if (pack == last || (noGarbage && pack.isGarbage()))
        continue;
      ObjectLoader ldr = pack.get(this, objectId);
      if (ldr != null) {
        last = pack;
        return ldr;
      }
    }
View Full Code Here

    final int type = Constants.OBJ_BLOB;
    byte[] data = getRng().nextBytes(300);
    byte[] gz = compressStandardFormat(type, data);
    ObjectId id = ObjectId.zeroId();

    ObjectLoader ol = UnpackedObject.open(new ByteArrayInputStream(gz),
        path(id), id, wc);
    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

    final int type = Constants.OBJ_BLOB;
    byte[] data = getRng().nextBytes(streamThreshold + 5);
    ObjectId id = new ObjectInserter.Formatter().idFor(type, data);
    write(id, compressStandardFormat(type, data));

    ObjectLoader ol;
    {
      FileInputStream fs = new FileInputStream(path(id));
      try {
        ol = UnpackedObject.open(fs, path(id), id, wc);
      } finally {
        fs.close();
      }
    }

    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

    gz[gz.length - 1] = 0;
    gz[gz.length - 2] = 0;

    write(id, gz);

    ObjectLoader ol;
    {
      FileInputStream fs = new FileInputStream(path(id));
      try {
        ol = UnpackedObject.open(fs, path(id), id, wc);
      } finally {
        fs.close();
      }
    }

    try {
      byte[] tmp = new byte[data.length];
      InputStream in = ol.openStream();
      try {
        IO.readFully(in, tmp, 0, tmp.length);
      } finally {
        in.close();
      }
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.