Class TreeCreator

java.lang.Object
com.google.gerrit.server.edit.tree.TreeCreator

public class TreeCreator extends Object
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 Details

    • basedOn

      public static TreeCreator basedOn(org.eclipse.jgit.revwalk.RevCommit baseCommit)
    • basedOnTree

      public static TreeCreator basedOnTree(org.eclipse.jgit.lib.ObjectId baseTreeId, com.google.common.collect.ImmutableList<? extends org.eclipse.jgit.lib.ObjectId> baseParents)
    • basedOnEmptyTree

      public static TreeCreator basedOnEmptyTree()
    • addTreeModifications

      public void addTreeModifications(List<TreeModification> treeModifications)
      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 TreeModifications (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