Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheIterator


    }

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

    assertModes("a", REGULAR_FILE, tw);

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


    // iterate again, now produce the result string
    NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
    tw.setRecursive(true);
    tw.reset();
    tw.addTree(new DirCacheIterator(dc));
    while (tw.next()) {
      DirCacheIterator dcIt = tw.getTree(0, DirCacheIterator.class);
      sb.append("["+tw.getPathString()+", mode:" + dcIt.getEntryFileMode());
      int stage = dcIt.getDirCacheEntry().getStage();
      if (stage != 0)
        sb.append(", stage:" + stage);
      if (0 != (includedOptions & MOD_TIME)) {
        sb.append(", time:t"+
          timeStamps.headSet(Long.valueOf(dcIt.getDirCacheEntry().getLastModified())).size());
      }
      if (0 != (includedOptions & SMUDGE))
        if (dcIt.getDirCacheEntry().isSmudged())
          sb.append(", smudged");
      if (0 != (includedOptions & LENGTH))
        sb.append(", length:"
            + Integer.toString(dcIt.getDirCacheEntry().getLength()));
      if (0 != (includedOptions & CONTENT_ID))
        sb.append(", sha1:" + ObjectId.toString(dcIt
                .getEntryObjectId()));
      sb.append("]");
    }
    return sb.toString();
  }
View Full Code Here

      assertEquals(1, tree1.getEntryCount());
    }

    final TreeWalk tw = new TreeWalk(db);
    tw.reset();
    tw.addTree(new DirCacheIterator(tree0));
    tw.addTree(new DirCacheIterator(tree1));

    assertModes("a", REGULAR_FILE, MISSING, tw);
    assertModes("a.b", EXECUTABLE_FILE, MISSING, tw);
    assertModes("a", MISSING, TREE, tw);
    tw.enterSubtree();
View Full Code Here

      assertEquals(1, tree1.getEntryCount());
    }

    final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
    tw.reset();
    tw.addTree(new DirCacheIterator(tree0));
    tw.addTree(new DirCacheIterator(tree1));

    assertModes("a", REGULAR_FILE, TREE, tw);
    assertTrue(tw.isDirectoryFileConflict());
    assertTrue(tw.isSubtree());
    tw.enterSubtree();
View Full Code Here

      assertEquals(2, tree1.getEntryCount());
    }

    final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
    tw.reset();
    tw.addTree(new DirCacheIterator(tree0));
    tw.addTree(new DirCacheIterator(tree1));

    assertModes("a", REGULAR_FILE, TREE, tw);
    assertTrue(tw.isSubtree());
    assertTrue(tw.isDirectoryFileConflict());
    tw.enterSubtree();
View Full Code Here

      assertEquals(3, tree1.getEntryCount());
    }

    final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
    tw.reset();
    tw.addTree(new DirCacheIterator(tree0));
    tw.addTree(new DirCacheIterator(tree1));

    assertModes("a", REGULAR_FILE, TREE, tw);
    assertTrue(tw.isSubtree());
    assertTrue(tw.isDirectoryFileConflict());
    tw.enterSubtree();
View Full Code Here

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

    final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
    tw.reset();
    tw.addTree(new DirCacheIterator(tree0));
    tw.addTree(new DirCacheIterator(tree1));

    assertModes("0", REGULAR_FILE, REGULAR_FILE, tw);
    assertFalse(tw.isDirectoryFileConflict());
    assertModes("a", REGULAR_FILE, TREE, tw);
    assertTrue(tw.isSubtree());
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

      addAll = true;

    try {
      dc = repo.lockDirCache();
      ObjectWriter ow = new ObjectWriter(repo);
      DirCacheIterator c;

      DirCacheBuilder builder = dc.builder();
      final TreeWalk tw = new TreeWalk(repo);
      tw.reset();
      tw.addTree(new DirCacheBuildIterator(builder));
      if (workingTreeIterator == null)
        workingTreeIterator = new FileTreeIterator(repo);
      tw.addTree(workingTreeIterator);
      tw.setRecursive(true);
      if (!addAll)
        tw.setFilter(PathFilterGroup.createFromStrings(filepatterns));

      String lastAddedFile = null;

      while (tw.next()) {
        String path = tw.getPathString();

        final File file = new File(repo.getWorkTree(), path);
        WorkingTreeIterator f = tw.getTree(1, WorkingTreeIterator.class);
        if (tw.getTree(0, DirCacheIterator.class) == null &&
            f != null && f.isEntryIgnored()) {
          // file is not in index but is ignored, do nothing
        }
        // In case of an existing merge conflict the
        // DirCacheBuildIterator iterates over all stages of
        // this path, we however want to add only one
        // new DirCacheEntry per path.
        else if (!(path.equals(lastAddedFile))) {
          if (!(update && tw.getTree(0, DirCacheIterator.class) == null)) {
            if (f != null) { // the file exists
              DirCacheEntry entry = new DirCacheEntry(path);
              entry.setLength((int)f.getEntryLength());
              entry.setLastModified(f.getEntryLastModified());
              entry.setFileMode(f.getEntryFileMode());
              entry.setObjectId(ow.writeBlob(file));

              builder.add(entry);
              lastAddedFile = path;
            } else if (!update){
              c = tw.getTree(0, DirCacheIterator.class);
              builder.add(c.getDirCacheEntry());
            }
          }
        }
      }
      builder.commit();
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

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.