Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.FileMode


   *            iterator or null if no {@link DirCacheIterator} is available
   *            at this iterator's current entry
   * @return index file mode
   */
  public FileMode getIndexFileMode(final DirCacheIterator indexIter) {
    final FileMode wtMode = getEntryFileMode();
    if (indexIter == null)
      return wtMode;
    if (getOptions().isFileMode())
      return wtMode;
    final FileMode iMode = indexIter.getEntryFileMode();
    if (FileMode.REGULAR_FILE == wtMode
        && FileMode.EXECUTABLE_FILE == iMode)
      return iMode;
    if (FileMode.EXECUTABLE_FILE == wtMode
        && FileMode.REGULAR_FILE == iMode)
View Full Code Here


        else { // revert index to commit
          // it seams that there is concurrent access to tree
          // variable, therefore we need to keep references to
          // entryFileMode and entryObjectId in local
          // variables
          final FileMode entryFileMode = tree.getEntryFileMode();
          final ObjectId entryObjectId = tree.getEntryObjectId();
          edit.add(new DirCacheEditor.PathEdit(path) {
            @Override
            public void apply(DirCacheEntry ent) {
              ent.setFileMode(entryFileMode);
View Full Code Here

            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
View Full Code Here

    }

    ObjectId iId = (i == null ? null : i.getEntryObjectId());
    ObjectId mId = (m == null ? null : m.getEntryObjectId());
    ObjectId hId = (h == null ? null : h.getEntryObjectId());
    FileMode iMode = (i == null ? null : i.getEntryFileMode());
    FileMode mMode = (m == null ? null : m.getEntryFileMode());
    FileMode hMode = (h == null ? null : h.getEntryFileMode());

    /**
     * <pre>
     *  File/Directory conflicts:
     *  the following table from ReadTreeTest tells what to do in case of directory/file
View Full Code Here

      final File workTree = repo.getWorkTree();
      final ObjectReader r = repo.getObjectDatabase().newReader();
      try {
        while (startWalk.next()) {
          final ObjectId blobId = startWalk.getObjectId(0);
          final FileMode mode = startWalk.getFileMode(0);
          editor.add(new PathEdit(startWalk.getPathString()) {
            public void apply(DirCacheEntry ent) {
              ent.setObjectId(blobId);
              ent.setFileMode(mode);
              try {
View Full Code Here

  private void formatHeader(ByteArrayOutputStream o, DiffEntry ent)
      throws IOException {
    final ChangeType type = ent.getChangeType();
    final String oldp = ent.getOldPath();
    final String newp = ent.getNewPath();
    final FileMode oldMode = ent.getOldMode();
    final FileMode newMode = ent.getNewMode();

    o.write(encodeASCII("diff --git "));
    o.write(encode(quotePath(oldPrefix + (type == ADD ? newp : oldp))));
    o.write(' ');
    o.write(encode(quotePath(newPrefix + (type == DELETE ? oldp : newp))));
    o.write('\n');

    switch (type) {
    case ADD:
      o.write(encodeASCII("new file mode "));
      newMode.copyTo(o);
      o.write('\n');
      break;

    case DELETE:
      o.write(encodeASCII("deleted file mode "));
      oldMode.copyTo(o);
      o.write('\n');
      break;

    case RENAME:
      o.write(encodeASCII("similarity index " + ent.getScore() + "%"));
      o.write('\n');

      o.write(encode("rename from " + quotePath(oldp)));
      o.write('\n');

      o.write(encode("rename to " + quotePath(newp)));
      o.write('\n');
      break;

    case COPY:
      o.write(encodeASCII("similarity index " + ent.getScore() + "%"));
      o.write('\n');

      o.write(encode("copy from " + quotePath(oldp)));
      o.write('\n');

      o.write(encode("copy to " + quotePath(newp)));
      o.write('\n');

      if (!oldMode.equals(newMode)) {
        o.write(encodeASCII("new file mode "));
        newMode.copyTo(o);
        o.write('\n');
      }
      break;

    case MODIFY:
      if (0 < ent.getScore()) {
        o.write(encodeASCII("dissimilarity index "
            + (100 - ent.getScore()) + "%"));
        o.write('\n');
      }
      break;
    }

    if ((type == MODIFY || type == RENAME) && !oldMode.equals(newMode)) {
      o.write(encodeASCII("old mode "));
      oldMode.copyTo(o);
      o.write('\n');

      o.write(encodeASCII("new mode "));
      newMode.copyTo(o);
      o.write('\n');
    }

    if (!ent.getOldId().equals(ent.getNewId())) {
      formatIndexLine(o, ent);
View Full Code Here

  private void formatHeader(ByteArrayOutputStream o, DiffEntry ent)
      throws IOException {
    final ChangeType type = ent.getChangeType();
    final String oldp = ent.getOldPath();
    final String newp = ent.getNewPath();
    final FileMode oldMode = ent.getOldMode();
    final FileMode newMode = ent.getNewMode();

    o.write(encodeASCII("diff --git "));
    o.write(encode(quotePath(oldPrefix + (type == ADD ? newp : oldp))));
    o.write(' ');
    o.write(encode(quotePath(newPrefix + (type == DELETE ? oldp : newp))));
    o.write('\n');

    switch (type) {
    case ADD:
      o.write(encodeASCII("new file mode "));
      newMode.copyTo(o);
      o.write('\n');
      break;

    case DELETE:
      o.write(encodeASCII("deleted file mode "));
      oldMode.copyTo(o);
      o.write('\n');
      break;

    case RENAME:
      o.write(encodeASCII("similarity index " + ent.getScore() + "%"));
      o.write('\n');

      o.write(encode("rename from " + quotePath(oldp)));
      o.write('\n');

      o.write(encode("rename to " + quotePath(newp)));
      o.write('\n');
      break;

    case COPY:
      o.write(encodeASCII("similarity index " + ent.getScore() + "%"));
      o.write('\n');

      o.write(encode("copy from " + quotePath(oldp)));
      o.write('\n');

      o.write(encode("copy to " + quotePath(newp)));
      o.write('\n');

      if (!oldMode.equals(newMode)) {
        o.write(encodeASCII("new file mode "));
        newMode.copyTo(o);
        o.write('\n');
      }
      break;

    case MODIFY:
      if (0 < ent.getScore()) {
        o.write(encodeASCII("dissimilarity index "
            + (100 - ent.getScore()) + "%"));
        o.write('\n');
      }
      break;
    }

    if ((type == MODIFY || type == RENAME) && !oldMode.equals(newMode)) {
      o.write(encodeASCII("old mode "));
      oldMode.copyTo(o);
      o.write('\n');

      o.write(encodeASCII("new mode "));
      newMode.copyTo(o);
      o.write('\n');
    }

    if (!ent.getOldId().equals(ent.getNewId())) {
      formatIndexLine(o, ent);
View Full Code Here

   *            iterator or null if no {@link DirCacheIterator} is available
   *            at this iterator's current entry
   * @return index file mode
   */
  public FileMode getIndexFileMode(final DirCacheIterator indexIter) {
    final FileMode wtMode = getEntryFileMode();
    if (indexIter == null)
      return wtMode;
    if (getOptions().isFileMode())
      return wtMode;
    final FileMode iMode = indexIter.getEntryFileMode();
    if (FileMode.REGULAR_FILE == wtMode
        && FileMode.EXECUTABLE_FILE == iMode)
      return iMode;
    if (FileMode.EXECUTABLE_FILE == wtMode
        && FileMode.REGULAR_FILE == iMode)
View Full Code Here

    FileHeader fh = new FileHeader(rawHdr, edits, PatchType.UNIFIED);
    return new PatchListEntry(fh, edits);
  }

  private PatchListEntry newEntry(RevTree aTree, FileHeader fileHeader) {
    final FileMode oldMode = fileHeader.getOldMode();
    final FileMode newMode = fileHeader.getNewMode();

    if (oldMode == FileMode.GITLINK || newMode == FileMode.GITLINK) {
      return new PatchListEntry(fileHeader, Collections.<Edit> emptyList());
    }
View Full Code Here

      TreeWalk tw = new TreeWalk(or);
      tw.reset(rw.parseTree(db.resolve(Constants.HEAD)));
      tw.setRecursive(true);

      while (tw.next()) {
        FileMode fm = tw.getFileMode(0);
        if (!FileMode.REGULAR_FILE.equals(fm)
            && !FileMode.EXECUTABLE_FILE.equals(fm))
          continue;

        byte[] raw;
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.FileMode

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.