@ -366,7 +366,6 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
}
}
@SuppressWarnings ( "null" )
private void copyAsIs2 ( PackOutputStream out , LocalObjectToPack src ,
boolean validate , WindowCursor curs ) throws IOException ,
StoredObjectRepresentationNotAvailableException {
@ -393,22 +392,26 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
c = buf [ headerCnt + + ] & 0xff ;
} while ( ( c & 128 ) ! = 0 ) ;
if ( validate ) {
assert ( crc1 ! = null & & crc2 ! = null ) ;
crc1 . update ( buf , 0 , headerCnt ) ;
crc2 . update ( buf , 0 , headerCnt ) ;
}
} else if ( typeCode = = Constants . OBJ_REF_DELTA ) {
if ( validate ) {
assert ( crc1 ! = null & & crc2 ! = null ) ;
crc1 . update ( buf , 0 , headerCnt ) ;
crc2 . update ( buf , 0 , headerCnt ) ;
}
readFully ( src . offset + headerCnt , buf , 0 , 20 , curs ) ;
if ( validate ) {
assert ( crc1 ! = null & & crc2 ! = null ) ;
crc1 . update ( buf , 0 , 20 ) ;
crc2 . update ( buf , 0 , 20 ) ;
}
headerCnt + = 20 ;
} else if ( validate ) {
assert ( crc1 ! = null & & crc2 ! = null ) ;
crc1 . update ( buf , 0 , headerCnt ) ;
crc2 . update ( buf , 0 , headerCnt ) ;
}
@ -425,6 +428,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
quickCopy = curs . quickCopy ( this , dataOffset , dataLength ) ;
if ( validate & & idx ( ) . hasCRC32Support ( ) ) {
assert ( crc1 ! = null ) ;
// Index has the CRC32 code cached, validate the object.
//
expectedCRC = idx ( ) . findCRC32 ( src ) ;
@ -457,6 +461,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
if ( quickCopy ! = null ) {
quickCopy . check ( inf , tmp , dataOffset , ( int ) dataLength ) ;
} else {
assert ( crc1 ! = null ) ;
long pos = dataOffset ;
long cnt = dataLength ;
while ( cnt > 0 ) {
@ -476,6 +481,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
JGitText . get ( ) . shortCompressedStreamAt ,
Long . valueOf ( src . offset ) ) ) ;
}
assert ( crc1 ! = null ) ;
expectedCRC = crc1 . getValue ( ) ;
} else {
expectedCRC = - 1 ;
@ -535,16 +541,21 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
while ( cnt > 0 ) {
final int n = ( int ) Math . min ( cnt , buf . length ) ;
readFully ( pos , buf , 0 , n , curs ) ;
if ( validate )
if ( validate ) {
assert ( crc2 ! = null ) ;
crc2 . update ( buf , 0 , n ) ;
}
out . write ( buf , 0 , n ) ;
pos + = n ;
cnt - = n ;
}
if ( validate & & crc2 . getValue ( ) ! = expectedCRC ) {
throw new CorruptObjectException ( MessageFormat . format (
JGitText . get ( ) . objectAtHasBadZlibStream ,
Long . valueOf ( src . offset ) , getPackFile ( ) ) ) ;
if ( validate ) {
assert ( crc2 ! = null ) ;
if ( crc2 . getValue ( ) ! = expectedCRC ) {
throw new CorruptObjectException ( MessageFormat . format (
JGitText . get ( ) . objectAtHasBadZlibStream ,
Long . valueOf ( src . offset ) , getPackFile ( ) ) ) ;
}
}
}
}
@ -712,7 +723,6 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
, getPackFile ( ) ) ) ;
}
@SuppressWarnings ( "null" )
ObjectLoader load ( final WindowCursor curs , long pos )
throws IOException , LargeObjectException {
try {
@ -811,6 +821,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
if ( data = = null )
throw new IOException ( JGitText . get ( ) . inMemoryBufferLimitExceeded ) ;
assert ( delta ! = null ) ;
do {
// Cache only the base immediately before desired object.
if ( cached )