List of usage examples for org.eclipse.jgit.diff DiffFormatter setBinaryFileThreshold
public void setBinaryFileThreshold(int threshold)
From source file:br.com.metricminer2.scm.GitRepository.java
License:Apache License
private List<DiffEntry> diffsForTheCommit(Repository repo, RevCommit commit) throws IOException, AmbiguousObjectException, IncorrectObjectTypeException { AnyObjectId currentCommit = repo.resolve(commit.getName()); AnyObjectId parentCommit = commit.getParentCount() > 0 ? repo.resolve(commit.getParent(0).getName()) : null; DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE); df.setBinaryFileThreshold(2 * 1024); // 2 mb max a file df.setRepository(repo);//from www .ja v a 2 s . co m df.setDiffComparator(RawTextComparator.DEFAULT); df.setDetectRenames(true); List<DiffEntry> diffs = null; if (parentCommit == null) { RevWalk rw = new RevWalk(repo); diffs = df.scan(new EmptyTreeIterator(), new CanonicalTreeParser(null, rw.getObjectReader(), commit.getTree())); rw.release(); } else { diffs = df.scan(parentCommit, currentCommit); } df.release(); return diffs; }