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(java.io.File gitDir)
Construct a representation of a Git repository.
|
FileRepository(java.lang.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.
|
java.util.Set<ObjectId> |
getAdditionalHaves()
Objects known to exist but not expressed by
Repository.getAllRefs() . |
FileBasedConfig |
getConfig() |
ObjectDirectory |
getObjectDatabase() |
java.io.File |
getObjectsDirectory() |
RefDatabase |
getRefDatabase() |
ReflogReader |
getReflogReader(java.lang.String refName) |
void |
notifyIndexChanged()
Notify that the index changed
|
void |
openPack(java.io.File pack,
java.io.File idx)
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, getRepositoryState, getTags, getWorkTree, hasObject, incrementOpen, isBare, isValidRefName, lockDirCache, newObjectInserter, newObjectReader, open, open, peel, readCherryPickHead, readDirCache, readMergeCommitMsg, readMergeHeads, readOrigHead, renameRef, resolve, shortenRefName, stripWorkDir, toString, updateRef, updateRef, writeCherryPickHead, writeMergeCommitMsg, writeMergeHeads, writeOrigHead
public FileRepository(java.io.File gitDir) throws java.io.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).java.io.IOException
- the repository appears to already exist but cannot be
accessed.FileRepositoryBuilder
public FileRepository(java.lang.String gitDir) throws java.io.IOException
FileRepository(File)
.gitDir
- GIT_DIR (the location of the repository metadata).java.io.IOException
- the repository appears to already exist but cannot be
accessed.FileRepositoryBuilder
public FileRepository(BaseRepositoryBuilder options) throws java.io.IOException
options
- description of the repository's important paths.java.io.IOException
- the user configuration file or repository configuration file
cannot be accessed.public void create(boolean bare) throws java.io.IOException
create
in class Repository
bare
- if true, a bare repository is created.java.io.IOException
- in case of IO problempublic java.io.File getObjectsDirectory()
public ObjectDirectory getObjectDatabase()
getObjectDatabase
in class Repository
public RefDatabase getRefDatabase()
getRefDatabase
in class Repository
public FileBasedConfig getConfig()
getConfig
in class Repository
public java.util.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(java.io.File pack, java.io.File idx) throws java.io.IOException
pack
- path of the pack file to open.idx
- path of the corresponding index file.java.io.IOException
- index file could not be opened, read, or is not recognized as
a Git pack file index.public void scanForRepoChanges() throws java.io.IOException
Repository
scanForRepoChanges
in class Repository
java.io.IOException
public void notifyIndexChanged()
Repository
notifyIndexChanged
in class Repository
public ReflogReader getReflogReader(java.lang.String refName) throws java.io.IOException
getReflogReader
in class Repository
refName
- ReflogReader
for the supplied refname, or null if the
named ref does not exist.java.io.IOException
- the ref could not be accessed.Copyright © 2012. All Rights Reserved.