@Signature public boolean isExists() throws IOException { return getWrappedObject().getRepository().getObjectDatabase().exists(); }
RemotePack(WalkRemoteObjectDatabase c, String pn) { connection = c; packName = pn; idxName = packName.substring(0, packName.length() - 5) + ".idx"; //$NON-NLS-1$ String tn = idxName; if (tn.startsWith("pack-")) //$NON-NLS-1$ tn = tn.substring(5); if (tn.endsWith(".idx")) //$NON-NLS-1$ tn = tn.substring(0, tn.length() - 4); if (local.getObjectDatabase() instanceof ObjectDirectory) { tmpIdx = new File(((ObjectDirectory) local.getObjectDatabase()) .getDirectory(), "walk-" + tn + ".walkidx"); //$NON-NLS-1$ //$NON-NLS-2$ } }
/** * 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; } }
/** * 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(); }
/** * 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(); }
/** * 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); }
/** * 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(); }
/** * 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); }
private void checkSubmodules() throws IOException { ObjectDatabase odb = db.getObjectDatabase(); if (objectChecker == null) { return; } for (GitmoduleEntry entry : objectChecker.getGitsubmodules()) { AnyObjectId blobId = entry.getBlobId(); ObjectLoader blob = odb.open(blobId, Constants.OBJ_BLOB); try { SubmoduleValidator.assertValidGitModulesFile( new String(blob.getBytes(), UTF_8)); } catch (LargeObjectException | SubmoduleValidationException e) { throw new IOException(e); } } }
/** * 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; }
CheckoutConflictException, IndexWriteException, CanceledException { toBeDeleted.clear(); try (ObjectReader objectReader = repo.getObjectDatabase().newReader()) { if (headCommitTree != null) preScanTwoTrees();
if (!repository.getObjectDatabase().exists()) repository.create(bare); return new Git(repository, true);
/** @return a new inserter to create objects in {@link #getObjectDatabase()} */ @NonNull public ObjectInserter newObjectInserter() { return getObjectDatabase().newInserter(); }
private static File objects(final HttpServletRequest req) { final Repository db = getRepository(req); return ((ObjectDirectory) db.getObjectDatabase()).getDirectory(); } }
private static File objects(final HttpServletRequest req) { final Repository db = getRepository(req); return ((ObjectDirectory) db.getObjectDatabase()).getDirectory(); } }
/** @return a new reader to read objects from {@link #getObjectDatabase()} */ @NonNull public ObjectReader newObjectReader() { return getObjectDatabase().newReader(); }
/** * 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(); }
private static Repository buildRepository(File basedir) { try { Repository repo = GitScmProvider.getVerifiedRepositoryBuilder(basedir.toPath()).build(); // SONARSCGIT-2 Force initialization of shallow commits to avoid later concurrent modification issue repo.getObjectDatabase().newReader().getShallowCommits(); return repo; } catch (IOException e) { throw new IllegalStateException("Unable to open Git repository", e); } }
/** * 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(); }
/** * 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(); }