Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.storage.dfs

public abstract Class DfsRefDatabase

extends RefDatabase
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.internal.storage.dfs.DfsReftableDatabase
Static Imports
org.eclipse.jgit.lib.Ref.UNDEFINED_UPDATE_INDEX, .Ref.Storage.NEW

Abstract DfsRefDatabase class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
DfsRefDatabase.RefCache

Collection of references managed by this database.

Field Summary

Modifier and TypeField and Description
private final AtomicReference<DfsRefDatabase.RefCache>
private final DfsRepository
Inherited from org.eclipse.jgit.lib.RefDatabase:
additionalRefsNamesALLMAX_SYMBOLIC_REF_DEPTHSEARCH_PATH

Constructor Summary

AccessConstructor and Description
protected
DfsRefDatabase(DfsRepository
the repository this database instance manages references for.
repository
)

Initialize the reference database for a repository.

Method Summary

Modifier and TypeMethod and Description
protected void
cachePeeledState(Ref
the old reference.
oldLeaf
,
Ref
the new reference, with peel information.
newLeaf
)

Update the cached peeled state of a reference

The ref database invokes this method after it peels a reference that had not been peeled before.

pack-priv void
public void
close()

Implements abstract org.eclipse.jgit.lib.RefDatabase.close.

Close any resources held by this database.

protected abstract boolean

Returns:

true if the put was successful; false otherwise.
compareAndPut
(Ref
old value to compare to. If the reference is expected to not exist the old value has a storage of org.eclipse.jgit.lib.Ref.Storage#NEW and an ObjectId value of null.
oldRef
,
Ref
new reference to store.
newRef
)

Compare a reference, and put if it matches.

protected abstract boolean

Returns:

true if the remove was successful; false otherwise.
compareAndRemove
(Ref
the old reference information that was previously read.
oldRef
)

Compare a reference, and delete if it matches.

public void
create()

Implements abstract org.eclipse.jgit.lib.RefDatabase.create.

Initialize a new reference database at this location.

pack-priv Ref
doPeel(Ref leaf)

public Ref
exactRef(String
the unabbreviated name of the reference.
name
)

Implements abstract org.eclipse.jgit.lib.RefDatabase.exactRef.

Read a single reference.

pack-priv boolean
public List<Ref>
getAdditionalRefs()

Implements abstract org.eclipse.jgit.lib.RefDatabase.getAdditionalRefs.

Get the additional reference-like entities from the repository.

public Map<String, Ref>
getRefs(String
prefix to search the namespace with; must end with /. If the empty string (ALL), obtain a complete snapshot of all references.
prefix
)

Implements abstract org.eclipse.jgit.lib.RefDatabase.getRefs.

Get a section of the reference namespace.

protected DfsRepository

Returns:

the repository the database holds the references of.
getRepository
()

Get the repository the database holds the references of.

public boolean
isNameConflicting(String
proposed name.
refName
)

Implements abstract org.eclipse.jgit.lib.RefDatabase.isNameConflicting.

Determine if a proposed reference name overlaps with an existing one.

public RefRename
newRename(String
name of reference to rename from
fromName
,
String
name of reference to rename to
toName
)

Implements abstract org.eclipse.jgit.lib.RefDatabase.newRename.

Create a new update command to rename a reference.

public RefUpdate
newUpdate(String
the name of the reference.
refName
,
boolean
if true and name is currently a org.eclipse.jgit.lib.SymbolicRef, the update will replace it with an org.eclipse.jgit.lib.ObjectIdRef. Otherwise, the update will recursively traverse org.eclipse.jgit.lib.SymbolicRefs and operate on the leaf org.eclipse.jgit.lib.ObjectIdRef.
detach
)

Implements abstract org.eclipse.jgit.lib.RefDatabase.newUpdate.

Create a new update command to create, modify or delete a reference.

public Ref
peel(Ref
The reference to peel
ref
)

Implements abstract org.eclipse.jgit.lib.RefDatabase.peel.

Peel a possibly unpeeled reference by traversing the annotated tags.

private DfsRefDatabase.RefCache
read()

pack-priv static Ref
recreate(Ref old, Ref leaf, boolean hasVersioning)

public void
refresh()

Overrides org.eclipse.jgit.lib.RefDatabase.refresh.

Triggers a refresh of all internal data structures.

pack-priv void
removed(String refName)

private Ref
resolve(Ref ref, int depth, RefList<Ref> loose)

protected abstract DfsRefDatabase.RefCache

Returns:

all current references of the repository.
scanAllRefs
()

Read all known references in the repository.

pack-priv void
stored(Ref ref)

Inherited from org.eclipse.jgit.lib.RefDatabase:
exactReffindReffindReffirstExactRefgetConflictingNamesgetReflogReadergetReflogReadergetRefsgetRefsByPrefixgetRefsByPrefixgetRefsByPrefixWithExclusionsgetTipsWithSha1hasFastTipsWithSha1hasRefshasVersioningnewBatchUpdatepackRefsperformsAtomicTransactions

Field Detail

cacheback to summary
private final AtomicReference<DfsRefDatabase.RefCache> cache
repositoryback to summary
private final DfsRepository repository

Constructor Detail

DfsRefDatabaseback to summary
protected DfsRefDatabase(DfsRepository repository)

Initialize the reference database for a repository.

Parameters
repository:DfsRepository

the repository this database instance manages references for.

Method Detail

cachePeeledStateback to summary
protected void cachePeeledState(Ref oldLeaf, Ref newLeaf)

Update the cached peeled state of a reference

The ref database invokes this method after it peels a reference that had not been peeled before. This allows the storage to cache the peel state of the reference, and if it is actually peelable, the target that it peels to, so that on-the-fly peeling doesn't have to happen on the next reference read.

Parameters
oldLeaf:Ref

the old reference.

newLeaf:Ref

the new reference, with peel information.

clearCacheback to summary
pack-priv void clearCache()
closeback to summary
public void close()

Implements abstract org.eclipse.jgit.lib.RefDatabase.close.

Doc from org.eclipse.jgit.lib.RefDatabase.close.

Close any resources held by this database.

Annotations
@Override
compareAndPutback to summary
protected abstract boolean compareAndPut(Ref oldRef, Ref newRef) throws IOException

Compare a reference, and put if it matches.

Two reference match if and only if they satisfy the following:

  • If one reference is a symbolic ref, the other one should be a symbolic ref.
  • If both are symbolic refs, the target names should be same.
  • If both are object ID refs, the object IDs should be same.
Parameters
oldRef:Ref

old value to compare to. If the reference is expected to not exist the old value has a storage of org.eclipse.jgit.lib.Ref.Storage#NEW and an ObjectId value of null.

newRef:Ref

new reference to store.

Returns:boolean

true if the put was successful; false otherwise.

Exceptions
IOException:
the reference cannot be put due to a system error.
compareAndRemoveback to summary
protected abstract boolean compareAndRemove(Ref oldRef) throws IOException

Compare a reference, and delete if it matches.

Parameters
oldRef:Ref

the old reference information that was previously read.

Returns:boolean

true if the remove was successful; false otherwise.

Exceptions
IOException:
the reference could not be removed due to a system error.
createback to summary
public void create()

Implements abstract org.eclipse.jgit.lib.RefDatabase.create.

Doc from org.eclipse.jgit.lib.RefDatabase.create.

Initialize a new reference database at this location.

Annotations
@Override
doPeelback to summary
pack-priv Ref doPeel(Ref leaf) throws MissingObjectException, IOException
exactRefback to summary
public Ref exactRef(String name) throws IOException

Implements abstract org.eclipse.jgit.lib.RefDatabase.exactRef.

Doc from org.eclipse.jgit.lib.RefDatabase.exactRef.

Read a single reference.

Unlike findRef, this method expects an unshortened reference name and does not search using the standard SEARCH_PATH.

Parameters
name:String

the unabbreviated name of the reference.

Returns:Ref

the reference (if it exists); else null.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
existsback to summary
pack-priv boolean exists() throws IOException
getAdditionalRefsback to summary
public List<Ref> getAdditionalRefs()

Implements abstract org.eclipse.jgit.lib.RefDatabase.getAdditionalRefs.

Doc from org.eclipse.jgit.lib.RefDatabase.getAdditionalRefs.

Get 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 by findRef(String) and exactRef(String).

Returns:List<Ref>

a list of additional refs

Annotations
@Override
getRefsback to summary
public Map<String, Ref> getRefs(String prefix) throws IOException

Implements abstract org.eclipse.jgit.lib.RefDatabase.getRefs.

Doc from org.eclipse.jgit.lib.RefDatabase.getRefs.

Get a section of the reference namespace.

Parameters
prefix:String

prefix to search the namespace with; must end with /. If the empty string (ALL), obtain a complete snapshot of all references.

Returns:Map<String, Ref>

modifiable map that is a complete snapshot of the current reference namespace, with prefix removed from the start of each key. The map can be an unsorted map.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
getRepositoryback to summary
protected DfsRepository getRepository()

Get the repository the database holds the references of.

Returns:DfsRepository

the repository the database holds the references of.

isNameConflictingback to summary
public boolean isNameConflicting(String refName) throws IOException

Implements abstract org.eclipse.jgit.lib.RefDatabase.isNameConflicting.

Doc from org.eclipse.jgit.lib.RefDatabase.isNameConflicting.

Determine 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.

Parameters
refName:String

proposed name.

Returns:boolean

true if the name overlaps with an existing reference; false if using this name right now would be safe.

Annotations
@Override
Exceptions
IOException:
the database could not be read to check for conflicts.
newRenameback to summary
public RefRename newRename(String fromName, String toName) throws IOException

Implements abstract org.eclipse.jgit.lib.RefDatabase.newRename.

Doc from org.eclipse.jgit.lib.RefDatabase.newRename.

Create a new update command to rename a reference.

Parameters
fromName:String

name of reference to rename from

toName:String

name of reference to rename to

Returns:RefRename

an update command that knows how to rename a branch to another.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
newUpdateback to summary
public RefUpdate newUpdate(String refName, boolean detach) throws IOException

Implements abstract org.eclipse.jgit.lib.RefDatabase.newUpdate.

Doc from org.eclipse.jgit.lib.RefDatabase.newUpdate.

Create a new update command to create, modify or delete a reference.

Parameters
refName:String

the name of the reference.

detach:boolean

if true and name is currently a org.eclipse.jgit.lib.SymbolicRef, the update will replace it with an org.eclipse.jgit.lib.ObjectIdRef. Otherwise, the update will recursively traverse org.eclipse.jgit.lib.SymbolicRefs and operate on the leaf org.eclipse.jgit.lib.ObjectIdRef.

Returns:RefUpdate

a new update for the requested name; never null.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
peelback to summary
public Ref peel(Ref ref) throws IOException

Implements abstract org.eclipse.jgit.lib.RefDatabase.peel.

Doc from org.eclipse.jgit.lib.RefDatabase.peel.

Peel 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 org.eclipse.jgit.lib.Ref#isPeeled() will be true.

Implementors should check org.eclipse.jgit.lib.Ref#isPeeled() before performing any additional work effort.

Parameters
ref:Ref

The reference to peel

Returns:Ref

ref if ref.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 (or null).

Annotations
@Override
Exceptions
IOException:
the reference space or object space cannot be accessed.
readback to summary
private DfsRefDatabase.RefCache read() throws IOException
recreateback to summary
pack-priv static Ref recreate(Ref old, Ref leaf, boolean hasVersioning)
refreshback to summary
public void refresh()

Overrides org.eclipse.jgit.lib.RefDatabase.refresh.

Doc from org.eclipse.jgit.lib.RefDatabase.refresh.

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.

Annotations
@Override
removedback to summary
pack-priv void removed(String refName)
resolveback to summary
private Ref resolve(Ref ref, int depth, RefList<Ref> loose) throws IOException
scanAllRefsback to summary
protected abstract DfsRefDatabase.RefCache scanAllRefs() throws IOException

Read all known references in the repository.

Returns:DfsRefDatabase.RefCache

all current references of the repository.

Exceptions
IOException:
references cannot be accessed.
storedback to summary
pack-priv void stored(Ref ref)
org.eclipse.jgit.internal.storage.dfs back to summary

public Class DfsRefDatabase.RefCache

extends Object
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.RefCache

Collection of references managed by this database.

Field Summary

Modifier and TypeField and Description
pack-priv final RefList<Ref>
pack-priv final RefList<Ref>

Constructor Summary

AccessConstructor and Description
public
RefCache(RefList<Ref>
references that carry an ObjectId, and all of sym.
ids
,
RefList<Ref>
references that are symbolic references to others.
sym
)

Initialize a new reference cache.

pack-priv

Method Summary

Modifier and TypeMethod and Description
public Ref

Returns:

the reference, if it exists, otherwise null.
get
(String
full name of the reference.
name
)

Find a reference by name.

public DfsRefDatabase.RefCache

Returns:

a copy of this cache, with the reference added or replaced.
put
(Ref
reference to add or replace.
ref
)

Obtain a modified copy of the cache with a ref stored.

public DfsRefDatabase.RefCache

Returns:

a copy of this cache, with the reference removed.
remove
(String
reference to remove, if it exists.
refName
)

Obtain a modified copy of the cache with the ref removed.

public int

Returns:

number of references in this cache.
size
()

Get number of references

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

idsback to summary
pack-priv final RefList<Ref> ids
symback to summary
pack-priv final RefList<Ref> sym

Constructor Detail

RefCacheback to summary
public RefCache(RefList<Ref> ids, RefList<Ref> sym)

Initialize a new reference cache.

The two reference lists supplied must be sorted in correct order (string compare order) by name.

Parameters
ids:RefList<Ref>

references that carry an ObjectId, and all of sym.

sym:RefList<Ref>

references that are symbolic references to others.

RefCacheback to summary
pack-priv RefCache(RefList<Ref> ids, DfsRefDatabase.RefCache old)

Method Detail

getback to summary
public Ref get(String name)

Find a reference by name.

Parameters
name:String

full name of the reference.

Returns:Ref

the reference, if it exists, otherwise null.

putback to summary
public DfsRefDatabase.RefCache put(Ref ref)

Obtain a modified copy of the cache with a ref stored.

This cache instance is not modified by this method.

Parameters
ref:Ref

reference to add or replace.

Returns:DfsRefDatabase.RefCache

a copy of this cache, with the reference added or replaced.

removeback to summary
public DfsRefDatabase.RefCache remove(String refName)

Obtain a modified copy of the cache with the ref removed.

This cache instance is not modified by this method.

Parameters
refName:String

reference to remove, if it exists.

Returns:DfsRefDatabase.RefCache

a copy of this cache, with the reference removed.

sizeback to summary
public int size()

Get number of references

Returns:int

number of references in this cache.