Package org.eclipse.jgit.revwalk

Examples of org.eclipse.jgit.revwalk.RevTree


          i = m;
        } else
          i = m - 1;
        break;
      case ':': {
        RevTree tree;
        if (ref == null) {
          // We might not yet have parsed the left hand side.
          ObjectId id;
          try {
            if (i == 0)
              id = resolve(rw, Constants.HEAD);
            else
              id = resolve(rw, new String(rev, 0, i));
          } catch (RevisionSyntaxException badSyntax) {
            throw new RevisionSyntaxException(revstr);
          }
          if (id == null)
            return null;
          tree = rw.parseTree(id);
        } else {
          tree = rw.parseTree(ref);
        }

        if (i == rev.length - 1)
          return tree.copy();

        TreeWalk tw = TreeWalk.forPath(rw.getObjectReader(),
            new String(rev, i + 1, rev.length - i - 1), tree);
        return tw != null ? tw.getObjectId(0) : null;
      }
View Full Code Here


          if (headCommitId != null) {
            // Not an empty repo
            RevWalk revWalk = new RevWalk(repo);
            RevCommit headCommit = revWalk
                .parseCommit(headCommitId);
            RevTree headTree = headCommit.getTree();
            TreeWalk projectInRepo = TreeWalk.forPath(repo,
                repoRelativePath, headTree);
            if (projectInRepo != null) {
              // the .project file is tracked by this repo
              treeItem.setChecked(true);
View Full Code Here

  }

  private class TreeMatcher extends SearchMatcher {

    public boolean matches(Pattern pattern, RevCommit commit) {
      RevTree tree = commit.getTree();
      return tree != null ? matches(pattern, tree.name()) : false;
    }
View Full Code Here

    }
  }

  private boolean isTracked(File file, Repository repo) throws IOException {
    ObjectId objectId = repo.resolve(Constants.HEAD);
    RevTree tree;
    if (objectId != null)
      tree = new RevWalk(repo).parseTree(objectId);
    else
      tree = null;
View Full Code Here

      } finally {
        if (reader != null)
          reader.release();
        rw.dispose();
      }
      RevTree treeId = baselineCommit.getTree();
      if (treeId.equals(lastTree)) {
        if (GitTraceLocation.QUICKDIFF.isActive())
          GitTraceLocation.getTrace().trace(
              GitTraceLocation.QUICKDIFF.getLocation(),
              "(GitDocument) already resolved"); //$NON-NLS-1$
        return;
      }

      tw = TreeWalk.forPath(repository, oldPath, treeId);
      if (tw == null) {
        if (GitTraceLocation.QUICKDIFF.isActive())
          GitTraceLocation
              .getTrace()
              .trace(
                  GitTraceLocation.QUICKDIFF.getLocation(),
                  "(GitDocument) resource " + resource + " not found in " + treeId + " in " + repository + ", baseline=" + baseline); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        setResolved(null, null, null, ""); //$NON-NLS-1$
        return;
      }
      ObjectId id = tw.getObjectId(0);
      if (id.equals(ObjectId.zeroId())) {
        setResolved(null, null, null, ""); //$NON-NLS-1$
        String msg = NLS
            .bind(UIText.GitDocument_errorLoadTree, new Object[] {
                treeId.getName(), baseline, resource, repository });
        Activator.logError(msg, new Throwable());
        setResolved(null, null, null, ""); //$NON-NLS-1$
        return;
      }
      if (!id.equals(lastBlob)) {
View Full Code Here

        // a RevWalk allows to walk over commits based on some filtering that is defined
        RevWalk walk = new RevWalk(repository);

        RevCommit commit = walk.parseCommit(head.getObjectId());
        RevTree tree = commit.getTree();
        System.out.println("Having tree: " + tree);

        // now use a TreeWalk to iterate over all files in the Tree recursively
        // you can set Filters to narrow down the results if needed
        TreeWalk treeWalk = new TreeWalk(repository);
View Full Code Here

        System.out.println("\nPrint contents of tree of head of master branch, i.e. the latest binary tree information");

        // a commit points to a tree
        RevWalk walk = new RevWalk(repository);
        RevCommit commit = walk.parseCommit(head.getObjectId());
        RevTree tree = walk.parseTree(commit.getTree().getId());
        System.out.println("Found Tree: " + tree);
        loader = repository.open(tree.getId());
        loader.copyTo(System.out);

        walk.dispose();

        repository.close();
View Full Code Here

            MissingObjectException,
            IncorrectObjectTypeException {
        // from the commit we can build the tree which allows us to construct the TreeParser
        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();
        try {
            oldTreeParser.reset(oldReader, tree.getId());
        } finally {
            oldReader.release();
        }
       
        walk.dispose();
View Full Code Here

        // a RevWalk allows to walk over commits based on some filtering that is defined
        RevWalk walk = new RevWalk(repository);

        RevCommit commit = walk.parseCommit(head.getObjectId());
        RevTree tree = commit.getTree();
        System.out.println("Having tree: " + tree);

        // now use a TreeWalk to iterate over all files in the Tree recursively
        // you can set Filters to narrow down the results if needed
        TreeWalk treeWalk = new TreeWalk(repository);
View Full Code Here

    public static void main(String[] args) throws IOException, GitAPIException {
        Repository repository = CookbookHelper.openJGitCookbookRepository();

        // find the Tree for current HEAD
        RevTree tree = getTree(repository);

        printFile(repository, tree);

        printDirectory(repository, tree);
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.revwalk.RevTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.