@ -64,6 +64,7 @@ import org.eclipse.jgit.treewalk.AbstractTreeIterator;
import org.eclipse.jgit.treewalk.CanonicalTreeParser ;
import org.eclipse.jgit.treewalk.CanonicalTreeParser ;
import org.eclipse.jgit.treewalk.FileTreeIterator ;
import org.eclipse.jgit.treewalk.FileTreeIterator ;
import org.eclipse.jgit.treewalk.filter.TreeFilter ;
import org.eclipse.jgit.treewalk.filter.TreeFilter ;
import org.eclipse.jgit.util.io.NullOutputStream ;
/ * *
/ * *
* Show changes between commits , commit and working tree , etc .
* Show changes between commits , commit and working tree , etc .
@ -108,8 +109,11 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
* @return a DiffEntry for each path which is different
* @return a DiffEntry for each path which is different
* /
* /
public List < DiffEntry > call ( ) throws GitAPIException , IOException {
public List < DiffEntry > call ( ) throws GitAPIException , IOException {
final DiffFormatter diffFmt = new DiffFormatter (
final DiffFormatter diffFmt ;
new BufferedOutputStream ( out ) ) ;
if ( out ! = null & & ! showNameAndStatusOnly )
diffFmt = new DiffFormatter ( new BufferedOutputStream ( out ) ) ;
else
diffFmt = new DiffFormatter ( NullOutputStream . INSTANCE ) ;
diffFmt . setRepository ( repo ) ;
diffFmt . setRepository ( repo ) ;
diffFmt . setProgressMonitor ( monitor ) ;
diffFmt . setProgressMonitor ( monitor ) ;
try {
try {
@ -136,17 +140,17 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
}
}
diffFmt . setPathFilter ( pathFilter ) ;
diffFmt . setPathFilter ( pathFilter ) ;
List < DiffEntry > result = diffFmt . scan ( oldTree , newTree ) ;
if ( showNameAndStatusOnly )
return result ;
else {
if ( contextLines > = 0 )
if ( contextLines > = 0 )
diffFmt . setContext ( contextLines ) ;
diffFmt . setContext ( contextLines ) ;
if ( destinationPrefix ! = null )
if ( destinationPrefix ! = null )
diffFmt . setNewPrefix ( destinationPrefix ) ;
diffFmt . setNewPrefix ( destinationPrefix ) ;
if ( sourcePrefix ! = null )
if ( sourcePrefix ! = null )
diffFmt . setOldPrefix ( sourcePrefix ) ;
diffFmt . setOldPrefix ( sourcePrefix ) ;
List < DiffEntry > result = diffFmt . scan ( oldTree , newTree ) ;
if ( showNameAndStatusOnly ) {
return result ;
} else {
diffFmt . format ( result ) ;
diffFmt . format ( result ) ;
diffFmt . flush ( ) ;
diffFmt . flush ( ) ;
return result ;
return result ;