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