use of org.eclipse.jgit.diff.DiffAlgorithm in project egit by eclipse.
the class BlameRevision method calculateDiffToParent.
private Diff calculateDiffToParent(RevCommit parentCommit) {
try (ObjectReader reader = repository.newObjectReader()) {
DiffEntry diffEntry = CompareCoreUtils.getChangeDiffEntry(repository, sourcePath, commit, parentCommit, reader);
if (diffEntry == null)
return null;
RawText oldText = readText(diffEntry.getOldId(), reader);
RawText newText = readText(diffEntry.getNewId(), reader);
StoredConfig config = repository.getConfig();
DiffAlgorithm diffAlgorithm = DiffAlgorithm.getAlgorithm(config.getEnum(ConfigConstants.CONFIG_DIFF_SECTION, null, ConfigConstants.CONFIG_KEY_ALGORITHM, SupportedAlgorithm.HISTOGRAM));
EditList editList = diffAlgorithm.diff(RawTextComparator.DEFAULT, oldText, newText);
return new Diff(diffEntry.getOldPath(), oldText, newText, editList);
} catch (IOException e) {
return null;
}
}
Aggregations