Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheIterator


    ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
    ed2.finish();

    TreeWalk tw = new TreeWalk(db);
    tw.setRecursive(true);
    tw.addTree(new DirCacheIterator(dc1));
    tw.addTree(new DirCacheIterator(dc2));
    tw.setFilter(InterIndexDiffFilter.INSTANCE);

    assertFalse(tw.next());
  }
View Full Code Here


    ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, true));
    ed2.finish();

    TreeWalk tw = new TreeWalk(db);
    tw.setRecursive(true);
    tw.addTree(new DirCacheIterator(dc1));
    tw.addTree(new DirCacheIterator(dc2));
    tw.setFilter(InterIndexDiffFilter.INSTANCE);

    assertTrue(tw.next());
    assertEquals("a/a", tw.getPathString());
    assertFalse(tw.next());
View Full Code Here

    ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("b"), 1, true));
    ed2.finish();

    TreeWalk tw = new TreeWalk(db);
    tw.setRecursive(true);
    tw.addTree(new DirCacheIterator(dc1));
    tw.addTree(new DirCacheIterator(dc2));
    tw.setFilter(InterIndexDiffFilter.INSTANCE);

    assertFalse(tw.next());
  }
View Full Code Here

    dce.finish();

    TreeWalk ret = new TreeWalk((ObjectReader) null);
    ret.reset();
    ret.setRecursive(true);
    ret.addTree(new DirCacheIterator(dc));
    ret.next();
    return ret;
  }
View Full Code Here

      try {
        dirc = DirCache.read(new File(name), FS.DETECTED);
      } catch (IOException e) {
        throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e);
      }
      setter.addValue(new DirCacheIterator(dirc));
      return 1;
    }

    final ObjectId id;
    try {
View Full Code Here

    } catch (NoWorkTreeException e) {
      return Collections.emptySet();
    }
    TreeWalk treeWalk = new TreeWalk(repo);
    try {
      treeWalk.addTree(new DirCacheIterator(repo.readDirCache()));
      ObjectId headID = repo.resolve(Constants.HEAD);
      if (headID != null) {
        revWalk = new RevWalk(repo);
        treeWalk.addTree(revWalk.parseTree(headID));
        revWalk.dispose();
View Full Code Here

    // add the trees (tree, dirchache, workdir)
    if (tree != null)
      treeWalk.addTree(tree);
    else
      treeWalk.addTree(new EmptyTreeIterator());
    treeWalk.addTree(new DirCacheIterator(dirCache));
    treeWalk.addTree(initialWorkingTreeIterator);
    Collection<TreeFilter> filters = new ArrayList<TreeFilter>(4);

    if (monitor != null) {
      // Get the maximum size of the work tree and index
      // and add some (quite arbitrary)
      if (estIndexSize == 0)
        estIndexSize = dirCache.getEntryCount();
      int total = Math.max(estIndexSize * 10 / 9,
          estWorkTreeSize * 10 / 9);
      monitor.beginTask(title, total);
      filters.add(new ProgressReportingFilter(monitor, total));
    }

    if (filter != null)
      filters.add(filter);
    filters.add(new SkipWorkTreeFilter(INDEX));
    indexDiffFilter = new IndexDiffFilter(INDEX, WORKDIR);
    filters.add(indexDiffFilter);
    treeWalk.setFilter(AndTreeFilter.create(filters));
    fileModes.clear();
    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) {
          int stage = dirCacheEntry.getStage();
          if (stage > 0) {
            String path = treeWalk.getPathString();
            addConflict(path, stage);
            continue;
          }
        }
      }

      if (treeIterator != null) {
        if (dirCacheIterator != null) {
          if (!treeIterator.idEqual(dirCacheIterator)
              || treeIterator.getEntryRawMode()
              != dirCacheIterator.getEntryRawMode()) {
            // in repo, in index, content diff => changed
            if (!isEntryGitLink(treeIterator)
                || !isEntryGitLink(dirCacheIterator)
                || ignoreSubmoduleMode != IgnoreSubmoduleMode.ALL)
              changed.add(treeWalk.getPathString());
          }
        } else {
          // in repo, not in index => removed
          if (!isEntryGitLink(treeIterator)
              || ignoreSubmoduleMode != IgnoreSubmoduleMode.ALL)
            removed.add(treeWalk.getPathString());
          if (workingTreeIterator != null)
            untracked.add(treeWalk.getPathString());
        }
      } else {
        if (dirCacheIterator != null) {
          // not in repo, in index => added
          if (!isEntryGitLink(dirCacheIterator)
              || ignoreSubmoduleMode != IgnoreSubmoduleMode.ALL)
            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
          if (!isEntryGitLink(dirCacheIterator)
              || ignoreSubmoduleMode != IgnoreSubmoduleMode.ALL)
            missing.add(treeWalk.getPathString());
        } else {
          if (workingTreeIterator.isModified(
              dirCacheIterator.getDirCacheEntry(), true,
              treeWalk.getObjectReader())) {
            // in index, in workdir, content differs => modified
            if (!isEntryGitLink(dirCacheIterator) || !isEntryGitLink(workingTreeIterator)
                || (ignoreSubmoduleMode != IgnoreSubmoduleMode.ALL && ignoreSubmoduleMode != IgnoreSubmoduleMode.DIRTY))
              modified.add(treeWalk.getPathString());
View Full Code Here

  private TreeWalk createTreeWalk(RevCommit commit, boolean isRecursive,
      boolean honorIgnores) throws Exception {
    TreeWalk treeWalk = new TreeWalk(db);
    treeWalk.setRecursive(isRecursive);
    treeWalk.addTree(commit.getTree());
    treeWalk.addTree(new DirCacheIterator(db.readDirCache()));
    treeWalk.addTree(new FileTreeIterator(db));
    if (!honorIgnores)
      treeWalk.setFilter(new IndexDiffFilter(1, 2, honorIgnores));
    else
      treeWalk.setFilter(new IndexDiffFilter(1, 2));
View Full Code Here

      ObjectId commitId;
      try {
        TreeWalk treeWalk = new TreeWalk(reader);
        treeWalk.setRecursive(true);
        treeWalk.addTree(headCommit.getTree());
        treeWalk.addTree(new DirCacheIterator(cache));
        treeWalk.addTree(new FileTreeIterator(repo));
        treeWalk.setFilter(AndTreeFilter.create(new SkipWorkTreeFilter(
            1), new IndexDiffFilter(1, 2)));

        // Return null if no local changes to stash
        if (!treeWalk.next())
          return null;

        MutableObjectId id = new MutableObjectId();
        List<PathEdit> wtEdits = new ArrayList<PathEdit>();
        List<String> wtDeletes = new ArrayList<String>();
        List<DirCacheEntry> untracked = new ArrayList<DirCacheEntry>();
        boolean hasChanges = false;
        do {
          AbstractTreeIterator headIter = treeWalk.getTree(0,
              AbstractTreeIterator.class);
          DirCacheIterator indexIter = treeWalk.getTree(1,
              DirCacheIterator.class);
          WorkingTreeIterator wtIter = treeWalk.getTree(2,
              WorkingTreeIterator.class);
          if (indexIter != null
              && !indexIter.getDirCacheEntry().isMerged())
            throw new UnmergedPathsException(
                new UnmergedPathException(
                    indexIter.getDirCacheEntry()));
          if (wtIter != null) {
            if (indexIter == null && headIter == null
                && !includeUntracked)
              continue;
            hasChanges = true;
View Full Code Here

      assertEquals(4, tree.getEntryCount());
    }

    final TreeWalk tw = new TreeWalk(db);
    tw.setPostOrderTraversal(false);
    tw.addTree(new DirCacheIterator(tree));

    assertModes("a", REGULAR_FILE, tw);
    assertModes("b", TREE, tw);
    assertTrue(tw.isSubtree());
    assertFalse(tw.isPostChildren());
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.dircache.DirCacheIterator

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.