List of usage examples for org.eclipse.jgit.diff DiffFormatter setDiffAlgorithm
public void setDiffAlgorithm(DiffAlgorithm alg)
From source file:com.google.gerrit.server.patch.PatchListLoader.java
License:Apache License
private FileHeader toFileHeaderWithoutMyersDiff(DiffFormatter diffFormatter, DiffEntry diffEntry) throws IOException { HistogramDiff histogramDiff = new HistogramDiff(); histogramDiff.setFallbackAlgorithm(null); diffFormatter.setDiffAlgorithm(histogramDiff); return diffFormatter.toFileHeader(diffEntry); }
From source file:org.kuali.student.git.tools.GitExtractor.java
License:Educational Community License
public void extractDifference(String targetTagName, String copyFromTagName) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevTree target = extractTag(targetTagName); RevTree copyFrom = extractTag(copyFromTagName); DiffFormatter formatter = new DiffFormatter(System.out); formatter.setRepository(repository); formatter.setDetectRenames(true);/*from w w w .jav a 2s. c o m*/ formatter.setDiffAlgorithm(DiffAlgorithm.getAlgorithm(SupportedAlgorithm.MYERS)); formatter.setDiffComparator(RawTextComparator.WS_IGNORE_ALL); List<DiffEntry> results = formatter.scan(target, copyFrom); for (DiffEntry entry : results) { if (entry.getChangeType().equals(ChangeType.COPY)) { AbbreviatedObjectId copyFromBlobId = entry.getOldId(); // Cscore:md5:target-path:copy-from-path log.info(String.format("C%d:%s:%s:%s", entry.getScore(), "md5", entry.getNewPath(), entry.getOldPath())); } else if (entry.getChangeType().equals(ChangeType.MODIFY)) { // Cscore:md5:target-path:copy-from-path log.info(String.format("M%d:%s:%s:%s", entry.getScore(), "md5", entry.getNewPath(), entry.getOldPath())); } } }