-
Field Summary
Fields inherited from class org.eclipse.jgit.lib.RefDatabase
additionalRefsNames, ALL, MAX_SYMBOLIC_REF_DEPTH, SEARCH_PATH -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close any resources held by this database.voidRuns a full compaction for GC purposes.static voidconvertFrom(FileRepository repo, boolean writeLogs) Convert FileRepository to a FileReftableDatabasevoidcreate()Initialize a new reference database at this location.Read a single reference.Get the additional reference-like entities from the repository.getReflogReader(String refname) Get the reflog readergetReflogReader(Ref ref) Get the reflog reader.getRefs()Returns all refs.Get a section of the reference namespace.getRefsByPrefixWithExclusions(String include, Set<String> excludes) Returns refs whose names start with a given prefix excluding all refs that start with one of the given prefixes.booleanIf the ref database does not support fast inverse queries, it may be advantageous to build a complete SHA1 to ref map in advance for multiple uses.booleanWhether the reftable stack is auto-refreshed if it is out of date.booleanisNameConflicting(String name) Determine if a proposed reference name overlaps with an existing one.static booleanisReftable(File repoDir) Whether the given repo uses reftable for refdb storageCreate a new batch update to attempt on this database.Create a new update command to rename a reference.Create a new update command to create, modify or delete a reference.voidpackRefs(ProgressMonitor pm, PackRefsCommand packRefs) Optimize pack ref storage.Peel a possibly unpeeled reference by traversing the annotated tags.booleanWhether the database is capable of performing batch updates as atomic transactions.voidrefresh()Check if the reftable stack is up to date, and if not, reload it.voidsetAutoRefresh(boolean autoRefresh) Whether to auto-refresh the reftable stack if it is out of date.Methods inherited from class org.eclipse.jgit.lib.RefDatabase
exactRef, findRef, findRef, firstExactRef, getConflictingNames, getRefsByPrefix, getRefsByPrefix, getTipsWithSha1, hasRefs, hasVersioning
-
Method Details
-
getReflogReader
Description copied from class:RefDatabaseGet the reflog reader.- Specified by:
getReflogReaderin classRefDatabase- Parameters:
ref- a Ref- Returns:
- a
ReflogReaderfor the supplied ref. - Throws:
IOException- if an IO error occurred
-
getReflogReader
Description copied from class:RefDatabaseGet the reflog reader- Overrides:
getReflogReaderin classRefDatabase- Parameters:
refname- aStringobject.- Returns:
- a
ReflogReaderfor the supplied refname, ornullif the named ref does not exist. - Throws:
IOException- the ref could not be accessed.
-
isReftable
Whether the given repo uses reftable for refdb storage- Parameters:
repoDir- the repository's metadata directory- Returns:
- whether the given repo uses reftable for refdb storage.
-
hasFastTipsWithSha1
Description copied from class:RefDatabaseIf the ref database does not support fast inverse queries, it may be advantageous to build a complete SHA1 to ref map in advance for multiple uses. To let applications decide on this decision, this function indicates whether the inverse map is available.- Overrides:
hasFastTipsWithSha1in classRefDatabase- Returns:
- whether this RefDatabase supports fast inverse ref queries.
- Throws:
IOException- on I/O problems.
-
packRefs
Optimize pack ref storage. For Reftable, all the data is compacted into a single table.- Overrides:
packRefsin classRefDatabase- Parameters:
pm- a progress monitorpackRefs-PackRefsCommandto control ref packing behavior- Throws:
IOException- if an IO error occurred
-
compactFully
Runs a full compaction for GC purposes.- Throws:
IOException- on I/O errors
-
performsAtomicTransactions
public boolean performsAtomicTransactions()Description copied from class:RefDatabaseWhether the database is capable of performing batch updates as atomic transactions.If true, by default
BatchRefUpdateinstances will perform updates atomically, meaning either all updates will succeed, or all updates will fail. It is still possible to turn off this behavior on a per-batch basis by callingupdate.setAtomic(false).If false,
BatchRefUpdateinstances will never perform updates atomically, and callingupdate.setAtomic(true)will cause the entire batch to fail withREJECTED_OTHER_REASON.This definition of atomicity is stronger than what is provided by
ReceivePack.ReceivePackwill attempt to reject all commands if it knows in advance some commands may fail, even if the storage layer does not support atomic transactions. Here, atomicity applies even in the case of unforeseeable errors.- Overrides:
performsAtomicTransactionsin classRefDatabase- Returns:
- whether transactions are atomic by default.
-
newBatchUpdate
Description copied from class:RefDatabaseCreate a new batch update to attempt on this database.The default implementation performs a sequential update of each command.
- Overrides:
newBatchUpdatein classRefDatabase- Returns:
- a new batch update object.
-
newUpdate
Description copied from class:RefDatabaseCreate a new update command to create, modify or delete a reference.- Specified by:
newUpdatein classRefDatabase- Parameters:
refName- the name of the reference.detach- iftrueandnameis currently aSymbolicRef, the update will replace it with anObjectIdRef. Otherwise, the update will recursively traverseSymbolicRefs and operate on the leafObjectIdRef.- Returns:
- a new update for the requested name; never null.
- Throws:
IOException- the reference space cannot be accessed.
-
exactRef
Description copied from class:RefDatabaseRead a single reference.Unlike
RefDatabase.findRef(java.lang.String), this method expects an unshortened reference name and does not search using the standardRefDatabase.SEARCH_PATH.- Specified by:
exactRefin classRefDatabase- Parameters:
name- the unabbreviated name of the reference.- Returns:
- the reference (if it exists); else
null. - Throws:
IOException- the reference space cannot be accessed.
-
getRefs
Description copied from class:RefDatabaseReturns all refs.This includes
HEAD, branches underref/heads/, tags underrefs/tags/, etc. It does not include pseudo-refs likeFETCH_HEAD; for those, seeRefDatabase.getAdditionalRefs().Symbolic references to a non-existent ref (for example,
HEADpointing to a branch yet to be born) are not included.Callers interested in only a portion of the ref hierarchy can call
RefDatabase.getRefsByPrefix(java.lang.String)instead.- Overrides:
getRefsin classRefDatabase- Returns:
- immutable list of all refs.
- Throws:
IOException- the reference space cannot be accessed.
-
getRefs
Description copied from class:RefDatabaseGet a section of the reference namespace.- Specified by:
getRefsin classRefDatabase- Parameters:
prefix- prefix to search the namespace with; must end with/. If the empty string (RefDatabase.ALL), obtain a complete snapshot of all references.- Returns:
- modifiable map that is a complete snapshot of the current
reference namespace, with
prefixremoved from the start of each key. The map can be an unsorted map. - Throws:
IOException- the reference space cannot be accessed.
-
getRefsByPrefixWithExclusions
public List<Ref> getRefsByPrefixWithExclusions(String include, Set<String> excludes) throws IOException Description copied from class:RefDatabaseReturns refs whose names start with a given prefix excluding all refs that start with one of the given prefixes.The default implementation is not efficient. Implementors of
RefDatabaseshould override this method directly if a better implementation is possible.- Overrides:
getRefsByPrefixWithExclusionsin classRefDatabase- Parameters:
include- string that names of refs should start with; may be empty.excludes- strings that names of refs can't start with; may be empty.- Returns:
- immutable list of refs whose names start with
prefixand none of the strings inexcludes. - Throws:
IOException- the reference space cannot be accessed.
-
getAdditionalRefs
Description copied from class:RefDatabaseGet the additional reference-like entities from the repository.The result list includes non-ref items such as MERGE_HEAD and FETCH_RESULT cast to be refs. The names of these refs are not returned by
getRefs()but are accepted byRefDatabase.findRef(String)andRefDatabase.exactRef(String).- Specified by:
getAdditionalRefsin classRefDatabase- Returns:
- a list of additional refs
- Throws:
IOException- the reference space cannot be accessed.
-
peel
Description copied from class:RefDatabasePeel a possibly unpeeled reference by traversing the annotated tags.If the reference cannot be peeled (as it does not refer to an annotated tag) the peeled id stays null, but
Ref.isPeeled()will be true.Implementors should check
Ref.isPeeled()before performing any additional work effort.- Specified by:
peelin classRefDatabase- Parameters:
ref- The reference to peel- Returns:
refifref.isPeeled()is true; otherwise a new Ref object representing the same data as Ref, but isPeeled() will be true and getPeeledObjectId() will contain the peeled object (ornull).- Throws:
IOException- the reference space or object space cannot be accessed.
-
setAutoRefresh
public void setAutoRefresh(boolean autoRefresh) Whether to auto-refresh the reftable stack if it is out of date.- Parameters:
autoRefresh- whether to auto-refresh the reftable stack if it is out of date.
-
isAutoRefresh
public boolean isAutoRefresh()Whether the reftable stack is auto-refreshed if it is out of date.- Returns:
- whether the reftable stack is auto-refreshed if it is out of date.
-
refresh
public void refresh()Check if the reftable stack is up to date, and if not, reload it.Triggers a refresh of all internal data structures.
In case the RefDatabase implementation has internal caches this method will trigger that all these caches are cleared.
Implementors should overwrite this method if they use any kind of caches.
- Overrides:
refreshin classRefDatabase
-
newRename
Description copied from class:RefDatabaseCreate a new update command to rename a reference.- Specified by:
newRenamein classRefDatabase- Parameters:
fromName- name of reference to rename fromtoName- name of reference to rename to- Returns:
- an update command that knows how to rename a branch to another.
- Throws:
IOException- the reference space cannot be accessed.
-
isNameConflicting
Description copied from class:RefDatabaseDetermine if a proposed reference name overlaps with an existing one.Reference names use '/' as a component separator, and may be stored in a hierarchical storage such as a directory on the local filesystem.
If the reference "refs/heads/foo" exists then "refs/heads/foo/bar" must not exist, as a reference cannot have a value and also be a container for other references at the same time.
If the reference "refs/heads/foo/bar" exists than the reference "refs/heads/foo" cannot exist, for the same reason.
- Specified by:
isNameConflictingin classRefDatabase- Parameters:
name- proposed name.- Returns:
- true if the name overlaps with an existing reference; false if using this name right now would be safe.
- Throws:
IOException- the database could not be read to check for conflicts.- See Also:
-
close
public void close()Description copied from class:RefDatabaseClose any resources held by this database.- Specified by:
closein classRefDatabase
-
create
Description copied from class:RefDatabaseInitialize a new reference database at this location.- Specified by:
createin classRefDatabase- Throws:
IOException- the database could not be created.
-
convertFrom
Convert FileRepository to a FileReftableDatabase- Parameters:
repo- the repositorywriteLogs- whether to write reflogs- Throws:
IOException- on IO error
-