A repository holds all objects and refs used for managing source code (could be any type of file, but source code is what SCM's are typically used for).
The thread-safety of a org. very much
depends on the concrete implementation. Applications working with a generic
Repository type must not assume the instance is thread-safe.
FileRepository is thread-safe.
DfsRepository thread-safety is determined by its subclass.
| Modifier and Type | Field and Description |
|---|---|
| private final AtomicReference | |
| pack-priv final AtomicLong | |
| private static final Pattern | FORBIDDEN_BRANCH_NAME_COMPONENTS
Branch names containing slashes should not have a name component that is one of the reserved device names on Windows. |
| private final FS | fs
File abstraction used to resolve paths. |
| private final File | gitCommonDir
$GIT_COMMON_DIR: metadata directory holding the common repository's critical files. |
| private final File | gitDir
$GIT_DIR: metadata directory holding the repository's critical files. |
| private static final ListenerList | |
| private final File | indexFile
If not bare, the index file caching the working file states. |
| private final String | |
| private static final Logger | |
| private final ListenerList | |
| pack-priv final AtomicInteger | useCnt
Use counter |
| private final File | workTree
If not bare, the top level directory of the working files. |
| Access | Constructor and Description |
|---|---|
| protected | Repository(BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Repository>
options to configure the repository. options)Initialize a new repository instance. |
| Modifier and Type | Method and Description |
|---|---|
| public void | autoGC(ProgressMonitor
to report progress monitor)Check whether any housekeeping is required; if yes, run garbage collection; if not, exit without performing any work. |
| public void | close()
Implements java. Closes this resource, relinquishing any underlying resources. |
| public void | |
| public abstract void | create(boolean
if true, a bare repository (a repository without a working
directory) is created. bare)Create a new Git repository initializing the necessary files and directories. |
| public abstract AttributesNodeProvider | Returns: a neworg..
This org.
is lazy loaded only once. It means that it will not be updated
after loading. Prefer creating new instance for each use.Create a new |
| protected void | |
| public final Ref | |
| public final Ref | |
| public void | |
| public Set | Returns: unmodifiable collection of other known objects.Objects known to exist but not expressed by |
| public Map | Returns: mutable map of all known refs (heads, tags, remotes).
Deprecated
use
getRefDatabase().getRefs() instead.
Get mutable map of all known refs, including symrefs like HEAD that may not point to any object yet. |
| public Map | Returns: a map with all objects referenced by a peeled ref.Get a map with all objects referenced by a peeled ref. |
| public String | Returns: name of current branch (for examplemaster), an ObjectId
in hex format if the current branch is detached, or null
if the repository is corrupt and has no HEAD reference.Get the short name of the current branch that |
| public File | |
| public abstract StoredConfig | |
| public File | Returns: local metadata directory;null if repository isn't local.Get local metadata directory |
| public FS | Returns: the used file system abstraction, ornull if
repository isn't local.Get the used file system abstraction. |
| public String | Returns: name of current branch (for examplerefs/heads/master),
an ObjectId in hex format if the current branch is detached, or
null if the repository is corrupt and has no HEAD
reference.Get the name of the reference that |
| public String | Returns: description text; null if no description has been configured.Read the |
| public static ListenerList | Returns: the global listener list observing all events in this JVM.Get the global listener list observing all events in this JVM. |
| public abstract String | Returns: repository identifier. The returned identifier has to be unique within a given Git server.Get repository identifier. |
| public File | Returns: the index file location ornull if repository isn't
local.Get the index file location or |
| protected String | Returns: the initial branch name of a new repositoryGet the initial branch name of a new repository |
| public ListenerList | Returns: listeners observing only events on this repository.Get listeners observing only events on this repository. |
| public abstract ObjectDatabase | Returns: the object database which stores this repository's data.Get the object database which stores this repository's data. |
| public abstract RefDatabase | Returns: the reference database which stores the reference namespace.Get the reference database which stores the reference namespace. |
| public ReflogReader | Returns: aorg. for the supplied
refname, or null if the named ref does not exist.a refName)java. object.
Deprecated
since 7.2. use
#getRefDatabase().getReflogReader(String) instead
Get the reflog reader |
| public ReflogReader | Returns: aorg. for the supplied ref.a Ref ref)
Deprecated
since 7.2. use
#getRefDatabase().getReflogReader(Ref) instead
Get the reflog reader. |
| public String | Returns: the remote name part ofrefName, i.e. without the
refs/remotes/<remote> prefix, if
refName represents a remote tracking branch;
otherwise null.a refName)java. object.Get remote name |
| public Set | |
| public RepositoryState | |
| public Map | Returns: mutable map of all tags; key is short tag name ("v1.0") and value of the entry contains the ref with the full tag name ("refs/tags/v1.0").
Deprecated
use
getRefDatabase().getRefsByPrefix(R_TAGS) instead
Get mutable map of all tags |
| public File | Returns: the root directory of the working tree, where files are checked out for viewing and editing.Get the root directory of the working tree, where files are checked out for viewing and editing. |
| public void | |
| private static boolean | |
| public boolean | Returns: true if this is bare, which implies it has no working directory.Whether this repository is bare |
| private static boolean | |
| public static boolean | Returns: true if refName is a valid ref namea refName)java. object.Check validity of a ref name. |
| public boolean | Returns: true if the work tree is case-insensitive; false
otherwiseTells whether the work tree is on a case-insensitive file system. |
| public DirCache | Returns: a cache representing the contents of the specified index file (if it exists) or an empty cache if the file does not exist.Create a new in-core index representation, lock it, and read from disk. |
| public ObjectInserter | Returns: a new inserter to create objects ingetObjectDatabase().Create a new inserter to create objects in |
| public ObjectReader | Returns: a new reader to read objects fromgetObjectDatabase().Create a new reader to read objects from |
| public static String | Returns: The normalized name or an empty String if it isnull or
empty.to normalize name)Normalizes the passed branch name into a possible valid branch name. |
| public abstract void | notifyIndexChanged(boolean
true if the index was changed by the same
JGit processNotify that the index changed by firing an IndexChangedEvent. |
| public ObjectLoader | Returns: aorg. for accessing the
object.identity of the object to open. objectId)Open an object from this repository. |
| public ObjectLoader | Returns: aorg. for accessing the
object.identity of the object to open. objectId, int hint about the type of object being requested, e.g.
typeHint)org.;
org. if the
object type is not known, or does not matter to the caller.Open an object from this repository. |
| public RevCommit | Returns: reference to the commit object. Never null.name of the commit object. id)Locate a reference to a commit and immediately parse its content. |
| private RevObject | |
| private Ref | |
| public ObjectId | Returns: object id from CHERRY_PICK_HEAD file ornull if this file
doesn't exist. Also if the file exists but is empty null
will be returnedReturn the information stored in the file $GIT_DIR/CHERRY_PICK_HEAD. |
| public String | Returns: a String containing the content of the COMMIT_EDITMSG file ornull if this file doesn't existReturn the information stored in the file $GIT_DIR/COMMIT_EDITMSG. |
| private String | |
| public DirCache | Returns: a cache representing the contents of the specified index file (if it exists) or an empty cache if the file does not exist.Create a new in-core index representation and read an index from disk. |
| private byte[] | Returns: the raw contents ornull if the file doesn't exist or is
emptythe file to read filename)Read a file from the git directory. |
| public String | Returns: a String containing the content of the MERGE_MSG file ornull if this file doesn't existReturn the information stored in the file $GIT_DIR/MERGE_MSG. |
| public List | Returns: a list of commits which IDs are listed in the MERGE_HEAD file ornull if this file doesn't exist. Also if the file exists
but is empty null will be returnedReturn the information stored in the file $GIT_DIR/MERGE_HEAD. |
| public ObjectId | Returns: object id from ORIG_HEAD file ornull if this file
doesn't exist. Also if the file exists but is empty null
will be returnedReturn the information stored in the file $GIT_DIR/ORIG_HEAD. |
| public List | Returns: the list of stepspath to the file relative to the repository's git-dir. E.g.
"rebase-merge/git-rebase-todo" or "rebase-append/done" path, boolean true if also comments should be reportedRead a file formatted like the git-rebase-todo file. |
| public ObjectId | Returns: object id from REVERT_HEAD file ornull if this file
doesn't exist. Also if the file exists but is empty null
will be returnedReturn the information stored in the file $GIT_DIR/REVERT_HEAD. |
| public String | Returns: a String containing the content of the SQUASH_MSG file ornull if this file doesn't existReturn the information stored in the file $GIT_DIR/SQUASH_MSG. |
| public RefRename | |
| public ObjectId | Returns: an ObjectId ornull if revstr can't be resolved to any
ObjectIdA git object references expression revstr)Parse a git revision string and return an object id. Combinations of these operators are supported:
|
| private Object | |
| private ObjectId | |
| private RevCommit | |
| private String | |
| private ObjectId | |
| public abstract void | |
| public void | setGitwebDescription(String
new description; null to clear the description. description)Set the |
| public static String | Returns: a more user friendly ref namea refName)java. object.Get a shortened more user friendly ref name |
| public String | Returns: the remote branch name part ofrefName, i.e. without
the refs/remotes/<remote> prefix, if
refName represents a remote tracking branch;
otherwise null.a refName)java. object.Get a shortened more user friendly remote tracking branch name |
| public String | Returns: object id or ref name from resolved expression ornull if
given expression cannot be resolveda revstr)java. object.Simplify an expression, but unlike |
| public static String | Returns: normalized repository relative path or the empty string if the file is not relative to the work directory.Work dir workDir, File File whose path shall be stripped of its workdir file)Strip work dir and return normalized repository path. |
| public String | |
| public RefUpdate | |
| public RefUpdate | Returns: an update command. The caller must finish populating this command and then invoke one of the update methods to actually make a change.name of the ref the caller wants to modify. ref, boolean true to create a detached head detach)Create a command to update, create or delete a ref in this repository. |
| public void | writeCherryPickHead(ObjectId
an object id of the cherry commit or head)null to
delete the fileWrite cherry pick commit into $GIT_DIR/CHERRY_PICK_HEAD. |
| public void | writeCommitEditMsg(String
the message which should be written or msg)null to delete
the fileWrite new content to the file $GIT_DIR/COMMIT_EDITMSG. |
| private void | |
| private void | writeHeadsFile(List<? extends ObjectId>
a list of object ids to write or null if the file should be
deleted. heads, String name of the file to write heads to filename)Write the given heads to a file in the git directory. |
| public void | writeMergeCommitMsg(String
the message which should be written or msg)null to
delete the fileWrite new content to the file $GIT_DIR/MERGE_MSG. |
| public void | writeMergeHeads(List<? extends ObjectId>
a list of commits which IDs should be written to
$GIT_DIR/MERGE_HEAD or heads)null to delete the fileWrite new merge-heads into $GIT_DIR/MERGE_HEAD. |
| public void | writeOrigHead(ObjectId
an object id of the original HEAD commit or head)null
to delete the fileWrite original HEAD commit into $GIT_DIR/ORIG_HEAD. |
| public void | writeRebaseTodoFile(String
path to the file relative to the repository's git-dir. E.g.
"rebase-merge/git-rebase-todo" or "rebase-append/done" path, List<RebaseTodoLine> the steps to be written steps, boolean whether to append to an existing file or to write a new file append)Write a file formatted like a git-rebase-todo file. |
| public void | writeRevertHead(ObjectId
an object id of the revert commit or head)null to
delete the fileWrite revert commit into $GIT_DIR/REVERT_HEAD. |
| public void | writeSquashCommitMsg(String
the message which should be written or msg)null to
delete the fileWrite new content to the file $GIT_DIR/SQUASH_MSG. |