Browse Source

Fix javadoc in org.eclipse.jgit storage/file package

Change-Id: Ieb2f66aef2cab7e2a6d8e35c5f5047da881994dd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.10
Matthias Sohn 7 years ago
parent
commit
5480da5999
  1. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BasePackBitmapIndex.java
  2. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteArrayWindow.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteBufferWindow.java
  5. 21
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteWindow.java
  6. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/CachedObjectDirectory.java
  7. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/CheckoutEntryImpl.java
  8. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileObjectDatabase.java
  9. 51
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
  10. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java
  11. 37
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
  12. 11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GlobalAttributesNode.java
  13. 11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/InfoAttributesNode.java
  14. 5
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LargePackedWholeObject.java
  15. 5
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java
  16. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalCachedPack.java
  17. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalObjectRepresentation.java
  18. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalObjectToPack.java
  19. 41
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
  20. 46
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
  21. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
  22. 27
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
  23. 16
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java
  24. 54
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
  25. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java
  26. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexV1.java
  27. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java
  28. 22
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
  29. 29
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java
  30. 8
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV1.java
  31. 9
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java
  32. 35
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexWriter.java
  33. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexWriterV1.java
  34. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexWriterV2.java
  35. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
  36. 15
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java
  37. 9
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackLock.java
  38. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackReverseIndex.java
  39. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java
  40. 19
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
  41. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryRename.java
  42. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
  43. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java
  44. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogReaderImpl.java
  45. 22
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogWriter.java
  46. 22
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/SimpleDataInput.java
  47. 14
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/SimpleDataOutput.java
  48. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
  49. 10
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
  50. 20
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java

1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BasePackBitmapIndex.java

@ -58,6 +58,7 @@ abstract class BasePackBitmapIndex extends PackBitmapIndex {
this.bitmaps = bitmaps; this.bitmaps = bitmaps;
} }
/** {@inheritDoc} */
@Override @Override
public EWAHCompressedBitmap getBitmap(AnyObjectId objectId) { public EWAHCompressedBitmap getBitmap(AnyObjectId objectId) {
StoredBitmap sb = bitmaps.get(objectId); StoredBitmap sb = bitmaps.get(objectId);

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java

@ -59,7 +59,9 @@ import org.eclipse.jgit.util.BlockList;
import com.googlecode.javaewah.EWAHCompressedBitmap; import com.googlecode.javaewah.EWAHCompressedBitmap;
import com.googlecode.javaewah.IntIterator; 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 { public class BitmapIndexImpl implements BitmapIndex {
private static final int EXTRA_BITS = 10 * 1024; private static final int EXTRA_BITS = 10 * 1024;
@ -85,6 +87,7 @@ public class BitmapIndexImpl implements BitmapIndex {
return packIndex; return packIndex;
} }
/** {@inheritDoc} */
@Override @Override
public CompressedBitmap getBitmap(AnyObjectId objectId) { public CompressedBitmap getBitmap(AnyObjectId objectId) {
EWAHCompressedBitmap compressed = packIndex.getBitmap(objectId); EWAHCompressedBitmap compressed = packIndex.getBitmap(objectId);
@ -93,6 +96,7 @@ public class BitmapIndexImpl implements BitmapIndex {
return new CompressedBitmap(compressed, this); return new CompressedBitmap(compressed, this);
} }
/** {@inheritDoc} */
@Override @Override
public CompressedBitmapBuilder newBitmapBuilder() { public CompressedBitmapBuilder newBitmapBuilder() {
return new CompressedBitmapBuilder(this); return new CompressedBitmapBuilder(this);

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteArrayWindow.java

@ -63,6 +63,7 @@ final class ByteArrayWindow extends ByteWindow {
array = b; array = b;
} }
/** {@inheritDoc} */
@Override @Override
protected int copy(final int p, final byte[] b, final int o, int n) { protected int copy(final int p, final byte[] b, final int o, int n) {
n = Math.min(array.length - p, n); n = Math.min(array.length - p, n);
@ -70,6 +71,7 @@ final class ByteArrayWindow extends ByteWindow {
return n; return n;
} }
/** {@inheritDoc} */
@Override @Override
protected int setInput(final int pos, final Inflater inf) protected int setInput(final int pos, final Inflater inf)
throws DataFormatException { throws DataFormatException {

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteBufferWindow.java

@ -65,6 +65,7 @@ final class ByteBufferWindow extends ByteWindow {
buffer = b; buffer = b;
} }
/** {@inheritDoc} */
@Override @Override
protected int copy(final int p, final byte[] b, final int o, int n) { protected int copy(final int p, final byte[] b, final int o, int n) {
final ByteBuffer s = buffer.slice(); final ByteBuffer s = buffer.slice();
@ -89,6 +90,7 @@ final class ByteBufferWindow extends ByteWindow {
} }
} }
/** {@inheritDoc} */
@Override @Override
protected int setInput(final int pos, final Inflater inf) protected int setInput(final int pos, final Inflater inf)
throws DataFormatException { throws DataFormatException {

21
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteWindow.java

@ -66,6 +66,16 @@ abstract class ByteWindow {
protected final long end; 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) { protected ByteWindow(final PackFile p, final long s, final int n) {
pack = p; pack = p;
start = s; start = s;
@ -127,6 +137,17 @@ abstract class ByteWindow {
return setInput((int) (pos - start), inf); 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) protected abstract int setInput(int pos, Inflater inf)
throws DataFormatException; throws DataFormatException;
} }

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/CachedObjectDirectory.java

@ -117,11 +117,13 @@ class CachedObjectDirectory extends FileObjectDatabase {
return m; return m;
} }
/** {@inheritDoc} */
@Override @Override
public void close() { public void close() {
// Don't close anything. // Don't close anything.
} }
/** {@inheritDoc} */
@Override @Override
public ObjectDatabase newCachedDatabase() { public ObjectDatabase newCachedDatabase() {
return this; return this;
@ -177,6 +179,7 @@ class CachedObjectDirectory extends FileObjectDatabase {
wrapped.resolve(matches, id); wrapped.resolve(matches, id);
} }
/** {@inheritDoc} */
@Override @Override
public boolean has(final AnyObjectId objectId) throws IOException { public boolean has(final AnyObjectId objectId) throws IOException {
return has(objectId, null); return has(objectId, null);

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/CheckoutEntryImpl.java

@ -65,11 +65,13 @@ public class CheckoutEntryImpl implements CheckoutEntry {
to = comment.substring(p2 + " to ".length(), p3); //$NON-NLS-1$ to = comment.substring(p2 + " to ".length(), p3); //$NON-NLS-1$
} }
/** {@inheritDoc} */
@Override @Override
public String getFromBranch() { public String getFromBranch() {
return from; return from;
} }
/** {@inheritDoc} */
@Override @Override
public String getToBranch() { public String getToBranch() {
return to; return to;

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileObjectDatabase.java

@ -64,11 +64,13 @@ abstract class FileObjectDatabase extends ObjectDatabase {
INSERTED, EXISTS_PACKED, EXISTS_LOOSE, FAILURE; INSERTED, EXISTS_PACKED, EXISTS_LOOSE, FAILURE;
} }
/** {@inheritDoc} */
@Override @Override
public ObjectReader newReader() { public ObjectReader newReader() {
return new WindowCursor(this); return new WindowCursor(this);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectDirectoryInserter newInserter() { public ObjectDirectoryInserter newInserter() {
return new ObjectDirectoryInserter(this, getConfig()); return new ObjectDirectoryInserter(this, getConfig());

51
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java

@ -116,7 +116,6 @@ import org.eclipse.jgit.util.SystemReader;
* This class is thread-safe. * This class is thread-safe.
* <p> * <p>
* This implementation only handles a subtly undocumented subset of git features. * This implementation only handles a subtly undocumented subset of git features.
*
*/ */
public class FileRepository extends Repository { public class FileRepository extends Repository {
private static final String UNNAMED = "Unnamed repository; edit this file to name it for gitweb."; //$NON-NLS-1$ 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> * <p>
* The work tree, object directory, alternate object directories and index * The work tree, object directory, alternate object directories and index
* file locations are deduced from the given git directory and the default * file locations are deduced from the given git directory and the default
* rules by running {@link FileRepositoryBuilder}. This constructor is the * rules by running
* same as saying: * {@link org.eclipse.jgit.storage.file.FileRepositoryBuilder}. This
* constructor is the same as saying:
* *
* <pre> * <pre>
* new FileRepositoryBuilder().setGitDir(gitDir).build() * new FileRepositoryBuilder().setGitDir(gitDir).build()
@ -142,7 +142,7 @@ public class FileRepository extends Repository {
* *
* @param gitDir * @param gitDir
* GIT_DIR (the location of the repository metadata). * GIT_DIR (the location of the repository metadata).
* @throws IOException * @throws java.io.IOException
* the repository appears to already exist but cannot be * the repository appears to already exist but cannot be
* accessed. * accessed.
* @see FileRepositoryBuilder * @see FileRepositoryBuilder
@ -156,7 +156,7 @@ public class FileRepository extends Repository {
* *
* @param gitDir * @param gitDir
* GIT_DIR (the location of the repository metadata). * GIT_DIR (the location of the repository metadata).
* @throws IOException * @throws java.io.IOException
* the repository appears to already exist but cannot be * the repository appears to already exist but cannot be
* accessed. * accessed.
* @see FileRepositoryBuilder * @see FileRepositoryBuilder
@ -170,7 +170,7 @@ public class FileRepository extends Repository {
* *
* @param options * @param options
* description of the repository's important paths. * description of the repository's important paths.
* @throws IOException * @throws java.io.IOException
* the user configuration file or repository configuration file * the user configuration file or repository configuration file
* cannot be accessed. * cannot be accessed.
*/ */
@ -279,14 +279,10 @@ public class FileRepository extends Repository {
} }
/** /**
* {@inheritDoc}
* <p>
* Create a new Git repository initializing the necessary files and * Create a new Git repository initializing the necessary files and
* directories. * directories.
*
* @param bare
* if true, a bare repository is created.
*
* @throws IOException
* in case of IO problem
*/ */
@Override @Override
public void create(boolean bare) throws IOException { public void create(boolean bare) throws IOException {
@ -380,25 +376,27 @@ public class FileRepository extends Repository {
} }
/** /**
* Get the directory containing the objects owned by this repository
*
* @return the directory containing the objects owned by this repository. * @return the directory containing the objects owned by this repository.
*/ */
public File getObjectsDirectory() { public File getObjectsDirectory() {
return objectDatabase.getDirectory(); return objectDatabase.getDirectory();
} }
/** @return the object database storing this repository's data. */ /** {@inheritDoc} */
@Override @Override
public ObjectDirectory getObjectDatabase() { public ObjectDirectory getObjectDatabase() {
return objectDatabase; return objectDatabase;
} }
/** @return the reference database which stores the reference namespace. */ /** {@inheritDoc} */
@Override @Override
public RefDatabase getRefDatabase() { public RefDatabase getRefDatabase() {
return refs; return refs;
} }
/** @return the configuration of this repository. */ /** {@inheritDoc} */
@Override @Override
public FileBasedConfig getConfig() { public FileBasedConfig getConfig() {
if (systemConfig.isOutdated()) { if (systemConfig.isOutdated()) {
@ -425,6 +423,7 @@ public class FileRepository extends Repository {
return repoConfig; return repoConfig;
} }
/** {@inheritDoc} */
@Override @Override
@Nullable @Nullable
public String getGitwebDescription() throws IOException { public String getGitwebDescription() throws IOException {
@ -443,6 +442,7 @@ public class FileRepository extends Repository {
return d; return d;
} }
/** {@inheritDoc} */
@Override @Override
public void setGitwebDescription(@Nullable String description) public void setGitwebDescription(@Nullable String description)
throws IOException { throws IOException {
@ -479,14 +479,14 @@ public class FileRepository extends Repository {
} }
/** /**
* {@inheritDoc}
* <p>
* Objects known to exist but not expressed by {@link #getAllRefs()}. * Objects known to exist but not expressed by {@link #getAllRefs()}.
* <p> * <p>
* When a repository borrows objects from another repository, it can * When a repository borrows objects from another repository, it can
* advertise that it safely has that other repository's references, without * advertise that it safely has that other repository's references, without
* exposing any other details about the other repository. This may help * exposing any other details about the other repository. This may help a
* a client trying to push changes avoid pushing more than it needs to. * client trying to push changes avoid pushing more than it needs to.
*
* @return unmodifiable collection of other known objects.
*/ */
@Override @Override
public Set<ObjectId> getAdditionalHaves() { public Set<ObjectId> getAdditionalHaves() {
@ -531,7 +531,7 @@ public class FileRepository extends Repository {
* *
* @param pack * @param pack
* path of the pack file to open. * 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 * index file could not be opened, read, or is not recognized as
* a Git pack file index. * a Git pack file index.
*/ */
@ -539,6 +539,7 @@ public class FileRepository extends Repository {
objectDatabase.openPack(pack); objectDatabase.openPack(pack);
} }
/** {@inheritDoc} */
@Override @Override
public void scanForRepoChanges() throws IOException { public void scanForRepoChanges() throws IOException {
getRefDatabase().getRefs(ALL); // This will look for changes to refs getRefDatabase().getRefs(ALL); // This will look for changes to refs
@ -557,18 +558,14 @@ public class FileRepository extends Repository {
notifyIndexChanged(); notifyIndexChanged();
} }
/** {@inheritDoc} */
@Override @Override
public void notifyIndexChanged() { public void notifyIndexChanged() {
snapshot = FileSnapshot.save(getIndexFile()); snapshot = FileSnapshot.save(getIndexFile());
fireEvent(new IndexChangedEvent()); fireEvent(new IndexChangedEvent());
} }
/** /** {@inheritDoc} */
* @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.
*/
@Override @Override
public ReflogReader getReflogReader(String refName) throws IOException { public ReflogReader getReflogReader(String refName) throws IOException {
Ref ref = findRef(refName); Ref ref = findRef(refName);
@ -577,6 +574,7 @@ public class FileRepository extends Repository {
return null; return null;
} }
/** {@inheritDoc} */
@Override @Override
public AttributesNodeProvider createAttributesNodeProvider() { public AttributesNodeProvider createAttributesNodeProvider() {
return new AttributesNodeProviderImpl(this); return new AttributesNodeProviderImpl(this);
@ -642,6 +640,7 @@ public class FileRepository extends Repository {
ConfigConstants.CONFIG_KEY_AUTODETACH, true); ConfigConstants.CONFIG_KEY_AUTODETACH, true);
} }
/** {@inheritDoc} */
@Override @Override
public void autoGC(ProgressMonitor monitor) { public void autoGC(ProgressMonitor monitor) {
GC gc = new GC(this); GC gc = new GC(this);

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java

@ -121,7 +121,6 @@ public class FileSnapshot {
* *
* @param modified * @param modified
* the last modification time of the file * the last modification time of the file
*
* @return the snapshot. * @return the snapshot.
*/ */
public static FileSnapshot save(long modified) { public static FileSnapshot save(long modified) {
@ -145,6 +144,8 @@ public class FileSnapshot {
} }
/** /**
* Get time of last snapshot update
*
* @return time of last snapshot update * @return time of last snapshot update
*/ */
public long lastModified() { public long lastModified() {
@ -208,6 +209,7 @@ public class FileSnapshot {
return lastModified == other.lastModified; return lastModified == other.lastModified;
} }
/** {@inheritDoc} */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof FileSnapshot) if (other instanceof FileSnapshot)
@ -215,6 +217,7 @@ public class FileSnapshot {
return false; return false;
} }
/** {@inheritDoc} */
@Override @Override
public int hashCode() { public int hashCode() {
// This is pretty pointless, but override hashCode to ensure that // This is pretty pointless, but override hashCode to ensure that
@ -223,6 +226,7 @@ public class FileSnapshot {
return (int) lastModified; return (int) lastModified;
} }
/** {@inheritDoc} */
@Override @Override
public String toString() { public String toString() {
if (this == DIRTY) if (this == DIRTY)

37
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

@ -124,8 +124,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* A garbage collector for git {@link FileRepository}. Instances of this class * A garbage collector for git
* are not thread-safe. Don't use the same instance from multiple threads. * {@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 * This class started as a copy of DfsGarbageCollector from Shawn O. Pearce
* adapted to FileRepositories. * adapted to FileRepositories.
@ -218,7 +220,8 @@ public class GC {
} }
/** /**
* 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> * <ul>
* <li>pack loose references into packed-refs</li> * <li>pack loose references into packed-refs</li>
* <li>repack all reachable objects into new pack files and delete the old * <li>repack all reachable objects into new pack files and delete the old
@ -235,9 +238,11 @@ public class GC {
* return immediately. In this case, errors will not be reported except in * return immediately. In this case, errors will not be reported except in
* gc.log. * gc.log.
* *
* @return the collection of {@link PackFile}'s which are newly created * @return the collection of
* @throws IOException * {@link org.eclipse.jgit.internal.storage.file.PackFile}'s which
* @throws ParseException * are newly created
* @throws java.io.IOException
* @throws java.text.ParseException
* If the configuration parameter "gc.pruneexpire" couldn't be * If the configuration parameter "gc.pruneexpire" couldn't be
* parsed * parsed
*/ */
@ -475,7 +480,7 @@ public class GC {
* which can be found in packs. If certain objects can't be pruned (e.g. * 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. * because the filesystem delete operation fails) this is silently ignored.
* *
* @throws IOException * @throws java.io.IOException
*/ */
public void prunePacked() throws IOException { public void prunePacked() throws IOException {
ObjectDirectory objdb = repo.getObjectDatabase(); ObjectDirectory objdb = repo.getObjectDatabase();
@ -533,9 +538,8 @@ public class GC {
* *
* @param objectsToKeep * @param objectsToKeep
* a set of objects which should explicitly not be pruned * a set of objects which should explicitly not be pruned
* * @throws java.io.IOException
* @throws IOException * @throws java.text.ParseException
* @throws ParseException
* If the configuration parameter "gc.pruneexpire" couldn't be * If the configuration parameter "gc.pruneexpire" couldn't be
* parsed * parsed
*/ */
@ -782,7 +786,7 @@ public class GC {
/** /**
* Packs all non-symbolic, loose refs into packed-refs. * Packs all non-symbolic, loose refs into packed-refs.
* *
* @throws IOException * @throws java.io.IOException
*/ */
public void packRefs() throws IOException { public void packRefs() throws IOException {
Collection<Ref> refs = repo.getRefDatabase().getRefs(Constants.R_REFS).values(); Collection<Ref> refs = repo.getRefDatabase().getRefs(Constants.R_REFS).values();
@ -810,10 +814,10 @@ public class GC {
* repacked. All old pack files which existed before are deleted. * repacked. All old pack files which existed before are deleted.
* *
* @return a collection of the newly created pack files * @return a collection of the newly created pack files
* @throws IOException * @throws java.io.IOException
* when during reading of refs, index, packfiles, objects, * when during reading of refs, index, packfiles, objects,
* reflog-entries or during writing to the packfiles * reflog-entries or during writing to the packfiles
* {@link IOException} occurs * {@link java.io.IOException} occurs
*/ */
public Collection<PackFile> repack() throws IOException { public Collection<PackFile> repack() throws IOException {
Collection<PackFile> toBeDeleted = repo.getObjectDatabase().getPacks(); Collection<PackFile> toBeDeleted = repo.getObjectDatabase().getPacks();
@ -1312,7 +1316,7 @@ public class GC {
* Returns information about objects and pack files for a FileRepository. * Returns information about objects and pack files for a FileRepository.
* *
* @return 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 { public RepoStatistics getStatistics() throws IOException {
RepoStatistics ret = new RepoStatistics(); RepoStatistics ret = new RepoStatistics();
@ -1357,7 +1361,7 @@ public class GC {
/** /**
* Set the progress monitor used for garbage collection methods. * Set the progress monitor used for garbage collection methods.
* *
* @param pm * @param pm a {@link org.eclipse.jgit.lib.ProgressMonitor} object.
* @return this * @return this
*/ */
public GC setProgressMonitor(ProgressMonitor pm) { public GC setProgressMonitor(ProgressMonitor pm) {
@ -1399,7 +1403,8 @@ public class GC {
* "git gc --aggressive" * "git gc --aggressive"
* *
* @param pconfig * @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) { public void setPackConfig(PackConfig pconfig) {
this.pconfig = pconfig; this.pconfig = pconfig;

11
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GlobalAttributesNode.java

@ -51,20 +51,27 @@ import org.eclipse.jgit.lib.CoreConfig;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.util.FS; 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 { public class GlobalAttributesNode extends AttributesNode {
final Repository repository; final Repository repository;
/** /**
* Constructor for GlobalAttributesNode.
*
* @param repository * @param repository
* the {@link org.eclipse.jgit.lib.Repository}.
*/ */
public GlobalAttributesNode(Repository repository) { public GlobalAttributesNode(Repository repository) {
this.repository = repository; this.repository = repository;
} }
/** /**
* Load the attributes node
*
* @return the attributes node * @return the attributes node
* @throws IOException * @throws java.io.IOException
*/ */
public AttributesNode load() throws IOException { public AttributesNode load() throws IOException {
AttributesNode r = new AttributesNode(); AttributesNode r = new AttributesNode();

11
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/InfoAttributesNode.java

@ -51,20 +51,27 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.util.FS; 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 { public class InfoAttributesNode extends AttributesNode {
final Repository repository; final Repository repository;
/** /**
* Constructor for InfoAttributesNode.
*
* @param repository * @param repository
* the {@link org.eclipse.jgit.lib.Repository}.
*/ */
public InfoAttributesNode(Repository repository) { public InfoAttributesNode(Repository repository) {
this.repository = repository; this.repository = repository;
} }
/** /**
* Load the attributes node
*
* @return the attributes node * @return the attributes node
* @throws IOException * @throws java.io.IOException
*/ */
public AttributesNode load() throws IOException { public AttributesNode load() throws IOException {
AttributesNode r = new AttributesNode(); AttributesNode r = new AttributesNode();

5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LargePackedWholeObject.java

@ -77,21 +77,25 @@ class LargePackedWholeObject extends ObjectLoader {
this.db = db; this.db = db;
} }
/** {@inheritDoc} */
@Override @Override
public int getType() { public int getType() {
return type; return type;
} }
/** {@inheritDoc} */
@Override @Override
public long getSize() { public long getSize() {
return size; return size;
} }
/** {@inheritDoc} */
@Override @Override
public boolean isLarge() { public boolean isLarge() {
return true; return true;
} }
/** {@inheritDoc} */
@Override @Override
public byte[] getCachedBytes() throws LargeObjectException { public byte[] getCachedBytes() throws LargeObjectException {
try { try {
@ -103,6 +107,7 @@ class LargePackedWholeObject extends ObjectLoader {
} }
} }
/** {@inheritDoc} */
@Override @Override
public ObjectStream openStream() throws MissingObjectException, IOException { public ObjectStream openStream() throws MissingObjectException, IOException {
WindowCursor wc = new WindowCursor(db); WindowCursor wc = new WindowCursor(db);

5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java

@ -57,7 +57,9 @@ import org.eclipse.jgit.lib.MutableObjectId;
import org.eclipse.jgit.lib.ObjectIdOwnerMap; import org.eclipse.jgit.lib.ObjectIdOwnerMap;
import org.eclipse.jgit.lib.ObjectIdSet; 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 { public class LazyObjectIdSetFile implements ObjectIdSet {
private final File src; private final File src;
private ObjectIdOwnerMap<Entry> set; private ObjectIdOwnerMap<Entry> set;
@ -72,6 +74,7 @@ public class LazyObjectIdSetFile implements ObjectIdSet {
this.src = src; this.src = src;
} }
/** {@inheritDoc} */
@Override @Override
public boolean contains(AnyObjectId objectId) { public boolean contains(AnyObjectId objectId) {
if (set == null) { if (set == null) {

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalCachedPack.java

@ -71,6 +71,7 @@ class LocalCachedPack extends CachedPack {
this.packs = packs.toArray(new PackFile[packs.size()]); this.packs = packs.toArray(new PackFile[packs.size()]);
} }
/** {@inheritDoc} */
@Override @Override
public long getObjectCount() throws IOException { public long getObjectCount() throws IOException {
long cnt = 0; long cnt = 0;
@ -85,6 +86,7 @@ class LocalCachedPack extends CachedPack {
pack.copyPackAsIs(out, wc); pack.copyPackAsIs(out, wc);
} }
/** {@inheritDoc} */
@Override @Override
public boolean hasObject(ObjectToPack obj, StoredObjectRepresentation rep) { public boolean hasObject(ObjectToPack obj, StoredObjectRepresentation rep) {
try { try {

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalObjectRepresentation.java

@ -92,11 +92,13 @@ class LocalObjectRepresentation extends StoredObjectRepresentation {
private ObjectId baseId; private ObjectId baseId;
/** {@inheritDoc} */
@Override @Override
public int getWeight() { public int getWeight() {
return (int) Math.min(length, Integer.MAX_VALUE); return (int) Math.min(length, Integer.MAX_VALUE);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId getDeltaBase() { public ObjectId getDeltaBase() {
if (baseId == null && getFormat() == PACK_DELTA) { if (baseId == null && getFormat() == PACK_DELTA) {

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalObjectToPack.java

@ -62,12 +62,14 @@ class LocalObjectToPack extends ObjectToPack {
super(src, type); super(src, type);
} }
/** {@inheritDoc} */
@Override @Override
protected void clearReuseAsIs() { protected void clearReuseAsIs() {
super.clearReuseAsIs(); super.clearReuseAsIs();
pack = null; pack = null;
} }
/** {@inheritDoc} */
@Override @Override
public void select(StoredObjectRepresentation ref) { public void select(StoredObjectRepresentation ref) {
LocalObjectRepresentation ptr = (LocalObjectRepresentation) ref; LocalObjectRepresentation ptr = (LocalObjectRepresentation) ref;

41
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java

@ -57,7 +57,6 @@ import java.nio.channels.FileChannel;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.text.MessageFormat; import java.text.MessageFormat;
import org.eclipse.jgit.errors.LockFailedException;
import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
@ -81,10 +80,12 @@ public class LockFile {
* Unlock the given file. * Unlock the given file.
* <p> * <p>
* This method can be used for recovering from a thrown * This method can be used for recovering from a thrown
* {@link LockFailedException} . This method does not validate that the lock * {@link org.eclipse.jgit.errors.LockFailedException} . This method does
* is or is not currently held before attempting to unlock it. * not validate that the lock is or is not currently held before attempting
* to unlock it.
* *
* @param file * @param file
* a {@link java.io.File} object.
* @return true if unlocked, false if unlocking failed * @return true if unlocked, false if unlocking failed
*/ */
public static boolean unlock(final File file) { public static boolean unlock(final File file) {
@ -138,7 +139,9 @@ public class LockFile {
* @param fs * @param fs
* the file system abstraction which will be necessary to perform * the file system abstraction which will be necessary to perform
* certain file system operations. * 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 @Deprecated
public LockFile(final File f, final FS fs) { public LockFile(final File f, final FS fs) {
@ -162,7 +165,7 @@ public class LockFile {
* *
* @return true if the lock is now held by the caller; false if it is held * @return true if the lock is now held by the caller; false if it is held
* by someone else. * by someone else.
* @throws IOException * @throws java.io.IOException
* the temporary output file could not be created. The caller * the temporary output file could not be created. The caller
* does not hold the lock. * does not hold the lock.
*/ */
@ -185,7 +188,7 @@ public class LockFile {
* *
* @return true if the lock is now held by the caller; false if it is held * @return true if the lock is now held by the caller; false if it is held
* by someone else. * by someone else.
* @throws IOException * @throws java.io.IOException
* the temporary output file could not be created. The caller * the temporary output file could not be created. The caller
* does not hold the lock. * does not hold the lock.
*/ */
@ -206,12 +209,12 @@ public class LockFile {
* This method does nothing if the current file does not exist, or exists * This method does nothing if the current file does not exist, or exists
* but is empty. * but is empty.
* *
* @throws IOException * @throws java.io.IOException
* the temporary file could not be written, or a read error * the temporary file could not be written, or a read error
* occurred while reading from the current file. The lock is * occurred while reading from the current file. The lock is
* released before throwing the underlying IO exception to the * released before throwing the underlying IO exception to the
* caller. * caller.
* @throws RuntimeException * @throws java.lang.RuntimeException
* the temporary file could not be written. The lock is released * the temporary file could not be written. The lock is released
* before throwing the underlying exception to the caller. * before throwing the underlying exception to the caller.
*/ */
@ -264,10 +267,10 @@ public class LockFile {
* @param id * @param id
* the id to store in the file. The id will be written in hex, * the id to store in the file. The id will be written in hex,
* followed by a sole LF. * followed by a sole LF.
* @throws IOException * @throws java.io.IOException
* the temporary file could not be written. The lock is released * the temporary file could not be written. The lock is released
* before throwing the underlying IO exception to the caller. * 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 * the temporary file could not be written. The lock is released
* before throwing the underlying exception to the caller. * before throwing the underlying exception to the caller.
*/ */
@ -285,10 +288,10 @@ public class LockFile {
* the bytes to store in the temporary file. No additional bytes * 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 * are added, so if the file must end with an LF it must appear
* at the end of the byte array. * at the end of the byte array.
* @throws IOException * @throws java.io.IOException
* the temporary file could not be written. The lock is released * the temporary file could not be written. The lock is released
* before throwing the underlying IO exception to the caller. * 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 * the temporary file could not be written. The lock is released
* before throwing the underlying exception to the caller. * before throwing the underlying exception to the caller.
*/ */
@ -394,7 +397,8 @@ public class LockFile {
} }
/** /**
* Request that {@link #commit()} remember the {@link FileSnapshot}. * Request that {@link #commit()} remember the
* {@link org.eclipse.jgit.internal.storage.file.FileSnapshot}.
* *
* @param on * @param on
* true if the commit method must remember the FileSnapshot. * true if the commit method must remember the FileSnapshot.
@ -420,7 +424,7 @@ public class LockFile {
* method sleeps until it can force the new lock file's modification date to * method sleeps until it can force the new lock file's modification date to
* be later than the target file. * be later than the target file.
* *
* @throws InterruptedException * @throws java.lang.InterruptedException
* the thread was interrupted before the last modified date of * the thread was interrupted before the last modified date of
* the lock file was different from the last modified date of * the lock file was different from the last modified date of
* the target file. * the target file.
@ -443,7 +447,7 @@ public class LockFile {
* @return true if the commit was successful and the file contains the new * @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 * data; false if the commit failed and the file remains with the
* old data. * old data.
* @throws IllegalStateException * @throws java.lang.IllegalStateException
* the lock is not held. * the lock is not held.
*/ */
public boolean commit() { public boolean commit() {
@ -477,7 +481,11 @@ public class LockFile {
return commitSnapshot.lastModified(); 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() { public FileSnapshot getCommitSnapshot() {
return commitSnapshot; return commitSnapshot;
} }
@ -517,6 +525,7 @@ public class LockFile {
} }
} }
/** {@inheritDoc} */
@SuppressWarnings("nls") @SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {

46
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java

@ -91,12 +91,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Traditional file system based {@link ObjectDatabase}. * Traditional file system based {@link org.eclipse.jgit.lib.ObjectDatabase}.
* <p> * <p>
* This is the classical object database representation for a Git repository, * This is the classical object database representation for a Git repository,
* where objects are stored loose by hashing them into directories by their * where objects are stored loose by hashing them into directories by their
* {@link ObjectId}, or are stored in compressed containers known as * {@link org.eclipse.jgit.lib.ObjectId}, or are stored in compressed containers
* {@link PackFile}s. * known as {@link org.eclipse.jgit.internal.storage.file.PackFile}s.
* <p> * <p>
* Optionally an object database can reference one or more alternates; other * Optionally an object database can reference one or more alternates; other
* ObjectDatabase instances that are searched in addition to the current * ObjectDatabase instances that are searched in addition to the current
@ -161,7 +161,7 @@ public class ObjectDirectory extends FileObjectDatabase {
* @param shallowFile * @param shallowFile
* file which contains IDs of shallow commits, null if shallow * file which contains IDs of shallow commits, null if shallow
* commits handling should be turned off * commits handling should be turned off
* @throws IOException * @throws java.io.IOException
* an alternate object cannot be opened. * an alternate object cannot be opened.
*/ */
public ObjectDirectory(final Config cfg, final File dir, public ObjectDirectory(final Config cfg, final File dir,
@ -188,15 +188,15 @@ public class ObjectDirectory extends FileObjectDatabase {
} }
} }
/** /** {@inheritDoc} */
* @return the location of the <code>objects</code> directory.
*/
@Override @Override
public final File getDirectory() { public final File getDirectory() {
return objects; return objects;
} }
/** /**
* <p>Getter for the field <code>packDirectory</code>.</p>
*
* @return the location of the <code>pack</code> directory. * @return the location of the <code>pack</code> directory.
* @since 4.10 * @since 4.10
*/ */
@ -205,17 +205,21 @@ public class ObjectDirectory extends FileObjectDatabase {
} }
/** /**
* <p>Getter for the field <code>preservedDirectory</code>.</p>
*
* @return the location of the <code>preserved</code> directory. * @return the location of the <code>preserved</code> directory.
*/ */
public final File getPreservedDirectory() { public final File getPreservedDirectory() {
return preservedDirectory; return preservedDirectory;
} }
/** {@inheritDoc} */
@Override @Override
public boolean exists() { public boolean exists() {
return fs.exists(objects); return fs.exists(objects);
} }
/** {@inheritDoc} */
@Override @Override
public void create() throws IOException { public void create() throws IOException {
FileUtils.mkdirs(objects); FileUtils.mkdirs(objects);
@ -223,6 +227,7 @@ public class ObjectDirectory extends FileObjectDatabase {
FileUtils.mkdir(packDirectory); FileUtils.mkdir(packDirectory);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectDirectoryInserter newInserter() { public ObjectDirectoryInserter newInserter() {
return new ObjectDirectoryInserter(this, config); return new ObjectDirectoryInserter(this, config);
@ -238,6 +243,7 @@ public class ObjectDirectory extends FileObjectDatabase {
return new PackInserter(this); return new PackInserter(this);
} }
/** {@inheritDoc} */
@Override @Override
public void close() { public void close() {
unpackedObjectCache.clear(); unpackedObjectCache.clear();
@ -256,13 +262,7 @@ public class ObjectDirectory extends FileObjectDatabase {
} }
} }
/** /** {@inheritDoc} */
* @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.
*/
@Override @Override
public Collection<PackFile> getPacks() { public Collection<PackFile> getPacks() {
PackList list = packList.get(); PackList list = packList.get();
@ -273,14 +273,9 @@ public class ObjectDirectory extends FileObjectDatabase {
} }
/** /**
* {@inheritDoc}
* <p>
* Add a single existing pack to the list of available pack files. * 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 @Override
public PackFile openPack(final File pack) public PackFile openPack(final File pack)
@ -307,11 +302,13 @@ public class ObjectDirectory extends FileObjectDatabase {
return res; return res;
} }
/** {@inheritDoc} */
@Override @Override
public String toString() { public String toString() {
return "ObjectDirectory[" + getDirectory() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ return "ObjectDirectory[" + getDirectory() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
} }
/** {@inheritDoc} */
@Override @Override
public boolean has(AnyObjectId objectId) { public boolean has(AnyObjectId objectId) {
return unpackedObjectCache.isUnpacked(objectId) return unpackedObjectCache.isUnpacked(objectId)
@ -1066,11 +1063,9 @@ public class ObjectDirectory extends FileObjectDatabase {
} }
/** /**
* {@inheritDoc}
* <p>
* Compute the location of a loose object file. * 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 @Override
public File fileFor(AnyObjectId objectId) { public File fileFor(AnyObjectId objectId) {
@ -1155,6 +1150,7 @@ public class ObjectDirectory extends FileObjectDatabase {
} }
} }
/** {@inheritDoc} */
@Override @Override
public ObjectDatabase newCachedDatabase() { public ObjectDatabase newCachedDatabase() {
return newCachedFileObjectDatabase(); return newCachedFileObjectDatabase();

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java

@ -83,6 +83,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
config = cfg.get(WriteConfig.KEY); config = cfg.get(WriteConfig.KEY);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId insert(int type, byte[] data, int off, int len) public ObjectId insert(int type, byte[] data, int off, int len)
throws IOException { throws IOException {
@ -114,6 +115,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
} }
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId insert(final int type, long len, final InputStream is) public ObjectId insert(final int type, long len, final InputStream is)
throws IOException { throws IOException {
@ -166,21 +168,25 @@ class ObjectDirectoryInserter extends ObjectInserter {
.format(JGitText.get().unableToCreateNewObject, dst)); .format(JGitText.get().unableToCreateNewObject, dst));
} }
/** {@inheritDoc} */
@Override @Override
public PackParser newPackParser(InputStream in) throws IOException { public PackParser newPackParser(InputStream in) throws IOException {
return new ObjectDirectoryPackParser(db, in); return new ObjectDirectoryPackParser(db, in);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectReader newReader() { public ObjectReader newReader() {
return new WindowCursor(db, this); return new WindowCursor(db, this);
} }
/** {@inheritDoc} */
@Override @Override
public void flush() throws IOException { public void flush() throws IOException {
// Do nothing. Loose objects are immediately visible. // Do nothing. Loose objects are immediately visible.
} }
/** {@inheritDoc} */
@Override @Override
public void close() { public void close() {
if (deflate != null) { if (deflate != null) {

27
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java

@ -64,7 +64,6 @@ import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.CoreConfig; import org.eclipse.jgit.lib.CoreConfig;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.ProgressMonitor; import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.transport.PackParser; import org.eclipse.jgit.transport.PackParser;
import org.eclipse.jgit.transport.PackedObjectInfo; import org.eclipse.jgit.transport.PackedObjectInfo;
@ -72,10 +71,11 @@ import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.NB; 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> * <p>
* To obtain an instance of a parser, applications should use * 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 { public class ObjectDirectoryPackParser extends PackParser {
private final FileObjectDatabase db; private final FileObjectDatabase db;
@ -158,7 +158,7 @@ public class ObjectDirectoryPackParser extends PackParser {
} }
/** /**
* Get the imported {@link PackFile}. * Get the imported {@link org.eclipse.jgit.internal.storage.file.PackFile}.
* <p> * <p>
* This method is supplied only to support testing; applications shouldn't * This method is supplied only to support testing; applications shouldn't
* be using it directly to access the imported data. * be using it directly to access the imported data.
@ -169,6 +169,7 @@ public class ObjectDirectoryPackParser extends PackParser {
return newPack; return newPack;
} }
/** {@inheritDoc} */
@Override @Override
public long getPackSize() { public long getPackSize() {
if (newPack == null) if (newPack == null)
@ -184,6 +185,7 @@ public class ObjectDirectoryPackParser extends PackParser {
return size; return size;
} }
/** {@inheritDoc} */
@Override @Override
public PackLock parse(ProgressMonitor receiving, ProgressMonitor resolving) public PackLock parse(ProgressMonitor receiving, ProgressMonitor resolving)
throws IOException { throws IOException {
@ -218,34 +220,40 @@ public class ObjectDirectoryPackParser extends PackParser {
} }
} }
/** {@inheritDoc} */
@Override @Override
protected void onPackHeader(long objectCount) throws IOException { protected void onPackHeader(long objectCount) throws IOException {
// Ignored, the count is not required. // Ignored, the count is not required.
} }
/** {@inheritDoc} */
@Override @Override
protected void onBeginWholeObject(long streamPosition, int type, protected void onBeginWholeObject(long streamPosition, int type,
long inflatedSize) throws IOException { long inflatedSize) throws IOException {
crc.reset(); crc.reset();
} }
/** {@inheritDoc} */
@Override @Override
protected void onEndWholeObject(PackedObjectInfo info) throws IOException { protected void onEndWholeObject(PackedObjectInfo info) throws IOException {
info.setCRC((int) crc.getValue()); info.setCRC((int) crc.getValue());
} }
/** {@inheritDoc} */
@Override @Override
protected void onBeginOfsDelta(long streamPosition, protected void onBeginOfsDelta(long streamPosition,
long baseStreamPosition, long inflatedSize) throws IOException { long baseStreamPosition, long inflatedSize) throws IOException {
crc.reset(); crc.reset();
} }
/** {@inheritDoc} */
@Override @Override
protected void onBeginRefDelta(long streamPosition, AnyObjectId baseId, protected void onBeginRefDelta(long streamPosition, AnyObjectId baseId,
long inflatedSize) throws IOException { long inflatedSize) throws IOException {
crc.reset(); crc.reset();
} }
/** {@inheritDoc} */
@Override @Override
protected UnresolvedDelta onEndDelta() throws IOException { protected UnresolvedDelta onEndDelta() throws IOException {
UnresolvedDelta delta = new UnresolvedDelta(); UnresolvedDelta delta = new UnresolvedDelta();
@ -253,30 +261,35 @@ public class ObjectDirectoryPackParser extends PackParser {
return delta; return delta;
} }
/** {@inheritDoc} */
@Override @Override
protected void onInflatedObjectData(PackedObjectInfo obj, int typeCode, protected void onInflatedObjectData(PackedObjectInfo obj, int typeCode,
byte[] data) throws IOException { byte[] data) throws IOException {
// ObjectDirectory ignores this event. // ObjectDirectory ignores this event.
} }
/** {@inheritDoc} */
@Override @Override
protected void onObjectHeader(Source src, byte[] raw, int pos, int len) protected void onObjectHeader(Source src, byte[] raw, int pos, int len)
throws IOException { throws IOException {
crc.update(raw, pos, len); crc.update(raw, pos, len);
} }
/** {@inheritDoc} */
@Override @Override
protected void onObjectData(Source src, byte[] raw, int pos, int len) protected void onObjectData(Source src, byte[] raw, int pos, int len)
throws IOException { throws IOException {
crc.update(raw, pos, len); crc.update(raw, pos, len);
} }
/** {@inheritDoc} */
@Override @Override
protected void onStoreStream(byte[] raw, int pos, int len) protected void onStoreStream(byte[] raw, int pos, int len)
throws IOException { throws IOException {
out.write(raw, pos, len); out.write(raw, pos, len);
} }
/** {@inheritDoc} */
@Override @Override
protected void onPackFooter(byte[] hash) throws IOException { protected void onPackFooter(byte[] hash) throws IOException {
packEnd = out.getFilePointer(); packEnd = out.getFilePointer();
@ -285,6 +298,7 @@ public class ObjectDirectoryPackParser extends PackParser {
packHash = hash; packHash = hash;
} }
/** {@inheritDoc} */
@Override @Override
protected ObjectTypeAndSize seekDatabase(UnresolvedDelta delta, protected ObjectTypeAndSize seekDatabase(UnresolvedDelta delta,
ObjectTypeAndSize info) throws IOException { ObjectTypeAndSize info) throws IOException {
@ -293,6 +307,7 @@ public class ObjectDirectoryPackParser extends PackParser {
return readObjectHeader(info); return readObjectHeader(info);
} }
/** {@inheritDoc} */
@Override @Override
protected ObjectTypeAndSize seekDatabase(PackedObjectInfo obj, protected ObjectTypeAndSize seekDatabase(PackedObjectInfo obj,
ObjectTypeAndSize info) throws IOException { ObjectTypeAndSize info) throws IOException {
@ -301,11 +316,13 @@ public class ObjectDirectoryPackParser extends PackParser {
return readObjectHeader(info); return readObjectHeader(info);
} }
/** {@inheritDoc} */
@Override @Override
protected int readDatabase(byte[] dst, int pos, int cnt) throws IOException { protected int readDatabase(byte[] dst, int pos, int cnt) throws IOException {
return out.read(dst, pos, cnt); return out.read(dst, pos, cnt);
} }
/** {@inheritDoc} */
@Override @Override
protected boolean checkCRC(int oldCRC) { protected boolean checkCRC(int oldCRC) {
return oldCRC == (int) crc.getValue(); return oldCRC == (int) crc.getValue();
@ -323,6 +340,7 @@ public class ObjectDirectoryPackParser extends PackParser {
tmpPack.deleteOnExit(); tmpPack.deleteOnExit();
} }
/** {@inheritDoc} */
@Override @Override
protected boolean onAppendBase(final int typeCode, final byte[] data, protected boolean onAppendBase(final int typeCode, final byte[] data,
final PackedObjectInfo info) throws IOException { final PackedObjectInfo info) throws IOException {
@ -365,6 +383,7 @@ public class ObjectDirectoryPackParser extends PackParser {
return true; return true;
} }
/** {@inheritDoc} */
@Override @Override
protected void onEndThinPack() throws IOException { protected void onEndThinPack() throws IOException {
final byte[] buf = buffer(); final byte[] buf = buffer();

16
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java

@ -58,11 +58,11 @@ import com.googlecode.javaewah.EWAHCompressedBitmap;
/** /**
* Logical representation of the bitmap data stored in the pack index. * 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 org.eclipse.jgit.lib.ObjectId}s are encoded as a single integer in the
* {@link #getObjectCount()}). Compressed bitmaps are available at certain * range [0, {@link #getObjectCount()}). Compressed bitmaps are available at
* {@code ObjectId}s, which represent all of the objects reachable from that * certain {@code ObjectId}s, which represent all of the objects reachable from
* {@code ObjectId} (include the {@code ObjectId} itself). The meaning of the * that {@code ObjectId} (include the {@code ObjectId} itself). The meaning of
* positions in the bitmaps can be decoded using {@link #getObject(int)} and * the positions in the bitmaps can be decoded using {@link #getObject(int)} and
* {@link #ofObjectType(EWAHCompressedBitmap, int)}. Furthermore, * {@link #ofObjectType(EWAHCompressedBitmap, int)}. Furthermore,
* {@link #findPosition(AnyObjectId)} can be used to build other bitmaps that a * {@link #findPosition(AnyObjectId)} can be used to build other bitmaps that a
* compatible with the encoded bitmaps available from the index. * compatible with the encoded bitmaps available from the index.
@ -85,7 +85,7 @@ public abstract class PackBitmapIndex {
* @param reverseIndex * @param reverseIndex
* the pack reverse index for the corresponding pack file. * the pack reverse index for the corresponding pack file.
* @return a copy of the index in-memory. * @return a copy of the index in-memory.
* @throws IOException * @throws java.io.IOException
* the stream cannot be read. * the stream cannot be read.
* @throws CorruptObjectException * @throws CorruptObjectException
* the stream does not contain a valid pack bitmap index. * the stream does not contain a valid pack bitmap index.
@ -128,7 +128,7 @@ public abstract class PackBitmapIndex {
* @param reverseIndex * @param reverseIndex
* the pack reverse index for the corresponding pack file. * the pack reverse index for the corresponding pack file.
* @return a copy of the index in-memory. * @return a copy of the index in-memory.
* @throws IOException * @throws java.io.IOException
* the stream cannot be read. * the stream cannot be read.
* @throws CorruptObjectException * @throws CorruptObjectException
* the stream does not contain a valid pack bitmap index. * the stream does not contain a valid pack bitmap index.
@ -157,7 +157,7 @@ public abstract class PackBitmapIndex {
* @param position * @param position
* the id for which the object will be found. * the id for which the object will be found.
* @return the ObjectId. * @return the ObjectId.
* @throws IllegalArgumentException * @throws java.lang.IllegalArgumentException
* when the item is not found. * when the item is not found.
*/ */
public abstract ObjectId getObject(int position) throws IllegalArgumentException; public abstract ObjectId getObject(int position) throws IllegalArgumentException;

54
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java

@ -64,7 +64,8 @@ import org.eclipse.jgit.util.BlockList;
import com.googlecode.javaewah.EWAHCompressedBitmap; 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 { public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
private static final int MAX_XOR_OFFSET_SEARCH = 10; private static final int MAX_XOR_OFFSET_SEARCH = 10;
@ -145,7 +146,11 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
} }
} }
/** @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() { public ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> getObjectSet() {
ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> r = new ObjectIdOwnerMap<>(); ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> r = new ObjectIdOwnerMap<>();
for (PositionEntry e : byOffset) { for (PositionEntry e : byOffset) {
@ -197,6 +202,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
byAddOrder.add(result); byAddOrder.add(result);
} }
/** {@inheritDoc} */
@Override @Override
public EWAHCompressedBitmap ofObjectType( public EWAHCompressedBitmap ofObjectType(
EWAHCompressedBitmap bitmap, int type) { EWAHCompressedBitmap bitmap, int type) {
@ -213,6 +219,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
/** {@inheritDoc} */
@Override @Override
public int findPosition(AnyObjectId objectId) { public int findPosition(AnyObjectId objectId) {
PositionEntry entry = positionEntries.get(objectId); PositionEntry entry = positionEntries.get(objectId);
@ -221,6 +228,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
return entry.offsetPosition; return entry.offsetPosition;
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId getObject(int position) throws IllegalArgumentException { public ObjectId getObject(int position) throws IllegalArgumentException {
ObjectId objectId = byOffset.get(position); ObjectId objectId = byOffset.get(position);
@ -229,48 +237,76 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
return objectId; return objectId;
} }
/** @return the commit object bitmap. */ /**
* Get the commit object bitmap.
*
* @return the commit object bitmap.
*/
public EWAHCompressedBitmap getCommits() { public EWAHCompressedBitmap getCommits() {
return commits; return commits;
} }
/** @return the tree object bitmap. */ /**
* Get the tree object bitmap.
*
* @return the tree object bitmap.
*/
public EWAHCompressedBitmap getTrees() { public EWAHCompressedBitmap getTrees() {
return trees; return trees;
} }
/** @return the blob object bitmap. */ /**
* Get the blob object bitmap.
*
* @return the blob object bitmap.
*/
public EWAHCompressedBitmap getBlobs() { public EWAHCompressedBitmap getBlobs() {
return blobs; return blobs;
} }
/** @return the tag object bitmap. */ /**
* Get the tag object bitmap.
*
* @return the tag object bitmap.
*/
public EWAHCompressedBitmap getTags() { public EWAHCompressedBitmap getTags() {
return tags; return tags;
} }
/** @return the index storage options. */ /**
* Get the index storage options.
*
* @return the index storage options.
*/
public int getOptions() { public int getOptions() {
return PackBitmapIndexV1.OPT_FULL; return PackBitmapIndexV1.OPT_FULL;
} }
/** {@inheritDoc} */
@Override @Override
public int getBitmapCount() { public int getBitmapCount() {
return getBitmaps().size(); return getBitmaps().size();
} }
/** Removes all the bitmaps entries added. */ /**
* Remove all the bitmaps entries added.
*/
public void clearBitmaps() { public void clearBitmaps() {
byAddOrder.clear(); byAddOrder.clear();
getBitmaps().clear(); getBitmaps().clear();
} }
/** {@inheritDoc} */
@Override @Override
public int getObjectCount() { public int getObjectCount() {
return byOffset.size(); 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() { public Iterable<StoredEntry> getCompressedBitmaps() {
// Add order is from oldest to newest. The reverse add order is the // Add order is from oldest to newest. The reverse add order is the
// output order. // output order.

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java

@ -116,27 +116,32 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
oldPackIndex.getObject(pos)); oldPackIndex.getObject(pos));
} }
/** {@inheritDoc} */
@Override @Override
public int findPosition(AnyObjectId objectId) { public int findPosition(AnyObjectId objectId) {
return newPackIndex.findPosition(objectId); return newPackIndex.findPosition(objectId);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId getObject(int position) throws IllegalArgumentException { public ObjectId getObject(int position) throws IllegalArgumentException {
return newPackIndex.getObject(position); return newPackIndex.getObject(position);
} }
/** {@inheritDoc} */
@Override @Override
public int getObjectCount() { public int getObjectCount() {
return newPackIndex.getObjectCount(); return newPackIndex.getObjectCount();
} }
/** {@inheritDoc} */
@Override @Override
public EWAHCompressedBitmap ofObjectType( public EWAHCompressedBitmap ofObjectType(
EWAHCompressedBitmap bitmap, int type) { EWAHCompressedBitmap bitmap, int type) {
return newPackIndex.ofObjectType(bitmap, type); return newPackIndex.ofObjectType(bitmap, type);
} }
/** {@inheritDoc} */
@Override @Override
public Iterator<Entry> iterator() { public Iterator<Entry> iterator() {
if (oldPackIndex == null) if (oldPackIndex == null)
@ -173,6 +178,7 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
}; };
} }
/** {@inheritDoc} */
@Override @Override
public EWAHCompressedBitmap getBitmap(AnyObjectId objectId) { public EWAHCompressedBitmap getBitmap(AnyObjectId objectId) {
EWAHCompressedBitmap bitmap = newPackIndex.getBitmap(objectId); EWAHCompressedBitmap bitmap = newPackIndex.getBitmap(objectId);
@ -214,6 +220,7 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
} }
} }
/** {@inheritDoc} */
@Override @Override
public int getBitmapCount() { public int getBitmapCount() {
// The count is only useful for the end index, not the remapper. // The count is only useful for the end index, not the remapper.

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexV1.java

@ -175,6 +175,7 @@ class PackBitmapIndexV1 extends BasePackBitmapIndex {
} }
} }
/** {@inheritDoc} */
@Override @Override
public int findPosition(AnyObjectId objectId) { public int findPosition(AnyObjectId objectId) {
long offset = packIndex.findOffset(objectId); long offset = packIndex.findOffset(objectId);
@ -183,6 +184,7 @@ class PackBitmapIndexV1 extends BasePackBitmapIndex {
return reverseIndex.findPostion(offset); return reverseIndex.findPostion(offset);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId getObject(int position) throws IllegalArgumentException { public ObjectId getObject(int position) throws IllegalArgumentException {
ObjectId objectId = reverseIndex.findObjectByPosition(position); ObjectId objectId = reverseIndex.findObjectByPosition(position);
@ -191,11 +193,13 @@ class PackBitmapIndexV1 extends BasePackBitmapIndex {
return objectId; return objectId;
} }
/** {@inheritDoc} */
@Override @Override
public int getObjectCount() { public int getObjectCount() {
return (int) packIndex.getObjectCount(); return (int) packIndex.getObjectCount();
} }
/** {@inheritDoc} */
@Override @Override
public EWAHCompressedBitmap ofObjectType( public EWAHCompressedBitmap ofObjectType(
EWAHCompressedBitmap bitmap, int type) { EWAHCompressedBitmap bitmap, int type) {
@ -212,11 +216,13 @@ class PackBitmapIndexV1 extends BasePackBitmapIndex {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
/** {@inheritDoc} */
@Override @Override
public int getBitmapCount() { public int getBitmapCount() {
return bitmaps.size(); return bitmaps.size();
} }
/** {@inheritDoc} */
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
// TODO(cranger): compare the pack checksum? // TODO(cranger): compare the pack checksum?
@ -225,6 +231,7 @@ class PackBitmapIndexV1 extends BasePackBitmapIndex {
return false; return false;
} }
/** {@inheritDoc} */
@Override @Override
public int hashCode() { public int hashCode() {
return getPackIndex().hashCode(); return getPackIndex().hashCode();

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java

@ -89,7 +89,7 @@ public class PackBitmapIndexWriterV1 {
* @param packDataChecksum * @param packDataChecksum
* checksum signature of the entire pack data content. This is * checksum signature of the entire pack data content. This is
* traditionally the last 20 bytes of the pack file's own stream. * 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 * an error occurred while writing to the output stream, or this
* index format cannot store the object data supplied. * index format cannot store the object data supplied.
*/ */

22
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

@ -201,20 +201,30 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
return loadedIdx; 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() { public File getPackFile() {
return packFile; return packFile;
} }
/** /**
* Get the index for this pack file.
*
* @return the index for this pack file. * @return the index for this pack file.
* @throws IOException * @throws java.io.IOException
*/ */
public PackIndex getIndex() throws IOException { public PackIndex getIndex() throws IOException {
return idx(); 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() { public String getPackName() {
String name = packName; String name = packName;
if (name == null) { if (name == null) {
@ -238,7 +248,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
* @param id * @param id
* the object to look for. Must not be null. * the object to look for. Must not be null.
* @return true if the object is in this pack; false otherwise. * @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. * the index file cannot be loaded into memory.
*/ */
public boolean hasObject(final AnyObjectId id) throws IOException { public boolean hasObject(final AnyObjectId id) throws IOException {
@ -292,6 +302,8 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
} }
/** /**
* {@inheritDoc}
* <p>
* Provide iterator over entries in associated pack index, that should also * Provide iterator over entries in associated pack index, that should also
* exist in this pack file. Objects returned by such iterator are mutable * exist in this pack file. Objects returned by such iterator are mutable
* during iteration. * during iteration.
@ -299,8 +311,6 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
* Iterator returns objects in SHA-1 lexicographical order. * Iterator returns objects in SHA-1 lexicographical order.
* </p> * </p>
* *
* @return iterator over entries of associated pack index
*
* @see PackIndex#iterator() * @see PackIndex#iterator()
*/ */
@Override @Override

29
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java

@ -66,7 +66,8 @@ import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.NB; 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> * <p>
* Indexes are strictly redundant information in that we can rebuild all of the * 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 * 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. * @return access implementation for the requested file.
* @throws FileNotFoundException * @throws FileNotFoundException
* the file does not exist. * the file does not exist.
* @throws IOException * @throws java.io.IOException
* the file exists but could not be read due to security errors, * the file exists but could not be read due to security errors,
* unrecognized data version, or unexpected data corruption. * unrecognized data version, or unexpected data corruption.
*/ */
@ -124,9 +125,9 @@ public abstract class PackIndex
* buffered as some small IOs are performed against the stream. * buffered as some small IOs are performed against the stream.
* The caller is responsible for closing the stream. * The caller is responsible for closing the stream.
* @return a copy of the index in-memory. * @return a copy of the index in-memory.
* @throws IOException * @throws java.io.IOException
* the stream cannot be read. * the stream cannot be read.
* @throws CorruptObjectException * @throws org.eclipse.jgit.errors.CorruptObjectException
* the stream does not contain a valid pack index. * the stream does not contain a valid pack index.
*/ */
public static PackIndex read(InputStream fd) throws IOException, public static PackIndex read(InputStream fd) throws IOException,
@ -167,12 +168,15 @@ public abstract class PackIndex
return findOffset(id) != -1; return findOffset(id) != -1;
} }
/** {@inheritDoc} */
@Override @Override
public boolean contains(AnyObjectId id) { public boolean contains(AnyObjectId id) {
return findOffset(id) != -1; return findOffset(id) != -1;
} }
/** /**
* {@inheritDoc}
* <p>
* Provide iterator that gives access to index entries. Note, that iterator * Provide iterator that gives access to index entries. Note, that iterator
* returns reference to mutable object, the same reference in each call - * returns reference to mutable object, the same reference in each call -
* for performance reason. If client needs immutable objects, it must copy * for performance reason. If client needs immutable objects, it must copy
@ -180,8 +184,6 @@ public abstract class PackIndex
* <p> * <p>
* Iterator returns objects in SHA-1 lexicographical order. * Iterator returns objects in SHA-1 lexicographical order.
* </p> * </p>
*
* @return iterator over pack index entries
*/ */
@Override @Override
public abstract Iterator<MutableEntry> iterator(); public abstract Iterator<MutableEntry> iterator();
@ -218,7 +220,8 @@ public abstract class PackIndex
* @param nthPosition * @param nthPosition
* position within the traversal of {@link #iterator()} that the * position within the traversal of {@link #iterator()} that the
* caller needs the object for. The first returned * 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. * @return the ObjectId for the corresponding entry.
*/ */
public abstract ObjectId getObjectId(long nthPosition); public abstract ObjectId getObjectId(long nthPosition);
@ -239,8 +242,10 @@ public abstract class PackIndex
* @param nthPosition * @param nthPosition
* unsigned 32 bit position within the traversal of * unsigned 32 bit position within the traversal of
* {@link #iterator()} that the caller needs the object for. The * {@link #iterator()} that the caller needs the object for. The
* first returned {@link MutableEntry} is 0, the second is 1, * first returned
* etc. Positions past 2**31-1 are negative, but still valid. * {@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. * @return the ObjectId for the corresponding entry.
*/ */
public final ObjectId getObjectId(final int nthPosition) { public final ObjectId getObjectId(final int nthPosition) {
@ -282,9 +287,9 @@ public abstract class PackIndex
* @param objId * @param objId
* id of object to look for * id of object to look for
* @return CRC32 checksum of specified object (at 32 less significant bits) * @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 * when requested ObjectId was not found in this index
* @throws UnsupportedOperationException * @throws java.lang.UnsupportedOperationException
* when this index doesn't support CRC32 checksum * when this index doesn't support CRC32 checksum
*/ */
public abstract long findCRC32(AnyObjectId objId) public abstract long findCRC32(AnyObjectId objId)
@ -308,7 +313,7 @@ public abstract class PackIndex
* @param matchLimit * @param matchLimit
* maximum number of results to return. At most this many * maximum number of results to return. At most this many
* ObjectIds should be added to matches before returning. * ObjectIds should be added to matches before returning.
* @throws IOException * @throws java.io.IOException
* the index cannot be read. * the index cannot be read.
*/ */
public abstract void resolve(Set<ObjectId> matches, AbbreviatedObjectId id, public abstract void resolve(Set<ObjectId> matches, AbbreviatedObjectId id,

8
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV1.java

@ -103,11 +103,13 @@ class PackIndexV1 extends PackIndex {
IO.readFully(fd, packChecksum, 0, packChecksum.length); IO.readFully(fd, packChecksum, 0, packChecksum.length);
} }
/** {@inheritDoc} */
@Override @Override
public long getObjectCount() { public long getObjectCount() {
return objectCnt; return objectCnt;
} }
/** {@inheritDoc} */
@Override @Override
public long getOffset64Count() { public long getOffset64Count() {
long n64 = 0; long n64 = 0;
@ -140,6 +142,7 @@ class PackIndexV1 extends PackIndex {
return (int) (nthPosition - base); return (int) (nthPosition - base);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId getObjectId(final long nthPosition) { public ObjectId getObjectId(final long nthPosition) {
final int levelOne = findLevelOne(nthPosition); final int levelOne = findLevelOne(nthPosition);
@ -156,6 +159,7 @@ class PackIndexV1 extends PackIndex {
return NB.decodeUInt32(idxdata[levelOne], p); return NB.decodeUInt32(idxdata[levelOne], p);
} }
/** {@inheritDoc} */
@Override @Override
public long findOffset(final AnyObjectId objId) { public long findOffset(final AnyObjectId objId) {
final int levelOne = objId.getFirstByte(); final int levelOne = objId.getFirstByte();
@ -182,21 +186,25 @@ class PackIndexV1 extends PackIndex {
return -1; return -1;
} }
/** {@inheritDoc} */
@Override @Override
public long findCRC32(AnyObjectId objId) { public long findCRC32(AnyObjectId objId) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public boolean hasCRC32Support() { public boolean hasCRC32Support() {
return false; return false;
} }
/** {@inheritDoc} */
@Override @Override
public Iterator<MutableEntry> iterator() { public Iterator<MutableEntry> iterator() {
return new IndexV1Iterator(); return new IndexV1Iterator();
} }
/** {@inheritDoc} */
@Override @Override
public void resolve(Set<ObjectId> matches, AbbreviatedObjectId id, public void resolve(Set<ObjectId> matches, AbbreviatedObjectId id,
int matchLimit) throws IOException { int matchLimit) throws IOException {

9
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java

@ -164,11 +164,13 @@ class PackIndexV2 extends PackIndex {
IO.readFully(fd, packChecksum, 0, packChecksum.length); IO.readFully(fd, packChecksum, 0, packChecksum.length);
} }
/** {@inheritDoc} */
@Override @Override
public long getObjectCount() { public long getObjectCount() {
return objectCnt; return objectCnt;
} }
/** {@inheritDoc} */
@Override @Override
public long getOffset64Count() { public long getOffset64Count() {
return offset64.length / 8; return offset64.length / 8;
@ -196,6 +198,7 @@ class PackIndexV2 extends PackIndex {
return (int) (nthPosition - base); return (int) (nthPosition - base);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId getObjectId(final long nthPosition) { public ObjectId getObjectId(final long nthPosition) {
final int levelOne = findLevelOne(nthPosition); final int levelOne = findLevelOne(nthPosition);
@ -204,6 +207,7 @@ class PackIndexV2 extends PackIndex {
return ObjectId.fromRaw(names[levelOne], p4 + p); // p * 5 return ObjectId.fromRaw(names[levelOne], p4 + p); // p * 5
} }
/** {@inheritDoc} */
@Override @Override
public long getOffset(final long nthPosition) { public long getOffset(final long nthPosition) {
final int levelOne = findLevelOne(nthPosition); final int levelOne = findLevelOne(nthPosition);
@ -211,6 +215,7 @@ class PackIndexV2 extends PackIndex {
return getOffset(levelOne, levelTwo); return getOffset(levelOne, levelTwo);
} }
/** {@inheritDoc} */
@Override @Override
public long findOffset(final AnyObjectId objId) { public long findOffset(final AnyObjectId objId) {
final int levelOne = objId.getFirstByte(); final int levelOne = objId.getFirstByte();
@ -227,6 +232,7 @@ class PackIndexV2 extends PackIndex {
return p; return p;
} }
/** {@inheritDoc} */
@Override @Override
public long findCRC32(AnyObjectId objId) throws MissingObjectException { public long findCRC32(AnyObjectId objId) throws MissingObjectException {
final int levelOne = objId.getFirstByte(); final int levelOne = objId.getFirstByte();
@ -236,16 +242,19 @@ class PackIndexV2 extends PackIndex {
return NB.decodeUInt32(crc32[levelOne], levelTwo << 2); return NB.decodeUInt32(crc32[levelOne], levelTwo << 2);
} }
/** {@inheritDoc} */
@Override @Override
public boolean hasCRC32Support() { public boolean hasCRC32Support() {
return true; return true;
} }
/** {@inheritDoc} */
@Override @Override
public Iterator<MutableEntry> iterator() { public Iterator<MutableEntry> iterator() {
return new EntriesIteratorV2(); return new EntriesIteratorV2();
} }
/** {@inheritDoc} */
@Override @Override
public void resolve(Set<ObjectId> matches, AbbreviatedObjectId id, public void resolve(Set<ObjectId> matches, AbbreviatedObjectId id,
int matchLimit) throws IOException { int matchLimit) throws IOException {

35
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexWriter.java

@ -53,16 +53,16 @@ import java.util.List;
import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.transport.PackedObjectInfo; import org.eclipse.jgit.transport.PackedObjectInfo;
import org.eclipse.jgit.util.NB; 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> * <p>
* Pack index files (the <code>.idx</code> suffix in a pack file pair) * Pack index files (the <code>.idx</code> suffix in a pack file pair) provides
* provides random access to any object in the pack by associating an ObjectId * random access to any object in the pack by associating an ObjectId to the
* to the byte offset within the pack where the object's data can be read. * byte offset within the pack where the object's data can be read.
*/ */
public abstract class PackIndexWriter { public abstract class PackIndexWriter {
/** Magic constant indicating post-version 1 format. */ /** 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. * will be examined until a format can be conclusively selected.
* @return a new writer to output an index file of the requested format to * @return a new writer to output an index file of the requested format to
* the supplied stream. * the supplied stream.
* @throws IllegalArgumentException * @throws java.lang.IllegalArgumentException
* no recognized pack index version can support the supplied * no recognized pack index version can support the supplied
* objects. This is likely a bug in the implementation. * objects. This is likely a bug in the implementation.
* @see #oldestPossibleFormat(List) * @see #oldestPossibleFormat(List)
@ -117,7 +117,7 @@ public abstract class PackIndexWriter {
* the objects the caller needs to store in the index. Entries * the objects the caller needs to store in the index. Entries
* will be examined until a format can be conclusively selected. * will be examined until a format can be conclusively selected.
* @return the index format. * @return the index format.
* @throws IllegalArgumentException * @throws java.lang.IllegalArgumentException
* no recognized pack index version can support the supplied * no recognized pack index version can support the supplied
* objects. This is likely a bug in the implementation. * objects. This is likely a bug in the implementation.
*/ */
@ -143,7 +143,7 @@ public abstract class PackIndexWriter {
* this formatted version will be written. * this formatted version will be written.
* @return a new writer to output an index file of the requested format to * @return a new writer to output an index file of the requested format to
* the supplied stream. * the supplied stream.
* @throws IllegalArgumentException * @throws java.lang.IllegalArgumentException
* the version requested is not supported by this * the version requested is not supported by this
* implementation. * implementation.
*/ */
@ -195,12 +195,13 @@ public abstract class PackIndexWriter {
* *
* @param toStore * @param toStore
* sorted list of objects to store in the index. The caller must * sorted list of objects to store in the index. The caller must
* have previously sorted the list using {@link PackedObjectInfo}'s * have previously sorted the list using
* native {@link Comparable} implementation. * {@link org.eclipse.jgit.transport.PackedObjectInfo}'s native
* {@link java.lang.Comparable} implementation.
* @param packDataChecksum * @param packDataChecksum
* checksum signature of the entire pack data content. This is * checksum signature of the entire pack data content. This is
* traditionally the last 20 bytes of the pack file's own stream. * 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 * an error occurred while writing to the output stream, or this
* index format cannot store the object data supplied. * index format cannot store the object data supplied.
*/ */
@ -230,7 +231,7 @@ public abstract class PackIndexWriter {
* the {@link #entries} collection may be iterated over more than once if * the {@link #entries} collection may be iterated over more than once if
* necessary. Implementors therefore have complete control over the data. * 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 * an error occurred while writing to the output stream, or this
* index format cannot store the object data supplied. * index format cannot store the object data supplied.
*/ */
@ -246,7 +247,7 @@ public abstract class PackIndexWriter {
* *
* @param version * @param version
* version number of this index format being written. * version number of this index format being written.
* @throws IOException * @throws java.io.IOException
* an error occurred while writing to the output stream. * an error occurred while writing to the output stream.
*/ */
protected void writeTOC(final int version) throws IOException { protected void writeTOC(final int version) throws IOException {
@ -260,10 +261,10 @@ public abstract class PackIndexWriter {
* <p> * <p>
* The fan-out table is 4 KB in size, holding 256 32-bit unsigned integer * 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 * counts. Each count represents the number of objects within this index
* whose {@link ObjectId#getFirstByte()} matches the count's position in the * whose {@link org.eclipse.jgit.lib.ObjectId#getFirstByte()} matches the
* fan-out table. * count's position in the fan-out table.
* *
* @throws IOException * @throws java.io.IOException
* an error occurred while writing to the output stream. * an error occurred while writing to the output stream.
*/ */
protected void writeFanOutTable() throws IOException { protected void writeFanOutTable() throws IOException {
@ -288,7 +289,7 @@ public abstract class PackIndexWriter {
* the pack data checksum above.</li> * the pack data checksum above.</li>
* </ol> * </ol>
* *
* @throws IOException * @throws java.io.IOException
* an error occurred while writing to the output stream. * an error occurred while writing to the output stream.
*/ */
protected void writeChecksumFooter() throws IOException { protected void writeChecksumFooter() throws IOException {

1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexWriterV1.java

@ -68,6 +68,7 @@ class PackIndexWriterV1 extends PackIndexWriter {
super(dst); super(dst);
} }
/** {@inheritDoc} */
@Override @Override
protected void writeImpl() throws IOException { protected void writeImpl() throws IOException {
writeFanOutTable(); writeFanOutTable();

1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexWriterV2.java

@ -63,6 +63,7 @@ class PackIndexWriterV2 extends PackIndexWriter {
super(dst); super(dst);
} }
/** {@inheritDoc} */
@Override @Override
protected void writeImpl() throws IOException { protected void writeImpl() throws IOException {
writeTOC(2); writeTOC(2);

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java

@ -64,6 +64,7 @@ class PackInputStream extends InputStream {
wc.pin(pack, pos); wc.pin(pack, pos);
} }
/** {@inheritDoc} */
@Override @Override
public int read(byte[] b, int off, int len) throws IOException { public int read(byte[] b, int off, int len) throws IOException {
int n = wc.copy(pack, pos, b, off, len); int n = wc.copy(pack, pos, b, off, len);
@ -71,6 +72,7 @@ class PackInputStream extends InputStream {
return n; return n;
} }
/** {@inheritDoc} */
@Override @Override
public int read() throws IOException { public int read() throws IOException {
byte[] buf = new byte[1]; byte[] buf = new byte[1];
@ -78,6 +80,7 @@ class PackInputStream extends InputStream {
return n == 1 ? buf[0] & 0xff : -1; return n == 1 ? buf[0] & 0xff : -1;
} }
/** {@inheritDoc} */
@Override @Override
public void close() { public void close() {
wc.close(); wc.close();

15
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java

@ -119,15 +119,20 @@ class PackInserter extends ObjectInserter {
} }
/** /**
* Whether to check if objects exist in the repo
*
* @param check * @param check
* if false, will write out possibly-duplicate objects without * if {@code false}, will write out possibly-duplicate objects
* first checking whether they exist in the repo; default is true. * without first checking whether they exist in the repo; default
* is true.
*/ */
public void checkExisting(boolean check) { public void checkExisting(boolean check) {
checkExisting = check; checkExisting = check;
} }
/** /**
* Set compression level for zlib deflater.
*
* @param compression * @param compression
* compression level for zlib deflater. * compression level for zlib deflater.
*/ */
@ -139,6 +144,7 @@ class PackInserter extends ObjectInserter {
return buffer().length; return buffer().length;
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId insert(int type, byte[] data, int off, int len) public ObjectId insert(int type, byte[] data, int off, int len)
throws IOException { throws IOException {
@ -157,6 +163,7 @@ class PackInserter extends ObjectInserter {
return endObject(id, offset); return endObject(id, offset);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectId insert(int type, long len, InputStream in) public ObjectId insert(int type, long len, InputStream in)
throws IOException { throws IOException {
@ -230,16 +237,19 @@ class PackInserter extends ObjectInserter {
return 12; return 12;
} }
/** {@inheritDoc} */
@Override @Override
public PackParser newPackParser(InputStream in) { public PackParser newPackParser(InputStream in) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public ObjectReader newReader() { public ObjectReader newReader() {
return new Reader(); return new Reader();
} }
/** {@inheritDoc} */
@Override @Override
public void flush() throws IOException { public void flush() throws IOException {
if (tmpPack == null) { if (tmpPack == null) {
@ -309,6 +319,7 @@ class PackInserter extends ObjectInserter {
return ObjectId.fromRaw(md.digest()); return ObjectId.fromRaw(md.digest());
} }
/** {@inheritDoc} */
@Override @Override
public void close() { public void close() {
try { try {

9
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackLock.java

@ -50,7 +50,10 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils; 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 { public class PackLock {
private final File keepFile; private final File keepFile;
@ -74,7 +77,7 @@ public class PackLock {
* @param msg * @param msg
* message to store in the file. * message to store in the file.
* @return true if the keep file was successfully written; false otherwise. * @return true if the keep file was successfully written; false otherwise.
* @throws IOException * @throws java.io.IOException
* the keep file could not be written. * the keep file could not be written.
*/ */
public boolean lock(String msg) throws IOException { public boolean lock(String msg) throws IOException {
@ -92,7 +95,7 @@ public class PackLock {
/** /**
* Remove the <code>.keep</code> file that holds this pack in place. * Remove the <code>.keep</code> file that holds this pack in place.
* *
* @throws IOException * @throws java.io.IOException
* if deletion of .keep file failed * if deletion of .keep file failed
*/ */
public void unlock() throws IOException { public void unlock() throws IOException {

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackReverseIndex.java

@ -174,7 +174,7 @@ public class PackReverseIndex {
* offset). * offset).
* @return offset of the next object in a pack or maxOffset if provided * @return offset of the next object in a pack or maxOffset if provided
* offset was the last one. * offset was the last one.
* @throws CorruptObjectException * @throws org.eclipse.jgit.errors.CorruptObjectException
* when there is no object with the provided offset. * when there is no object with the provided offset.
*/ */
public long findNextOffset(final long offset, final long maxOffset) public long findNextOffset(final long offset, final long maxOffset)

1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java

@ -125,6 +125,7 @@ class PackedBatchRefUpdate extends BatchRefUpdate {
this.refdb = refdb; this.refdb = refdb;
} }
/** {@inheritDoc} */
@Override @Override
public void execute(RevWalk walk, ProgressMonitor monitor, public void execute(RevWalk walk, ProgressMonitor monitor,
List<String> options) throws IOException { List<String> options) throws IOException {

19
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

@ -111,14 +111,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Traditional file system based {@link RefDatabase}. * Traditional file system based {@link org.eclipse.jgit.lib.RefDatabase}.
* <p> * <p>
* This is the classical reference database representation for a Git repository. * This is the classical reference database representation for a Git repository.
* References are stored in two formats: loose, and packed. * References are stored in two formats: loose, and packed.
* <p> * <p>
* Loose references are stored as individual files within the {@code refs/} * Loose references are stored as individual files within the {@code refs/}
* directory. The file name matches the reference name and the file contents is * 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> * <p>
* Packed references are stored in a single text file named {@code packed-refs}. * 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 * In the packed format, each reference is stored on its own line. This file
@ -243,6 +243,7 @@ public class RefDirectory extends RefDatabase {
return new File(logsDir, name); return new File(logsDir, name);
} }
/** {@inheritDoc} */
@Override @Override
public void create() throws IOException { public void create() throws IOException {
FileUtils.mkdir(refsDir); FileUtils.mkdir(refsDir);
@ -251,6 +252,7 @@ public class RefDirectory extends RefDatabase {
newLogWriter(false).create(); newLogWriter(false).create();
} }
/** {@inheritDoc} */
@Override @Override
public void close() { public void close() {
clearReferences(); clearReferences();
@ -261,12 +263,14 @@ public class RefDirectory extends RefDatabase {
packedRefs.set(NO_PACKED_REFS); packedRefs.set(NO_PACKED_REFS);
} }
/** {@inheritDoc} */
@Override @Override
public void refresh() { public void refresh() {
super.refresh(); super.refresh();
clearReferences(); clearReferences();
} }
/** {@inheritDoc} */
@Override @Override
public boolean isNameConflicting(String name) throws IOException { public boolean isNameConflicting(String name) throws IOException {
RefList<Ref> packed = getPackedRefs(); RefList<Ref> packed = getPackedRefs();
@ -312,6 +316,7 @@ public class RefDirectory extends RefDatabase {
return loose; return loose;
} }
/** {@inheritDoc} */
@Override @Override
public Ref exactRef(String name) throws IOException { public Ref exactRef(String name) throws IOException {
RefList<Ref> packed = getPackedRefs(); RefList<Ref> packed = getPackedRefs();
@ -336,6 +341,7 @@ public class RefDirectory extends RefDatabase {
return ref; return ref;
} }
/** {@inheritDoc} */
@Override @Override
public Ref getRef(final String needle) throws IOException { public Ref getRef(final String needle) throws IOException {
final RefList<Ref> packed = getPackedRefs(); final RefList<Ref> packed = getPackedRefs();
@ -360,6 +366,7 @@ public class RefDirectory extends RefDatabase {
return ref; return ref;
} }
/** {@inheritDoc} */
@Override @Override
public Map<String, Ref> getRefs(String prefix) throws IOException { public Map<String, Ref> getRefs(String prefix) throws IOException {
final RefList<LooseRef> oldLoose = looseRefs.get(); final RefList<LooseRef> oldLoose = looseRefs.get();
@ -399,6 +406,7 @@ public class RefDirectory extends RefDatabase {
return new RefMap(prefix, packed, upcast(loose), symbolic.toRefList()); return new RefMap(prefix, packed, upcast(loose), symbolic.toRefList());
} }
/** {@inheritDoc} */
@Override @Override
public List<Ref> getAdditionalRefs() throws IOException { public List<Ref> getAdditionalRefs() throws IOException {
List<Ref> ret = new LinkedList<>(); List<Ref> ret = new LinkedList<>();
@ -533,6 +541,7 @@ public class RefDirectory extends RefDatabase {
} }
} }
/** {@inheritDoc} */
@Override @Override
public Ref peel(final Ref ref) throws IOException { public Ref peel(final Ref ref) throws IOException {
final Ref leaf = ref.getLeaf(); final Ref leaf = ref.getLeaf();
@ -584,6 +593,7 @@ public class RefDirectory extends RefDatabase {
fireRefsChanged(); fireRefsChanged();
} }
/** {@inheritDoc} */
@Override @Override
public RefDirectoryUpdate newUpdate(String name, boolean detach) public RefDirectoryUpdate newUpdate(String name, boolean detach)
throws IOException { throws IOException {
@ -603,6 +613,7 @@ public class RefDirectory extends RefDatabase {
return refDirUpdate; return refDirUpdate;
} }
/** {@inheritDoc} */
@Override @Override
public RefDirectoryRename newRename(String fromName, String toName) public RefDirectoryRename newRename(String fromName, String toName)
throws IOException { throws IOException {
@ -611,11 +622,13 @@ public class RefDirectory extends RefDatabase {
return new RefDirectoryRename(from, to); return new RefDirectoryRename(from, to);
} }
/** {@inheritDoc} */
@Override @Override
public PackedBatchRefUpdate newBatchUpdate() { public PackedBatchRefUpdate newBatchUpdate() {
return new PackedBatchRefUpdate(this); return new PackedBatchRefUpdate(this);
} }
/** {@inheritDoc} */
@Override @Override
public boolean performsAtomicTransactions() { public boolean performsAtomicTransactions() {
return true; return true;
@ -695,7 +708,7 @@ public class RefDirectory extends RefDatabase {
* *
* @param refs * @param refs
* the refs to be added. Must be fully qualified. * the refs to be added. Must be fully qualified.
* @throws IOException * @throws java.io.IOException
*/ */
public void pack(List<String> refs) throws IOException { public void pack(List<String> refs) throws IOException {
pack(refs, Collections.emptyMap()); pack(refs, Collections.emptyMap());

1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryRename.java

@ -95,6 +95,7 @@ class RefDirectoryRename extends RefRename {
refdb = src.getRefDatabase(); refdb = src.getRefDatabase();
} }
/** {@inheritDoc} */
@Override @Override
protected Result doRename() throws IOException { protected Result doRename() throws IOException {
if (source.getRef().isSymbolic()) if (source.getRef().isSymbolic())

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java

@ -65,16 +65,19 @@ class RefDirectoryUpdate extends RefUpdate {
database = r; database = r;
} }
/** {@inheritDoc} */
@Override @Override
protected RefDirectory getRefDatabase() { protected RefDirectory getRefDatabase() {
return database; return database;
} }
/** {@inheritDoc} */
@Override @Override
protected Repository getRepository() { protected Repository getRepository() {
return database.getRepository(); return database.getRepository();
} }
/** {@inheritDoc} */
@Override @Override
protected boolean tryLock(boolean deref) throws IOException { protected boolean tryLock(boolean deref) throws IOException {
shouldDeref = deref; shouldDeref = deref;
@ -92,6 +95,7 @@ class RefDirectoryUpdate extends RefUpdate {
} }
} }
/** {@inheritDoc} */
@Override @Override
protected void unlock() { protected void unlock() {
if (lock != null) { if (lock != null) {
@ -100,6 +104,7 @@ class RefDirectoryUpdate extends RefUpdate {
} }
} }
/** {@inheritDoc} */
@Override @Override
protected Result doUpdate(final Result status) throws IOException { protected Result doUpdate(final Result status) throws IOException {
WriteConfig wc = database.getRepository().getConfig() WriteConfig wc = database.getRepository().getConfig()
@ -141,6 +146,7 @@ class RefDirectoryUpdate extends RefUpdate {
} }
} }
/** {@inheritDoc} */
@Override @Override
protected Result doDelete(final Result status) throws IOException { protected Result doDelete(final Result status) throws IOException {
if (getRef().getStorage() != Ref.Storage.NEW) if (getRef().getStorage() != Ref.Storage.NEW)
@ -148,6 +154,7 @@ class RefDirectoryUpdate extends RefUpdate {
return status; return status;
} }
/** {@inheritDoc} */
@Override @Override
protected Result doLink(final String target) throws IOException { protected Result doLink(final String target) throws IOException {
WriteConfig wc = database.getRepository().getConfig() WriteConfig wc = database.getRepository().getConfig()

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java

@ -93,6 +93,7 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getOldId() * @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getOldId()
*/ */
/** {@inheritDoc} */
@Override @Override
public ObjectId getOldId() { public ObjectId getOldId() {
return oldId; return oldId;
@ -101,6 +102,7 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getNewId() * @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getNewId()
*/ */
/** {@inheritDoc} */
@Override @Override
public ObjectId getNewId() { public ObjectId getNewId() {
return newId; return newId;
@ -109,6 +111,7 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getWho() * @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getWho()
*/ */
/** {@inheritDoc} */
@Override @Override
public PersonIdent getWho() { public PersonIdent getWho() {
return who; return who;
@ -117,11 +120,13 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getComment() * @see org.eclipse.jgit.internal.storage.file.ReflogEntry#getComment()
*/ */
/** {@inheritDoc} */
@Override @Override
public String getComment() { public String getComment() {
return comment; return comment;
} }
/** {@inheritDoc} */
@SuppressWarnings("nls") @SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
@ -132,6 +137,7 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogEntry#parseCheckout() * @see org.eclipse.jgit.internal.storage.file.ReflogEntry#parseCheckout()
*/ */
/** {@inheritDoc} */
@Override @Override
public CheckoutEntry parseCheckout() { public CheckoutEntry parseCheckout() {
if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM)) if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM))

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogReaderImpl.java

@ -74,6 +74,7 @@ class ReflogReaderImpl implements ReflogReader {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getLastEntry() * @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getLastEntry()
*/ */
/** {@inheritDoc} */
@Override @Override
public ReflogEntry getLastEntry() throws IOException { public ReflogEntry getLastEntry() throws IOException {
return getReverseEntry(0); return getReverseEntry(0);
@ -82,6 +83,7 @@ class ReflogReaderImpl implements ReflogReader {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntries() * @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntries()
*/ */
/** {@inheritDoc} */
@Override @Override
public List<ReflogEntry> getReverseEntries() throws IOException { public List<ReflogEntry> getReverseEntries() throws IOException {
return getReverseEntries(Integer.MAX_VALUE); return getReverseEntries(Integer.MAX_VALUE);
@ -90,6 +92,7 @@ class ReflogReaderImpl implements ReflogReader {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntry(int) * @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntry(int)
*/ */
/** {@inheritDoc} */
@Override @Override
public ReflogEntry getReverseEntry(int number) throws IOException { public ReflogEntry getReverseEntry(int number) throws IOException {
if (number < 0) if (number < 0)
@ -119,6 +122,7 @@ class ReflogReaderImpl implements ReflogReader {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntries(int) * @see org.eclipse.jgit.internal.storage.file.ReflogReaader#getReverseEntries(int)
*/ */
/** {@inheritDoc} */
@Override @Override
public List<ReflogEntry> getReverseEntries(int max) throws IOException { public List<ReflogEntry> getReverseEntries(int max) throws IOException {
final byte[] log; final byte[] log;

22
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogWriter.java

@ -95,6 +95,8 @@ public class ReflogWriter {
* Create writer for ref directory. * Create writer for ref directory.
* *
* @param refdb * @param refdb
* a {@link org.eclipse.jgit.internal.storage.file.RefDirectory}
* object.
*/ */
public ReflogWriter(RefDirectory refdb) { public ReflogWriter(RefDirectory refdb) {
this(refdb, false); this(refdb, false);
@ -104,6 +106,8 @@ public class ReflogWriter {
* Create writer for ref directory. * Create writer for ref directory.
* *
* @param refdb * @param refdb
* a {@link org.eclipse.jgit.internal.storage.file.RefDirectory}
* object.
* @param forceWrite * @param forceWrite
* true to write to disk all entries logged, false to respect the * true to write to disk all entries logged, false to respect the
* repository's config and current log file status. * repository's config and current log file status.
@ -116,7 +120,7 @@ public class ReflogWriter {
/** /**
* Create the log directories. * Create the log directories.
* *
* @throws IOException * @throws java.io.IOException
* @return this writer. * @return this writer.
*/ */
public ReflogWriter create() throws IOException { public ReflogWriter create() throws IOException {
@ -131,9 +135,11 @@ public class ReflogWriter {
* Write the given entry to the ref's log. * Write the given entry to the ref's log.
* *
* @param refName * @param refName
* a {@link java.lang.String} object.
* @param entry * @param entry
* a {@link org.eclipse.jgit.lib.ReflogEntry} object.
* @return this writer * @return this writer
* @throws IOException * @throws java.io.IOException
*/ */
public ReflogWriter log(String refName, ReflogEntry entry) public ReflogWriter log(String refName, ReflogEntry entry)
throws IOException { throws IOException {
@ -145,12 +151,17 @@ public class ReflogWriter {
* Write the given entry information to the ref's log * Write the given entry information to the ref's log
* *
* @param refName * @param refName
* ref name
* @param oldId * @param oldId
* old object id
* @param newId * @param newId
* new object id
* @param ident * @param ident
* a {@link org.eclipse.jgit.lib.PersonIdent}
* @param message * @param message
* reflog message
* @return this writer * @return this writer
* @throws IOException * @throws java.io.IOException
*/ */
public ReflogWriter log(String refName, ObjectId oldId, public ReflogWriter log(String refName, ObjectId oldId,
ObjectId newId, PersonIdent ident, String message) throws IOException { ObjectId newId, PersonIdent ident, String message) throws IOException {
@ -162,10 +173,13 @@ public class ReflogWriter {
* Write the given ref update to the ref's log. * Write the given ref update to the ref's log.
* *
* @param update * @param update
* a {@link org.eclipse.jgit.lib.RefUpdate}
* @param msg * @param msg
* reflog message
* @param deref * @param deref
* whether to dereference symbolic refs
* @return this writer * @return this writer
* @throws IOException * @throws java.io.IOException
*/ */
public ReflogWriter log(RefUpdate update, String msg, public ReflogWriter log(RefUpdate update, String msg,
boolean deref) throws IOException { boolean deref) throws IOException {

22
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/SimpleDataInput.java

@ -64,83 +64,105 @@ class SimpleDataInput implements DataInput {
this.fd = fd; this.fd = fd;
} }
/** {@inheritDoc} */
@Override @Override
public int readInt() throws IOException { public int readInt() throws IOException {
readFully(buf, 0, 4); readFully(buf, 0, 4);
return NB.decodeInt32(buf, 0); return NB.decodeInt32(buf, 0);
} }
/** {@inheritDoc} */
@Override @Override
public long readLong() throws IOException { public long readLong() throws IOException {
readFully(buf, 0, 8); readFully(buf, 0, 8);
return NB.decodeInt64(buf, 0); return NB.decodeInt64(buf, 0);
} }
/**
* Read unsigned int
*
* @return a long.
* @throws java.io.IOException
* if any.
*/
public long readUnsignedInt() throws IOException { public long readUnsignedInt() throws IOException {
readFully(buf, 0, 4); readFully(buf, 0, 4);
return NB.decodeUInt32(buf, 0); return NB.decodeUInt32(buf, 0);
} }
/** {@inheritDoc} */
@Override @Override
public void readFully(byte[] b) throws IOException { public void readFully(byte[] b) throws IOException {
readFully(b, 0, b.length); readFully(b, 0, b.length);
} }
/** {@inheritDoc} */
@Override @Override
public void readFully(byte[] b, int off, int len) throws IOException { public void readFully(byte[] b, int off, int len) throws IOException {
IO.readFully(fd, b, off, len); IO.readFully(fd, b, off, len);
} }
/** {@inheritDoc} */
@Override @Override
public int skipBytes(int n) throws IOException { public int skipBytes(int n) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public boolean readBoolean() throws IOException { public boolean readBoolean() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public byte readByte() throws IOException { public byte readByte() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public int readUnsignedByte() throws IOException { public int readUnsignedByte() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public short readShort() throws IOException { public short readShort() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public int readUnsignedShort() throws IOException { public int readUnsignedShort() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public char readChar() throws IOException { public char readChar() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public float readFloat() throws IOException { public float readFloat() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public double readDouble() throws IOException { public double readDouble() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public String readLine() throws IOException { public String readLine() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public String readUTF() throws IOException { public String readUTF() throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

14
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/SimpleDataOutput.java

@ -64,74 +64,88 @@ class SimpleDataOutput implements DataOutput {
this.fd = fd; this.fd = fd;
} }
/** {@inheritDoc} */
@Override @Override
public void writeShort(int v) throws IOException { public void writeShort(int v) throws IOException {
NB.encodeInt16(buf, 0, v); NB.encodeInt16(buf, 0, v);
fd.write(buf, 0, 2); fd.write(buf, 0, 2);
} }
/** {@inheritDoc} */
@Override @Override
public void writeInt(int v) throws IOException { public void writeInt(int v) throws IOException {
NB.encodeInt32(buf, 0, v); NB.encodeInt32(buf, 0, v);
fd.write(buf, 0, 4); fd.write(buf, 0, 4);
} }
/** {@inheritDoc} */
@Override @Override
public void writeLong(long v) throws IOException { public void writeLong(long v) throws IOException {
NB.encodeInt64(buf, 0, v); NB.encodeInt64(buf, 0, v);
fd.write(buf, 0, 8); fd.write(buf, 0, 8);
} }
/** {@inheritDoc} */
@Override @Override
public void write(int b) throws IOException { public void write(int b) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void write(byte[] b) throws IOException { public void write(byte[] b) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void write(byte[] b, int off, int len) throws IOException { public void write(byte[] b, int off, int len) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void writeBoolean(boolean v) throws IOException { public void writeBoolean(boolean v) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void writeByte(int v) throws IOException { public void writeByte(int v) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void writeChar(int v) throws IOException { public void writeChar(int v) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void writeFloat(float v) throws IOException { public void writeFloat(float v) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void writeDouble(double v) throws IOException { public void writeDouble(double v) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void writeBytes(String s) throws IOException { public void writeBytes(String s) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void writeChars(String s) throws IOException { public void writeChars(String s) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */
@Override @Override
public void writeUTF(String s) throws IOException { public void writeUTF(String s) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java

@ -86,7 +86,7 @@ public class UnpackedObject {
* expected ObjectId of the object, used only for error reporting * expected ObjectId of the object, used only for error reporting
* in exceptions. * in exceptions.
* @return loader to read the inflated contents. * @return loader to read the inflated contents.
* @throws IOException * @throws java.io.IOException
* the object cannot be parsed. * the object cannot be parsed.
*/ */
public static ObjectLoader parse(byte[] raw, AnyObjectId id) public static ObjectLoader parse(byte[] raw, AnyObjectId id)

10
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java

@ -57,7 +57,8 @@ import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.storage.file.WindowCacheConfig; 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> * <p>
* The WindowCache serves as a Java based "buffer cache", loading segments of a * 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 * PackFile into the JVM heap prior to use. As JGit often wants to do reads of
@ -111,8 +112,9 @@ import org.eclipse.jgit.storage.file.WindowCacheConfig;
* {@link #createRef(PackFile, long, ByteWindow)} methods, and matching * {@link #createRef(PackFile, long, ByteWindow)} methods, and matching
* decrements during {@link #clear(Ref)}. Implementors may need to override * decrements during {@link #clear(Ref)}. Implementors may need to override
* {@link #createRef(PackFile, long, ByteWindow)} in order to embed additional * {@link #createRef(PackFile, long, ByteWindow)} in order to embed additional
* accounting information into an implementation specific {@link Ref} subclass, * accounting information into an implementation specific
* as the cached entity may have already been evicted by the JRE's garbage * {@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. * collector.
* <p> * <p>
* To maintain higher concurrency workloads, during eviction only one thread * To maintain higher concurrency workloads, during eviction only one thread
@ -150,7 +152,7 @@ public class WindowCache {
* @deprecated use {@code cfg.install()} to avoid internal reference. * @deprecated use {@code cfg.install()} to avoid internal reference.
* @param cfg * @param cfg
* the new window cache configuration. * the new window cache configuration.
* @throws IllegalArgumentException * @throws java.lang.IllegalArgumentException
* the cache configuration contains one or more invalid * the cache configuration contains one or more invalid
* settings, usually too low of a limit. * settings, usually too low of a limit.
*/ */

20
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java

@ -110,11 +110,13 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
return baseCache; return baseCache;
} }
/** {@inheritDoc} */
@Override @Override
public ObjectReader newReader() { public ObjectReader newReader() {
return new WindowCursor(db); return new WindowCursor(db);
} }
/** {@inheritDoc} */
@Override @Override
public BitmapIndex getBitmapIndex() throws IOException { public BitmapIndex getBitmapIndex() throws IOException {
for (PackFile pack : db.getPacks()) { for (PackFile pack : db.getPacks()) {
@ -125,6 +127,7 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
return null; return null;
} }
/** {@inheritDoc} */
@Override @Override
public Collection<CachedPack> getCachedPacksAndUpdate( public Collection<CachedPack> getCachedPacksAndUpdate(
BitmapBuilder needBitmap) throws IOException { BitmapBuilder needBitmap) throws IOException {
@ -137,6 +140,7 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
return Collections.emptyList(); return Collections.emptyList();
} }
/** {@inheritDoc} */
@Override @Override
public Collection<ObjectId> resolve(AbbreviatedObjectId id) public Collection<ObjectId> resolve(AbbreviatedObjectId id)
throws IOException { throws IOException {
@ -147,11 +151,13 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
return matches; return matches;
} }
/** {@inheritDoc} */
@Override @Override
public boolean has(AnyObjectId objectId) throws IOException { public boolean has(AnyObjectId objectId) throws IOException {
return db.has(objectId); return db.has(objectId);
} }
/** {@inheritDoc} */
@Override @Override
public ObjectLoader open(AnyObjectId objectId, int typeHint) public ObjectLoader open(AnyObjectId objectId, int typeHint)
throws MissingObjectException, IncorrectObjectTypeException, throws MissingObjectException, IncorrectObjectTypeException,
@ -168,11 +174,13 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
return ldr; return ldr;
} }
/** {@inheritDoc} */
@Override @Override
public Set<ObjectId> getShallowCommits() throws IOException { public Set<ObjectId> getShallowCommits() throws IOException {
return db.getShallowCommits(); return db.getShallowCommits();
} }
/** {@inheritDoc} */
@Override @Override
public long getObjectSize(AnyObjectId objectId, int typeHint) public long getObjectSize(AnyObjectId objectId, int typeHint)
throws MissingObjectException, IncorrectObjectTypeException, throws MissingObjectException, IncorrectObjectTypeException,
@ -187,11 +195,13 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
return sz; return sz;
} }
/** {@inheritDoc} */
@Override @Override
public LocalObjectToPack newObjectToPack(AnyObjectId objectId, int type) { public LocalObjectToPack newObjectToPack(AnyObjectId objectId, int type) {
return new LocalObjectToPack(objectId, type); return new LocalObjectToPack(objectId, type);
} }
/** {@inheritDoc} */
@Override @Override
public void selectObjectRepresentation(PackWriter packer, public void selectObjectRepresentation(PackWriter packer,
ProgressMonitor monitor, Iterable<ObjectToPack> objects) ProgressMonitor monitor, Iterable<ObjectToPack> objects)
@ -202,6 +212,7 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
} }
} }
/** {@inheritDoc} */
@Override @Override
public void copyObjectAsIs(PackOutputStream out, ObjectToPack otp, public void copyObjectAsIs(PackOutputStream out, ObjectToPack otp,
boolean validate) throws IOException, boolean validate) throws IOException,
@ -210,6 +221,7 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
src.pack.copyAsIs(out, src, validate, this); src.pack.copyAsIs(out, src, validate, this);
} }
/** {@inheritDoc} */
@Override @Override
public void writeObjects(PackOutputStream out, List<ObjectToPack> list) public void writeObjects(PackOutputStream out, List<ObjectToPack> list)
throws IOException { throws IOException {
@ -253,6 +265,7 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
return cnt - need; return cnt - need;
} }
/** {@inheritDoc} */
@Override @Override
public void copyPackAsIs(PackOutputStream out, CachedPack pack) public void copyPackAsIs(PackOutputStream out, CachedPack pack)
throws IOException { throws IOException {
@ -348,13 +361,18 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
} }
} }
/** {@inheritDoc} */
@Override @Override
@Nullable @Nullable
public ObjectInserter getCreatedFromInserter() { public ObjectInserter getCreatedFromInserter() {
return createdFromInserter; return createdFromInserter;
} }
/** Release the current window cursor. */ /**
* {@inheritDoc}
* <p>
* Release the current window cursor.
*/
@Override @Override
public void close() { public void close() {
window = null; window = null;

Loading…
Cancel
Save