org.eclipse.jgit.internal.storage.file

## Class FileRepository

- java.lang.Object
- - org.eclipse.jgit.lib.Repository
  - - org.eclipse.jgit.internal.storage.file.FileRepository

    public class FileRepository
    extends Repository

Represents a Git repository. A repository holds all objects and refs used for managing source code (could by any type of file, but source code is what SCM's are typically used for). In Git terms all data is stored in GIT_DIR, typically a directory called .git. A work tree is maintained unless the repository is a bare repository. Typically the .git directory is located at the root of the work dir.

- GIT_DIR
  - objects/ - objects
  - refs/ - tags and heads
  - config - configuration
  - info/ - more configurations

This class is thread-safe.

This implementation only handles a subtly undocumented subset of git features.

### Constructor Summary

Constructors
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)`.

### Method Summary

All Methods Instance Methods Concrete Methods
`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.

### Methods inherited from class org.eclipse.jgit.lib.Repository

`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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### FileRepository

    public FileRepository(File gitDir)
                   throws IOException

Construct a representation of a Git repository.

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()

Parameters:
  `gitDir` - GIT_DIR (the location of the repository metadata).
Throws:
  `IOException` - the repository appears to already exist but cannot be accessed.
See Also:
  `FileRepositoryBuilder`

#### FileRepository

    public FileRepository(String gitDir)
                   throws IOException

A convenience API for `FileRepository(File)`.

Parameters:
  `gitDir` - GIT_DIR (the location of the repository metadata).
Throws:
  `IOException` - the repository appears to already exist but cannot be accessed.
See Also:
  `FileRepositoryBuilder`

#### FileRepository

    public FileRepository(BaseRepositoryBuilder options)
                   throws IOException

Create a repository using the local file system.

Parameters:
  `options` - description of the repository's important paths.
Throws:
  `IOException` - the user configuration file or repository configuration file cannot be accessed.

### Method Detail

#### create

    public void create(boolean bare)
                throws IOException

Create a new Git repository initializing the necessary files and directories.

Specified by:
  `create` in class `Repository`
Parameters:
  `bare` - if true, a bare repository is created.
Throws:
  `IOException` - in case of IO problem

#### getObjectsDirectory

    public File getObjectsDirectory()

Returns:
  the directory containing the objects owned by this repository.

#### getObjectDatabase

    public ObjectDirectory getObjectDatabase()

Specified by:
  `getObjectDatabase` in class `Repository`
Returns:
  the object database which stores this repository's data.

#### getRefDatabase

    public RefDatabase getRefDatabase()

Specified by:
  `getRefDatabase` in class `Repository`
Returns:
  the reference database which stores the reference namespace.

#### getConfig

    public FileBasedConfig getConfig()

Specified by:
  `getConfig` in class `Repository`
Returns:
  the configuration of this repository

#### getAdditionalHaves

    public Set<ObjectId> getAdditionalHaves()

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.

Overrides:
  `getAdditionalHaves` in class `Repository`
Returns:
  unmodifiable collection of other known objects.

#### openPack

    public void openPack(File pack)
                  throws IOException

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

Parameters:
  `pack` - path of the pack file to open.
Throws:
  `IOException` - index file could not be opened, read, or is not recognized as a Git pack file index.

#### scanForRepoChanges

    public void scanForRepoChanges()
                            throws IOException

Description copied from class: `Repository`
Force a scan for changed refs.

Specified by:
  `scanForRepoChanges` in class `Repository`
Throws:
  `IOException`

#### notifyIndexChanged

    public void notifyIndexChanged()

Description copied from class: `Repository`
Notify that the index changed

Specified by:
  `notifyIndexChanged` in class `Repository`

#### getReflogReader

    public ReflogReader getReflogReader(String refName)
                                 throws IOException

Specified by:
  `getReflogReader` in class `Repository`
Parameters:
  `refName` -
Returns:
  a `ReflogReader` for the supplied refname, or null if the named ref does not exist.
Throws:
  `IOException` - the ref could not be accessed.