Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheEntry


    if (modeB == modeO && tw.idEqual(T_BASE, T_OURS)) {
      // OURS was not changed compared to base. All changes must be in
      // THEIRS. Choose THEIRS.
      if (nonTree(modeT)) {
        DirCacheEntry e = add(tw.getRawPath(), theirs,
            DirCacheEntry.STAGE_0);
        if (e != null)
          toBeCheckedOut.put(tw.getPathString(), e);
        return true;
      } else if ((modeT == 0) && (modeB != 0)) {
View Full Code Here


      mergeResults.put(tw.getPathString(), result);
      return false;
    } else {
      // no conflict occured, the file will contain fully merged content.
      // the index will be populated with the new merged version
      DirCacheEntry dce = new DirCacheEntry(tw.getPathString());
      dce.setFileMode(tw.getFileMode(0));
      dce.setLastModified(of.lastModified());
      dce.setLength((int) of.length());
      InputStream is = new FileInputStream(of);
      try {
        dce.setObjectId(oi.insert(Constants.OBJ_BLOB, of.length(),
            is));
      } finally {
        is.close();
        if (inCore)
          FileUtils.delete(of);
View Full Code Here

  public boolean include(TreeWalk walker) {
    DirCacheIterator i = walker.getTree(treeIdx, DirCacheIterator.class);
    if (i == null)
      return true;

    DirCacheEntry e = i.getDirCacheEntry();
    return e == null || !e.isSkipWorkTree();
  }
View Full Code Here

      // the cached index information for the path.
      //
      DirCacheIterator i = state.walk.getTree(state.dirCacheTree,
          DirCacheIterator.class);
      if (i != null) {
        DirCacheEntry ent = i.getDirCacheEntry();
        if (ent != null && compareMetadata(ent) == MetadataDiff.EQUAL)
          return i.idBuffer();
      }
    }
View Full Code Here

        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()) {
                entry.setLength(sz);
                entry.setLastModified(f.getEntryLastModified());
                entry.setFileMode(f.getEntryFileMode());

                InputStream in = f.openEntryStream();
                try {
                  entry.setObjectId(inserter.insert(
                      Constants.OBJ_BLOB, sz, in));
                } finally {
                  in.close();
                }
View Full Code Here

        timeStamps.add(Long.valueOf(dc.getEntry(i).getLastModified()));
    }

    // iterate again, now produce the result string
    for (int i=0; i<dc.getEntryCount(); ++i) {
      DirCacheEntry entry = dc.getEntry(i);
      sb.append("["+entry.getPathString()+", mode:" + entry.getFileMode());
      int stage = entry.getStage();
      if (stage != 0)
        sb.append(", stage:" + stage);
      if (0 != (includedOptions & MOD_TIME)) {
        sb.append(", time:t"+
          timeStamps.headSet(Long.valueOf(entry.getLastModified())).size());
      }
      if (0 != (includedOptions & SMUDGE))
        if (entry.isSmudged())
          sb.append(", smudged");
      if (0 != (includedOptions & LENGTH))
        sb.append(", length:"
            + Integer.toString(entry.getLength()));
      if (0 != (includedOptions & CONTENT_ID))
        sb.append(", sha1:" + ObjectId.toString(entry.getObjectId()));
      if (0 != (includedOptions & CONTENT)) {
        sb.append(", content:"
            + new String(db.open(entry.getObjectId(),
                Constants.OBJ_BLOB).getCachedBytes(), "UTF-8"));
      }
      if (0 != (includedOptions & ASSUME_UNCHANGED))
        sb.append(", assume-unchanged:"
            + Boolean.toString(entry.isAssumeValid()));
      sb.append("]");
    }
    return sb.toString();
  }
View Full Code Here

   */
  protected void resetIndex(FileTreeIterator treeItr)
      throws FileNotFoundException, IOException {
    ObjectInserter inserter = db.newObjectInserter();
    DirCacheBuilder builder = db.lockDirCache().builder();
    DirCacheEntry dce;

    while (!treeItr.eof()) {
      long len = treeItr.getEntryLength();

      dce = new DirCacheEntry(treeItr.getEntryPathString());
      dce.setFileMode(treeItr.getEntryFileMode());
      dce.setLastModified(treeItr.getEntryLastModified());
      dce.setLength((int) len);
      FileInputStream in = new FileInputStream(treeItr.getEntryFile());
      dce.setObjectId(inserter.insert(Constants.OBJ_BLOB, len, in));
      in.close();
      builder.add(dce);
      treeItr.next(1);
    }
    builder.commit();
View Full Code Here

    return createEntry(path, mode, DirCacheEntry.STAGE_0, content);
  }

  protected DirCacheEntry createEntry(final String path, final FileMode mode,
      final int stage, final String content) {
    final DirCacheEntry entry = new DirCacheEntry(path, stage);
    entry.setFileMode(mode);
    entry.setObjectId(new ObjectInserter.Formatter().idFor(
        Constants.OBJ_BLOB, Constants.encode(content)));
    return entry;
  }
View Full Code Here

    DirCacheBuilder builder = newIndex.builder();
    ObjectInserter inserter = db.newObjectInserter();

    try {
      // create an index entry for the revised index
      final DirCacheEntry idIndexEntry = new DirCacheEntry(file);
      idIndexEntry.setLength(content.length());
      idIndexEntry.setLastModified(System.currentTimeMillis());
      idIndexEntry.setFileMode(FileMode.REGULAR_FILE);

      // insert new ticket index
      idIndexEntry.setObjectId(inserter.insert(org.eclipse.jgit.lib.Constants.OBJ_BLOB,
          content.getBytes(Constants.ENCODING)));

      // add to temporary in-core index
      builder.add(idIndexEntry);
View Full Code Here

            hTree = treeWalk.getTree(hIdx, CanonicalTreeParser.class);
          }
          if (!path.startsWith(ticketPath)) {
            // add entries from HEAD for all other paths
            if (hTree != null) {
              final DirCacheEntry entry = new DirCacheEntry(path);
              entry.setObjectId(hTree.getEntryObjectId());
              entry.setFileMode(hTree.getEntryFileMode());

              // add to temporary in-core index
              builder.add(entry);
            }
          }
View Full Code Here

TOP

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

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.