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 |
create(boolean bare)
Create a new Git repository initializing the necessary files and
directories.
|
Set<ObjectId> |
getAdditionalHaves()
Objects known to exist but not expressed by
Repository.getAllRefs() . |
FileBasedConfig |
getConfig() |
ObjectDirectory |
getObjectDatabase() |
File |
getObjectsDirectory() |
RefDatabase |
getRefDatabase() |
ReflogReader |
getReflogReader(String refName) |
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.
|
close, create, doClose, fireEvent, getAllRefs, getAllRefsByPeeledObjectId, getBranch, getDirectory, getFS, getFullBranch, getGlobalListenerList, getIndexFile, getListenerList, getRef, getRemoteName, getRemoteNames, getRepositoryState, getTags, getWorkTree, hasObject, incrementOpen, isBare, isValidRefName, lockDirCache, newObjectInserter, newObjectReader, open, open, peel, readCherryPickHead, readDirCache, readMergeCommitMsg, readMergeHeads, readOrigHead, readRebaseTodo, readRevertHead, readSquashCommitMsg, renameRef, resolve, shortenRefName, shortenRemoteBranchName, simplify, stripWorkDir, toString, updateRef, updateRef, writeCherryPickHead, 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
in class Repository
bare
- if true, a bare repository 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
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.
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
Repository
scanForRepoChanges
in class Repository
IOException
public void notifyIndexChanged()
Repository
notifyIndexChanged
in class Repository
public ReflogReader getReflogReader(String refName) throws IOException
getReflogReader
in class Repository
refName
- ReflogReader
for the supplied refname, or null if the
named ref does not exist.IOException
- the ref could not be accessed.Copyright © 2014. All rights reserved.