public class FileRepository extends Repository
This class is thread-safe.
This implementation only handles a subtly undocumented subset of git features.
Constructor and Description |
---|
FileRepository(BaseRepositoryBuilder options)
Create a repository using the local file system.
|
FileRepository(File gitDir)
Construct a representation of a Git repository.
|
FileRepository(String gitDir)
A convenience API for
FileRepository(File) . |
Modifier and Type | Method and Description |
---|---|
void |
autoGC(ProgressMonitor monitor)
Check whether any housekeeping is required; if yes, run garbage
collection; if not, exit without performing any work.
|
void |
create(boolean bare)
Create a new Git repository initializing the necessary files and
directories.
|
AttributesNodeProvider |
createAttributesNodeProvider()
Create a new
AttributesNodeProvider . |
Set<ObjectId> |
getAdditionalHaves()
Objects known to exist but not expressed by
Repository.getAllRefs() . |
FileBasedConfig |
getConfig()
Get the configuration of this repository.
|
String |
getGitwebDescription()
Read the
GIT_DIR/description file for gitweb. |
ObjectDirectory |
getObjectDatabase()
Get the object database which stores this repository's data.
|
File |
getObjectsDirectory()
Get the directory containing the objects owned by this repository
|
RefDatabase |
getRefDatabase()
Get the reference database which stores the reference namespace.
|
ReflogReader |
getReflogReader(String refName)
Get the reflog reader
|
void |
notifyIndexChanged()
Notify that the index changed
|
void |
openPack(File pack)
Add a single existing pack to the list of available pack files.
|
void |
scanForRepoChanges()
Force a scan for changed refs.
|
void |
setGitwebDescription(String description)
Set the
GIT_DIR/description file for gitweb. |
close, create, doClose, exactRef, findRef, fireEvent, getAllRefs, getAllRefsByPeeledObjectId, getBranch, getDirectory, getFS, getFullBranch, getGlobalListenerList, getIndexFile, getListenerList, getRef, getRemoteName, getRemoteNames, getRepositoryState, getTags, getWorkTree, hasObject, incrementOpen, isBare, isValidRefName, lockDirCache, newObjectInserter, newObjectReader, normalizeBranchName, open, open, parseCommit, peel, readCherryPickHead, readCommitEditMsg, readDirCache, readMergeCommitMsg, readMergeHeads, readOrigHead, readRebaseTodo, readRevertHead, readSquashCommitMsg, renameRef, resolve, shortenRefName, shortenRemoteBranchName, simplify, stripWorkDir, toString, updateRef, updateRef, writeCherryPickHead, writeCommitEditMsg, writeMergeCommitMsg, writeMergeHeads, writeOrigHead, writeRebaseTodoFile, writeRevertHead, writeSquashCommitMsg
public FileRepository(File gitDir) throws IOException
The work tree, object directory, alternate object directories and index
file locations are deduced from the given git directory and the default
rules by running
FileRepositoryBuilder
. This
constructor is the same as saying:
new FileRepositoryBuilder().setGitDir(gitDir).build()
gitDir
- GIT_DIR (the location of the repository metadata).IOException
- the repository appears to already exist but cannot be
accessed.FileRepositoryBuilder
public FileRepository(String gitDir) throws IOException
FileRepository(File)
.gitDir
- GIT_DIR (the location of the repository metadata).IOException
- the repository appears to already exist but cannot be
accessed.FileRepositoryBuilder
public FileRepository(BaseRepositoryBuilder options) throws IOException
options
- description of the repository's important paths.IOException
- the user configuration file or repository configuration file
cannot be accessed.public void create(boolean bare) throws IOException
Create a new Git repository initializing the necessary files and directories.
create
in class Repository
bare
- if true, a bare repository (a repository without a working
directory) is created.IOException
- in case of IO problempublic File getObjectsDirectory()
public ObjectDirectory getObjectDatabase()
getObjectDatabase
in class Repository
public RefDatabase getRefDatabase()
getRefDatabase
in class Repository
public FileBasedConfig getConfig()
getConfig
in class Repository
@Nullable public String getGitwebDescription() throws IOException
GIT_DIR/description
file for gitweb.getGitwebDescription
in class Repository
IOException
- description cannot be accessed.public void setGitwebDescription(@Nullable String description) throws IOException
GIT_DIR/description
file for gitweb.setGitwebDescription
in class Repository
description
- new description; null to clear the description.IOException
- description cannot be persisted.public Set<ObjectId> getAdditionalHaves()
Repository.getAllRefs()
.
When a repository borrows objects from another repository, it can advertise that it safely has that other repository's references, without exposing any other details about the other repository. This may help a client trying to push changes avoid pushing more than it needs to.
Objects known to exist but not expressed by Repository.getAllRefs()
.
When a repository borrows objects from another repository, it can advertise that it safely has that other repository's references, without exposing any other details about the other repository. This may help a client trying to push changes avoid pushing more than it needs to.
getAdditionalHaves
in class Repository
public void openPack(File pack) throws IOException
pack
- path of the pack file to open.IOException
- index file could not be opened, read, or is not recognized as
a Git pack file index.public void scanForRepoChanges() throws IOException
scanForRepoChanges
in class Repository
IOException
public void notifyIndexChanged()
notifyIndexChanged
in class Repository
public ReflogReader getReflogReader(String refName) throws IOException
getReflogReader
in class Repository
refName
- a String
object.ReflogReader
for the supplied
refname, or null
if the named ref does not exist.IOException
- the ref could not be accessed.public AttributesNodeProvider createAttributesNodeProvider()
AttributesNodeProvider
.createAttributesNodeProvider
in class Repository
AttributesNodeProvider
.
This AttributesNodeProvider
is lazy loaded only once. It means that it will not be updated
after loading. Prefer creating new instance for each use.public void autoGC(ProgressMonitor monitor)
Currently this option is supported for repositories of type
FileRepository
only. See
GC.setAuto(boolean)
for
configuration details.
autoGC
in class Repository
monitor
- to report progressCopyright © 2020 Eclipse JGit Project. All rights reserved.