private byte[] contentFromTree(RevTree tree) { try { final ObjectReader reader = gitRepo.newObjectReader(); CanonicalTreeParser parser = new CanonicalTreeParser(); parser.reset(reader, tree); String lastPath = null; while (true) { final String path = parser.getEntryPathString(); parser = parser.next(); if (path.equals(lastPath)) { break; } lastPath = path; if (path.equals(CRUISE_CONFIG_XML)) { final ObjectId id = parser.getEntryObjectId(); final ObjectLoader loader = reader.open(id); return loader.getBytes(); } } return null; } catch (IOException e) { LOGGER.error("Could not fetch content from the config repository found at path '{}'", workingDir.getAbsolutePath(), e); throw new RuntimeException("Error while fetching content from the config repository.", e); } }
@Override public long size(String path, ObjectId id) throws IOException { try { return reader.getObjectSize(id, Constants.OBJ_BLOB); } catch (MissingObjectException ignore) { return 0; } }
/** * Obtain a unique abbreviation (prefix) of an object SHA-1. * * This method uses a reasonable default for the minimum length. Callers who * don't care about the minimum length should prefer this method. * * The returned abbreviation would expand back to the argument ObjectId when * passed to {@link #resolve(AbbreviatedObjectId)}, assuming no new objects * are added to this repository between calls. * * @param objectId * object identity that needs to be abbreviated. * @return SHA-1 abbreviation. * @throws java.io.IOException * the object store cannot be read. */ public AbbreviatedObjectId abbreviate(AnyObjectId objectId) throws IOException { return abbreviate(objectId, 7); }
/** * Does the requested object exist in this database? * <p> * This differs from ObjectDatabase's implementation in that we can selectively * ignore unreachable (garbage) objects. * * @param objectId * identity of the object to test for existence of. * @param avoidUnreachableObjects * if true, ignore objects that are unreachable. * @return true if the specified object is stored in this database. * @throws java.io.IOException * the object store cannot be accessed. */ public boolean has(AnyObjectId objectId, boolean avoidUnreachableObjects) throws IOException { try (ObjectReader or = newReader()) { or.setAvoidUnreachableObjects(avoidUnreachableObjects); return or.has(objectId); } }
/** * {@inheritDoc} * <p> * Release the internal ObjectReader state. * * @since 4.0 */ @Override public void close() { if (reader != null && closeReader) { reader.close(); } }
/** * Does the requested object exist in this database? * * @param objectId * identity of the object to test for existence of. * @return true if the specified object is stored in this database. * @throws java.io.IOException * the object store cannot be accessed. */ public boolean has(AnyObjectId objectId) throws IOException { return has(objectId, OBJ_ANY); }
public void widgetDisposed(DisposeEvent e) { if (objectReader != null) objectReader.release(); } });
@Override public Set<ObjectId> getShallowCommits() throws IOException { return ctx.getShallowCommits(); }
/** {@inheritDoc} */ @Override public Object call() throws Exception { or = block.templateReader.newReader(); try { DeltaWindow w; for (;;) { synchronized (this) { if (slices.isEmpty()) { break; } w = initWindow(slices.removeFirst()); } runWindow(w); } while ((w = block.stealWork(this)) != null) { runWindow(w); } } finally { block.pm.endWorker(); or.close(); or = null; } return null; }
@Override public void close() { ctx.close(); }
private void checkObjectCollision() throws IOException { for (PackedObjectInfo obj : collisionCheckObjs) { if (!readCurs.has(obj)) { continue; } checkObjectCollision(obj); } }
public void widgetDisposed(DisposeEvent e) { if (reader != null) reader.release(); } });
@Override public Set<ObjectId> getShallowCommits() throws IOException { return delegate().getShallowCommits(); }
@Override public ObjectLoader open(String path, ObjectId id) throws IOException { return reader.open(id, Constants.OBJ_BLOB); } }
@Override public boolean next() throws MissingObjectException, IOException { if (idItr.hasNext()) { cur = idItr.next(); sz = getObjectSize(cur, OBJ_ANY); return true; } else { return false; } }
@Override public AbbreviatedObjectId abbreviate(AnyObjectId objectId) throws IOException { return delegate().abbreviate(objectId); }
/** * {@inheritDoc} * <p> * Release any resources used by this walker's reader. * <p> * A walker that has been released can be used again, but may need to be * released after the subsequent usage. * * @since 4.0 */ @Override public void close() { if (closeReader) { reader.close(); } }
@Override public boolean has(AnyObjectId objectId) throws IOException { return delegate().has(objectId); }
public void widgetDisposed(DisposeEvent e) { if (reader != null) reader.release(); } });