@ -50,13 +50,11 @@ import static org.eclipse.jgit.lib.FileMode.GITLINK;
import java.io.ByteArrayOutputStream ;
import java.io.IOException ;
import java.io.InputStream ;
import java.io.OutputStream ;
import java.util.List ;
import org.eclipse.jgit.JGitText ;
import org.eclipse.jgit.errors.CorruptObjectException ;
import org.eclipse.jgit.errors.LargeObjectException ;
import org.eclipse.jgit.errors.MissingObjectException ;
import org.eclipse.jgit.lib.AbbreviatedObjectId ;
import org.eclipse.jgit.lib.Constants ;
@ -68,7 +66,6 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.patch.FileHeader ;
import org.eclipse.jgit.patch.HunkHeader ;
import org.eclipse.jgit.patch.FileHeader.PatchType ;
import org.eclipse.jgit.util.IO ;
import org.eclipse.jgit.util.QuotedString ;
import org.eclipse.jgit.util.io.DisabledOutputStream ;
@ -88,7 +85,7 @@ public class DiffFormatter {
private RawText . Factory rawTextFactory = RawText . FACTORY ;
private long bigFileThreshold = 50 * 1024 * 1024 ;
private int bigFileThreshold = 50 * 1024 * 1024 ;
/ * *
* Create a new formatter with a default level of context .
@ -176,7 +173,7 @@ public class DiffFormatter {
* @param bigFileThreshold
* the limit , in bytes .
* /
public void setBigFileThreshold ( long bigFileThreshold ) {
public void setBigFileThreshold ( int bigFileThreshold ) {
this . bigFileThreshold = bigFileThreshold ;
}
@ -358,34 +355,8 @@ public class DiffFormatter {
if ( db = = null )
throw new IllegalStateException ( JGitText . get ( ) . repositoryIsRequired ) ;
if ( id . isComplete ( ) ) {
ObjectLoader ldr = db . open ( id . toObjectId ( ) ) ;
if ( ! ldr . isLarge ( ) )
return ldr . getCachedBytes ( ) ;
long sz = ldr . getSize ( ) ;
if ( sz < bigFileThreshold & & sz < Integer . MAX_VALUE ) {
byte [ ] buf ;
try {
buf = new byte [ ( int ) sz ] ;
} catch ( OutOfMemoryError noMemory ) {
LargeObjectException e ;
e = new LargeObjectException ( id . toObjectId ( ) ) ;
e . initCause ( noMemory ) ;
throw e ;
}
InputStream in = ldr . openStream ( ) ;
try {
IO . readFully ( in , buf , 0 , buf . length ) ;
} finally {
in . close ( ) ;
}
return buf ;
}
}
return new byte [ ] { } ;
ObjectLoader ldr = db . open ( id . toObjectId ( ) ) ;
return ldr . getCachedBytes ( bigFileThreshold ) ;
}
/ * *