JGitText.get().corruptObjectNegativeSize);
if (hdr[p.value++] != 0)
throw new CorruptObjectException(id,
JGitText.get().corruptObjectGarbageAfterSize);
if (path == null && Integer.MAX_VALUE < size)
throw new LargeObjectException(id.copy());
if (size < wc.getStreamFileThreshold() || path == null) {
byte[] data = new byte[(int) size];
int n = avail - p.value;
if (n > 0)
System.arraycopy(hdr, p.value, data, 0, n);
IO.readFully(zIn, data, n, data.length - n);
checkValidEndOfStream(in, inf, id, hdr);
return new ObjectLoader.SmallObject(type, data);
}
return new LargeObject(type, size, path, id, wc.db);
} else {
readSome(in, hdr, 2, 18);
int c = hdr[0] & 0xff;
int type = (c >> 4) & 7;
long size = c & 15;
int shift = 4;
int p = 1;
while ((c & 0x80) != 0) {
c = hdr[p++] & 0xff;
size += (c & 0x7f) << shift;
shift += 7;
}
switch (type) {
case Constants.OBJ_COMMIT:
case Constants.OBJ_TREE:
case Constants.OBJ_BLOB:
case Constants.OBJ_TAG:
// Acceptable types for a loose object.
break;
default:
throw new CorruptObjectException(id,
JGitText.get().corruptObjectInvalidType);
}
if (path == null && Integer.MAX_VALUE < size)
throw new LargeObjectException(id.copy());
if (size < wc.getStreamFileThreshold() || path == null) {
in.reset();
IO.skipFully(in, p);
Inflater inf = wc.inflater();
InputStream zIn = inflate(in, inf);