Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectLoader


    assertTrue(0 < cache.getOpenBytes());
  }

  private void doCacheTests() throws IOException {
    for (final TestObject o : toLoad) {
      final ObjectLoader or = db.open(o.id, o.type);
      assertNotNull(or);
      assertEquals(o.type, or.getType());
    }
  }
View Full Code Here


    lockedDircache = db.lockDirCache();
    dcedit = lockedDircache.editor();
    try {
      if (id != null) {
        final ObjectLoader contLoader = db.newObjectReader().open(id);
        dcedit.add(new DirCacheEditor.PathEdit(path) {
          @Override
          public void apply(DirCacheEntry ent) {
            ent.setFileMode(FileMode.REGULAR_FILE);
            ent.setLength(contLoader.getSize());
            ent.setObjectId(id);
          }
        });
      } else
        dcedit.add(new DirCacheEditor.DeletePath(path));
View Full Code Here

  private static final String PACK_NAME = "34be9032ac282b11fa9babdc2b2a93ca996c9c2f";

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

    PackFile pr = null;
    for (PackFile p : db.getObjectDatabase().getPacks()) {
      if (PACK_NAME.equals(p.getPackName())) {
        pr = p;
        break;
      }
    }
    assertNotNull("have pack-" + PACK_NAME, pr);

    id = ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327");
    or = pr.get(new WindowCursor(null), id);
    assertNotNull(or);
    assertEquals(Constants.OBJ_TREE, or.getType());
    assertEquals(35, or.getSize());
    pr.close();
  }
View Full Code Here

      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

    }
  }

  private static String readContentAsNormalizedString(DirCacheEntry entry,
      ObjectReader reader) throws MissingObjectException, IOException {
    ObjectLoader open = reader.open(entry.getObjectId());
    byte[] cachedBytes = open.getCachedBytes();
    return FS.detect().normalize(RawParseUtils.decode(cachedBytes));
  }
View Full Code Here

    }

    @Override
    public ObjectLoader open(String path, ObjectId id) throws IOException {
      seek(path);
      return new ObjectLoader() {
        @Override
        public long getSize() {
          return ptr.getEntryLength();
        }
View Full Code Here

      switch (getOptions().getAutoCRLF()) {
      case INPUT:
      case TRUE:
        InputStream dcIn = null;
        try {
          ObjectLoader loader = reader.open(entry.getObjectId());
          if (loader == null)
            return true;

          // We need to compute the length, but only if it is not
          // a binary stream.
          dcIn = new EolCanonicalizingInputStream(
              loader.openStream(), true, true /* abort if binary */);
          long dcInLen;
          try {
            dcInLen = computeLength(dcIn);
          } catch (EolCanonicalizingInputStream.IsBinaryException e) {
            return true;
          } finally {
            dcIn.close();
          }

          dcIn = new EolCanonicalizingInputStream(
              loader.openStream(), true);
          byte[] autoCrLfHash = computeHash(dcIn, dcInLen);
          boolean changed = getEntryObjectId().compareTo(
              autoCrLfHash, 0) != 0;
          return changed;
        } catch (IOException e) {
View Full Code Here

  @Override
  ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId)
      throws IOException {
    if (unpackedObjectCache.isUnpacked(objectId)) {
      ObjectLoader ldr = openLooseObject(curs, objectId);
      if (ldr != null)
        return ldr;
    }
    ObjectLoader ldr = openPackedFromSelfOrAlternate(curs, objectId);
    if (ldr != null)
      return ldr;
    return openLooseFromSelfOrAlternate(curs, objectId);
  }
View Full Code Here

    return openLooseFromSelfOrAlternate(curs, objectId);
  }

  private ObjectLoader openPackedFromSelfOrAlternate(WindowCursor curs,
      AnyObjectId objectId) {
    ObjectLoader ldr = openPackedObject(curs, objectId);
    if (ldr != null)
      return ldr;
    for (AlternateHandle alt : myAlternates()) {
      ldr = alt.db.openPackedFromSelfOrAlternate(curs, objectId);
      if (ldr != null)
View Full Code Here

    return null;
  }

  private ObjectLoader openLooseFromSelfOrAlternate(WindowCursor curs,
      AnyObjectId objectId) throws IOException {
    ObjectLoader ldr = openLooseObject(curs, objectId);
    if (ldr != null)
      return ldr;
    for (AlternateHandle alt : myAlternates()) {
      ldr = alt.db.openLooseFromSelfOrAlternate(curs, objectId);
      if (ldr != null)
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.