protected void movedToEntry()

in git-server/src/main/java/org/eclipse/jgit/treewalk/SubmoduleAwareTreeIterator.java [171:223]


  protected void movedToEntry() throws CorruptObjectException {
    myIsEof = eof();
    if (myIsEof) {
      return;
    }
    int wrappedMode = myWrappedIterator.getEntryRawMode();
    String entryPath = myWrappedIterator.getEntryPathString();
    myIsOnSubmodule = checkoutSubmodules() && GITLINK_MODE_BITS == wrappedMode;
    if (myIsOnSubmodule && !isSubmodulePathAffectedByCheckoutRules(entryPath)) {
      myIsOnSubmodule = false;
    }

    mode = myIsOnSubmodule ? TREE_MODE_BITS : wrappedMode;
    if (myIsOnSubmodule) {
      try {
        mySubmoduleCommit = getSubmoduleCommit(entryPath, myWrappedIterator.getEntryObjectId());
      } catch (Exception e) {
        if (mySubmodulesPolicy.isIgnoreSubmodulesErrors()) {
          if (myLogSubmoduleErrors)
            LOG.warn("Ignore submodule error for SHA " + ObjectId.toString(myWrappedIterator.getEntryObjectId()) + ": \"" + e.getMessage() + "\". It seems to be fixed in one of the later commits.");
          mySubmoduleCommit = null;
          myIsOnSubmodule = false;
          mySubmoduleError = true;
          mode = wrappedMode;
          if (myMissingSubmoduleCommitInfo != null && TeamCityProperties.getBoolean(jetbrains.buildServer.buildTriggers.vcs.git.Constants.COLLECT_BROKEN_SUBMODULES_INFO)) {
            myMissingSubmoduleCommitInfo.addMissingSubmoduleCommit(ObjectId.toString(myWrappedIterator.getEntryObjectId()), myWrappedIterator.getEntryPathString());
          }
        } else {
          if (e instanceof CorruptObjectException) {
            throw (CorruptObjectException) e;
          } else {
            CorruptObjectException ex = new CorruptObjectException(myWrappedIterator.getEntryObjectId(), e.getMessage());
            ex.initCause(e);
            throw ex;
          }
        }
      }
      if (myIdBuffer == null) {
        myIdBuffer = new byte[Constants.OBJECT_ID_LENGTH];
      }
      if (mySubmoduleCommit != null) {
        mySubmoduleCommit.getTree().getId().copyRawTo(myIdBuffer, 0);
      }
    } else {
      mySubmoduleCommit = null;
    }
    // copy name
    final int nameLength = myWrappedIterator.getNameLength();
    final int pathLength = nameLength + pathOffset;
    ensurePathCapacity(pathLength, pathOffset);
    myWrappedIterator.getName(path, pathOffset);
    pathLen = pathLength;
  }