@Signature public boolean isExists() throws IOException { return getWrappedObject().getRepository().getObjectDatabase().exists(); }
/** * Does the requested object exist in this database? * <p> * This is a one-shot call interface which may be faster than allocating a * {@link #newReader()} to perform the lookup. * * @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 { try (ObjectReader or = newReader()) { return or.has(objectId); } }
/** * Whether the specified object is stored in this repo or any of the known * shared repositories. * * @param objectId * a {@link org.eclipse.jgit.lib.AnyObjectId} object. * @return true if the specified object is stored in this repo or any of the * known shared repositories. */ public boolean hasObject(AnyObjectId objectId) { try { return getObjectDatabase().has(objectId); } catch (IOException e) { // Legacy API, assume error means "no" return false; } }
/** * Initialize a pack parser. * * @param odb * database the parser will write its objects into. * @param src * the stream the parser will read. */ protected PackParser(ObjectDatabase odb, InputStream src) { objectDatabase = odb.newCachedDatabase(); in = src; inflater = new InflaterStream(); readCurs = objectDatabase.newReader(); buf = new byte[BUFFER_SIZE]; tempBuffer = new byte[BUFFER_SIZE]; hdrBuf = new byte[64]; tempObjectId = new MutableObjectId(); packDigest = Constants.newMessageDigest(); checkObjectCollisions = true; }
/** * Open an object from this database. * <p> * This is a one-shot call interface which may be faster than allocating a * {@link #newReader()} to perform the lookup. * * @param objectId * identity of the object to open. * @return a {@link org.eclipse.jgit.lib.ObjectLoader} for accessing the object. * @throws MissingObjectException * the object does not exist. * @throws java.io.IOException * the object store cannot be accessed. */ public ObjectLoader open(AnyObjectId objectId) throws IOException { return open(objectId, ObjectReader.OBJ_ANY); }
/** * Create a new inserter to create objects in {@link #getObjectDatabase()}. * * @return a new inserter to create objects in {@link #getObjectDatabase()}. */ @NonNull public ObjectInserter newObjectInserter() { return getObjectDatabase().newInserter(); }
/** * Invoked when the use count drops to zero during {@link #close()}. * <p> * The default implementation closes the object and ref databases. */ protected void doClose() { getObjectDatabase().close(); getRefDatabase().close(); }
/** * Initialize a pack parser. * * @param odb * database the parser will write its objects into. * @param src * the stream the parser will read. */ protected PackParser(ObjectDatabase odb, InputStream src) { objectDatabase = odb.newCachedDatabase(); in = src; inflater = new InflaterStream(); readCurs = objectDatabase.newReader(); buf = new byte[BUFFER_SIZE]; tempBuffer = new byte[BUFFER_SIZE]; hdrBuf = new byte[64]; tempObjectId = new MutableObjectId(); packDigest = Constants.newMessageDigest(); checkObjectCollisions = true; }
/** * Open an object from this repository. * <p> * This is a one-shot call interface which may be faster than allocating a * {@link #newObjectReader()} to perform the lookup. * * @param objectId * identity of the object to open. * @return a {@link org.eclipse.jgit.lib.ObjectLoader} for accessing the * object. * @throws org.eclipse.jgit.errors.MissingObjectException * the object does not exist. * @throws java.io.IOException * the object store cannot be accessed. */ @NonNull public ObjectLoader open(AnyObjectId objectId) throws MissingObjectException, IOException { return getObjectDatabase().open(objectId); }
/** @return a new inserter to create objects in {@link #getObjectDatabase()} */ @NonNull public ObjectInserter newObjectInserter() { return getObjectDatabase().newInserter(); }
/** * Invoked when the use count drops to zero during {@link #close()}. * <p> * The default implementation closes the object and ref databases. */ protected void doClose() { getObjectDatabase().close(); getRefDatabase().close(); }
/** * Create a repository matching the configuration in this builder. * <p> * If an option was not set, the build method will try to default the option * based on other options. If insufficient information is available, an * exception is thrown to the caller. * * @return a repository matching this configuration. The caller is * responsible to close the repository instance when it is no longer * needed. * @throws java.lang.IllegalArgumentException * insufficient parameters were set. * @throws java.io.IOException * the repository could not be accessed to configure the rest of * the builder's parameters. */ @SuppressWarnings({ "unchecked", "resource" }) public R build() throws IOException { R repo = (R) new FileRepository(setup()); if (isMustExist() && !repo.getObjectDatabase().exists()) throw new RepositoryNotFoundException(getGitDir()); return repo; }
/** * Open an object from this database. * <p> * This is a one-shot call interface which may be faster than allocating a * {@link #newReader()} to perform the lookup. * * @param objectId * identity of the object to open. * @param typeHint * hint about the type of object being requested, e.g. * {@link org.eclipse.jgit.lib.Constants#OBJ_BLOB}; * {@link org.eclipse.jgit.lib.ObjectReader#OBJ_ANY} if the * object type is not known, or does not matter to the caller. * @return a {@link org.eclipse.jgit.lib.ObjectLoader} for accessing the * object. * @throws org.eclipse.jgit.errors.MissingObjectException * the object does not exist. * @throws org.eclipse.jgit.errors.IncorrectObjectTypeException * typeHint was not OBJ_ANY, and the object's actual type does * not match typeHint. * @throws java.io.IOException * the object store cannot be accessed. */ public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { try (ObjectReader or = newReader()) { return or.open(objectId, typeHint); } }
/** * Initialize a pack parser. * * @param odb * database the parser will write its objects into. * @param src * the stream the parser will read. */ protected PackParser(final ObjectDatabase odb, final InputStream src) { objectDatabase = odb.newCachedDatabase(); in = src; inflater = new InflaterStream(); readCurs = objectDatabase.newReader(); buf = new byte[BUFFER_SIZE]; tempBuffer = new byte[BUFFER_SIZE]; hdrBuf = new byte[64]; objectDigest = Constants.newMessageDigest(); tempObjectId = new MutableObjectId(); packDigest = Constants.newMessageDigest(); checkObjectCollisions = true; }
/** * @param objectId * @return true if the specified object is stored in this repo or any of the * known shared repositories. */ public boolean hasObject(AnyObjectId objectId) { try { return getObjectDatabase().has(objectId); } catch (IOException e) { // Legacy API, assume error means "no" return false; } }
/** * Open an object from this repository. * <p> * This is a one-shot call interface which may be faster than allocating a * {@link #newObjectReader()} to perform the lookup. * * @param objectId * identity of the object to open. * @param typeHint * hint about the type of object being requested, e.g. * {@link org.eclipse.jgit.lib.Constants#OBJ_BLOB}; * {@link org.eclipse.jgit.lib.ObjectReader#OBJ_ANY} if the * object type is not known, or does not matter to the caller. * @return a {@link org.eclipse.jgit.lib.ObjectLoader} for accessing the * object. * @throws org.eclipse.jgit.errors.MissingObjectException * the object does not exist. * @throws org.eclipse.jgit.errors.IncorrectObjectTypeException * typeHint was not OBJ_ANY, and the object's actual type does * not match typeHint. * @throws java.io.IOException * the object store cannot be accessed. */ @NonNull public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { return getObjectDatabase().open(objectId, typeHint); }
/** * Create a new inserter to create objects in {@link #getObjectDatabase()}. * * @return a new inserter to create objects in {@link #getObjectDatabase()}. */ @NonNull public ObjectInserter newObjectInserter() { return getObjectDatabase().newInserter(); }
/** * Invoked when the use count drops to zero during {@link #close()}. * <p> * The default implementation closes the object and ref databases. */ protected void doClose() { getObjectDatabase().close(); getRefDatabase().close(); }
if (!repository.getObjectDatabase().exists()) repository.create(bare); return new Git(repository, true);
/** * Create a new reader to read objects from {@link #getObjectDatabase()}. * * @return a new reader to read objects from {@link #getObjectDatabase()}. */ @NonNull public ObjectReader newObjectReader() { return getObjectDatabase().newReader(); }