Java Code Examples for org.eclipse.jgit.revwalk.RevWalk#parseTree()

The following examples show how to use org.eclipse.jgit.revwalk.RevWalk#parseTree() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayoutHelper.java    From git-as-svn with GNU General Public License v2.0 6 votes vote down vote up
@Nullable
static RevCommit loadOriginalCommit(@NotNull ObjectReader reader, @Nullable ObjectId cacheCommit) throws IOException {
  final RevWalk revWalk = new RevWalk(reader);
  if (cacheCommit != null) {
    final RevCommit revCommit = revWalk.parseCommit(cacheCommit);
    revWalk.parseTree(revCommit.getTree());

    final CanonicalTreeParser treeParser = new CanonicalTreeParser(GitRepository.emptyBytes, reader, revCommit.getTree());
    while (!treeParser.eof()) {
      if (treeParser.getEntryPathString().equals(ENTRY_COMMIT_REF)) {
        return revWalk.parseCommit(treeParser.getEntryObjectId());
      }
      treeParser.next();
    }
  }
  return null;
}
 
Example 2
Source File: GitRepoMetaData.java    From GitFx with Apache License 2.0 5 votes vote down vote up
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException,
        MissingObjectException,
        IncorrectObjectTypeException {
    RevWalk walk = new RevWalk(repository) ;
    RevCommit commit = walk.parseCommit(ObjectId.fromString(objectId));
    RevTree tree = walk.parseTree(commit.getTree().getId());
    CanonicalTreeParser oldTreeParser = new CanonicalTreeParser();
    ObjectReader oldReader = repository.newObjectReader();
    oldTreeParser.reset(oldReader, tree.getId());
    walk.dispose();
    return oldTreeParser;
}
 
Example 3
Source File: PGA.java    From coming with MIT License 5 votes vote down vote up
private AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException {
    // from the commit we can build the tree which allows us to construct the TreeParser
    //noinspection Duplicates
    RevWalk walk = new RevWalk(repository);
    RevCommit commit = walk.parseCommit(repository.resolve(objectId));
    RevTree tree = walk.parseTree(commit.getTree().getId());

    CanonicalTreeParser treeParser = new CanonicalTreeParser();
    ObjectReader reader = repository.newObjectReader();
    treeParser.reset(reader, tree.getId());

    walk.dispose();

    return treeParser;
}
 
Example 4
Source File: AppraiseGitReviewClient.java    From git-appraise-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
private AbstractTreeIterator prepareTreeParserHelper(RevWalk walk, RevCommit commit)
    throws IOException, MissingObjectException, IncorrectObjectTypeException {
  RevTree tree = walk.parseTree(commit.getTree().getId());
  CanonicalTreeParser oldTreeParser = new CanonicalTreeParser();
  try (ObjectReader oldReader = repo.newObjectReader()) {
    oldTreeParser.reset(oldReader, tree.getId());
  }
  return oldTreeParser;
}