Package org.eclipse.jgit.treewalk

Examples of org.eclipse.jgit.treewalk.WorkingTreeIterator


  public static boolean isIgnored(IPath path) throws IOException {
    RepositoryMapping mapping = RepositoryMapping.getMapping(path);
    if (mapping == null)
      return true; // Linked resources may not be mapped
    Repository repository = mapping.getRepository();
    WorkingTreeIterator treeIterator = IteratorService
        .createInitialIterator(repository);
    if (treeIterator == null)
      return true;
    String repoRelativePath = mapping.getRepoRelativePath(path);
    TreeWalk walk = new TreeWalk(repository);
    try {
      walk.addTree(treeIterator);
      walk.setFilter(PathFilter.create(repoRelativePath));
      while (walk.next()) {
        WorkingTreeIterator workingTreeIterator = walk.getTree(0,
            WorkingTreeIterator.class);
        if (walk.getPathString().equals(repoRelativePath))
          return workingTreeIterator.isEntryIgnored();
        if (workingTreeIterator.getEntryFileMode()
            .equals(FileMode.TREE))
          walk.enterSubtree();
      }
    } finally {
      walk.release();
View Full Code Here


    EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(
        monitor);

    List<String> treeFilterPaths = calcTreeFilterPaths(filesToUpdate);

    WorkingTreeIterator iterator = IteratorService.createInitialIterator(repository);
    if (iterator == null)
      return null; // workspace is closed
    IndexDiff diffForChangedResources = new IndexDiff(repository,
        Constants.HEAD, iterator);
    diffForChangedResources.setFilter(PathFilterGroup
View Full Code Here

      throws IOException {
    EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(
        monitor);

    IndexDiff newIndexDiff;
    WorkingTreeIterator iterator = IteratorService
        .createInitialIterator(repository);
    if (iterator == null)
      return null; // workspace is closed
    newIndexDiff = new IndexDiff(repository, Constants.HEAD, iterator);
    newIndexDiff.diff(jgitMonitor, 0, 0, jobName);
View Full Code Here

    assertEquals(1, repositoryPaths.size());
    treeWalk.setFilter(PathFilterGroup.createFromStrings(repositoryPaths));

    assertTrue(treeWalk.next());

    final WorkingTreeIterator iterator = treeWalk.getTree(0,
        WorkingTreeIterator.class);
    assertTrue(iterator instanceof ContainerTreeIterator);
  }
View Full Code Here

    IFile file = project1.getFile("link2project2folder1file1.txt");
    file.createLink(
        project2.getFile("project2folder1/project2folder1file1.txt")
            .getLocation(), IResource.ALLOW_MISSING_LOCAL, null);
    // Test iterator
    WorkingTreeIterator iterator = IteratorService
        .createInitialIterator(repository1.repository);
    assertTrue(iterator instanceof ContainerTreeIterator);
    while (!iterator.eof()) {
      assertFalse(iterator.getEntryPathString().startsWith("link2"));
      iterator.next(1);
    }
  }
View Full Code Here

    tw.addTree(new DirCacheIterator(dc));
    tw.addTree(new FileTreeIterator(repo));
    tw.setRecursive(true);
    tw.setFilter(PathFilter.create(path));
    DirCacheIterator dcIt;
    WorkingTreeIterator wtIt;
    while(tw.next()) {
      dcIt = tw.getTree(0, DirCacheIterator.class);
      wtIt = tw.getTree(1, WorkingTreeIterator.class);
      if (dcIt == null || wtIt == null)
        return true;
      if (wtIt.isModified(dcIt.getDirCacheEntry(), true)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

    tw.addTree(new DirCacheIterator(dc));
    tw.addTree(new FileTreeIterator(repo));
    tw.setRecursive(true);
    tw.setFilter(PathFilter.create(path));
    DirCacheIterator dcIt;
    WorkingTreeIterator wtIt;
    while(tw.next()) {
      dcIt = tw.getTree(0, DirCacheIterator.class);
      wtIt = tw.getTree(1, WorkingTreeIterator.class);
      if (dcIt == null || wtIt == null)
        return true;
      if (wtIt.isModified(dcIt.getDirCacheEntry(), true)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

    while (treeWalk.next()) {
      AbstractTreeIterator treeIterator = treeWalk.getTree(TREE,
          AbstractTreeIterator.class);
      DirCacheIterator dirCacheIterator = treeWalk.getTree(INDEX,
          DirCacheIterator.class);
      WorkingTreeIterator workingTreeIterator = treeWalk.getTree(WORKDIR,
          WorkingTreeIterator.class);

      if (dirCacheIterator != null) {
        final DirCacheEntry dirCacheEntry = dirCacheIterator
            .getDirCacheEntry();
        if (dirCacheEntry != null && dirCacheEntry.getStage() > 0) {
          conflicts.add(treeWalk.getPathString());
          continue;
        }
      }

      if (treeIterator != null) {
        if (dirCacheIterator != null) {
          if (!treeIterator.idEqual(dirCacheIterator)
              || treeIterator.getEntryRawMode()
              != dirCacheIterator.getEntryRawMode()) {
            // in repo, in index, content diff => changed
            changed.add(treeWalk.getPathString());
          }
        } else {
          // in repo, not in index => removed
          removed.add(treeWalk.getPathString());
          if (workingTreeIterator != null)
            untracked.add(treeWalk.getPathString());
        }
      } else {
        if (dirCacheIterator != null) {
          // not in repo, in index => added
          added.add(treeWalk.getPathString());
        } else {
          // not in repo, not in index => untracked
          if (workingTreeIterator != null
              && !workingTreeIterator.isEntryIgnored()) {
            untracked.add(treeWalk.getPathString());
          }
        }
      }

      if (dirCacheIterator != null) {
        if (workingTreeIterator == null) {
          // in index, not in workdir => missing
          missing.add(treeWalk.getPathString());
        } else {
          if (workingTreeIterator.isModified(
              dirCacheIterator.getDirCacheEntry(), true)) {
            // in index, in workdir, content differs => modified
            modified.add(treeWalk.getPathString());
          }
        }
View Full Code Here

        do {
          AbstractTreeIterator headIter = treeWalk.getTree(0,
              AbstractTreeIterator.class);
          DirCacheIterator indexIter = treeWalk.getTree(1,
              DirCacheIterator.class);
          WorkingTreeIterator wtIter = treeWalk.getTree(2,
              WorkingTreeIterator.class);
          if (headIter != null && indexIter != null && wtIter != null) {
            if (!indexIter.getDirCacheEntry().isMerged())
              throw new UnmergedPathsException(
                  new UnmergedPathException(
                      indexIter.getDirCacheEntry()));
            if (wtIter.idEqual(indexIter)
                || wtIter.idEqual(headIter))
              continue;
            treeWalk.getObjectId(id, 0);
            final DirCacheEntry entry = new DirCacheEntry(
                treeWalk.getRawPath());
            entry.setLength(wtIter.getEntryLength());
            entry.setLastModified(wtIter.getEntryLastModified());
            entry.setFileMode(wtIter.getEntryFileMode());
            long contentLength = wtIter.getEntryContentLength();
            InputStream in = wtIter.openEntryStream();
            try {
              entry.setObjectId(inserter.insert(
                  Constants.OBJ_BLOB, contentLength, in));
            } finally {
              in.close();
View Full Code Here

    // disable that we update the working-tree. We set this back to the
    // original values once a single base commit is created.
    RevCommit currentBase = baseCommits.get(0);
    DirCache oldDircache = dircache;
    boolean oldIncore = inCore;
    WorkingTreeIterator oldWTreeIt = workingTreeIterator;
    workingTreeIterator = null;
    try {
      dircache = dircacheFromTree(currentBase.getTree());
      inCore = true;
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.treewalk.WorkingTreeIterator

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.