/** * 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); } }
/** * 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); } }
/** * 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(); }
/** * 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; }
CheckoutConflictException, IndexWriteException, CanceledException { toBeDeleted.clear(); try (ObjectReader objectReader = repo.getObjectDatabase().newReader()) { if (headCommitTree != null) preScanTwoTrees();
/** * 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 IOException * the object store cannot be accessed. */ public boolean has(final AnyObjectId objectId) throws IOException { try (final ObjectReader or = newReader()) { return or.has(objectId); } }
/** * 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); } }
/** * 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 Constants#OBJ_BLOB}; {@link ObjectReader#OBJ_ANY} if * the object type is not known, or does not matter to the * caller. * @return a {@link ObjectLoader} for accessing the object. * @throws MissingObjectException * the object does not exist. * @throws IncorrectObjectTypeException * typeHint was not OBJ_ANY, and the object's actual type does * not match typeHint. * @throws IOException * the object store cannot be accessed. */ public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { try (final ObjectReader or = newReader()) { return or.open(objectId, typeHint); } }
/** * 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); } }
/** @return a new reader to read objects from {@link #getObjectDatabase()} */ @NonNull public ObjectReader newObjectReader() { return getObjectDatabase().newReader(); }
/** * 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(); }
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); } }
@Override public String getAbbreviatedCommitId(GitCommit commit) throws GitRepositoryException { try { RevCommit rawCommit = ((JGitCommit) commit).commit; return repository.getObjectDatabase().newReader() .abbreviate(rawCommit).name(); } catch (IOException e) { throw new GitRepositoryException( String.format("Commit \"%s\" could not be abbreviated.", commit.getId()), e); } }
/** * 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; }
this.repository = new FileRepositoryBuilder().findGitDir(anyFile).build(); this.repository.getObjectDatabase().newReader().getShallowCommits();
this.repository = new FileRepositoryBuilder().findGitDir(anyFile).build(); this.repository.getObjectDatabase().newReader().getShallowCommits();
/** * 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; }
CheckoutConflictException, IndexWriteException { toBeDeleted.clear(); try (ObjectReader objectReader = repo.getObjectDatabase().newReader()) { if (headCommitTree != null) preScanTwoTrees();
CheckoutConflictException, IndexWriteException, CanceledException { toBeDeleted.clear(); try (ObjectReader objectReader = repo.getObjectDatabase().newReader()) { if (headCommitTree != null) preScanTwoTrees();
public Ref execute() { try { final Ref value = repo.getRefDatabase().getRef(name); if (value != null) { return value; } final ObjectId treeRef = repo.resolve(name + "^{tree}"); if (treeRef != null) { final ObjectLoader loader = repo.getObjectDatabase().newReader().open(treeRef); if (loader.getType() == OBJ_TREE) { return new ObjectIdRef.PeeledTag(Ref.Storage.NEW, name, ObjectId.fromString(name), treeRef); } } } catch (final Exception ignored) { } return null; } }