Source:
private PatchList readPatchList(final PatchListKey key, final Repository repo) throws IOException { final RawTextComparator cmp = comparatorFor(key.getWhitespace()); final ObjectReader reader = repo.newObjectReader(); try { final RevWalk rw = new RevWalk(reader); final RevCommit b = rw.parseCommit(key.getNewId()); final RevObject a = aFor(key, repo, rw, b); if (a == null) { final PatchListEntry[] entries = new PatchListEntry[1]; entries[0] = newCommitMessage(cmp, repo, reader, null, b); return new PatchList(a, b, true, entries); } final boolean againstParent = b.getParentCount() > 0 && b.getParent(0) == a; RevCommit aCommit = a instanceof RevCommit ? (RevCommit) a : null; RevTree aTree = rw.parseTree(a); RevTree bTree = b.getTree(); DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE); df.setRepository(repo); df.setDiffComparator(cmp); df.setDetectRenames(true); List<DiffEntry> diffEntries = df.scan(aTree, bTree); Set<String> paths = key.getOldId() != null ? getPaths(new PatchListKey(key.projectKey, null, key.getNewId(), key.getWhitespace()), repo, rw) : null; int cnt = diffEntries.size(); List<PatchListEntry> entries = new ArrayList<>(); entries.add(newCommitMessage(cmp, repo, reader, againstParent ? null : aCommit, b)); for (int i = 0; i < cnt; i++) { DiffEntry diffEntry = diffEntries.get(i); if (paths != null && (!paths.contains(diffEntry.getNewPath()) && !paths.contains(diffEntry.getOldPath()))) { continue; } FileHeader fh = df.toFileHeader(diffEntry); entries.add(newEntry(aTree, fh)); } return new PatchList(a, b, againstParent, entries.toArray(new PatchListEntry[entries.size()])); } finally { reader.release(); } }

Target:
private PatchList readPatchList(final PatchListKey key, final Repository repo) throws IOException { final RawTextComparator cmp = comparatorFor(key.getWhitespace()); final ObjectReader reader = repo.newObjectReader(); try { final RevWalk rw = new RevWalk(reader); final RevCommit b = rw.parseCommit(key.getNewId()); final RevObject a = aFor(key, repo, rw, b); if (a == null) { final PatchListEntry[] entries = new PatchListEntry[1]; entries[0] = newCommitMessage(cmp, repo, reader, null, b); return new PatchList(a, b, true, entries); } final boolean againstParent = b.getParentCount() > 0 && b.getParent(0) == a; RevCommit aCommit = a instanceof RevCommit ? (RevCommit) a : null; RevTree aTree = rw.parseTree(a); RevTree bTree = b.getTree(); DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE); df.setRepository(repo); df.setDiffComparator(cmp); df.setDetectRenames(true); List<DiffEntry> diffEntries = df.scan(aTree, bTree); Set<String> paths = key.getOldId() != null ? getPaths(new PatchListKey(key.projectKey, null, key.getNewId(), key.getWhitespace()), repo, rw) : null; int cnt = diffEntries.size(); List<PatchListEntry> entries = new ArrayList<>(); entries.add(newCommitMessage(cmp, repo, reader, againstParent ? null : aCommit, b)); for (int i = 0; i < cnt; i++) { DiffEntry diffEntry = diffEntries.get(i); if (paths == null || paths.contains(diffEntry.getNewPath()) || paths.contains(diffEntry.getOldPath())) { FileHeader fh = df.toFileHeader(diffEntry); entries.add(newEntry(aTree, fh)); } } return new PatchList(a, b, againstParent, entries.toArray(new PatchListEntry[entries.size()])); } finally { reader.release(); } }