@ -143,7 +143,7 @@ public abstract class PackParser {
private boolean expectDataAfterPackFooter ;
private long o bjectCount;
private long expectedO bjectCount;
private PackedObjectInfo [ ] entries ;
@ -525,15 +525,15 @@ public abstract class PackParser {
try {
readPackHeader ( ) ;
entries = new PackedObjectInfo [ ( int ) o bjectCount] ;
entries = new PackedObjectInfo [ ( int ) expectedO bjectCount] ;
baseById = new ObjectIdOwnerMap < > ( ) ;
baseByPos = new LongMap < > ( ) ;
collisionCheckObjs = new BlockList < > ( ) ;
receiving . beginTask ( JGitText . get ( ) . receivingObjects ,
( int ) o bjectCount) ;
( int ) expectedO bjectCount) ;
try {
for ( int done = 0 ; done < o bjectCount; done + + ) {
for ( int done = 0 ; done < expectedO bjectCount; done + + ) {
indexOneObject ( ) ;
receiving . update ( 1 ) ;
if ( receiving . isCancelled ( ) )
@ -557,19 +557,19 @@ public abstract class PackParser {
}
resolving . beginTask ( JGitText . get ( ) . resolvingDeltas , deltaCount ) ;
resolveDeltas ( resolving ) ;
if ( entryCount < o bjectCount) {
if ( entryCount < expectedO bjectCount) {
if ( ! isAllowThin ( ) ) {
throw new IOException ( MessageFormat . format (
JGitText . get ( ) . packHasUnresolvedDeltas ,
Long . valueOf ( o bjectCount - entryCount ) ) ) ;
Long . valueOf ( expectedO bjectCount - entryCount ) ) ) ;
}
resolveDeltasWithExternalBases ( resolving ) ;
if ( entryCount < o bjectCount) {
if ( entryCount < expectedO bjectCount) {
throw new IOException ( MessageFormat . format (
JGitText . get ( ) . packHasUnresolvedDeltas ,
Long . valueOf ( o bjectCount - entryCount ) ) ) ;
Long . valueOf ( expectedO bjectCount - entryCount ) ) ) ;
}
}
resolving . endTask ( ) ;
@ -878,7 +878,7 @@ public abstract class PackParser {
private void growEntries ( int extraObjects ) {
final PackedObjectInfo [ ] ne ;
ne = new PackedObjectInfo [ ( int ) o bjectCount + extraObjects ] ;
ne = new PackedObjectInfo [ ( int ) expectedO bjectCount + extraObjects ] ;
System . arraycopy ( entries , 0 , ne , 0 , entryCount ) ;
entries = ne ;
}
@ -901,9 +901,9 @@ public abstract class PackParser {
if ( vers ! = 2 & & vers ! = 3 )
throw new IOException ( MessageFormat . format (
JGitText . get ( ) . unsupportedPackVersion , Long . valueOf ( vers ) ) ) ;
objectCount = NB . decodeUInt32 ( buf , p + 8 ) ;
final long objectCount = NB . decodeUInt32 ( buf , p + 8 ) ;
use ( hdrln ) ;
setExpectedObjectCount ( objectCount ) ;
onPackHeader ( objectCount ) ;
}
@ -1260,6 +1260,22 @@ public abstract class PackParser {
return oe ;
}
/ * *
* Set the expected number of objects in the pack stream .
* < p >
* The object count in the pack header is not always correct for some Dfs
* pack files . e . g . INSERT pack always assume 1 object in the header since
* the actual object count is unknown when the pack is written .
* < p >
* If external implementation wants to overwrite the expectedObjectCount ,
* they should call this method during { @link # onPackHeader ( long ) } .
*
* @param expectedObjectCount
* /
protected void setExpectedObjectCount ( long expectedObjectCount ) {
this . expectedObjectCount = expectedObjectCount ;
}
/ * *
* Store bytes received from the raw stream .
* < p >