Package org.eclipse.jgit.treewalk

Examples of org.eclipse.jgit.treewalk.WorkingTreeIterator$Entry


    // If the path does not appear in the DirCache and its ignored
    // we can avoid returning a result here, but only if its not in any
    // other tree.
    final int dm = tw.getRawMode(dirCache);
    WorkingTreeIterator wi = workingTree(tw);
    if (dm == FileMode.TYPE_MISSING) {
      if (honorIgnores && wi.isEntryIgnored()) {
        ignoredPaths.add(wi.getEntryPathString());
        int i = 0;
        for (; i < cnt; i++) {
          if (i == dirCache || i == workingTree)
            continue;
          if (tw.getRawMode(i) != FileMode.TYPE_MISSING)
            break;
        }

        // If i is cnt then the path does not appear in any other tree,
        // and this working tree entry can be safely ignored.
        return i == cnt ? false : true;
      } else {
        // In working tree and not ignored, and not in DirCache.
        return true;
      }
    }

    // Always include subtrees as WorkingTreeIterator cannot provide
    // efficient elimination of unmodified subtrees.
    if (tw.isSubtree())
      return true;

    // Try the inexpensive comparisons between index and all real trees
    // first. Only if we don't find a diff here we have to bother with
    // the working tree
    for (int i = 0; i < cnt; i++) {
      if (i == dirCache || i == workingTree)
        continue;
      if (tw.getRawMode(i) != dm || !tw.idEqual(i, dirCache))
        return true;
    }

    // Only one chance left to detect a diff: between index and working
    // tree. Make use of the WorkingTreeIterator#isModified() method to
    // avoid computing SHA1 on filesystem content if not really needed.
    return wi.isModified(di.getDirCacheEntry(), true);
  }
View Full Code Here


      String lastAddedFile = null;

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

        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)) {
            c = tw.getTree(0, DirCacheIterator.class);
            if (f != null) { // the file exists
              long sz = f.getEntryLength();
              DirCacheEntry entry = new DirCacheEntry(path);
              if (c == null || c.getDirCacheEntry() == null
                  || !c.getDirCacheEntry().isAssumeValid()) {
                FileMode mode = f.getIndexFileMode(c);
                entry.setFileMode(mode);

                if (FileMode.GITLINK != mode) {
                  entry.setLength(sz);
                  entry.setLastModified(f
                      .getEntryLastModified());
                  long contentSize = f
                      .getEntryContentLength();
                  InputStream in = f.openEntryStream();
                  try {
                    entry.setObjectId(inserter.insert(
                        Constants.OBJ_BLOB, contentSize, in));
                  } finally {
                    in.close();
                  }
                } else
                  entry.setObjectId(f.getEntryObjectId());
                builder.add(entry);
                lastAddedFile = path;
              } else {
                builder.add(c.getDirCacheEntry());
              }
View Full Code Here

TOP

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

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.