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");
}
}