Class LooseObjects
java.lang.Object
org.eclipse.jgit.internal.storage.file.LooseObjects
Traditional file system based loose objects handler.
This is the loose object representation for a Git object database, where
objects are stored loose by hashing them into directories by their
ObjectId
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final File
private static final org.slf4j.Logger
private static final int
Maximum number of attempts to read a loose object for which a stale file handle exception is thrownprivate final UnpackedObjectCache
-
Constructor Summary
ConstructorsConstructorDescriptionLooseObjects
(File dir) Initialize a reference to an on-disk object directory. -
Method Summary
Modifier and TypeMethodDescription(package private) void
close()
(package private) void
create()
(package private) File
fileFor
(AnyObjectId objectId) Compute the location of a loose object file.(package private) File
Getter for the fielddirectory
.(package private) ObjectLoader
getObjectLoader
(WindowCursor curs, File path, AnyObjectId id) Provides a loader for an objectId(package private) long
getSize
(WindowCursor curs, AnyObjectId id) (package private) boolean
has
(AnyObjectId objectId) Does the requested object exist as a loose object?(package private) boolean
hasCached
(AnyObjectId id) (package private) FileObjectDatabase.InsertLooseObjectResult
(package private) ObjectLoader
open
(WindowCursor curs, AnyObjectId id) (package private) boolean
resolve
(Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit) Find objects matching the prefix abbreviation.toString()
(package private) UnpackedObjectCache
Getter for the fieldunpackedObjectCache
.
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
MAX_LOOSE_OBJECT_STALE_READ_ATTEMPTS
private static final int MAX_LOOSE_OBJECT_STALE_READ_ATTEMPTSMaximum number of attempts to read a loose object for which a stale file handle exception is thrown- See Also:
-
directory
-
unpackedObjectCache
-
-
Constructor Details
-
LooseObjects
LooseObjects(File dir) Initialize a reference to an on-disk object directory.- Parameters:
dir
- the location of theobjects
directory.
-
-
Method Details
-
getDirectory
File getDirectory()Getter for the fielddirectory
.- Returns:
- the location of the
objects
directory.
-
create
- Throws:
IOException
-
close
void close() -
toString
-
hasCached
-
has
Does the requested object exist as a loose object?- Parameters:
objectId
- identity of the object to test for existence of.- Returns:
true
if the specified object is stored as a loose object.
-
resolve
Find objects matching the prefix abbreviation.- Parameters:
matches
- set to add any located ObjectIds to. This is an output parameter.id
- prefix to search for.matchLimit
- maximum number of results to return. At most this many ObjectIds should be added to matches before returning.- Returns:
true
if the matches were exhausted before reachingmaxLimit
.
-
open
- Throws:
IOException
-
getObjectLoader
Provides a loader for an objectId- Parameters:
curs
- cursor on the databasepath
- the path of the loose objectid
- the object id- Returns:
- a loader for the loose file object
- Throws:
IOException
- when file does not exist or it could not be opened
-
unpackedObjectCache
UnpackedObjectCache unpackedObjectCache()Getter for the field
This accessor is particularly useful to allow mocking of this class for testing purposes.unpackedObjectCache
.- Returns:
- the cache of the objects currently unpacked.
-
getSize
- Throws:
IOException
-
insert
- Throws:
IOException
-
tryMove
private FileObjectDatabase.InsertLooseObjectResult tryMove(File tmp, File dst, ObjectId id) throws IOException - Throws:
IOException
-
fileFor
Compute the location of a loose object file.- Parameters:
objectId
- identity of the object to get the File location for.- Returns:
File
location of the specified loose object.
-