Package org.eclipse.jgit.errors

Examples of org.eclipse.jgit.errors.CorruptObjectException


    } else {
      // cmd == 0 has been reserved for future encoding but
      // for now its not acceptable.
      //
      throw new CorruptObjectException(JGitText.get().unsupportedCommand0);
    }
  }
View Full Code Here


  private void seekBase() throws IOException {
    if (baseStream == null) {
      baseStream = openBase();
      if (getBaseSize() != baseSize)
        throw new CorruptObjectException(
            JGitText.get().baseLengthIncorrect);
      IO.skipFully(baseStream, copyOffset);
      baseOffset = copyOffset;

    } else if (baseOffset < copyOffset) {
View Full Code Here

      break;
    case Constants.OBJ_BLOB:
      checkBlob(raw);
      break;
    default:
      throw new CorruptObjectException(MessageFormat.format(
          JGitText.get().corruptObjectInvalidType2, objType));
    }
  }
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

   */
  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')
          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;
      for (;;) {
        if (ptr == sz)
          throw new CorruptObjectException("truncated in name");
        final byte c = raw[ptr++];
        if (c == 0)
          break;
        if (c == '/')
          throw new CorruptObjectException("name contains '/'");
      }
      if (thisNameB + 1 == ptr)
        throw new CorruptObjectException("zero length name");
      if (raw[thisNameB] == '.') {
        final int nameLen = (ptr - 1) - thisNameB;
        if (nameLen == 1)
          throw new CorruptObjectException("invalid name '.'");
        if (nameLen == 2 && raw[thisNameB + 1] == '.')
          throw new CorruptObjectException("invalid name '..'");
      }
      if (duplicateName(raw, thisNameB, ptr - 1))
        throw new CorruptObjectException("duplicate entry names");

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

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

      ptr += Constants.OBJECT_ID_LENGTH;
      if (ptr > sz)
        throw new CorruptObjectException("truncated in object id");
    }
  }
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

      }
      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

    final byte[] srcHash = new byte[20];
    System.arraycopy(buf, c, srcHash, 0, 20);
    use(20);

    if (!Arrays.equals(actHash, srcHash))
      throw new CorruptObjectException(
          JGitText.get().corruptObjectPackfileChecksumIncorrect);

    onPackFooter(srcHash);
  }
View Full Code Here

              use(bAvail);

              p = fill(src, 1);
              inf.setInput(buf, p, bAvail);
            } else {
              throw new CorruptObjectException(
                  MessageFormat
                      .format(
                          JGitText.get().packfileCorruptionDetected,
                          JGitText.get().unknownZlibError));
            }
          } else {
            n += r;
          }
        }
        actualSize += n;
        return 0 < n ? n : -1;
      } catch (DataFormatException dfe) {
        throw new CorruptObjectException(MessageFormat.format(JGitText
            .get().packfileCorruptionDetected, dfe.getMessage()));
      }
    }
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.