Package org.eclipse.jgit.errors

Examples of org.eclipse.jgit.errors.CorruptObjectException


    }

    try {
      return BinaryDelta.getResultSize(getDeltaHeader(ctx, deltaAt));
    } catch (DataFormatException dfe) {
      CorruptObjectException coe = new CorruptObjectException(
          MessageFormat.format(
              JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos),
              getPackName()));
      coe.initCause(dfe);
      throw coe;
    }
  }
View Full Code Here


      break;
    case Constants.OBJ_BLOB:
      checkBlob(raw);
      break;
    default:
      throw new CorruptObjectException(MessageFormat.format(
          JGitText.get().corruptObjectInvalidType2,
          Integer.valueOf(objType)));
    }
  }
View Full Code Here

        default:
          if (FileMode.GITLINK.equals(mode))
            continue;
          treeWalk.getObjectId(idBuffer, 0);
          throw new CorruptObjectException(MessageFormat.format(JGitText.get().invalidModeFor
              , mode, idBuffer.name(), treeWalk.getPathString(), obj.getId().name()));
        }
      }
    } catch (IOException ioe) {
      throw new TransportException(MessageFormat.format(JGitText.get().cannotReadTree, obj.name()), ioe);
View Full Code Here

   */
  public void checkCommit(final byte[] raw) throws CorruptObjectException {
    int ptr = 0;

    if ((ptr = match(raw, ptr, tree)) < 0)
      throw new CorruptObjectException("no tree header");
    if ((ptr = id(raw, ptr)) < 0 || raw[ptr++] != '\n')
      throw new CorruptObjectException("invalid tree");

    while (match(raw, ptr, parent) >= 0) {
      ptr += parent.length;
      if ((ptr = id(raw, ptr)) < 0 || raw[ptr++] != '\n')
        throw new CorruptObjectException("invalid parent");
    }

    if ((ptr = match(raw, ptr, author)) < 0)
      throw new CorruptObjectException("no author");
    if ((ptr = personIdent(raw, ptr)) < 0 || raw[ptr++] != '\n')
      throw new CorruptObjectException("invalid author");

    if ((ptr = match(raw, ptr, committer)) < 0)
      throw new CorruptObjectException("no committer");
    if ((ptr = personIdent(raw, ptr)) < 0 || raw[ptr++] != '\n')
      throw new CorruptObjectException("invalid committer");
  }
View Full Code Here

      }
      default:
        if (FileMode.GITLINK.equals(mode))
          continue;
        treeWalk.getObjectId(idBuffer, 0);
        throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3
            , mode, idBuffer.name(), treeWalk.getPathString(), tree.name()));
      }
    }
  }
View Full Code Here

   */
  public void checkTag(final byte[] raw) throws CorruptObjectException {
    int ptr = 0;

    if ((ptr = match(raw, ptr, object)) < 0)
      throw new CorruptObjectException("no object header");
    if ((ptr = id(raw, ptr)) < 0 || raw[ptr++] != '\n')
      throw new CorruptObjectException("invalid object");

    if ((ptr = match(raw, ptr, type)) < 0)
      throw new CorruptObjectException("no type header");
    ptr = nextLF(raw, ptr);

    if ((ptr = match(raw, ptr, tag)) < 0)
      throw new CorruptObjectException("no tag header");
    ptr = nextLF(raw, ptr);

    if ((ptr = match(raw, ptr, tagger)) > 0) {
      if ((ptr = personIdent(raw, ptr)) < 0 || raw[ptr++] != '\n')
        throw new CorruptObjectException("invalid tagger");
    }
  }
View Full Code Here

    while (ptr < sz) {
      int thisMode = 0;
      for (;;) {
        if (ptr == sz)
          throw new CorruptObjectException("truncated in mode");
        final byte c = raw[ptr++];
        if (' ' == c)
          break;
        if (c < '0' || c > '7')
          throw new CorruptObjectException("invalid mode character");
        if (thisMode == 0 && c == '0' && !allowZeroMode)
          throw new CorruptObjectException("mode starts with '0'");
        thisMode <<= 3;
        thisMode += c - '0';
      }

      if (FileMode.fromBits(thisMode).getObjectType() == Constants.OBJ_BAD)
        throw new CorruptObjectException("invalid mode " + thisMode);

      final int thisNameB = ptr;
      ptr = scanPathSegment(raw, ptr, sz);
      if (ptr == sz || raw[ptr] != 0)
        throw new CorruptObjectException("truncated in name");
      checkPathSegment2(raw, thisNameB, ptr);
      if (normalized != null) {
        if (!normalized.add(normalize(raw, thisNameB, ptr)))
          throw new CorruptObjectException("duplicate entry names");
      } else if (duplicateName(raw, thisNameB, ptr))
        throw new CorruptObjectException("duplicate entry names");

      if (lastNameB != 0) {
        final int cmp = pathCompare(raw, lastNameB, lastNameE,
            lastMode, thisNameB, ptr, thisMode);
        if (cmp > 0)
          throw new CorruptObjectException("incorrectly sorted");
      }

      lastNameB = thisNameB;
      lastNameE = ptr;
      lastMode = thisMode;

      ptr += 1 + Constants.OBJECT_ID_LENGTH;
      if (ptr > sz)
        throw new CorruptObjectException("truncated in object id");
    }
  }
View Full Code Here

    for (; ptr < end; ptr++) {
      byte c = raw[ptr];
      if (c == 0)
        return ptr;
      if (c == '/')
        throw new CorruptObjectException("name contains '/'");
      if (windows && isInvalidOnWindows(c)) {
        if (c > 31)
          throw new CorruptObjectException(String.format(
              "name contains '%c'", c));
        throw new CorruptObjectException(String.format(
            "name contains byte 0x%x", c & 0xff));
      }
    }
    return ptr;
  }
View Full Code Here

   */
  public void checkPathSegment(byte[] raw, int ptr, int end)
      throws CorruptObjectException {
    int e = scanPathSegment(raw, ptr, end);
    if (e < end && raw[e] == 0)
      throw new CorruptObjectException("name contains byte 0x00");
    checkPathSegment2(raw, ptr, end);
  }
View Full Code Here

  }

  private void checkPathSegment2(byte[] raw, int ptr, int end)
      throws CorruptObjectException {
    if (ptr == end)
      throw new CorruptObjectException("zero length name");
    if (raw[ptr] == '.') {
      switch (end - ptr) {
      case 1:
        throw new CorruptObjectException("invalid name '.'");
      case 2:
        if (raw[ptr + 1] == '.')
          throw new CorruptObjectException("invalid name '..'");
        break;
      case 4:
        if (isDotGit(raw, ptr + 1))
          throw new CorruptObjectException(String.format(
              "invalid name '%s'",
              RawParseUtils.decode(raw, ptr, end)));
      }
    }

    if (windows) {
      // Windows ignores space and dot at end of file name.
      if (raw[end - 1] == ' ' || raw[end - 1] == '.')
        throw new CorruptObjectException("invalid name ends with '"
            + ((char) raw[end - 1]) + "'");
      if (end - ptr >= 3)
        checkNotWindowsDevice(raw, ptr, end);
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.errors.CorruptObjectException

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.