use of org.eclipse.che.api.git.shared.DiffType in project che by eclipse.
the class JGitDiffPage method writeTo.
@Override
public final void writeTo(OutputStream out) throws IOException {
DiffFormatter formatter = new DiffFormatter(new BufferedOutputStream(out));
formatter.setRepository(repository);
List<String> rawFileFilter = params.getFileFilter();
TreeFilter pathFilter = (rawFileFilter != null && rawFileFilter.size() > 0) ? PathFilterGroup.createFromStrings(rawFileFilter) : TreeFilter.ALL;
formatter.setPathFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, pathFilter));
try {
String commitA = params.getCommitA();
String commitB = params.getCommitB();
boolean cached = params.isCached();
List<DiffEntry> diff;
if (commitA == null && commitB == null && !cached) {
diff = indexToWorkingTree(formatter);
} else if (commitA != null && commitB == null && !cached) {
diff = commitToWorkingTree(commitA, formatter);
} else if (commitA == null && commitB != null) {
diff = emptyToCommit(commitB, formatter);
} else if (commitB == null) {
diff = commitToIndex(commitA, formatter);
} else {
diff = commitToCommit(commitA, commitB, formatter);
}
DiffType type = params.getType();
if (type == DiffType.NAME_ONLY) {
writeNames(diff, out);
} else if (type == DiffType.NAME_STATUS) {
writeNamesAndStatus(diff, out);
} else {
writeRawDiff(diff, formatter);
}
} finally {
formatter.close();
repository.close();
}
}
Aggregations