@ -61,6 +61,7 @@ import org.eclipse.jgit.errors.RevWalkException;
import org.eclipse.jgit.lib.AnyObjectId ;
import org.eclipse.jgit.lib.AnyObjectId ;
import org.eclipse.jgit.lib.AsyncObjectLoaderQueue ;
import org.eclipse.jgit.lib.AsyncObjectLoaderQueue ;
import org.eclipse.jgit.lib.Constants ;
import org.eclipse.jgit.lib.Constants ;
import org.eclipse.jgit.lib.CoreConfig ;
import org.eclipse.jgit.lib.MutableObjectId ;
import org.eclipse.jgit.lib.MutableObjectId ;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectIdSubclassMap ;
import org.eclipse.jgit.lib.ObjectIdSubclassMap ;
@ -170,6 +171,9 @@ public class RevWalk implements Iterable<RevCommit> {
private final ObjectIdSubclassMap < RevObject > objects ;
private final ObjectIdSubclassMap < RevObject > objects ;
/** Largest commit or annotated tag we are willing to touch. */
private final int bigFileThreshold ;
private int freeFlags = APP_FLAGS ;
private int freeFlags = APP_FLAGS ;
private int delayFreeFlags ;
private int delayFreeFlags ;
@ -226,6 +230,13 @@ public class RevWalk implements Iterable<RevCommit> {
filter = RevFilter . ALL ;
filter = RevFilter . ALL ;
treeFilter = TreeFilter . ALL ;
treeFilter = TreeFilter . ALL ;
retainBody = true ;
retainBody = true ;
if ( repo ! = null ) {
CoreConfig cfg = repo . getConfig ( ) . get ( CoreConfig . KEY ) ;
bigFileThreshold = cfg . getStreamFileThreshold ( ) ;
} else {
bigFileThreshold = 15 * 1024 * 1024 ;
}
}
}
/** @return the reader this walker is using to load objects. */
/** @return the reader this walker is using to load objects. */
@ -813,13 +824,14 @@ public class RevWalk implements Iterable<RevCommit> {
}
}
private RevObject parseNew ( AnyObjectId id , ObjectLoader ldr )
private RevObject parseNew ( AnyObjectId id , ObjectLoader ldr )
throws CorruptObjectException , LargeObjectException {
throws LargeObjectException , CorruptObjectException ,
MissingObjectException , IOException {
RevObject r ;
RevObject r ;
int type = ldr . getType ( ) ;
int type = ldr . getType ( ) ;
switch ( type ) {
switch ( type ) {
case Constants . OBJ_COMMIT : {
case Constants . OBJ_COMMIT : {
final RevCommit c = createCommit ( id ) ;
final RevCommit c = createCommit ( id ) ;
c . parseCanonical ( this , ldr . getCachedBytes ( ) ) ;
c . parseCanonical ( this , getCachedBytes ( c , ldr ) ) ;
r = c ;
r = c ;
break ;
break ;
}
}
@ -835,7 +847,7 @@ public class RevWalk implements Iterable<RevCommit> {
}
}
case Constants . OBJ_TAG : {
case Constants . OBJ_TAG : {
final RevTag t = new RevTag ( id ) ;
final RevTag t = new RevTag ( id ) ;
t . parseCanonical ( this , ldr . getCachedBytes ( ) ) ;
t . parseCanonical ( this , getCachedBytes ( t , ldr ) ) ;
r = t ;
r = t ;
break ;
break ;
}
}
@ -847,6 +859,21 @@ public class RevWalk implements Iterable<RevCommit> {
return r ;
return r ;
}
}
byte [ ] getCachedBytes ( RevObject obj ) throws LargeObjectException ,
MissingObjectException , IncorrectObjectTypeException , IOException {
return getCachedBytes ( obj , reader . open ( obj , obj . getType ( ) ) ) ;
}
byte [ ] getCachedBytes ( RevObject obj , ObjectLoader ldr )
throws LargeObjectException , MissingObjectException , IOException {
try {
return ldr . getCachedBytes ( bigFileThreshold ) ;
} catch ( LargeObjectException tooBig ) {
tooBig . setObjectId ( obj ) ;
throw tooBig ;
}
}
/ * *
/ * *
* Asynchronous object parsing .
* Asynchronous object parsing .
*
*