Class TreeCreator
java.lang.Object
com.google.gerrit.server.edit.tree.TreeCreator
A creator for a new Git tree. To create the new tree, the tree of another commit is taken as a
basis and modified. Alternatively, an empty tree can serve as base.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTreeModifications
(List<TreeModification> treeModifications) Apply modifications to the tree which is taken as a basis.static TreeCreator
basedOn
(org.eclipse.jgit.revwalk.RevCommit baseCommit) static TreeCreator
basedOn
(org.eclipse.jgit.revwalk.RevCommit baseCommit, org.eclipse.jgit.lib.ObjectInserter objectInserter) static TreeCreator
static TreeCreator
basedOnTree
(org.eclipse.jgit.lib.ObjectId baseTreeId, com.google.common.collect.ImmutableList<? extends org.eclipse.jgit.lib.ObjectId> baseParents) org.eclipse.jgit.lib.ObjectId
createNewTreeAndGetId
(org.eclipse.jgit.lib.Repository repository) Creates the new tree.
-
Method Details
-
basedOn
-
basedOn
public static TreeCreator basedOn(org.eclipse.jgit.revwalk.RevCommit baseCommit, org.eclipse.jgit.lib.ObjectInserter objectInserter) -
basedOnTree
public static TreeCreator basedOnTree(org.eclipse.jgit.lib.ObjectId baseTreeId, com.google.common.collect.ImmutableList<? extends org.eclipse.jgit.lib.ObjectId> baseParents) -
basedOnEmptyTree
-
addTreeModifications
Apply modifications to the tree which is taken as a basis. If this method is called multiple times, the modifications are applied subsequently in exactly the order they were provided (though JGit applies some internal optimizations which involve sorting, too).Beware: All provided
TreeModification
s (even from previous calls of this method) must touch different file paths!- Parameters:
treeModifications
- modifications which should be applied to the base tree
-
createNewTreeAndGetId
public org.eclipse.jgit.lib.ObjectId createNewTreeAndGetId(org.eclipse.jgit.lib.Repository repository) throws IOException Creates the new tree. When this method is called, the specified base tree is read from the repository, the specified modifications are applied, and the resulting tree is written to the object store of the repository.- Parameters:
repository
- the affected Git repository- Returns:
- the
ObjectId
of the created tree - Throws:
IOException
- if problems arise when accessing the repository
-