Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.storage.file

public Class ObjectDirectory

extends FileObjectDatabase
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.UTF_8, org.eclipse.jgit.internal.storage.pack.PackExt.PACK, .PackExt.BITMAP_INDEX, .PackExt.INDEX

Traditional file system based org.eclipse.jgit.lib.ObjectDatabase.

This is the classical object database representation for a Git repository, where objects are stored loose by hashing them into directories by their org.eclipse.jgit.lib.ObjectId, or are stored in compressed containers known as org.eclipse.jgit.internal.storage.file.Packs.

Optionally an object database can reference one or more alternates; other ObjectDatabase instances that are searched in addition to the current database.

Databases are divided into two halves: a half that is considered to be fast to search (the PackFiles), and a half that is considered to be slow to search (loose objects). When alternates are present the fast half is fully searched (recursively through all alternates) before the slow half is considered.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final AtomicReference<ObjectDirectory.AlternateHandle[]>
private final File
private final Config
private final FileCommitGraph
private final FS
private final ObjectDirectory.AlternateHandle
private final File
private final LooseObjects
private final File
private final PackDirectory
private final PackDirectory
private static final int
RESOLVE_ABBREV_LIMIT

Maximum number of candidates offered as resolutions of abbreviation.

private Set<ObjectId>
private final File
private FileSnapshot

Constructor Summary

AccessConstructor and Description
public
ObjectDirectory(final Config
configuration this directory consults for write settings.
cfg
,
final File
the location of the objects directory.
dir
,
File[]
a list of alternate object directories
alternatePaths
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
,
File
file which contains IDs of shallow commits, null if shallow commits handling should be turned off
shallowFile
)

Initialize a reference to an on-disk object directory.

Method Summary

Modifier and TypeMethod and Description
pack-priv Set<ObjectDirectory.AlternateHandle.Id>
public void
close()

Implements abstract org.eclipse.jgit.lib.ObjectDatabase.close.

Implements java.lang.AutoCloseable.close.

Close any resources held by this database.

pack-priv void
public void
create()

Overrides org.eclipse.jgit.lib.ObjectDatabase.create.

Initialize a new object database at this location.

public boolean
exists()

Overrides org.eclipse.jgit.lib.ObjectDatabase.exists.

Does this database exist yet?

public File
fileFor(AnyObjectId objectId)

Implements abstract org.eclipse.jgit.internal.storage.file.FileObjectDatabase.fileFor.

Compute the location of a loose object file.

pack-priv ObjectDirectory.AlternateHandle.Id
public long
getApproximateObjectCount()

Implements abstract org.eclipse.jgit.lib.ObjectDatabase.getApproximateObjectCount.

Get a quick, rough count of objects in this repository.

public Optional<CommitGraph>
pack-priv Config
public final File
pack-priv FS
pack-priv File
private long
pack-priv long
private long
public final File

Returns:

the location of the pack directory.
getPackDirectory
()

Getter for the field packDirectory.

private long
public Collection<Pack>
public final File

Returns:

the location of the preserved directory.
getPreservedDirectory
()

Getter for the field preservedDirectory.

public Set<ObjectId>
getShallowCommits()

Overrides org.eclipse.jgit.lib.ObjectDatabase.getShallowCommits.

Get the shallow commits of the current repository

public boolean
has(AnyObjectId
identity of the object to test for existence of.
objectId
)

Overrides org.eclipse.jgit.lib.ObjectDatabase.has.

Does the requested object exist in this database?

private boolean
private boolean
pack-priv boolean
private boolean
pack-priv FileObjectDatabase.InsertLooseObjectResult
private ObjectDirectory.AlternateHandle[]
pack-priv ObjectDirectory.AlternateHandle[]
public ObjectDatabase
newCachedDatabase()

Overrides org.eclipse.jgit.lib.ObjectDatabase.newCachedDatabase.

Create a new cached database instance over this database.

pack-priv CachedObjectDirectory
public ObjectDirectoryInserter
newInserter()

Overrides org.eclipse.jgit.internal.storage.file.FileObjectDatabase.newInserter.

Create a new ObjectInserter to insert new objects.

public PackInserter

Returns:

new inserter.
newPackInserter
()

Create a new inserter that inserts all objects as pack files, not loose objects.

private static BufferedReader
private ObjectDirectory.AlternateHandle
private ObjectDirectory.AlternateHandle
private ObjectLoader
pack-priv ObjectLoader
pack-priv ObjectLoader
private ObjectLoader
public Pack
openPack(File pack)

Implements abstract org.eclipse.jgit.internal.storage.file.FileObjectDatabase.openPack.

Add a single existing pack to the list of available pack files.

private ObjectLoader
pack-priv ObjectLoader
pack-priv void
private void
private boolean
restore(PackFile preservedPack)

private boolean
private boolean
pack-priv void
private void
public void
setShallowCommits(Set<ObjectId>
the new shallow commits
shallowCommits
)

Overrides org.eclipse.jgit.lib.ObjectDatabase.setShallowCommits.

Update the shallow commits of the current repository

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jgit.internal.storage.file.FileObjectDatabase:
newReader