- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
DfsRepository,FileRepository
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 Repository very much
depends on the concrete implementation. Applications working with a generic
Repository type must not assume the instance is thread-safe.
FileRepositoryis thread-safe.DfsRepositorythread-safety is determined by its subclass.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRepository(BaseRepositoryBuilder options) Initialize a new repository instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidautoGC(ProgressMonitor monitor) Check whether any housekeeping is required; if yes, run garbage collection; if not, exit without performing any work.voidclose()voidcreate()Create a new Git repository.abstract voidcreate(boolean bare) Create a new Git repository initializing the necessary files and directories.abstract AttributesNodeProviderCreate a newAttributesNodeProvider.protected voiddoClose()Invoked when the use count drops to zero duringclose().final RefGet a ref by name.final RefSearch for a ref by (possibly abbreviated) name.voidfireEvent(RepositoryEvent<?> event) Fire an event to all registered listeners.Objects known to exist but not expressed bygetAllRefs().Deprecated.Map<AnyObjectId,Set<Ref>> Get a map with all objects referenced by a peeled ref.Get the short name of the current branch thatHEADpoints to.Get common dir.abstract StoredConfigGet the configuration of this repository.Get local metadata directorygetFS()Get the used file system abstraction.Get the name of the reference thatHEADpoints to.Read theGIT_DIR/descriptionfile for gitweb.static ListenerListGet the global listener list observing all events in this JVM.abstract StringGet repository identifier.Get the index file location ornullif repository isn't local.protected StringGet the initial branch name of a new repositoryGet listeners observing only events on this repository.abstract ObjectDatabaseGet the object database which stores this repository's data.abstract RefDatabaseGet the reference database which stores the reference namespace.getReflogReader(String refName) Deprecated.use#getRefDatabase().getReflogReader(String)insteadgetReflogReader(Ref ref) Deprecated.use#getRefDatabase().getReflogReader(Ref)insteadgetRemoteName(String refName) Get remote nameGet the names of all known remotesGet the repository stategetTags()Deprecated.usegetRefDatabase().getRefsByPrefix(R_TAGS)insteadGet the root directory of the working tree, where files are checked out for viewing and editing.voidIncrement the use counter by one, requiring a matchedclose().booleanisBare()Whether this repository is barestatic booleanisValidRefName(String refName) Check validity of a ref name.booleanTells whether the work tree is on a case-insensitive file system.Create a new in-core index representation, lock it, and read from disk.Create a new inserter to create objects ingetObjectDatabase().Create a new reader to read objects fromgetObjectDatabase().static StringnormalizeBranchName(String name) Normalizes the passed branch name into a possible valid branch name.abstract voidnotifyIndexChanged(boolean internal) Notify that the index changed by firing an IndexChangedEvent.open(AnyObjectId objectId) Open an object from this repository.open(AnyObjectId objectId, int typeHint) Open an object from this repository.Locate a reference to a commit and immediately parse its content.Return the information stored in the file $GIT_DIR/CHERRY_PICK_HEAD.Return the information stored in the file $GIT_DIR/COMMIT_EDITMSG.Create a new in-core index representation and read an index from disk.Return the information stored in the file $GIT_DIR/MERGE_MSG.Return the information stored in the file $GIT_DIR/MERGE_HEAD.Return the information stored in the file $GIT_DIR/ORIG_HEAD.readRebaseTodo(String path, boolean includeComments) Read a file formatted like the git-rebase-todo file.Return the information stored in the file $GIT_DIR/REVERT_HEAD.Return the information stored in the file $GIT_DIR/SQUASH_MSG.Create a command to rename a ref in this repositoryParse a git revision string and return an object id.abstract voidForce a scan for changed refs.voidsetGitwebDescription(String description) Set theGIT_DIR/descriptionfile for gitweb.static StringshortenRefName(String refName) Get a shortened more user friendly ref nameshortenRemoteBranchName(String refName) Get a shortened more user friendly remote tracking branch nameSimplify an expression, but unlikeresolve(String)it will not resolve a branch passed or resulting from the expression, such as @{-}.static StringstripWorkDir(File workDir, File file) Strip work dir and return normalized repository path.toString()Create a command to update, create or delete a ref in this repository.Create a command to update, create or delete a ref in this repository.voidwriteCherryPickHead(ObjectId head) Write cherry pick commit into $GIT_DIR/CHERRY_PICK_HEAD.voidwriteCommitEditMsg(String msg) Write new content to the file $GIT_DIR/COMMIT_EDITMSG.voidWrite new content to the file $GIT_DIR/MERGE_MSG.voidwriteMergeHeads(List<? extends ObjectId> heads) Write new merge-heads into $GIT_DIR/MERGE_HEAD.voidwriteOrigHead(ObjectId head) Write original HEAD commit into $GIT_DIR/ORIG_HEAD.voidwriteRebaseTodoFile(String path, List<RebaseTodoLine> steps, boolean append) Write a file formatted like a git-rebase-todo file.voidwriteRevertHead(ObjectId head) Write revert commit into $GIT_DIR/REVERT_HEAD.voidWrite new content to the file $GIT_DIR/SQUASH_MSG.
-
Constructor Details
-
Repository
Initialize a new repository instance.- Parameters:
options- options to configure the repository.
-
-
Method Details
-
getGlobalListenerList
Get the global listener list observing all events in this JVM.- Returns:
- the global listener list observing all events in this JVM.
-
getListenerList
Get listeners observing only events on this repository.- Returns:
- listeners observing only events on this repository.
-
fireEvent
Fire an event to all registered listeners.The source repository of the event is automatically set to this repository, before the event is delivered to any listeners.
- Parameters:
event- the event to deliver.
-
create
Create a new Git repository.Repository with working tree is created using this method. This method is the same as
create(false).- Throws:
IOException- if an IO error occurred- See Also:
-
create
Create a new Git repository initializing the necessary files and directories.- Parameters:
bare- if true, a bare repository (a repository without a working directory) is created.- Throws:
IOException- in case of IO problem
-
getDirectory
Get local metadata directory- Returns:
- local metadata directory;
nullif repository isn't local.
-
getIdentifier
Get repository identifier.- Returns:
- repository identifier. The returned identifier has to be unique within a given Git server.
- Since:
- 5.4
-
getCommonDirectory
Get common dir.- Returns:
- $GIT_COMMON_DIR: local common metadata directory;
- Since:
- 7.0
-
getObjectDatabase
Get the object database which stores this repository's data.- Returns:
- the object database which stores this repository's data.
-
newObjectInserter
Create a new inserter to create objects ingetObjectDatabase().- Returns:
- a new inserter to create objects in
getObjectDatabase().
-
newObjectReader
Create a new reader to read objects fromgetObjectDatabase().- Returns:
- a new reader to read objects from
getObjectDatabase().
-
getRefDatabase
Get the reference database which stores the reference namespace.- Returns:
- the reference database which stores the reference namespace.
-
getConfig
Get the configuration of this repository.- Returns:
- the configuration of this repository.
-
createAttributesNodeProvider
Create a newAttributesNodeProvider.- Returns:
- a new
AttributesNodeProvider. ThisAttributesNodeProvideris lazy loaded only once. It means that it will not be updated after loading. Prefer creating new instance for each use. - Since:
- 4.2
-
getFS
Get the used file system abstraction.- Returns:
- the used file system abstraction, or
nullif repository isn't local.
-
open
Open an object from this repository.This is a one-shot call interface which may be faster than allocating a
newObjectReader()to perform the lookup.- Parameters:
objectId- identity of the object to open.- Returns:
- a
ObjectLoaderfor accessing the object. - Throws:
MissingObjectException- the object does not exist.IOException- the object store cannot be accessed.
-
open
@NonNull public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException Open an object from this repository.This is a one-shot call interface which may be faster than allocating a
newObjectReader()to perform the lookup.- Parameters:
objectId- identity of the object to open.typeHint- hint about the type of object being requested, e.g.Constants.OBJ_BLOB;ObjectReader.OBJ_ANYif the object type is not known, or does not matter to the caller.- Returns:
- a
ObjectLoaderfor accessing the object. - Throws:
MissingObjectException- the object does not exist.IncorrectObjectTypeException- typeHint was not OBJ_ANY, and the object's actual type does not match typeHint.IOException- the object store cannot be accessed.
-
updateRef
Create a command to update, create or delete a ref in this repository.- Parameters:
ref- name of the ref the caller wants to modify.- Returns:
- an update command. The caller must finish populating this command and then invoke one of the update methods to actually make a change.
- Throws:
IOException- a symbolic ref was passed in and could not be resolved back to the base ref, as the symbolic ref could not be read.
-
updateRef
Create a command to update, create or delete a ref in this repository.- Parameters:
ref- name of the ref the caller wants to modify.detach- true to create a detached head- Returns:
- an update command. The caller must finish populating this command and then invoke one of the update methods to actually make a change.
- Throws:
IOException- a symbolic ref was passed in and could not be resolved back to the base ref, as the symbolic ref could not be read.
-
renameRef
Create a command to rename a ref in this repository- Parameters:
fromRef- name of ref to rename fromtoRef- name of ref to rename to- Returns:
- an update command that knows how to rename a branch to another.
- Throws:
IOException- the rename could not be performed.
-
resolve
@Nullable public ObjectId resolve(String revstr) throws AmbiguousObjectException, IncorrectObjectTypeException, RevisionSyntaxException, IOException Parse a git revision string and return an object id. Combinations of these operators are supported:- HEAD, MERGE_HEAD, FETCH_HEAD
- SHA-1: a complete or abbreviated SHA-1
- refs/...: a complete reference name
- short-name: a short reference name under
refs/heads,refs/tags, orrefs/remotesnamespace - tag-NN-gABBREV: output from describe, parsed by treating
ABBREVas an abbreviated SHA-1. - id^: first parent of commit id, this is the same
as
id^1 - id^0: ensure id is a commit
- id^n: n-th parent of commit id
- id~n: n-th historical ancestor of id, by first
parent.
id~3is equivalent toid^1^1^1orid^^^. - id:path: Lookup path under tree named by id
- id^{commit}: ensure id is a commit
- id^{tree}: ensure id is a tree
- id^{tag}: ensure id is a tag
- id^{blob}: ensure id is a blob
The following operators are specified by Git conventions, but are not supported by this method:
- ref@{n}: n-th version of ref as given by its reflog
- ref@{time}: value of ref at the designated time
- Parameters:
revstr- A git object references expression- Returns:
- an ObjectId or
nullif revstr can't be resolved to any ObjectId - Throws:
AmbiguousObjectException-revstrcontains an abbreviated ObjectId and this repository contains more than one object which match to the input abbreviation.IncorrectObjectTypeException- the id parsed does not meet the type required to finish applying the operators in the expression.RevisionSyntaxException- the expression is not supported by this implementation, or does not meet the standard syntax.IOException- on serious errors
-
simplify
Simplify an expression, but unlikeresolve(String)it will not resolve a branch passed or resulting from the expression, such as @{-}. Thus this method can be used to process an expression to a method that expects a branch or revision id.- Parameters:
revstr- aStringobject.- Returns:
- object id or ref name from resolved expression or
nullif given expression cannot be resolved - Throws:
AmbiguousObjectException- if a shortened ObjectId was ambiguousIOException- if an IO error occurred
-
incrementOpen
public void incrementOpen()Increment the use counter by one, requiring a matchedclose(). -
close
public void close()Decrement the use count, and maybe close resources.
- Specified by:
closein interfaceAutoCloseable
-
doClose
protected void doClose()Invoked when the use count drops to zero duringclose().The default implementation closes the object and ref databases.
-
toString
-
getFullBranch
Get the name of the reference thatHEADpoints to.This is essentially the same as doing:
return exactRef(Constants.HEAD).getTarget().getName()
Except when HEAD is detached, in which case this method returns the current ObjectId in hexadecimal string format.- Returns:
- name of current branch (for example
refs/heads/master), an ObjectId in hex format if the current branch is detached, ornullif the repository is corrupt and has no HEAD reference. - Throws:
IOException- if an IO error occurred
-
getBranch
Get the short name of the current branch thatHEADpoints to.This is essentially the same as
getFullBranch(), except the leading prefixrefs/heads/is removed from the reference before it is returned to the caller.- Returns:
- name of current branch (for example
master), an ObjectId in hex format if the current branch is detached, ornullif the repository is corrupt and has no HEAD reference. - Throws:
IOException- if an IO error occurred
-
getInitialBranch
Get the initial branch name of a new repository- Returns:
- the initial branch name of a new repository
- Since:
- 5.11
-
getAdditionalHaves
Objects known to exist but not expressed bygetAllRefs().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.
- Returns:
- unmodifiable collection of other known objects.
- Throws:
IOException- if an IO error occurred
-
exactRef
Get a ref by name.- Parameters:
name- the name of the ref to lookup. Must not be a short-hand form; e.g., "master" is not automatically expanded to "refs/heads/master".- Returns:
- the Ref with the given name, or
nullif it does not exist - Throws:
IOException- if an IO error occurred- Since:
- 4.2
-
findRef
Search for a ref by (possibly abbreviated) name.- Parameters:
name- the name of the ref to lookup. May be a short-hand form, e.g. "master" which is automatically expanded to "refs/heads/master" if "refs/heads/master" already exists.- Returns:
- the Ref with the given name, or
nullif it does not exist - Throws:
IOException- if an IO error occurred- Since:
- 4.2
-
getAllRefs
Deprecated.usegetRefDatabase().getRefs()instead.Get mutable map of all known refs, including symrefs like HEAD that may not point to any object yet.- Returns:
- mutable map of all known refs (heads, tags, remotes).
-
getTags
Deprecated.usegetRefDatabase().getRefsByPrefix(R_TAGS)insteadGet mutable map of all tags- 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").
-
getAllRefsByPeeledObjectId
Get a map with all objects referenced by a peeled ref.- Returns:
- a map with all objects referenced by a peeled ref.
- Throws:
IOException- if an IO error occurred
-
getIndexFile
Get the index file location ornullif repository isn't local.- Returns:
- the index file location or
nullif repository isn't local. - Throws:
NoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().
-
parseCommit
public RevCommit parseCommit(AnyObjectId id) throws IncorrectObjectTypeException, IOException, MissingObjectException Locate a reference to a commit and immediately parse its content.This method only returns successfully if the commit object exists, is verified to be a commit, and was parsed without error.
- Parameters:
id- name of the commit object.- Returns:
- reference to the commit object. Never null.
- Throws:
MissingObjectException- the supplied commit does not exist.IncorrectObjectTypeException- the supplied id is not a commit or an annotated tag.IOException- a pack file or loose object could not be read.- Since:
- 4.8
-
readDirCache
@NonNull public DirCache readDirCache() throws NoWorkTreeException, CorruptObjectException, IOExceptionCreate a new in-core index representation and read an index from disk.The new index will be read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.
- Returns:
- a cache representing the contents of the specified index file (if it exists) or an empty cache if the file does not exist.
- Throws:
NoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().IOException- the index file is present but could not be read.CorruptObjectException- the index file is using a format or extension that this library does not support.
-
lockDirCache
@NonNull public DirCache lockDirCache() throws NoWorkTreeException, CorruptObjectException, IOExceptionCreate a new in-core index representation, lock it, and read from disk.The new index will be locked and then read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.
- Returns:
- a cache representing the contents of the specified index file (if it exists) or an empty cache if the file does not exist.
- Throws:
NoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().IOException- the index file is present but could not be read, or the lock could not be obtained.CorruptObjectException- the index file is using a format or extension that this library does not support.
-
getRepositoryState
Get the repository state- Returns:
- the repository state
-
isValidRefName
Check validity of a ref name. It must not contain character that has a special meaning in a Git object reference expression. Some other dangerous characters are also excluded. For portability reasons '\' is excluded- Parameters:
refName- aStringobject.- Returns:
- true if refName is a valid ref name
-
normalizeBranchName
Normalizes the passed branch name into a possible valid branch name. The validity of the returned name should be checked by a subsequent call toisValidRefName(String).Future implementations of this method could be more restrictive or more lenient about the validity of specific characters in the returned name.
The current implementation returns the trimmed input string if this is already a valid branch name. Otherwise it returns a trimmed string with special characters not allowed by
isValidRefName(String)replaced by hyphens ('-') and blanks replaced by underscores ('_'). Leading and trailing slashes, dots, hyphens, and underscores are removed.- Parameters:
name- to normalize- Returns:
- The normalized name or an empty String if it is
nullor empty. - Since:
- 4.7
- See Also:
-
stripWorkDir
Strip work dir and return normalized repository path.- Parameters:
workDir- Work dirfile- File whose path shall be stripped of its workdir- Returns:
- normalized repository relative path or the empty string if the file is not relative to the work directory.
-
isBare
public boolean isBare()Whether this repository is bare- Returns:
- true if this is bare, which implies it has no working directory.
-
getWorkTree
Get the root directory of the working tree, where files are checked out for viewing and editing.- Returns:
- the root directory of the working tree, where files are checked out for viewing and editing.
- Throws:
NoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().
-
isWorkTreeCaseInsensitive
Tells whether the work tree is on a case-insensitive file system.- Returns:
trueif the work tree is case-insensitive;falseotherwise- Throws:
NoWorkTreeException- if the repository is bare- Since:
- 7.2
-
scanForRepoChanges
Force a scan for changed refs. Fires an IndexChangedEvent(false) if changes are detected.- Throws:
IOException- if an IO error occurred
-
notifyIndexChanged
public abstract void notifyIndexChanged(boolean internal) Notify that the index changed by firing an IndexChangedEvent.- Parameters:
internal-trueif the index was changed by the same JGit process- Since:
- 5.0
-
shortenRefName
Get a shortened more user friendly ref name- Parameters:
refName- aStringobject.- Returns:
- a more user friendly ref name
-
shortenRemoteBranchName
Get a shortened more user friendly remote tracking branch name- Parameters:
refName- aStringobject.- Returns:
- the remote branch name part of
refName, i.e. without therefs/remotes/<remote>prefix, ifrefNamerepresents a remote tracking branch; otherwisenull. - Since:
- 3.4
-
getRemoteName
Get remote name- Parameters:
refName- aStringobject.- Returns:
- the remote name part of
refName, i.e. without therefs/remotes/<remote>prefix, ifrefNamerepresents a remote tracking branch; otherwisenull. - Since:
- 3.4
-
getGitwebDescription
Read theGIT_DIR/descriptionfile for gitweb.- Returns:
- description text; null if no description has been configured.
- Throws:
IOException- description cannot be accessed.- Since:
- 4.6
-
setGitwebDescription
Set theGIT_DIR/descriptionfile for gitweb.- Parameters:
description- new description; null to clear the description.- Throws:
IOException- description cannot be persisted.- Since:
- 4.6
-
getReflogReader
@Deprecated(since="7.2") @Nullable public ReflogReader getReflogReader(String refName) throws IOException Deprecated.use#getRefDatabase().getReflogReader(String)insteadGet the reflog reader- Parameters:
refName- aStringobject.- Returns:
- a
ReflogReaderfor the supplied refname, ornullif the named ref does not exist. - Throws:
IOException- the ref could not be accessed.- Since:
- 3.0
-
getReflogReader
@Deprecated(since="7.2") @NonNull public ReflogReader getReflogReader(@NonNull Ref ref) throws IOException Deprecated.use#getRefDatabase().getReflogReader(Ref)insteadGet the reflog reader. Subclasses should override this method and provide a more efficient implementation.- Parameters:
ref- a Ref- Returns:
- a
ReflogReaderfor the supplied ref. - Throws:
IOException- if an IO error occurred- Since:
- 5.13.2
-
readMergeCommitMsg
Return the information stored in the file $GIT_DIR/MERGE_MSG. In this file operations triggering a merge will store a template for the commit message of the merge commit.- Returns:
- a String containing the content of the MERGE_MSG file or
nullif this file doesn't exist - Throws:
IOException- if an IO error occurredNoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().
-
writeMergeCommitMsg
Write new content to the file $GIT_DIR/MERGE_MSG. In this file operations triggering a merge will store a template for the commit message of the merge commit. Ifnullis specified as message the file will be deleted.- Parameters:
msg- the message which should be written ornullto delete the file- Throws:
IOException- if an IO error occurred
-
readCommitEditMsg
Return the information stored in the file $GIT_DIR/COMMIT_EDITMSG. In this file hooks triggered by an operation may read or modify the current commit message.- Returns:
- a String containing the content of the COMMIT_EDITMSG file or
nullif this file doesn't exist - Throws:
IOException- if an IO error occurredNoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().- Since:
- 4.0
-
writeCommitEditMsg
Write new content to the file $GIT_DIR/COMMIT_EDITMSG. In this file hooks triggered by an operation may read or modify the current commit message. Ifnullis specified as message the file will be deleted.- Parameters:
msg- the message which should be written ornullto delete the file- Throws:
IOException- if an IO error occurred- Since:
- 4.0
-
readMergeHeads
Return the information stored in the file $GIT_DIR/MERGE_HEAD. In this file operations triggering a merge will store the IDs of all heads which should be merged together with HEAD.- Returns:
- a list of commits which IDs are listed in the MERGE_HEAD file or
nullif this file doesn't exist. Also if the file exists but is emptynullwill be returned - Throws:
IOException- if an IO error occurredNoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().
-
writeMergeHeads
Write new merge-heads into $GIT_DIR/MERGE_HEAD. In this file operations triggering a merge will store the IDs of all heads which should be merged together with HEAD. Ifnullis specified as list of commits the file will be deleted- Parameters:
heads- a list of commits which IDs should be written to $GIT_DIR/MERGE_HEAD ornullto delete the file- Throws:
IOException- if an IO error occurred
-
readCherryPickHead
Return the information stored in the file $GIT_DIR/CHERRY_PICK_HEAD.- Returns:
- object id from CHERRY_PICK_HEAD file or
nullif this file doesn't exist. Also if the file exists but is emptynullwill be returned - Throws:
IOException- if an IO error occurredNoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().
-
readRevertHead
Return the information stored in the file $GIT_DIR/REVERT_HEAD.- Returns:
- object id from REVERT_HEAD file or
nullif this file doesn't exist. Also if the file exists but is emptynullwill be returned - Throws:
IOException- if an IO error occurredNoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().
-
writeCherryPickHead
Write cherry pick commit into $GIT_DIR/CHERRY_PICK_HEAD. This is used in case of conflicts to store the cherry which was tried to be picked.- Parameters:
head- an object id of the cherry commit ornullto delete the file- Throws:
IOException- if an IO error occurred
-
writeRevertHead
Write revert commit into $GIT_DIR/REVERT_HEAD. This is used in case of conflicts to store the revert which was tried to be picked.- Parameters:
head- an object id of the revert commit ornullto delete the file- Throws:
IOException- if an IO error occurred
-
writeOrigHead
Write original HEAD commit into $GIT_DIR/ORIG_HEAD.- Parameters:
head- an object id of the original HEAD commit ornullto delete the file- Throws:
IOException- if an IO error occurred
-
readOrigHead
Return the information stored in the file $GIT_DIR/ORIG_HEAD.- Returns:
- object id from ORIG_HEAD file or
nullif this file doesn't exist. Also if the file exists but is emptynullwill be returned - Throws:
IOException- if an IO error occurredNoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().
-
readSquashCommitMsg
Return the information stored in the file $GIT_DIR/SQUASH_MSG. In this file operations triggering a squashed merge will store a template for the commit message of the squash commit.- Returns:
- a String containing the content of the SQUASH_MSG file or
nullif this file doesn't exist - Throws:
IOException- if an IO error occurredNoWorkTreeException- if this is bare, which implies it has no working directory. SeeisBare().
-
writeSquashCommitMsg
Write new content to the file $GIT_DIR/SQUASH_MSG. In this file operations triggering a squashed merge will store a template for the commit message of the squash commit. Ifnullis specified as message the file will be deleted.- Parameters:
msg- the message which should be written ornullto delete the file- Throws:
IOException- if an IO error occurred
-
readRebaseTodo
@NonNull public List<RebaseTodoLine> readRebaseTodo(String path, boolean includeComments) throws IOException Read a file formatted like the git-rebase-todo file. The "done" file is also formatted like the git-rebase-todo file. These files can be found in .git/rebase-merge/ or .git/rebase-append/ folders.- Parameters:
path- path to the file relative to the repository's git-dir. E.g. "rebase-merge/git-rebase-todo" or "rebase-append/done"includeComments-trueif also comments should be reported- Returns:
- the list of steps
- Throws:
IOException- if an IO error occurred- Since:
- 3.2
-
writeRebaseTodoFile
public void writeRebaseTodoFile(String path, List<RebaseTodoLine> steps, boolean append) throws IOException Write a file formatted like a git-rebase-todo file.- Parameters:
path- path to the file relative to the repository's git-dir. E.g. "rebase-merge/git-rebase-todo" or "rebase-append/done"steps- the steps to be writtenappend- whether to append to an existing file or to write a new file- Throws:
IOException- if an IO error occurred- Since:
- 3.2
-
getRemoteNames
Get the names of all known remotes- Returns:
- the names of all known remotes
- Since:
- 3.4
-
autoGC
Check whether any housekeeping is required; if yes, run garbage collection; if not, exit without performing any work. Some JGit commands run autoGC after performing operations that could create many loose objects.Currently this option is supported for repositories of type
FileRepositoryonly. SeeGC.setAuto(boolean)for configuration details.- Parameters:
monitor- to report progress- Since:
- 4.6
-
getRefDatabase().getRefs()instead.