Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.FileMode


  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();

    formatGitDiffFirstHeaderLine(o, type, oldp, newp);

    switch (type) {
    case ADD:
      o.write(encodeASCII("new file mode ")); //$NON-NLS-1$
      newMode.copyTo(o);
      o.write('\n');
      break;

    case DELETE:
      o.write(encodeASCII("deleted file mode ")); //$NON-NLS-1$
      oldMode.copyTo(o);
      o.write('\n');
      break;

    case RENAME:
      o.write(encodeASCII("similarity index " + ent.getScore() + "%")); //$NON-NLS-1$ //$NON-NLS-2$
      o.write('\n');

      o.write(encode("rename from " + quotePath(oldp))); //$NON-NLS-1$
      o.write('\n');

      o.write(encode("rename to " + quotePath(newp))); //$NON-NLS-1$
      o.write('\n');
      break;

    case COPY:
      o.write(encodeASCII("similarity index " + ent.getScore() + "%")); //$NON-NLS-1$ //$NON-NLS-2$
      o.write('\n');

      o.write(encode("copy from " + quotePath(oldp))); //$NON-NLS-1$
      o.write('\n');

      o.write(encode("copy to " + quotePath(newp))); //$NON-NLS-1$
      o.write('\n');

      if (!oldMode.equals(newMode)) {
        o.write(encodeASCII("new file mode ")); //$NON-NLS-1$
        newMode.copyTo(o);
        o.write('\n');
      }
      break;

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

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

      o.write(encodeASCII("new mode ")); //$NON-NLS-1$
      newMode.copyTo(o);
      o.write('\n');
    }

    if (!ent.getOldId().equals(ent.getNewId())) {
      formatIndexLine(o, ent);
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

  private void processTree(final RevObject obj) throws TransportException {
    try {
      treeWalk.reset(obj);
      while (treeWalk.next()) {
        final FileMode mode = treeWalk.getFileMode(0);
        final int sType = mode.getObjectType();

        switch (sType) {
        case Constants.OBJ_BLOB:
        case Constants.OBJ_TREE:
          treeWalk.getObjectId(idBuffer, 0);
View Full Code Here

    if (tree.has(COMPLETE))
      return;
    tree.add(COMPLETE);
    treeWalk.reset(tree);
    while (treeWalk.next()) {
      final FileMode mode = treeWalk.getFileMode(0);
      final int sType = mode.getObjectType();

      switch (sType) {
      case Constants.OBJ_BLOB:
        treeWalk.getObjectId(idBuffer, 0);
        revWalk.lookupAny(idBuffer, sType).add(COMPLETE);
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

      tw.setFilter(PathFilterGroup.createFromStrings(filepatterns));
      tw.addTree(new DirCacheBuildIterator(builder));

      while (tw.next()) {
        if (!cached) {
          final FileMode mode = tw.getFileMode(0);
          if (mode.getObjectType() == Constants.OBJ_BLOB) {
            final File path = new File(repo.getWorkTree(),
                tw.getPathString());
            // Deleting a blob is simply a matter of removing
            // the file or symlink named by the tree entry.
            delete(path);
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

    }

    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

    treeWalk.addTree(commit.getTree());
    final ObjectReader r = treeWalk.getObjectReader();
    DirCacheEditor editor = dc.editor();
    while (treeWalk.next()) {
      final ObjectId blobId = treeWalk.getObjectId(0);
      final FileMode mode = treeWalk.getFileMode(0);
      editor.add(new PathEdit(treeWalk.getPathString()) {
        public void apply(DirCacheEntry ent) {
          ent.setObjectId(blobId);
          ent.setFileMode(mode);
          checkoutPath(ent, r);
View Full Code Here

        walk.reset(rw.parseTree(tree));
        walk.setRecursive(true);
        while (walk.next()) {
          final String name = walk.getPathString();
          final FileMode mode = walk.getFileMode(0);

          if (mode == FileMode.TREE)
            // ZIP entries for directories are optional.
            // Leave them out, mimicking "git archive".
            continue;
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.