Fix javadoc in org.eclipse.jgit storage/file package
Change-Id: Ieb2f66aef2cab7e2a6d8e35c5f5047da881994dd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
a224b78675
commit
5480da5999
|
@ -58,6 +58,7 @@ abstract class BasePackBitmapIndex extends PackBitmapIndex {
|
|||
this.bitmaps = bitmaps;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public EWAHCompressedBitmap getBitmap(AnyObjectId objectId) {
|
||||
StoredBitmap sb = bitmaps.get(objectId);
|
||||
|
|
|
@ -59,7 +59,9 @@
|
|||
import com.googlecode.javaewah.EWAHCompressedBitmap;
|
||||
import com.googlecode.javaewah.IntIterator;
|
||||
|
||||
/** A compressed bitmap representation of the entire object graph. */
|
||||
/**
|
||||
* A compressed bitmap representation of the entire object graph.
|
||||
*/
|
||||
public class BitmapIndexImpl implements BitmapIndex {
|
||||
private static final int EXTRA_BITS = 10 * 1024;
|
||||
|
||||
|
@ -85,6 +87,7 @@ PackBitmapIndex getPackBitmapIndex() {
|
|||
return packIndex;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public CompressedBitmap getBitmap(AnyObjectId objectId) {
|
||||
EWAHCompressedBitmap compressed = packIndex.getBitmap(objectId);
|
||||
|
@ -93,6 +96,7 @@ public CompressedBitmap getBitmap(AnyObjectId objectId) {
|
|||
return new CompressedBitmap(compressed, this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public CompressedBitmapBuilder newBitmapBuilder() {
|
||||
return new CompressedBitmapBuilder(this);
|
||||
|
|
|
@ -63,6 +63,7 @@ final class ByteArrayWindow extends ByteWindow {
|
|||
array = b;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected int copy(final int p, final byte[] b, final int o, int n) {
|
||||
n = Math.min(array.length - p, n);
|
||||
|
@ -70,6 +71,7 @@ protected int copy(final int p, final byte[] b, final int o, int n) {
|
|||
return n;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected int setInput(final int pos, final Inflater inf)
|
||||
throws DataFormatException {
|
||||
|
|
|
@ -65,6 +65,7 @@ final class ByteBufferWindow extends ByteWindow {
|
|||
buffer = b;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected int copy(final int p, final byte[] b, final int o, int n) {
|
||||
final ByteBuffer s = buffer.slice();
|
||||
|
@ -89,6 +90,7 @@ void write(PackOutputStream out, long pos, int cnt)
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected int setInput(final int pos, final Inflater inf)
|
||||
throws DataFormatException {
|
||||
|
|
|
@ -66,6 +66,16 @@ abstract class ByteWindow {
|
|||
|
||||
protected final long end;
|
||||
|
||||
/**
|
||||
* Constructor for ByteWindow.
|
||||
*
|
||||
* @param p
|
||||
* a {@link org.eclipse.jgit.internal.storage.file.PackFile}.
|
||||
* @param s
|
||||
* where the byte window starts in the pack file
|
||||
* @param n
|
||||
* size of the byte window
|
||||
*/
|
||||
protected ByteWindow(final PackFile p, final long s, final int n) {
|
||||
pack = p;
|
||||
start = s;
|
||||
|
@ -127,6 +137,17 @@ final int setInput(long pos, Inflater inf) throws DataFormatException {
|
|||
return setInput((int) (pos - start), inf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the input
|
||||
*
|
||||
* @param pos
|
||||
* position
|
||||
* @param inf
|
||||
* an {@link java.util.zip.Inflater} object.
|
||||
* @return size of the byte window
|
||||
* @throws java.util.zip.DataFormatException
|
||||
* if any.
|
||||
*/
|
||||
protected abstract int setInput(int pos, Inflater inf)
|
||||
throws DataFormatException;
|
||||
}
|
||||
|
|
|
@ -117,11 +117,13 @@ private ObjectIdOwnerMap<UnpackedObjectId> scanLoose() {
|
|||
return m;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void close() {
|
||||
// Don't close anything.
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectDatabase newCachedDatabase() {
|
||||
return this;
|
||||
|
@ -177,6 +179,7 @@ void resolve(Set<ObjectId> matches, AbbreviatedObjectId id)
|
|||
wrapped.resolve(matches, id);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean has(final AnyObjectId objectId) throws IOException {
|
||||
return has(objectId, null);
|
||||
|
|
|
@ -65,11 +65,13 @@ public class CheckoutEntryImpl implements CheckoutEntry {
|
|||
to = comment.substring(p2 + " to ".length(), p3); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getFromBranch() {
|
||||
return from;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getToBranch() {
|
||||
return to;
|
||||
|
|
|
@ -64,11 +64,13 @@ static enum InsertLooseObjectResult {
|
|||
INSERTED, EXISTS_PACKED, EXISTS_LOOSE, FAILURE;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectReader newReader() {
|
||||
return new WindowCursor(this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectDirectoryInserter newInserter() {
|
||||
return new ObjectDirectoryInserter(this, getConfig());
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
* This class is thread-safe.
|
||||
* <p>
|
||||
* This implementation only handles a subtly undocumented subset of git features.
|
||||
*
|
||||
*/
|
||||
public class FileRepository extends Repository {
|
||||
private static final String UNNAMED = "Unnamed repository; edit this file to name it for gitweb."; //$NON-NLS-1$
|
||||
|
@ -133,8 +132,9 @@ public class FileRepository extends Repository {
|
|||
* <p>
|
||||
* The work tree, object directory, alternate object directories and index
|
||||
* file locations are deduced from the given git directory and the default
|
||||
* rules by running {@link FileRepositoryBuilder}. This constructor is the
|
||||
* same as saying:
|
||||
* rules by running
|
||||
* {@link org.eclipse.jgit.storage.file.FileRepositoryBuilder}. This
|
||||
* constructor is the same as saying:
|
||||
*
|
||||
* <pre>
|
||||
* new FileRepositoryBuilder().setGitDir(gitDir).build()
|
||||
|
@ -142,7 +142,7 @@ public class FileRepository extends Repository {
|
|||
*
|
||||
* @param gitDir
|
||||
* GIT_DIR (the location of the repository metadata).
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the repository appears to already exist but cannot be
|
||||
* accessed.
|
||||
* @see FileRepositoryBuilder
|
||||
|
@ -156,7 +156,7 @@ public FileRepository(final File gitDir) throws IOException {
|
|||
*
|
||||
* @param gitDir
|
||||
* GIT_DIR (the location of the repository metadata).
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the repository appears to already exist but cannot be
|
||||
* accessed.
|
||||
* @see FileRepositoryBuilder
|
||||
|
@ -170,7 +170,7 @@ public FileRepository(final String gitDir) throws IOException {
|
|||
*
|
||||
* @param options
|
||||
* description of the repository's important paths.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the user configuration file or repository configuration file
|
||||
* cannot be accessed.
|
||||
*/
|
||||
|
@ -279,14 +279,10 @@ private void loadRepoConfig() throws IOException {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Create a new Git repository initializing the necessary files and
|
||||
* directories.
|
||||
*
|
||||
* @param bare
|
||||
* if true, a bare repository is created.
|
||||
*
|
||||
* @throws IOException
|
||||
* in case of IO problem
|
||||
*/
|
||||
@Override
|
||||
public void create(boolean bare) throws IOException {
|
||||
|
@ -380,25 +376,27 @@ ConfigConstants.CONFIG_KEY_WORKTREE, getWorkTree()
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the directory containing the objects owned by this repository
|
||||
*
|
||||
* @return the directory containing the objects owned by this repository.
|
||||
*/
|
||||
public File getObjectsDirectory() {
|
||||
return objectDatabase.getDirectory();
|
||||
}
|
||||
|
||||
/** @return the object database storing this repository's data. */
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectDirectory getObjectDatabase() {
|
||||
return objectDatabase;
|
||||
}
|
||||
|
||||
/** @return the reference database which stores the reference namespace. */
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RefDatabase getRefDatabase() {
|
||||
return refs;
|
||||
}
|
||||
|
||||
/** @return the configuration of this repository. */
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FileBasedConfig getConfig() {
|
||||
if (systemConfig.isOutdated()) {
|
||||
|
@ -425,6 +423,7 @@ public FileBasedConfig getConfig() {
|
|||
return repoConfig;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
@Nullable
|
||||
public String getGitwebDescription() throws IOException {
|
||||
|
@ -443,6 +442,7 @@ public String getGitwebDescription() throws IOException {
|
|||
return d;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setGitwebDescription(@Nullable String description)
|
||||
throws IOException {
|
||||
|
@ -479,14 +479,14 @@ private File descriptionFile() {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Objects known to exist but not expressed by {@link #getAllRefs()}.
|
||||
* <p>
|
||||
* When a repository borrows objects from another repository, it can
|
||||
* advertise that it safely has that other repository's references, without
|
||||
* exposing any other details about the other repository. This may help
|
||||
* a client trying to push changes avoid pushing more than it needs to.
|
||||
*
|
||||
* @return unmodifiable collection of other known objects.
|
||||
* exposing any other details about the other repository. This may help a
|
||||
* client trying to push changes avoid pushing more than it needs to.
|
||||
*/
|
||||
@Override
|
||||
public Set<ObjectId> getAdditionalHaves() {
|
||||
|
@ -531,7 +531,7 @@ private Set<ObjectId> getAdditionalHaves(Set<AlternateHandle.Id> skips) {
|
|||
*
|
||||
* @param pack
|
||||
* path of the pack file to open.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* index file could not be opened, read, or is not recognized as
|
||||
* a Git pack file index.
|
||||
*/
|
||||
|
@ -539,6 +539,7 @@ public void openPack(final File pack) throws IOException {
|
|||
objectDatabase.openPack(pack);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void scanForRepoChanges() throws IOException {
|
||||
getRefDatabase().getRefs(ALL); // This will look for changes to refs
|
||||
|
@ -557,18 +558,14 @@ else if (snapshot.isModified(indexFile))
|
|||
notifyIndexChanged();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void notifyIndexChanged() {
|
||||
snapshot = FileSnapshot.save(getIndexFile());
|
||||
fireEvent(new IndexChangedEvent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param refName
|
||||
* @return a {@link ReflogReader} for the supplied refname, or null if the
|
||||
* named ref does not exist.
|
||||
* @throws IOException the ref could not be accessed.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ReflogReader getReflogReader(String refName) throws IOException {
|
||||
Ref ref = findRef(refName);
|
||||
|
@ -577,6 +574,7 @@ public ReflogReader getReflogReader(String refName) throws IOException {
|
|||
return null;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public AttributesNodeProvider createAttributesNodeProvider() {
|
||||
return new AttributesNodeProviderImpl(this);
|
||||
|
@ -642,6 +640,7 @@ private boolean shouldAutoDetach() {
|
|||
ConfigConstants.CONFIG_KEY_AUTODETACH, true);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void autoGC(ProgressMonitor monitor) {
|
||||
GC gc = new GC(this);
|
||||
|
|
|
@ -121,7 +121,6 @@ public static FileSnapshot save(File path) {
|
|||
*
|
||||
* @param modified
|
||||
* the last modification time of the file
|
||||
*
|
||||
* @return the snapshot.
|
||||
*/
|
||||
public static FileSnapshot save(long modified) {
|
||||
|
@ -145,6 +144,8 @@ private FileSnapshot(long read, long modified) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get time of last snapshot update
|
||||
*
|
||||
* @return time of last snapshot update
|
||||
*/
|
||||
public long lastModified() {
|
||||
|
@ -208,6 +209,7 @@ public boolean equals(FileSnapshot other) {
|
|||
return lastModified == other.lastModified;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof FileSnapshot)
|
||||
|
@ -215,6 +217,7 @@ public boolean equals(Object other) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// This is pretty pointless, but override hashCode to ensure that
|
||||
|
@ -223,6 +226,7 @@ public int hashCode() {
|
|||
return (int) lastModified;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this == DIRTY)
|
||||
|
|
|
@ -124,8 +124,10 @@
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A garbage collector for git {@link FileRepository}. Instances of this class
|
||||
* are not thread-safe. Don't use the same instance from multiple threads.
|
||||
* A garbage collector for git
|
||||
* {@link org.eclipse.jgit.internal.storage.file.FileRepository}. Instances of
|
||||
* this class are not thread-safe. Don't use the same instance from multiple
|
||||
* threads.
|
||||
*
|
||||
* This class started as a copy of DfsGarbageCollector from Shawn O. Pearce
|
||||
* adapted to FileRepositories.
|
||||
|
@ -218,7 +220,8 @@ public GC(FileRepository repo) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Runs a garbage collector on a {@link FileRepository}. It will
|
||||
* Runs a garbage collector on a
|
||||
* {@link org.eclipse.jgit.internal.storage.file.FileRepository}. It will
|
||||
* <ul>
|
||||
* <li>pack loose references into packed-refs</li>
|
||||
* <li>repack all reachable objects into new pack files and delete the old
|
||||
|
@ -235,9 +238,11 @@ public GC(FileRepository repo) {
|
|||
* return immediately. In this case, errors will not be reported except in
|
||||
* gc.log.
|
||||
*
|
||||
* @return the collection of {@link PackFile}'s which are newly created
|
||||
* @throws IOException
|
||||
* @throws ParseException
|
||||
* @return the collection of
|
||||
* {@link org.eclipse.jgit.internal.storage.file.PackFile}'s which
|
||||
* are newly created
|
||||
* @throws java.io.IOException
|
||||
* @throws java.text.ParseException
|
||||
* If the configuration parameter "gc.pruneexpire" couldn't be
|
||||
* parsed
|
||||
*/
|
||||
|
@ -475,7 +480,7 @@ private void prunePack(String packName) {
|
|||
* which can be found in packs. If certain objects can't be pruned (e.g.
|
||||
* because the filesystem delete operation fails) this is silently ignored.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void prunePacked() throws IOException {
|
||||
ObjectDirectory objdb = repo.getObjectDatabase();
|
||||
|
@ -533,9 +538,8 @@ public void prunePacked() throws IOException {
|
|||
*
|
||||
* @param objectsToKeep
|
||||
* a set of objects which should explicitly not be pruned
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ParseException
|
||||
* @throws java.io.IOException
|
||||
* @throws java.text.ParseException
|
||||
* If the configuration parameter "gc.pruneexpire" couldn't be
|
||||
* parsed
|
||||
*/
|
||||
|
@ -782,7 +786,7 @@ private static boolean equals(Ref r1, Ref r2) {
|
|||
/**
|
||||
* Packs all non-symbolic, loose refs into packed-refs.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void packRefs() throws IOException {
|
||||
Collection<Ref> refs = repo.getRefDatabase().getRefs(Constants.R_REFS).values();
|
||||
|
@ -810,10 +814,10 @@ public void packRefs() throws IOException {
|
|||
* repacked. All old pack files which existed before are deleted.
|
||||
*
|
||||
* @return a collection of the newly created pack files
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* when during reading of refs, index, packfiles, objects,
|
||||
* reflog-entries or during writing to the packfiles
|
||||
* {@link IOException} occurs
|
||||
* {@link java.io.IOException} occurs
|
||||
*/
|
||||
public Collection<PackFile> repack() throws IOException {
|
||||
Collection<PackFile> toBeDeleted = repo.getObjectDatabase().getPacks();
|
||||
|
@ -1312,7 +1316,7 @@ public String toString() {
|
|||
* Returns information about objects and pack files for a FileRepository.
|
||||
*
|
||||
* @return information about objects and pack files for a FileRepository
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public RepoStatistics getStatistics() throws IOException {
|
||||
RepoStatistics ret = new RepoStatistics();
|
||||
|
@ -1357,7 +1361,7 @@ public RepoStatistics getStatistics() throws IOException {
|
|||
/**
|
||||
* Set the progress monitor used for garbage collection methods.
|
||||
*
|
||||
* @param pm
|
||||
* @param pm a {@link org.eclipse.jgit.lib.ProgressMonitor} object.
|
||||
* @return this
|
||||
*/
|
||||
public GC setProgressMonitor(ProgressMonitor pm) {
|
||||
|
@ -1399,7 +1403,8 @@ public void setPackExpireAgeMillis(long packExpireAgeMillis) {
|
|||
* "git gc --aggressive"
|
||||
*
|
||||
* @param pconfig
|
||||
* the {@link PackConfig} used when writing packs
|
||||
* the {@link org.eclipse.jgit.storage.pack.PackConfig} used when
|
||||
* writing packs
|
||||
*/
|
||||
public void setPackConfig(PackConfig pconfig) {
|
||||
this.pconfig = pconfig;
|
||||
|
|
|
@ -51,20 +51,27 @@
|
|||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
|
||||
/** Attribute node loaded from global system-wide file. */
|
||||
/**
|
||||
* Attribute node loaded from global system-wide file.
|
||||
*/
|
||||
public class GlobalAttributesNode extends AttributesNode {
|
||||
final Repository repository;
|
||||
|
||||
/**
|
||||
* Constructor for GlobalAttributesNode.
|
||||
*
|
||||
* @param repository
|
||||
* the {@link org.eclipse.jgit.lib.Repository}.
|
||||
*/
|
||||
public GlobalAttributesNode(Repository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the attributes node
|
||||
*
|
||||
* @return the attributes node
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public AttributesNode load() throws IOException {
|
||||
AttributesNode r = new AttributesNode();
|
||||
|
|
|
@ -51,20 +51,27 @@
|
|||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
|
||||
/** Attribute node loaded from the $GIT_DIR/info/attributes file. */
|
||||
/**
|
||||
* Attribute node loaded from the $GIT_DIR/info/attributes file.
|
||||
*/
|
||||
public class InfoAttributesNode extends AttributesNode {
|
||||
final Repository repository;
|
||||
|
||||
/**
|
||||
* Constructor for InfoAttributesNode.
|
||||
*
|
||||
* @param repository
|
||||
* the {@link org.eclipse.jgit.lib.Repository}.
|
||||
*/
|
||||
public InfoAttributesNode(Repository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the attributes node
|
||||
*
|
||||
* @return the attributes node
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public AttributesNode load() throws IOException {
|
||||
AttributesNode r = new AttributesNode();
|
||||
|
|
|
@ -77,21 +77,25 @@ class LargePackedWholeObject extends ObjectLoader {
|
|||
this.db = db;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isLarge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public byte[] getCachedBytes() throws LargeObjectException {
|
||||
try {
|
||||
|
@ -103,6 +107,7 @@ public byte[] getCachedBytes() throws LargeObjectException {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectStream openStream() throws MissingObjectException, IOException {
|
||||
WindowCursor wc = new WindowCursor(db);
|
||||
|
|
|
@ -57,7 +57,9 @@
|
|||
import org.eclipse.jgit.lib.ObjectIdOwnerMap;
|
||||
import org.eclipse.jgit.lib.ObjectIdSet;
|
||||
|
||||
/** Lazily loads a set of ObjectIds, one per line. */
|
||||
/**
|
||||
* Lazily loads a set of ObjectIds, one per line.
|
||||
*/
|
||||
public class LazyObjectIdSetFile implements ObjectIdSet {
|
||||
private final File src;
|
||||
private ObjectIdOwnerMap<Entry> set;
|
||||
|
@ -72,6 +74,7 @@ public LazyObjectIdSetFile(File src) {
|
|||
this.src = src;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean contains(AnyObjectId objectId) {
|
||||
if (set == null) {
|
||||
|
|
|
@ -71,6 +71,7 @@ class LocalCachedPack extends CachedPack {
|
|||
this.packs = packs.toArray(new PackFile[packs.size()]);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getObjectCount() throws IOException {
|
||||
long cnt = 0;
|
||||
|
@ -85,6 +86,7 @@ void copyAsIs(PackOutputStream out, WindowCursor wc)
|
|||
pack.copyPackAsIs(out, wc);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasObject(ObjectToPack obj, StoredObjectRepresentation rep) {
|
||||
try {
|
||||
|
|
|
@ -92,11 +92,13 @@ static LocalObjectRepresentation newDelta(PackFile f, long p, long n,
|
|||
|
||||
private ObjectId baseId;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getWeight() {
|
||||
return (int) Math.min(length, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId getDeltaBase() {
|
||||
if (baseId == null && getFormat() == PACK_DELTA) {
|
||||
|
|
|
@ -62,12 +62,14 @@ class LocalObjectToPack extends ObjectToPack {
|
|||
super(src, type);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void clearReuseAsIs() {
|
||||
super.clearReuseAsIs();
|
||||
pack = null;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void select(StoredObjectRepresentation ref) {
|
||||
LocalObjectRepresentation ptr = (LocalObjectRepresentation) ref;
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
import java.nio.file.StandardCopyOption;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.jgit.errors.LockFailedException;
|
||||
import org.eclipse.jgit.internal.JGitText;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
@ -81,10 +80,12 @@ public class LockFile {
|
|||
* Unlock the given file.
|
||||
* <p>
|
||||
* This method can be used for recovering from a thrown
|
||||
* {@link LockFailedException} . This method does not validate that the lock
|
||||
* is or is not currently held before attempting to unlock it.
|
||||
* {@link org.eclipse.jgit.errors.LockFailedException} . This method does
|
||||
* not validate that the lock is or is not currently held before attempting
|
||||
* to unlock it.
|
||||
*
|
||||
* @param file
|
||||
* a {@link java.io.File} object.
|
||||
* @return true if unlocked, false if unlocking failed
|
||||
*/
|
||||
public static boolean unlock(final File file) {
|
||||
|
@ -138,7 +139,9 @@ public boolean accept(File dir, String name) {
|
|||
* @param fs
|
||||
* the file system abstraction which will be necessary to perform
|
||||
* certain file system operations.
|
||||
* @deprecated use {@link LockFile#LockFile(File)} instead
|
||||
* @deprecated use
|
||||
* {@link org.eclipse.jgit.internal.storage.file.LockFile#LockFile(File)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public LockFile(final File f, final FS fs) {
|
||||
|
@ -162,7 +165,7 @@ public LockFile(final File f) {
|
|||
*
|
||||
* @return true if the lock is now held by the caller; false if it is held
|
||||
* by someone else.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the temporary output file could not be created. The caller
|
||||
* does not hold the lock.
|
||||
*/
|
||||
|
@ -185,7 +188,7 @@ public boolean lock() throws IOException {
|
|||
*
|
||||
* @return true if the lock is now held by the caller; false if it is held
|
||||
* by someone else.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the temporary output file could not be created. The caller
|
||||
* does not hold the lock.
|
||||
*/
|
||||
|
@ -206,12 +209,12 @@ public boolean lockForAppend() throws IOException {
|
|||
* This method does nothing if the current file does not exist, or exists
|
||||
* but is empty.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the temporary file could not be written, or a read error
|
||||
* occurred while reading from the current file. The lock is
|
||||
* released before throwing the underlying IO exception to the
|
||||
* caller.
|
||||
* @throws RuntimeException
|
||||
* @throws java.lang.RuntimeException
|
||||
* the temporary file could not be written. The lock is released
|
||||
* before throwing the underlying exception to the caller.
|
||||
*/
|
||||
|
@ -264,10 +267,10 @@ public void copyCurrentContent() throws IOException {
|
|||
* @param id
|
||||
* the id to store in the file. The id will be written in hex,
|
||||
* followed by a sole LF.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the temporary file could not be written. The lock is released
|
||||
* before throwing the underlying IO exception to the caller.
|
||||
* @throws RuntimeException
|
||||
* @throws java.lang.RuntimeException
|
||||
* the temporary file could not be written. The lock is released
|
||||
* before throwing the underlying exception to the caller.
|
||||
*/
|
||||
|
@ -285,10 +288,10 @@ public void write(final ObjectId id) throws IOException {
|
|||
* the bytes to store in the temporary file. No additional bytes
|
||||
* are added, so if the file must end with an LF it must appear
|
||||
* at the end of the byte array.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the temporary file could not be written. The lock is released
|
||||
* before throwing the underlying IO exception to the caller.
|
||||
* @throws RuntimeException
|
||||
* @throws java.lang.RuntimeException
|
||||
* the temporary file could not be written. The lock is released
|
||||
* before throwing the underlying exception to the caller.
|
||||
*/
|
||||
|
@ -394,7 +397,8 @@ public void setNeedStatInformation(final boolean on) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Request that {@link #commit()} remember the {@link FileSnapshot}.
|
||||
* Request that {@link #commit()} remember the
|
||||
* {@link org.eclipse.jgit.internal.storage.file.FileSnapshot}.
|
||||
*
|
||||
* @param on
|
||||
* true if the commit method must remember the FileSnapshot.
|
||||
|
@ -420,7 +424,7 @@ public void setFSync(final boolean on) {
|
|||
* method sleeps until it can force the new lock file's modification date to
|
||||
* be later than the target file.
|
||||
*
|
||||
* @throws InterruptedException
|
||||
* @throws java.lang.InterruptedException
|
||||
* the thread was interrupted before the last modified date of
|
||||
* the lock file was different from the last modified date of
|
||||
* the target file.
|
||||
|
@ -443,7 +447,7 @@ public void waitForStatChange() throws InterruptedException {
|
|||
* @return true if the commit was successful and the file contains the new
|
||||
* data; false if the commit failed and the file remains with the
|
||||
* old data.
|
||||
* @throws IllegalStateException
|
||||
* @throws java.lang.IllegalStateException
|
||||
* the lock is not held.
|
||||
*/
|
||||
public boolean commit() {
|
||||
|
@ -477,7 +481,11 @@ public long getCommitLastModified() {
|
|||
return commitSnapshot.lastModified();
|
||||
}
|
||||
|
||||
/** @return get the {@link FileSnapshot} just before commit. */
|
||||
/**
|
||||
* Get the {@link FileSnapshot} just before commit.
|
||||
*
|
||||
* @return get the {@link FileSnapshot} just before commit.
|
||||
*/
|
||||
public FileSnapshot getCommitSnapshot() {
|
||||
return commitSnapshot;
|
||||
}
|
||||
|
@ -517,6 +525,7 @@ public void unlock() {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@SuppressWarnings("nls")
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -91,12 +91,12 @@
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Traditional file system based {@link ObjectDatabase}.
|
||||
* Traditional file system based {@link org.eclipse.jgit.lib.ObjectDatabase}.
|
||||
* <p>
|
||||
* This is the classical object database representation for a Git repository,
|
||||
* where objects are stored loose by hashing them into directories by their
|
||||
* {@link ObjectId}, or are stored in compressed containers known as
|
||||
* {@link PackFile}s.
|
||||
* {@link org.eclipse.jgit.lib.ObjectId}, or are stored in compressed containers
|
||||
* known as {@link org.eclipse.jgit.internal.storage.file.PackFile}s.
|
||||
* <p>
|
||||
* Optionally an object database can reference one or more alternates; other
|
||||
* ObjectDatabase instances that are searched in addition to the current
|
||||
|
@ -161,7 +161,7 @@ public class ObjectDirectory extends FileObjectDatabase {
|
|||
* @param shallowFile
|
||||
* file which contains IDs of shallow commits, null if shallow
|
||||
* commits handling should be turned off
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* an alternate object cannot be opened.
|
||||
*/
|
||||
public ObjectDirectory(final Config cfg, final File dir,
|
||||
|
@ -188,15 +188,15 @@ public ObjectDirectory(final Config cfg, final File dir,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the location of the <code>objects</code> directory.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final File getDirectory() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>packDirectory</code>.</p>
|
||||
*
|
||||
* @return the location of the <code>pack</code> directory.
|
||||
* @since 4.10
|
||||
*/
|
||||
|
@ -205,17 +205,21 @@ public final File getPackDirectory() {
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>preservedDirectory</code>.</p>
|
||||
*
|
||||
* @return the location of the <code>preserved</code> directory.
|
||||
*/
|
||||
public final File getPreservedDirectory() {
|
||||
return preservedDirectory;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean exists() {
|
||||
return fs.exists(objects);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void create() throws IOException {
|
||||
FileUtils.mkdirs(objects);
|
||||
|
@ -223,6 +227,7 @@ public void create() throws IOException {
|
|||
FileUtils.mkdir(packDirectory);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectDirectoryInserter newInserter() {
|
||||
return new ObjectDirectoryInserter(this, config);
|
||||
|
@ -238,6 +243,7 @@ public PackInserter newPackInserter() {
|
|||
return new PackInserter(this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void close() {
|
||||
unpackedObjectCache.clear();
|
||||
|
@ -256,13 +262,7 @@ public void close() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return unmodifiable collection of all known pack files local to this
|
||||
* directory. Most recent packs are presented first. Packs most
|
||||
* likely to contain more recent objects appear before packs
|
||||
* containing objects referenced by commits further back in the
|
||||
* history of the repository.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Collection<PackFile> getPacks() {
|
||||
PackList list = packList.get();
|
||||
|
@ -273,14 +273,9 @@ public Collection<PackFile> getPacks() {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Add a single existing pack to the list of available pack files.
|
||||
*
|
||||
* @param pack
|
||||
* path of the pack file to open.
|
||||
* @return the pack that was opened and added to the database.
|
||||
* @throws IOException
|
||||
* index file could not be opened, read, or is not recognized as
|
||||
* a Git pack file index.
|
||||
*/
|
||||
@Override
|
||||
public PackFile openPack(final File pack)
|
||||
|
@ -307,11 +302,13 @@ public PackFile openPack(final File pack)
|
|||
return res;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ObjectDirectory[" + getDirectory() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean has(AnyObjectId objectId) {
|
||||
return unpackedObjectCache.isUnpacked(objectId)
|
||||
|
@ -1066,11 +1063,9 @@ private AlternateHandle openAlternate(File objdir) throws IOException {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Compute the location of a loose object file.
|
||||
*
|
||||
* @param objectId
|
||||
* identity of the loose object to map to the directory.
|
||||
* @return location of the object, if it were to exist as a loose object.
|
||||
*/
|
||||
@Override
|
||||
public File fileFor(AnyObjectId objectId) {
|
||||
|
@ -1155,6 +1150,7 @@ void close() {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectDatabase newCachedDatabase() {
|
||||
return newCachedFileObjectDatabase();
|
||||
|
|
|
@ -83,6 +83,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
|
|||
config = cfg.get(WriteConfig.KEY);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId insert(int type, byte[] data, int off, int len)
|
||||
throws IOException {
|
||||
|
@ -114,6 +115,7 @@ private ObjectId insert(
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId insert(final int type, long len, final InputStream is)
|
||||
throws IOException {
|
||||
|
@ -166,21 +168,25 @@ private ObjectId insertOneObject(
|
|||
.format(JGitText.get().unableToCreateNewObject, dst));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public PackParser newPackParser(InputStream in) throws IOException {
|
||||
return new ObjectDirectoryPackParser(db, in);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectReader newReader() {
|
||||
return new WindowCursor(db, this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
// Do nothing. Loose objects are immediately visible.
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void close() {
|
||||
if (deflate != null) {
|
||||
|
|
|
@ -64,7 +64,6 @@
|
|||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.CoreConfig;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectInserter;
|
||||
import org.eclipse.jgit.lib.ProgressMonitor;
|
||||
import org.eclipse.jgit.transport.PackParser;
|
||||
import org.eclipse.jgit.transport.PackedObjectInfo;
|
||||
|
@ -72,10 +71,11 @@
|
|||
import org.eclipse.jgit.util.NB;
|
||||
|
||||
/**
|
||||
* Consumes a pack stream and stores as a pack file in {@link ObjectDirectory}.
|
||||
* Consumes a pack stream and stores as a pack file in
|
||||
* {@link org.eclipse.jgit.internal.storage.file.ObjectDirectory}.
|
||||
* <p>
|
||||
* To obtain an instance of a parser, applications should use
|
||||
* {@link ObjectInserter#newPackParser(InputStream)}.
|
||||
* {@link org.eclipse.jgit.lib.ObjectInserter#newPackParser(InputStream)}.
|
||||
*/
|
||||
public class ObjectDirectoryPackParser extends PackParser {
|
||||
private final FileObjectDatabase db;
|
||||
|
@ -158,7 +158,7 @@ public void setKeepEmpty(final boolean empty) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the imported {@link PackFile}.
|
||||
* Get the imported {@link org.eclipse.jgit.internal.storage.file.PackFile}.
|
||||
* <p>
|
||||
* This method is supplied only to support testing; applications shouldn't
|
||||
* be using it directly to access the imported data.
|
||||
|
@ -169,6 +169,7 @@ public PackFile getPackFile() {
|
|||
return newPack;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getPackSize() {
|
||||
if (newPack == null)
|
||||
|
@ -184,6 +185,7 @@ public long getPackSize() {
|
|||
return size;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public PackLock parse(ProgressMonitor receiving, ProgressMonitor resolving)
|
||||
throws IOException {
|
||||
|
@ -218,34 +220,40 @@ public PackLock parse(ProgressMonitor receiving, ProgressMonitor resolving)
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onPackHeader(long objectCount) throws IOException {
|
||||
// Ignored, the count is not required.
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onBeginWholeObject(long streamPosition, int type,
|
||||
long inflatedSize) throws IOException {
|
||||
crc.reset();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onEndWholeObject(PackedObjectInfo info) throws IOException {
|
||||
info.setCRC((int) crc.getValue());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onBeginOfsDelta(long streamPosition,
|
||||
long baseStreamPosition, long inflatedSize) throws IOException {
|
||||
crc.reset();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onBeginRefDelta(long streamPosition, AnyObjectId baseId,
|
||||
long inflatedSize) throws IOException {
|
||||
crc.reset();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected UnresolvedDelta onEndDelta() throws IOException {
|
||||
UnresolvedDelta delta = new UnresolvedDelta();
|
||||
|
@ -253,30 +261,35 @@ protected UnresolvedDelta onEndDelta() throws IOException {
|
|||
return delta;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onInflatedObjectData(PackedObjectInfo obj, int typeCode,
|
||||
byte[] data) throws IOException {
|
||||
// ObjectDirectory ignores this event.
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onObjectHeader(Source src, byte[] raw, int pos, int len)
|
||||
throws IOException {
|
||||
crc.update(raw, pos, len);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onObjectData(Source src, byte[] raw, int pos, int len)
|
||||
throws IOException {
|
||||
crc.update(raw, pos, len);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onStoreStream(byte[] raw, int pos, int len)
|
||||
throws IOException {
|
||||
out.write(raw, pos, len);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onPackFooter(byte[] hash) throws IOException {
|
||||
packEnd = out.getFilePointer();
|
||||
|
@ -285,6 +298,7 @@ protected void onPackFooter(byte[] hash) throws IOException {
|
|||
packHash = hash;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected ObjectTypeAndSize seekDatabase(UnresolvedDelta delta,
|
||||
ObjectTypeAndSize info) throws IOException {
|
||||
|
@ -293,6 +307,7 @@ protected ObjectTypeAndSize seekDatabase(UnresolvedDelta delta,
|
|||
return readObjectHeader(info);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected ObjectTypeAndSize seekDatabase(PackedObjectInfo obj,
|
||||
ObjectTypeAndSize info) throws IOException {
|
||||
|
@ -301,11 +316,13 @@ protected ObjectTypeAndSize seekDatabase(PackedObjectInfo obj,
|
|||
return readObjectHeader(info);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected int readDatabase(byte[] dst, int pos, int cnt) throws IOException {
|
||||
return out.read(dst, pos, cnt);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected boolean checkCRC(int oldCRC) {
|
||||
return oldCRC == (int) crc.getValue();
|
||||
|
@ -323,6 +340,7 @@ private void cleanupTemporaryFiles() {
|
|||
tmpPack.deleteOnExit();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected boolean onAppendBase(final int typeCode, final byte[] data,
|
||||
final PackedObjectInfo info) throws IOException {
|
||||
|
@ -365,6 +383,7 @@ protected boolean onAppendBase(final int typeCode, final byte[] data,
|
|||
return true;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onEndThinPack() throws IOException {
|
||||
final byte[] buf = buffer();
|
||||
|
|
|
@ -58,11 +58,11 @@
|
|||
|
||||
/**
|
||||
* Logical representation of the bitmap data stored in the pack index.
|
||||
* {@link ObjectId}s are encoded as a single integer in the range [0,
|
||||
* {@link #getObjectCount()}). Compressed bitmaps are available at certain
|
||||
* {@code ObjectId}s, which represent all of the objects reachable from that
|
||||
* {@code ObjectId} (include the {@code ObjectId} itself). The meaning of the
|
||||
* positions in the bitmaps can be decoded using {@link #getObject(int)} and
|
||||
* {@link org.eclipse.jgit.lib.ObjectId}s are encoded as a single integer in the
|
||||
* range [0, {@link #getObjectCount()}). Compressed bitmaps are available at
|
||||
* certain {@code ObjectId}s, which represent all of the objects reachable from
|
||||
* that {@code ObjectId} (include the {@code ObjectId} itself). The meaning of
|
||||
* the positions in the bitmaps can be decoded using {@link #getObject(int)} and
|
||||
* {@link #ofObjectType(EWAHCompressedBitmap, int)}. Furthermore,
|
||||
* {@link #findPosition(AnyObjectId)} can be used to build other bitmaps that a
|
||||
* compatible with the encoded bitmaps available from the index.
|
||||
|
@ -85,7 +85,7 @@ public abstract class PackBitmapIndex {
|
|||
* @param reverseIndex
|
||||
* the pack reverse index for the corresponding pack file.
|
||||
* @return a copy of the index in-memory.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the stream cannot be read.
|
||||
* @throws CorruptObjectException
|
||||
* the stream does not contain a valid pack bitmap index.
|
||||
|
@ -128,7 +128,7 @@ public static PackBitmapIndex open(
|
|||
* @param reverseIndex
|
||||
* the pack reverse index for the corresponding pack file.
|
||||
* @return a copy of the index in-memory.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the stream cannot be read.
|
||||
* @throws CorruptObjectException
|
||||
* the stream does not contain a valid pack bitmap index.
|
||||
|
@ -157,7 +157,7 @@ public static PackBitmapIndex read(
|
|||
* @param position
|
||||
* the id for which the object will be found.
|
||||
* @return the ObjectId.
|
||||
* @throws IllegalArgumentException
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* when the item is not found.
|
||||
*/
|
||||
public abstract ObjectId getObject(int position) throws IllegalArgumentException;
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
import com.googlecode.javaewah.EWAHCompressedBitmap;
|
||||
|
||||
/**
|
||||
* Helper for constructing {@link PackBitmapIndex}es.
|
||||
* Helper for constructing
|
||||
* {@link org.eclipse.jgit.internal.storage.file.PackBitmapIndex}es.
|
||||
*/
|
||||
public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
|
||||
private static final int MAX_XOR_OFFSET_SEARCH = 10;
|
||||
|
@ -145,7 +146,11 @@ public int compare(ObjectToPack a, ObjectToPack b) {
|
|||
}
|
||||
}
|
||||
|
||||
/** @return set of objects included in the pack. */
|
||||
/**
|
||||
* Get set of objects included in the pack.
|
||||
*
|
||||
* @return set of objects included in the pack.
|
||||
*/
|
||||
public ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> getObjectSet() {
|
||||
ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> r = new ObjectIdOwnerMap<>();
|
||||
for (PositionEntry e : byOffset) {
|
||||
|
@ -197,6 +202,7 @@ public void addBitmap(
|
|||
byAddOrder.add(result);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public EWAHCompressedBitmap ofObjectType(
|
||||
EWAHCompressedBitmap bitmap, int type) {
|
||||
|
@ -213,6 +219,7 @@ public EWAHCompressedBitmap ofObjectType(
|
|||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int findPosition(AnyObjectId objectId) {
|
||||
PositionEntry entry = positionEntries.get(objectId);
|
||||
|
@ -221,6 +228,7 @@ public int findPosition(AnyObjectId objectId) {
|
|||
return entry.offsetPosition;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId getObject(int position) throws IllegalArgumentException {
|
||||
ObjectId objectId = byOffset.get(position);
|
||||
|
@ -229,48 +237,76 @@ public ObjectId getObject(int position) throws IllegalArgumentException {
|
|||
return objectId;
|
||||
}
|
||||
|
||||
/** @return the commit object bitmap. */
|
||||
/**
|
||||
* Get the commit object bitmap.
|
||||
*
|
||||
* @return the commit object bitmap.
|
||||
*/
|
||||
public EWAHCompressedBitmap getCommits() {
|
||||
return commits;
|
||||
}
|
||||
|
||||
/** @return the tree object bitmap. */
|
||||
/**
|
||||
* Get the tree object bitmap.
|
||||
*
|
||||
* @return the tree object bitmap.
|
||||
*/
|
||||
public EWAHCompressedBitmap getTrees() {
|
||||
return trees;
|
||||
}
|
||||
|
||||
/** @return the blob object bitmap. */
|
||||
/**
|
||||
* Get the blob object bitmap.
|
||||
*
|
||||
* @return the blob object bitmap.
|
||||
*/
|
||||
public EWAHCompressedBitmap getBlobs() {
|
||||
return blobs;
|
||||
}
|
||||
|
||||
/** @return the tag object bitmap. */
|
||||
/**
|
||||
* Get the tag object bitmap.
|
||||
*
|
||||
* @return the tag object bitmap.
|
||||
*/
|
||||
public EWAHCompressedBitmap getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/** @return the index storage options. */
|
||||
/**
|
||||
* Get the index storage options.
|
||||
*
|
||||
* @return the index storage options.
|
||||
*/
|
||||
public int getOptions() {
|
||||
return PackBitmapIndexV1.OPT_FULL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getBitmapCount() {
|
||||
return getBitmaps().size();
|
||||
}
|
||||
|
||||
/** Removes all the bitmaps entries added. */
|
||||
/**
|
||||
* Remove all the bitmaps entries added.
|
||||
*/
|
||||
public void clearBitmaps() {
|
||||
byAddOrder.clear();
|
||||
getBitmaps().clear();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getObjectCount() {
|
||||
return byOffset.size();
|
||||
}
|
||||
|
||||
/** @return an iterator over the xor compressed entries. */
|
||||
/**
|
||||
* Get an iterator over the xor compressed entries.
|
||||
*
|
||||
* @return an iterator over the xor compressed entries.
|
||||
*/
|
||||
public Iterable<StoredEntry> getCompressedBitmaps() {
|
||||
// Add order is from oldest to newest. The reverse add order is the
|
||||
// output order.
|
||||
|
|
|
@ -116,27 +116,32 @@ private PackBitmapIndexRemapper(
|
|||
oldPackIndex.getObject(pos));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int findPosition(AnyObjectId objectId) {
|
||||
return newPackIndex.findPosition(objectId);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId getObject(int position) throws IllegalArgumentException {
|
||||
return newPackIndex.getObject(position);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getObjectCount() {
|
||||
return newPackIndex.getObjectCount();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public EWAHCompressedBitmap ofObjectType(
|
||||
EWAHCompressedBitmap bitmap, int type) {
|
||||
return newPackIndex.ofObjectType(bitmap, type);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Iterator<Entry> iterator() {
|
||||
if (oldPackIndex == null)
|
||||
|
@ -173,6 +178,7 @@ public void remove() {
|
|||
};
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public EWAHCompressedBitmap getBitmap(AnyObjectId objectId) {
|
||||
EWAHCompressedBitmap bitmap = newPackIndex.getBitmap(objectId);
|
||||
|
@ -214,6 +220,7 @@ public int getFlags() {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getBitmapCount() {
|
||||
// The count is only useful for the end index, not the remapper.
|
||||
|
|
|
@ -175,6 +175,7 @@ class PackBitmapIndexV1 extends BasePackBitmapIndex {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int findPosition(AnyObjectId objectId) {
|
||||
long offset = packIndex.findOffset(objectId);
|
||||
|
@ -183,6 +184,7 @@ public int findPosition(AnyObjectId objectId) {
|
|||
return reverseIndex.findPostion(offset);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId getObject(int position) throws IllegalArgumentException {
|
||||
ObjectId objectId = reverseIndex.findObjectByPosition(position);
|
||||
|
@ -191,11 +193,13 @@ public ObjectId getObject(int position) throws IllegalArgumentException {
|
|||
return objectId;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getObjectCount() {
|
||||
return (int) packIndex.getObjectCount();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public EWAHCompressedBitmap ofObjectType(
|
||||
EWAHCompressedBitmap bitmap, int type) {
|
||||
|
@ -212,11 +216,13 @@ public EWAHCompressedBitmap ofObjectType(
|
|||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getBitmapCount() {
|
||||
return bitmaps.size();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
// TODO(cranger): compare the pack checksum?
|
||||
|
@ -225,6 +231,7 @@ public boolean equals(Object o) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getPackIndex().hashCode();
|
||||
|
|
|
@ -89,7 +89,7 @@ public PackBitmapIndexWriterV1(final OutputStream dst) {
|
|||
* @param packDataChecksum
|
||||
* checksum signature of the entire pack data content. This is
|
||||
* traditionally the last 20 bytes of the pack file's own stream.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* an error occurred while writing to the output stream, or this
|
||||
* index format cannot store the object data supplied.
|
||||
*/
|
||||
|
|
|
@ -201,20 +201,30 @@ private synchronized PackIndex idx() throws IOException {
|
|||
return loadedIdx;
|
||||
}
|
||||
|
||||
/** @return the File object which locates this pack on disk. */
|
||||
/**
|
||||
* Get the File object which locates this pack on disk.
|
||||
*
|
||||
* @return the File object which locates this pack on disk.
|
||||
*/
|
||||
public File getPackFile() {
|
||||
return packFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index for this pack file.
|
||||
*
|
||||
* @return the index for this pack file.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public PackIndex getIndex() throws IOException {
|
||||
return idx();
|
||||
}
|
||||
|
||||
/** @return name extracted from {@code pack-*.pack} pattern. */
|
||||
/**
|
||||
* Get name extracted from {@code pack-*.pack} pattern.
|
||||
*
|
||||
* @return name extracted from {@code pack-*.pack} pattern.
|
||||
*/
|
||||
public String getPackName() {
|
||||
String name = packName;
|
||||
if (name == null) {
|
||||
|
@ -238,7 +248,7 @@ public String getPackName() {
|
|||
* @param id
|
||||
* the object to look for. Must not be null.
|
||||
* @return true if the object is in this pack; false otherwise.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the index file cannot be loaded into memory.
|
||||
*/
|
||||
public boolean hasObject(final AnyObjectId id) throws IOException {
|
||||
|
@ -292,6 +302,8 @@ public void close() {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Provide iterator over entries in associated pack index, that should also
|
||||
* exist in this pack file. Objects returned by such iterator are mutable
|
||||
* during iteration.
|
||||
|
@ -299,8 +311,6 @@ public void close() {
|
|||
* Iterator returns objects in SHA-1 lexicographical order.
|
||||
* </p>
|
||||
*
|
||||
* @return iterator over entries of associated pack index
|
||||
*
|
||||
* @see PackIndex#iterator()
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,8 @@
|
|||
import org.eclipse.jgit.util.NB;
|
||||
|
||||
/**
|
||||
* Access path to locate objects by {@link ObjectId} in a {@link PackFile}.
|
||||
* Access path to locate objects by {@link org.eclipse.jgit.lib.ObjectId} in a
|
||||
* {@link org.eclipse.jgit.internal.storage.file.PackFile}.
|
||||
* <p>
|
||||
* Indexes are strictly redundant information in that we can rebuild all of the
|
||||
* data held in the index file from the on disk representation of the pack file
|
||||
|
@ -89,7 +90,7 @@ public abstract class PackIndex
|
|||
* @return access implementation for the requested file.
|
||||
* @throws FileNotFoundException
|
||||
* the file does not exist.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the file exists but could not be read due to security errors,
|
||||
* unrecognized data version, or unexpected data corruption.
|
||||
*/
|
||||
|
@ -124,9 +125,9 @@ public static PackIndex open(final File idxFile) throws IOException {
|
|||
* buffered as some small IOs are performed against the stream.
|
||||
* The caller is responsible for closing the stream.
|
||||
* @return a copy of the index in-memory.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the stream cannot be read.
|
||||
* @throws CorruptObjectException
|
||||
* @throws org.eclipse.jgit.errors.CorruptObjectException
|
||||
* the stream does not contain a valid pack index.
|
||||
*/
|
||||
public static PackIndex read(InputStream fd) throws IOException,
|
||||
|
@ -167,12 +168,15 @@ public boolean hasObject(final AnyObjectId id) {
|
|||
return findOffset(id) != -1;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean contains(AnyObjectId id) {
|
||||
return findOffset(id) != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Provide iterator that gives access to index entries. Note, that iterator
|
||||
* returns reference to mutable object, the same reference in each call -
|
||||
* for performance reason. If client needs immutable objects, it must copy
|
||||
|
@ -180,8 +184,6 @@ public boolean contains(AnyObjectId id) {
|
|||
* <p>
|
||||
* Iterator returns objects in SHA-1 lexicographical order.
|
||||
* </p>
|
||||
*
|
||||
* @return iterator over pack index entries
|
||||
*/
|
||||
@Override
|
||||
public abstract Iterator<MutableEntry> iterator();
|
||||
|
@ -218,7 +220,8 @@ public boolean contains(AnyObjectId id) {
|
|||
* @param nthPosition
|
||||
* position within the traversal of {@link #iterator()} that the
|
||||
* caller needs the object for. The first returned
|
||||
* {@link MutableEntry} is 0, the second is 1, etc.
|
||||
* {@link org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry}
|
||||
* is 0, the second is 1, etc.
|
||||
* @return the ObjectId for the corresponding entry.
|
||||
*/
|
||||
public abstract ObjectId getObjectId(long nthPosition);
|
||||
|
@ -239,8 +242,10 @@ public boolean contains(AnyObjectId id) {
|
|||
* @param nthPosition
|
||||
* unsigned 32 bit position within the traversal of
|
||||
* {@link #iterator()} that the caller needs the object for. The
|
||||
* first returned {@link MutableEntry} is 0, the second is 1,
|
||||
* etc. Positions past 2**31-1 are negative, but still valid.
|
||||
* first returned
|
||||
* {@link org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry}
|
||||
* is 0, the second is 1, etc. Positions past 2**31-1 are
|
||||
* negative, but still valid.
|
||||
* @return the ObjectId for the corresponding entry.
|
||||
*/
|
||||
public final ObjectId getObjectId(final int nthPosition) {
|
||||
|
@ -282,9 +287,9 @@ public final ObjectId getObjectId(final int nthPosition) {
|
|||
* @param objId
|
||||
* id of object to look for
|
||||
* @return CRC32 checksum of specified object (at 32 less significant bits)
|
||||
* @throws MissingObjectException
|
||||
* @throws org.eclipse.jgit.errors.MissingObjectException
|
||||
* when requested ObjectId was not found in this index
|
||||
* @throws UnsupportedOperationException
|
||||
* @throws java.lang.UnsupportedOperationException
|
||||
* when this index doesn't support CRC32 checksum
|
||||
*/
|
||||
public abstract long findCRC32(AnyObjectId objId)
|
||||
|
@ -308,7 +313,7 @@ public abstract long findCRC32(AnyObjectId objId)
|
|||
* @param matchLimit
|
||||
* maximum number of results to return. At most this many
|
||||
* ObjectIds should be added to matches before returning.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the index cannot be read.
|
||||
*/
|
||||
public abstract void resolve(Set<ObjectId> matches, AbbreviatedObjectId id,
|
||||
|
|
|
@ -103,11 +103,13 @@ class PackIndexV1 extends PackIndex {
|
|||
IO.readFully(fd, packChecksum, 0, packChecksum.length);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getObjectCount() {
|
||||
return objectCnt;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getOffset64Count() {
|
||||
long n64 = 0;
|
||||
|
@ -140,6 +142,7 @@ private int getLevelTwo(final long nthPosition, final int levelOne) {
|
|||
return (int) (nthPosition - base);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId getObjectId(final long nthPosition) {
|
||||
final int levelOne = findLevelOne(nthPosition);
|
||||
|
@ -156,6 +159,7 @@ long getOffset(long nthPosition) {
|
|||
return NB.decodeUInt32(idxdata[levelOne], p);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long findOffset(final AnyObjectId objId) {
|
||||
final int levelOne = objId.getFirstByte();
|
||||
|
@ -182,21 +186,25 @@ else if (cmp == 0) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long findCRC32(AnyObjectId objId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasCRC32Support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Iterator<MutableEntry> iterator() {
|
||||
return new IndexV1Iterator();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void resolve(Set<ObjectId> matches, AbbreviatedObjectId id,
|
||||
int matchLimit) throws IOException {
|
||||
|
|
|
@ -164,11 +164,13 @@ class PackIndexV2 extends PackIndex {
|
|||
IO.readFully(fd, packChecksum, 0, packChecksum.length);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getObjectCount() {
|
||||
return objectCnt;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getOffset64Count() {
|
||||
return offset64.length / 8;
|
||||
|
@ -196,6 +198,7 @@ private int getLevelTwo(final long nthPosition, final int levelOne) {
|
|||
return (int) (nthPosition - base);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId getObjectId(final long nthPosition) {
|
||||
final int levelOne = findLevelOne(nthPosition);
|
||||
|
@ -204,6 +207,7 @@ public ObjectId getObjectId(final long nthPosition) {
|
|||
return ObjectId.fromRaw(names[levelOne], p4 + p); // p * 5
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getOffset(final long nthPosition) {
|
||||
final int levelOne = findLevelOne(nthPosition);
|
||||
|
@ -211,6 +215,7 @@ public long getOffset(final long nthPosition) {
|
|||
return getOffset(levelOne, levelTwo);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long findOffset(final AnyObjectId objId) {
|
||||
final int levelOne = objId.getFirstByte();
|
||||
|
@ -227,6 +232,7 @@ private long getOffset(final int levelOne, final int levelTwo) {
|
|||
return p;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long findCRC32(AnyObjectId objId) throws MissingObjectException {
|
||||
final int levelOne = objId.getFirstByte();
|
||||
|
@ -236,16 +242,19 @@ public long findCRC32(AnyObjectId objId) throws MissingObjectException {
|
|||
return NB.decodeUInt32(crc32[levelOne], levelTwo << 2);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasCRC32Support() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Iterator<MutableEntry> iterator() {
|
||||
return new EntriesIteratorV2();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void resolve(Set<ObjectId> matches, AbbreviatedObjectId id,
|
||||
int matchLimit) throws IOException {
|
||||
|
|
|
@ -53,16 +53,16 @@
|
|||
|
||||
import org.eclipse.jgit.internal.JGitText;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.transport.PackedObjectInfo;
|
||||
import org.eclipse.jgit.util.NB;
|
||||
|
||||
/**
|
||||
* Creates a table of contents to support random access by {@link PackFile}.
|
||||
* Creates a table of contents to support random access by
|
||||
* {@link org.eclipse.jgit.internal.storage.file.PackFile}.
|
||||
* <p>
|
||||
* Pack index files (the <code>.idx</code> suffix in a pack file pair)
|
||||
* provides random access to any object in the pack by associating an ObjectId
|
||||
* to the byte offset within the pack where the object's data can be read.
|
||||
* Pack index files (the <code>.idx</code> suffix in a pack file pair) provides
|
||||
* random access to any object in the pack by associating an ObjectId to the
|
||||
* byte offset within the pack where the object's data can be read.
|
||||
*/
|
||||
public abstract class PackIndexWriter {
|
||||
/** Magic constant indicating post-version 1 format. */
|
||||
|
@ -90,7 +90,7 @@ public abstract class PackIndexWriter {
|
|||
* will be examined until a format can be conclusively selected.
|
||||
* @return a new writer to output an index file of the requested format to
|
||||
* the supplied stream.
|
||||
* @throws IllegalArgumentException
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* no recognized pack index version can support the supplied
|
||||
* objects. This is likely a bug in the implementation.
|
||||
* @see #oldestPossibleFormat(List)
|
||||
|
@ -117,7 +117,7 @@ public static PackIndexWriter createOldestPossible(final OutputStream dst,
|
|||
* the objects the caller needs to store in the index. Entries
|
||||
* will be examined until a format can be conclusively selected.
|
||||
* @return the index format.
|
||||
* @throws IllegalArgumentException
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* no recognized pack index version can support the supplied
|
||||
* objects. This is likely a bug in the implementation.
|
||||
*/
|
||||
|
@ -143,7 +143,7 @@ public static int oldestPossibleFormat(
|
|||
* this formatted version will be written.
|
||||
* @return a new writer to output an index file of the requested format to
|
||||
* the supplied stream.
|
||||
* @throws IllegalArgumentException
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* the version requested is not supported by this
|
||||
* implementation.
|
||||
*/
|
||||
|
@ -195,12 +195,13 @@ protected PackIndexWriter(final OutputStream dst) {
|
|||
*
|
||||
* @param toStore
|
||||
* sorted list of objects to store in the index. The caller must
|
||||
* have previously sorted the list using {@link PackedObjectInfo}'s
|
||||
* native {@link Comparable} implementation.
|
||||
* have previously sorted the list using
|
||||
* {@link org.eclipse.jgit.transport.PackedObjectInfo}'s native
|
||||
* {@link java.lang.Comparable} implementation.
|
||||
* @param packDataChecksum
|
||||
* checksum signature of the entire pack data content. This is
|
||||
* traditionally the last 20 bytes of the pack file's own stream.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* an error occurred while writing to the output stream, or this
|
||||
* index format cannot store the object data supplied.
|
||||
*/
|
||||
|
@ -230,7 +231,7 @@ public void write(final List<? extends PackedObjectInfo> toStore,
|
|||
* the {@link #entries} collection may be iterated over more than once if
|
||||
* necessary. Implementors therefore have complete control over the data.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* an error occurred while writing to the output stream, or this
|
||||
* index format cannot store the object data supplied.
|
||||
*/
|
||||
|
@ -246,7 +247,7 @@ public void write(final List<? extends PackedObjectInfo> toStore,
|
|||
*
|
||||
* @param version
|
||||
* version number of this index format being written.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* an error occurred while writing to the output stream.
|
||||
*/
|
||||
protected void writeTOC(final int version) throws IOException {
|
||||
|
@ -260,10 +261,10 @@ protected void writeTOC(final int version) throws IOException {
|
|||
* <p>
|
||||
* The fan-out table is 4 KB in size, holding 256 32-bit unsigned integer
|
||||
* counts. Each count represents the number of objects within this index
|
||||
* whose {@link ObjectId#getFirstByte()} matches the count's position in the
|
||||
* fan-out table.
|
||||
* whose {@link org.eclipse.jgit.lib.ObjectId#getFirstByte()} matches the
|
||||
* count's position in the fan-out table.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* an error occurred while writing to the output stream.
|
||||
*/
|
||||
protected void writeFanOutTable() throws IOException {
|
||||
|
@ -288,7 +289,7 @@ protected void writeFanOutTable() throws IOException {
|
|||
* the pack data checksum above.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* an error occurred while writing to the output stream.
|
||||
*/
|
||||
protected void writeChecksumFooter() throws IOException {
|
||||
|
|
|
@ -68,6 +68,7 @@ static boolean canStore(final PackedObjectInfo oe) {
|
|||
super(dst);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void writeImpl() throws IOException {
|
||||
writeFanOutTable();
|
||||
|
|
|
@ -63,6 +63,7 @@ class PackIndexWriterV2 extends PackIndexWriter {
|
|||
super(dst);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void writeImpl() throws IOException {
|
||||
writeTOC(2);
|
||||
|
|
|
@ -64,6 +64,7 @@ class PackInputStream extends InputStream {
|
|||
wc.pin(pack, pos);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
int n = wc.copy(pack, pos, b, off, len);
|
||||
|
@ -71,6 +72,7 @@ public int read(byte[] b, int off, int len) throws IOException {
|
|||
return n;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
byte[] buf = new byte[1];
|
||||
|
@ -78,6 +80,7 @@ public int read() throws IOException {
|
|||
return n == 1 ? buf[0] & 0xff : -1;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void close() {
|
||||
wc.close();
|
||||
|
|
|
@ -119,15 +119,20 @@ class PackInserter extends ObjectInserter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Whether to check if objects exist in the repo
|
||||
*
|
||||
* @param check
|
||||
* if false, will write out possibly-duplicate objects without
|
||||
* first checking whether they exist in the repo; default is true.
|
||||
* if {@code false}, will write out possibly-duplicate objects
|
||||
* without first checking whether they exist in the repo; default
|
||||
* is true.
|
||||
*/
|
||||
public void checkExisting(boolean check) {
|
||||
checkExisting = check;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set compression level for zlib deflater.
|
||||
*
|
||||
* @param compression
|
||||
* compression level for zlib deflater.
|
||||
*/
|
||||
|
@ -139,6 +144,7 @@ int getBufferSize() {
|
|||
return buffer().length;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId insert(int type, byte[] data, int off, int len)
|
||||
throws IOException {
|
||||
|
@ -157,6 +163,7 @@ public ObjectId insert(int type, byte[] data, int off, int len)
|
|||
return endObject(id, offset);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId insert(int type, long len, InputStream in)
|
||||
throws IOException {
|
||||
|
@ -230,16 +237,19 @@ private static int writePackHeader(byte[] buf, int objectCount) {
|
|||
return 12;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public PackParser newPackParser(InputStream in) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectReader newReader() {
|
||||
return new Reader();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
if (tmpPack == null) {
|
||||
|
@ -309,6 +319,7 @@ private ObjectId computeName(List<PackedObjectInfo> list) {
|
|||
return ObjectId.fromRaw(md.digest());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
|
|
|
@ -50,7 +50,10 @@
|
|||
import org.eclipse.jgit.util.FS;
|
||||
import org.eclipse.jgit.util.FileUtils;
|
||||
|
||||
/** Keeps track of a {@link PackFile}'s associated <code>.keep</code> file. */
|
||||
/**
|
||||
* Keeps track of a {@link org.eclipse.jgit.internal.storage.file.PackFile}'s
|
||||
* associated <code>.keep</code> file.
|
||||
*/
|
||||
public class PackLock {
|
||||
private final File keepFile;
|
||||
|
||||
|
@ -74,7 +77,7 @@ public PackLock(final File packFile, final FS fs) {
|
|||
* @param msg
|
||||
* message to store in the file.
|
||||
* @return true if the keep file was successfully written; false otherwise.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the keep file could not be written.
|
||||
*/
|
||||
public boolean lock(String msg) throws IOException {
|
||||
|
@ -92,7 +95,7 @@ public boolean lock(String msg) throws IOException {
|
|||
/**
|
||||
* Remove the <code>.keep</code> file that holds this pack in place.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* if deletion of .keep file failed
|
||||
*/
|
||||
public void unlock() throws IOException {
|
||||
|
|
|
@ -174,7 +174,7 @@ public ObjectId findObject(final long offset) {
|
|||
* offset).
|
||||
* @return offset of the next object in a pack or maxOffset if provided
|
||||
* offset was the last one.
|
||||
* @throws CorruptObjectException
|
||||
* @throws org.eclipse.jgit.errors.CorruptObjectException
|
||||
* when there is no object with the provided offset.
|
||||
*/
|
||||
public long findNextOffset(final long offset, final long maxOffset)
|
||||
|
|
|
@ -125,6 +125,7 @@ class PackedBatchRefUpdate extends BatchRefUpdate {
|
|||
this.refdb = refdb;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void execute(RevWalk walk, ProgressMonitor monitor,
|
||||
List<String> options) throws IOException {
|
||||
|
|
|
@ -111,14 +111,14 @@
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Traditional file system based {@link RefDatabase}.
|
||||
* Traditional file system based {@link org.eclipse.jgit.lib.RefDatabase}.
|
||||
* <p>
|
||||
* This is the classical reference database representation for a Git repository.
|
||||
* References are stored in two formats: loose, and packed.
|
||||
* <p>
|
||||
* Loose references are stored as individual files within the {@code refs/}
|
||||
* directory. The file name matches the reference name and the file contents is
|
||||
* the current {@link ObjectId} in string form.
|
||||
* the current {@link org.eclipse.jgit.lib.ObjectId} in string form.
|
||||
* <p>
|
||||
* Packed references are stored in a single text file named {@code packed-refs}.
|
||||
* In the packed format, each reference is stored on its own line. This file
|
||||
|
@ -243,6 +243,7 @@ public File logFor(String name) {
|
|||
return new File(logsDir, name);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void create() throws IOException {
|
||||
FileUtils.mkdir(refsDir);
|
||||
|
@ -251,6 +252,7 @@ public void create() throws IOException {
|
|||
newLogWriter(false).create();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void close() {
|
||||
clearReferences();
|
||||
|
@ -261,12 +263,14 @@ private void clearReferences() {
|
|||
packedRefs.set(NO_PACKED_REFS);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void refresh() {
|
||||
super.refresh();
|
||||
clearReferences();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isNameConflicting(String name) throws IOException {
|
||||
RefList<Ref> packed = getPackedRefs();
|
||||
|
@ -312,6 +316,7 @@ private RefList<LooseRef> getLooseRefs() {
|
|||
return loose;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Ref exactRef(String name) throws IOException {
|
||||
RefList<Ref> packed = getPackedRefs();
|
||||
|
@ -336,6 +341,7 @@ public Ref exactRef(String name) throws IOException {
|
|||
return ref;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Ref getRef(final String needle) throws IOException {
|
||||
final RefList<Ref> packed = getPackedRefs();
|
||||
|
@ -360,6 +366,7 @@ public Ref getRef(final String needle) throws IOException {
|
|||
return ref;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Map<String, Ref> getRefs(String prefix) throws IOException {
|
||||
final RefList<LooseRef> oldLoose = looseRefs.get();
|
||||
|
@ -399,6 +406,7 @@ public Map<String, Ref> getRefs(String prefix) throws IOException {
|
|||
return new RefMap(prefix, packed, upcast(loose), symbolic.toRefList());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public List<Ref> getAdditionalRefs() throws IOException {
|
||||
List<Ref> ret = new LinkedList<>();
|
||||
|
@ -533,6 +541,7 @@ private void scanOne(String name) {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Ref peel(final Ref ref) throws IOException {
|
||||
final Ref leaf = ref.getLeaf();
|
||||
|
@ -584,6 +593,7 @@ void storedSymbolicRef(RefDirectoryUpdate u, FileSnapshot snapshot,
|
|||
fireRefsChanged();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RefDirectoryUpdate newUpdate(String name, boolean detach)
|
||||
throws IOException {
|
||||
|
@ -603,6 +613,7 @@ public RefDirectoryUpdate newUpdate(String name, boolean detach)
|
|||
return refDirUpdate;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RefDirectoryRename newRename(String fromName, String toName)
|
||||
throws IOException {
|
||||
|
@ -611,11 +622,13 @@ public RefDirectoryRename newRename(String fromName, String toName)
|
|||
return new RefDirectoryRename(from, to);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public PackedBatchRefUpdate newBatchUpdate() {
|
||||
return new PackedBatchRefUpdate(this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean performsAtomicTransactions() {
|
||||
return true;
|
||||
|
@ -695,7 +708,7 @@ void delete(RefDirectoryUpdate update) throws IOException {
|
|||
*
|
||||
* @param refs
|
||||
* the refs to be added. Must be fully qualified.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void pack(List<String> refs) throws IOException {
|
||||
pack(refs, Collections.emptyMap());
|
||||
|
|
|
@ -95,6 +95,7 @@ class RefDirectoryRename extends RefRename {
|
|||
refdb = src.getRefDatabase();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected Result doRename() throws IOException {
|
||||
if (source.getRef().isSymbolic())
|
||||
|
|
|
@ -65,16 +65,19 @@ class RefDirectoryUpdate extends RefUpdate {
|
|||
database = r;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected RefDirectory getRefDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected Repository getRepository() {
|
||||
return database.getRepository();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected boolean tryLock(boolean deref) throws IOException {
|
||||
shouldDeref = deref;
|
||||
|
@ -92,6 +95,7 @@ protected boolean tryLock(boolean deref) throws IOException {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void unlock() {
|
||||
if (lock != null) {
|
||||
|
@ -100,6 +104,7 @@ protected void unlock() {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected Result doUpdate(final Result status) throws IOException {
|
||||
WriteConfig wc = database.getRepository().getConfig()
|
||||
|
@ -141,6 +146,7 @@ private String toResultString(Result status) {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected Result doDelete(final Result status) throws IOException {
|
||||
if (getRef().getStorage() != Ref.Storage.NEW)
|
||||
|
@ -148,6 +154,7 @@ protected Result doDelete(final Result status) throws IOException {
|
|||
return status;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected Result doLink(final String target) throws IOException {
|
||||
WriteConfig wc = database.getRepository().getConfig()
|
||||
|
|
|
@ -93,6 +93,7 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getOldId()
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId getOldId() {
|
||||
return oldId;
|
||||
|
@ -101,6 +102,7 @@ public ObjectId getOldId() {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getNewId()
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectId getNewId() {
|
||||
return newId;
|
||||
|
@ -109,6 +111,7 @@ public ObjectId getNewId() {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getWho()
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public PersonIdent getWho() {
|
||||
return who;
|
||||
|
@ -117,11 +120,13 @@ public PersonIdent getWho() {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getComment()
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@SuppressWarnings("nls")
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -132,6 +137,7 @@ public String toString() {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#parseCheckout()
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public CheckoutEntry parseCheckout() {
|
||||
if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM))
|
||||
|
|
|
@ -74,6 +74,7 @@ class ReflogReaderImpl implements ReflogReader {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getLastEntry()
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ReflogEntry getLastEntry() throws IOException {
|
||||
return getReverseEntry(0);
|
||||
|
@ -82,6 +83,7 @@ public ReflogEntry getLastEntry() throws IOException {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntries()
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public List<ReflogEntry> getReverseEntries() throws IOException {
|
||||
return getReverseEntries(Integer.MAX_VALUE);
|
||||
|
@ -90,6 +92,7 @@ public List<ReflogEntry> getReverseEntries() throws IOException {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntry(int)
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ReflogEntry getReverseEntry(int number) throws IOException {
|
||||
if (number < 0)
|
||||
|
@ -119,6 +122,7 @@ public ReflogEntry getReverseEntry(int number) throws IOException {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntries(int)
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public List<ReflogEntry> getReverseEntries(int max) throws IOException {
|
||||
final byte[] log;
|
||||
|
|
|
@ -95,6 +95,8 @@ public static String refLockFor(String name) {
|
|||
* Create writer for ref directory.
|
||||
*
|
||||
* @param refdb
|
||||
* a {@link org.eclipse.jgit.internal.storage.file.RefDirectory}
|
||||
* object.
|
||||
*/
|
||||
public ReflogWriter(RefDirectory refdb) {
|
||||
this(refdb, false);
|
||||
|
@ -104,6 +106,8 @@ public ReflogWriter(RefDirectory refdb) {
|
|||
* Create writer for ref directory.
|
||||
*
|
||||
* @param refdb
|
||||
* a {@link org.eclipse.jgit.internal.storage.file.RefDirectory}
|
||||
* object.
|
||||
* @param forceWrite
|
||||
* true to write to disk all entries logged, false to respect the
|
||||
* repository's config and current log file status.
|
||||
|
@ -116,7 +120,7 @@ public ReflogWriter(RefDirectory refdb, boolean forceWrite) {
|
|||
/**
|
||||
* Create the log directories.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* @return this writer.
|
||||
*/
|
||||
public ReflogWriter create() throws IOException {
|
||||
|
@ -131,9 +135,11 @@ public ReflogWriter create() throws IOException {
|
|||
* Write the given entry to the ref's log.
|
||||
*
|
||||
* @param refName
|
||||
* a {@link java.lang.String} object.
|
||||
* @param entry
|
||||
* a {@link org.eclipse.jgit.lib.ReflogEntry} object.
|
||||
* @return this writer
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public ReflogWriter log(String refName, ReflogEntry entry)
|
||||
throws IOException {
|
||||
|
@ -145,12 +151,17 @@ public ReflogWriter log(String refName, ReflogEntry entry)
|
|||
* Write the given entry information to the ref's log
|
||||
*
|
||||
* @param refName
|
||||
* ref name
|
||||
* @param oldId
|
||||
* old object id
|
||||
* @param newId
|
||||
* new object id
|
||||
* @param ident
|
||||
* a {@link org.eclipse.jgit.lib.PersonIdent}
|
||||
* @param message
|
||||
* reflog message
|
||||
* @return this writer
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public ReflogWriter log(String refName, ObjectId oldId,
|
||||
ObjectId newId, PersonIdent ident, String message) throws IOException {
|
||||
|
@ -162,10 +173,13 @@ public ReflogWriter log(String refName, ObjectId oldId,
|
|||
* Write the given ref update to the ref's log.
|
||||
*
|
||||
* @param update
|
||||
* a {@link org.eclipse.jgit.lib.RefUpdate}
|
||||
* @param msg
|
||||
* reflog message
|
||||
* @param deref
|
||||
* whether to dereference symbolic refs
|
||||
* @return this writer
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public ReflogWriter log(RefUpdate update, String msg,
|
||||
boolean deref) throws IOException {
|
||||
|
|
|
@ -64,83 +64,105 @@ class SimpleDataInput implements DataInput {
|
|||
this.fd = fd;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int readInt() throws IOException {
|
||||
readFully(buf, 0, 4);
|
||||
return NB.decodeInt32(buf, 0);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long readLong() throws IOException {
|
||||
readFully(buf, 0, 8);
|
||||
return NB.decodeInt64(buf, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read unsigned int
|
||||
*
|
||||
* @return a long.
|
||||
* @throws java.io.IOException
|
||||
* if any.
|
||||
*/
|
||||
public long readUnsignedInt() throws IOException {
|
||||
readFully(buf, 0, 4);
|
||||
return NB.decodeUInt32(buf, 0);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void readFully(byte[] b) throws IOException {
|
||||
readFully(b, 0, b.length);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void readFully(byte[] b, int off, int len) throws IOException {
|
||||
IO.readFully(fd, b, off, len);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int skipBytes(int n) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean readBoolean() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public byte readByte() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int readUnsignedByte() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public short readShort() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int readUnsignedShort() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public char readChar() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public float readFloat() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double readDouble() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String readLine() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String readUTF() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -64,74 +64,88 @@ class SimpleDataOutput implements DataOutput {
|
|||
this.fd = fd;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeShort(int v) throws IOException {
|
||||
NB.encodeInt16(buf, 0, v);
|
||||
fd.write(buf, 0, 2);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeInt(int v) throws IOException {
|
||||
NB.encodeInt32(buf, 0, v);
|
||||
fd.write(buf, 0, 4);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeLong(long v) throws IOException {
|
||||
NB.encodeInt64(buf, 0, v);
|
||||
fd.write(buf, 0, 8);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeBoolean(boolean v) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeByte(int v) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeChar(int v) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeFloat(float v) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeDouble(double v) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeBytes(String s) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeChars(String s) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeUTF(String s) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -86,7 +86,7 @@ public class UnpackedObject {
|
|||
* expected ObjectId of the object, used only for error reporting
|
||||
* in exceptions.
|
||||
* @return loader to read the inflated contents.
|
||||
* @throws IOException
|
||||
* @throws java.io.IOException
|
||||
* the object cannot be parsed.
|
||||
*/
|
||||
public static ObjectLoader parse(byte[] raw, AnyObjectId id)
|
||||
|
|
|
@ -57,7 +57,8 @@
|
|||
import org.eclipse.jgit.storage.file.WindowCacheConfig;
|
||||
|
||||
/**
|
||||
* Caches slices of a {@link PackFile} in memory for faster read access.
|
||||
* Caches slices of a {@link org.eclipse.jgit.internal.storage.file.PackFile} in
|
||||
* memory for faster read access.
|
||||
* <p>
|
||||
* The WindowCache serves as a Java based "buffer cache", loading segments of a
|
||||
* PackFile into the JVM heap prior to use. As JGit often wants to do reads of
|
||||
|
@ -111,8 +112,9 @@
|
|||
* {@link #createRef(PackFile, long, ByteWindow)} methods, and matching
|
||||
* decrements during {@link #clear(Ref)}. Implementors may need to override
|
||||
* {@link #createRef(PackFile, long, ByteWindow)} in order to embed additional
|
||||
* accounting information into an implementation specific {@link Ref} subclass,
|
||||
* as the cached entity may have already been evicted by the JRE's garbage
|
||||
* accounting information into an implementation specific
|
||||
* {@link org.eclipse.jgit.internal.storage.file.WindowCache.Ref} subclass, as
|
||||
* the cached entity may have already been evicted by the JRE's garbage
|
||||
* collector.
|
||||
* <p>
|
||||
* To maintain higher concurrency workloads, during eviction only one thread
|
||||
|
@ -150,7 +152,7 @@ private static final int bits(int newSize) {
|
|||
* @deprecated use {@code cfg.install()} to avoid internal reference.
|
||||
* @param cfg
|
||||
* the new window cache configuration.
|
||||
* @throws IllegalArgumentException
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* the cache configuration contains one or more invalid
|
||||
* settings, usually too low of a limit.
|
||||
*/
|
||||
|
|
|
@ -110,11 +110,13 @@ DeltaBaseCache getDeltaBaseCache() {
|
|||
return baseCache;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectReader newReader() {
|
||||
return new WindowCursor(db);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public BitmapIndex getBitmapIndex() throws IOException {
|
||||
for (PackFile pack : db.getPacks()) {
|
||||
|
@ -125,6 +127,7 @@ public BitmapIndex getBitmapIndex() throws IOException {
|
|||
return null;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Collection<CachedPack> getCachedPacksAndUpdate(
|
||||
BitmapBuilder needBitmap) throws IOException {
|
||||
|
@ -137,6 +140,7 @@ public Collection<CachedPack> getCachedPacksAndUpdate(
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Collection<ObjectId> resolve(AbbreviatedObjectId id)
|
||||
throws IOException {
|
||||
|
@ -147,11 +151,13 @@ public Collection<ObjectId> resolve(AbbreviatedObjectId id)
|
|||
return matches;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean has(AnyObjectId objectId) throws IOException {
|
||||
return db.has(objectId);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ObjectLoader open(AnyObjectId objectId, int typeHint)
|
||||
throws MissingObjectException, IncorrectObjectTypeException,
|
||||
|
@ -168,11 +174,13 @@ public ObjectLoader open(AnyObjectId objectId, int typeHint)
|
|||
return ldr;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Set<ObjectId> getShallowCommits() throws IOException {
|
||||
return db.getShallowCommits();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getObjectSize(AnyObjectId objectId, int typeHint)
|
||||
throws MissingObjectException, IncorrectObjectTypeException,
|
||||
|
@ -187,11 +195,13 @@ public long getObjectSize(AnyObjectId objectId, int typeHint)
|
|||
return sz;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public LocalObjectToPack newObjectToPack(AnyObjectId objectId, int type) {
|
||||
return new LocalObjectToPack(objectId, type);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void selectObjectRepresentation(PackWriter packer,
|
||||
ProgressMonitor monitor, Iterable<ObjectToPack> objects)
|
||||
|
@ -202,6 +212,7 @@ public void selectObjectRepresentation(PackWriter packer,
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void copyObjectAsIs(PackOutputStream out, ObjectToPack otp,
|
||||
boolean validate) throws IOException,
|
||||
|
@ -210,6 +221,7 @@ public void copyObjectAsIs(PackOutputStream out, ObjectToPack otp,
|
|||
src.pack.copyAsIs(out, src, validate, this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void writeObjects(PackOutputStream out, List<ObjectToPack> list)
|
||||
throws IOException {
|
||||
|
@ -253,6 +265,7 @@ int copy(final PackFile pack, long position, final byte[] dstbuf,
|
|||
return cnt - need;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void copyPackAsIs(PackOutputStream out, CachedPack pack)
|
||||
throws IOException {
|
||||
|
@ -348,13 +361,18 @@ void pin(final PackFile pack, final long position)
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
@Nullable
|
||||
public ObjectInserter getCreatedFromInserter() {
|
||||
return createdFromInserter;
|
||||
}
|
||||
|
||||
/** Release the current window cursor. */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Release the current window cursor.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
window = null;
|
||||
|
|
Loading…
Reference in New Issue