Examples of ObjectLoader


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

Examples of org.eclipse.jgit.lib.ObjectLoader

   * @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

Examples of org.eclipse.jgit.lib.ObjectLoader

      else
        throw new AmbiguousObjectException(id, ids);
    }

    try {
      ObjectLoader ldr = source.open(side, entry);
      return ldr.getBytes(binaryFileThreshold);

    } catch (LargeObjectException.ExceedsLimit overLimit) {
      return BINARY;

    } catch (LargeObjectException.ExceedsByteArrayLimit overLimit) {
View Full Code Here

Examples of org.eclipse.jgit.lib.ObjectLoader

  @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;
    }

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

Examples of org.eclipse.jgit.lib.ObjectLoader

  }

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

    out.resetCRC32();
    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

Examples of org.eclipse.jgit.lib.ObjectLoader

  }

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

    out.resetCRC32();
    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

Examples of org.eclipse.jgit.lib.ObjectLoader

      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

Examples of org.eclipse.jgit.lib.ObjectLoader

  }

  public ObjectLoader open(AnyObjectId objectId, int typeHint)
      throws MissingObjectException, IncorrectObjectTypeException,
      IOException {
    final ObjectLoader ldr = db.openObject(this, objectId);
    if (ldr == null) {
      if (typeHint == OBJ_ANY)
        throw new MissingObjectException(objectId.copy(), "unknown");
      throw new MissingObjectException(objectId.copy(), typeHint);
    }
    if (typeHint != OBJ_ANY && ldr.getType() != typeHint)
      throw new IncorrectObjectTypeException(objectId.copy(), typeHint);
    return ldr;
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.ObjectLoader

   *            the entry containing new mode and content
   * @throws IOException
   */
  public static void checkoutEntry(final Repository repo, File f,
      DirCacheEntry entry) throws IOException {
    ObjectLoader ol = repo.open(entry.getObjectId());
    File parentDir = f.getParentFile();
    File tmpFile = File.createTempFile("._" + f.getName(), null, parentDir);
    FileOutputStream channel = new FileOutputStream(tmpFile);
    try {
      ol.copyTo(channel);
    } finally {
      channel.close();
    }
    FS fs = repo.getFS();
    WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
    if (opt.isFileMode() && fs.supportsExecute()) {
      if (FileMode.EXECUTABLE_FILE.equals(entry.getRawMode())) {
        if (!fs.canExecute(tmpFile))
          fs.setExecute(tmpFile, true);
      } else {
        if (fs.canExecute(tmpFile))
          fs.setExecute(tmpFile, false);
      }
    }
    if (!tmpFile.renameTo(f)) {
      // tried to rename which failed. Let' delete the target file and try
      // again
      FileUtils.delete(f);
      if (!tmpFile.renameTo(f)) {
        throw new IOException(MessageFormat.format(
            JGitText.get().couldNotWriteFile, tmpFile.getPath(),
            f.getPath()));
      }
    }
    entry.setLastModified(f.lastModified());
    entry.setLength((int) ol.getSize());
  }
View Full Code Here

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
TOP
Copyright © 2018 www.massapi.com. 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.