public class RefTree extends Object
The root corresponds to the "refs/"
subdirectory, for example the
default reference "refs/heads/master"
is stored at path
"heads/master"
in a RefTree
.
Normal references are stored as FileMode.GITLINK
tree entries. The
ObjectId in the tree entry is the ObjectId the reference refers to.
Symbolic references are stored as FileMode.SYMLINK
entries, with the
blob storing the name of the target reference.
Annotated tags also store the peeled object using a GITLINK
entry
with the suffix " ^"
(space carrot), for example
"tags/v1.0"
stores the annotated tag object, while
"tags/v1.0 ^"
stores the commit the tag annotates.
HEAD
is a special case and stored as "..HEAD"
.
Modifier and Type | Field and Description |
---|---|
static String |
PEELED_SUFFIX
Suffix applied to GITLINK to indicate its the peeled value of a tag.
|
Modifier and Type | Method and Description |
---|---|
boolean |
apply(Collection<Command> cmdList)
Attempt a batch of commands against this RefTree.
|
RefTree |
copy() |
Ref |
exactRef(ObjectReader reader,
String name)
Read one reference.
|
static RefTree |
newEmptyTree()
Create an empty reference tree.
|
static RefTree |
read(ObjectReader reader,
RevTree tree)
Load a reference tree.
|
static String |
refName(String path)
Convert a path name in a RefTree to the reference name known by Git.
|
ObjectId |
writeTree(ObjectInserter inserter)
Write this reference tree.
|
public static final String PEELED_SUFFIX
public static RefTree newEmptyTree()
public static RefTree read(ObjectReader reader, RevTree tree) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException
reader
- reader to scan the reference tree with.tree
- the tree to read.IOException
- the repository cannot be accessed through the reader.CorruptObjectException
- a tree object is corrupt and cannot be read.IncorrectObjectTypeException
- a tree object wasn't actually a tree.MissingObjectException
- a reference tree object doesn't exist.@Nullable public Ref exactRef(ObjectReader reader, String name) throws IOException
References are always returned peeled (Ref.isPeeled()
is true).
If the reference points to an annotated tag, the returned reference will
be peeled and contain Ref.getPeeledObjectId()
.
If the reference is a symbolic reference and the chain depth is less than
RefDatabase.MAX_SYMBOLIC_REF_DEPTH
the
returned reference is resolved. If the chain depth is longer, the
symbolic reference is returned without resolving.
reader
- to access objects necessary to read the requested reference.name
- name of the reference to read.IOException
- cannot read a symbolic reference target.public boolean apply(Collection<Command> cmdList)
The batch is applied atomically, either all commands apply at once, or they all reject and the RefTree is left unmodified.
On success (when this method returns true
) the command results
are left as-is (probably NOT_ATTEMPTED
). Result fields are set
only when this method returns false
to indicate failure.
cmdList
- to apply. All commands should still have result NOT_ATTEMPTED.public static String refName(String path)
path
- name read from the RefTree structure, for example
"heads/master"
."refs/heads/master"
.public ObjectId writeTree(ObjectInserter inserter) throws IOException
inserter
- inserter to use when writing trees to the object database.
Caller is responsible for flushing the inserter before trying
to read the objects, or exposing them through a reference.IOException
- a tree could not be written.public RefTree copy()
Copyright © 2016 Eclipse JGit Project. All rights reserved.