private void setReader(ObjectReader reader, Config cfg, boolean closeReader) { close(); this.closeReader = closeReader; this.reader = reader; this.diffCfg = cfg.get(DiffConfig.KEY); ContentSource cs = ContentSource.create(reader); source = new ContentSource.Pair(cs, cs); if (diffCfg.isNoPrefix()) { setOldPrefix(""); //$NON-NLS-1$ setNewPrefix(""); //$NON-NLS-1$ } setDetectRenames(diffCfg.isRenameDetectionEnabled()); diffAlgorithm = DiffAlgorithm.getAlgorithm(cfg.getEnum( ConfigConstants.CONFIG_DIFF_SECTION, null, ConfigConstants.CONFIG_KEY_ALGORITHM, SupportedAlgorithm.HISTOGRAM)); }
protected static DiffFormatter createDiffFormatter(Repository r, OutputStream buffer) { DiffFormatter formatter = new DiffFormatter(buffer); formatter.setRepository(r); formatter.setDiffComparator(RawTextComparator.DEFAULT); formatter.setDetectRenames(true); return formatter; }
protected static DiffFormatter createDiffFormatter(Repository r, OutputStream buffer) { DiffFormatter formatter = new DiffFormatter(buffer); formatter.setRepository(r); formatter.setDiffComparator(RawTextComparator.DEFAULT); formatter.setDetectRenames(true); return formatter; }
setDetectRenames(true); files = updateFollowFilter(detectRenames(DiffEntry.scan(walk)));
public DiffFormatter getDiffFormatter(OutputStream out) { DiffFormatter formatter = new DiffFormatter(out); formatter.setRepository(git.getRepository()); formatter.setDiffComparator(RawTextComparator.DEFAULT); formatter.setDetectRenames(true); return formatter; }
private List<DiffEntry> getDiffs(RevCommit commit, RevCommit parent) throws IOException { DiffFormatter formatter = new DiffFormatter(DisabledOutputStream.INSTANCE); formatter.setRepository(repository); formatter.setDiffComparator(RawTextComparator.DEFAULT); formatter.setDetectRenames(true); return formatter.scan(parent.getTree(), commit.getTree()); } }
diffFmt.setPathFilter(pathFilter); if (detectRenames != null) diffFmt.setDetectRenames(detectRenames.booleanValue()); if (renameLimit != null && diffFmt.isDetectRenames()) { RenameDetector rd = diffFmt.getRenameDetector();
int linesAdded = 0; int linesDeleted = 0; int filesChanged = 0; try { repo = new FileRepository(new File("repo/.git")); RevWalk rw = new RevWalk(repo); RevCommit commit = rw.parseCommit(repo.resolve("486817d67b")); // Any ref will work here (HEAD, a sha1, tag, branch) RevCommit parent = rw.parseCommit(commit.getParent(0).getId()); DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE); df.setRepository(repo); df.setDiffComparator(RawTextComparator.DEFAULT); df.setDetectRenames(true); List<DiffEntry> diffs; diffs = df.scan(parent.getTree(), commit.getTree()); filesChanged = diffs.size(); for (DiffEntry diff : diffs) { for (Edit edit : df.toFileHeader(diff).toEditList()) { linesDeleted += edit.getEndA() - edit.getBeginA(); linesAdded += edit.getEndB() - edit.getBeginB(); } } } catch (IOException e1) { throw new RuntimeException(e1); }
formatter.setDetectRenames(true);
/** * Helper method for calculating the diff of a Git commit. */ public List<DiffEntry> getDiffEntries(final Git git, final RevCommit commit) { try { final Repository repository = git.getRepository(); int _parentCount = commit.getParentCount(); boolean _greaterThan = (_parentCount > 1); if (_greaterThan) { throw new IllegalArgumentException("Not supported for merge commits."); } final RevCommit parent = IterableExtensions.<RevCommit>head(((Iterable<RevCommit>)Conversions.doWrapArray(commit.getParents()))); DiffFormatter _diffFormatter = new DiffFormatter(DisabledOutputStream.INSTANCE); final Procedure1<DiffFormatter> _function = (DiffFormatter df) -> { df.setRepository(repository); df.setDiffComparator(RawTextComparator.DEFAULT); df.setDetectRenames(true); }; final DiffFormatter diffFormatter = ObjectExtensions.<DiffFormatter>operator_doubleArrow(_diffFormatter, _function); return diffFormatter.scan(parent, commit.getTree()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private void setReader(ObjectReader reader, Config cfg, boolean closeReader) { close(); this.closeReader = closeReader; this.reader = reader; this.diffCfg = cfg.get(DiffConfig.KEY); ContentSource cs = ContentSource.create(reader); source = new ContentSource.Pair(cs, cs); if (diffCfg.isNoPrefix()) { setOldPrefix(""); //$NON-NLS-1$ setNewPrefix(""); //$NON-NLS-1$ } setDetectRenames(diffCfg.isRenameDetectionEnabled()); diffAlgorithm = DiffAlgorithm.getAlgorithm(cfg.getEnum( ConfigConstants.CONFIG_DIFF_SECTION, null, ConfigConstants.CONFIG_KEY_ALGORITHM, SupportedAlgorithm.HISTOGRAM)); }
private void setReader(ObjectReader reader, Config cfg, boolean closeReader) { close(); this.closeReader = closeReader; this.reader = reader; this.diffCfg = cfg.get(DiffConfig.KEY); ContentSource cs = ContentSource.create(reader); source = new ContentSource.Pair(cs, cs); if (diffCfg.isNoPrefix()) { setOldPrefix(""); //$NON-NLS-1$ setNewPrefix(""); //$NON-NLS-1$ } setDetectRenames(diffCfg.isRenameDetectionEnabled()); diffAlgorithm = DiffAlgorithm.getAlgorithm(cfg.getEnum( ConfigConstants.CONFIG_DIFF_SECTION, null, ConfigConstants.CONFIG_KEY_ALGORITHM, SupportedAlgorithm.HISTOGRAM)); }
df.setRepository( repository ); df.setDiffComparator( RawTextComparator.DEFAULT ); df.setDetectRenames( true ); List<DiffEntry> diffs = df.scan( parent.getTree(), commit.getTree() ); for ( DiffEntry diff : diffs )
df.setRepository( repository ); df.setDiffComparator( RawTextComparator.DEFAULT ); df.setDetectRenames( true ); List<DiffEntry> diffs = df.scan( parent.getTree(), commit.getTree() ); for ( DiffEntry diff : diffs )
ObjectReader reader = repository.newObjectReader();) { diffFormatter.setRepository(repository); diffFormatter.setDetectRenames(true); diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
private List<DiffEntry> getDiffBetweenCommits(Repository repo, AnyObjectId parentCommit, AnyObjectId currentCommit) { try (DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE)) { df.setBinaryFileThreshold(2 * 1024); // 2 mb max a file df.setRepository(repo); df.setDiffComparator(RawTextComparator.DEFAULT); df.setDetectRenames(true); setContext(df); List<DiffEntry> diffs = null; if (parentCommit == null) { try (RevWalk rw = new RevWalk(repo)) { RevCommit commit = rw.parseCommit(currentCommit); diffs = df.scan(new EmptyTreeIterator(), new CanonicalTreeParser(null, rw.getObjectReader(), commit.getTree())); } } else { diffs = df.scan(parentCommit, currentCommit); } return diffs; } catch (IOException e) { throw new RuntimeException( "error diffing " + parentCommit.getName() + " and " + currentCommit.getName() + " in " + path, e); } }
diffFmt.setPathFilter(pathFilter); if (detectRenames != null) diffFmt.setDetectRenames(detectRenames.booleanValue()); if (renameLimit != null && diffFmt.isDetectRenames()) { RenameDetector rd = diffFmt.getRenameDetector();
diffFmt.setPathFilter(pathFilter); if (detectRenames != null) diffFmt.setDetectRenames(detectRenames.booleanValue()); if (renameLimit != null && diffFmt.isDetectRenames()) { RenameDetector rd = diffFmt.getRenameDetector();
setDetectRenames(true); files = updateFollowFilter(detectRenames(DiffEntry.scan(walk)));
setDetectRenames(true); files = updateFollowFilter(detectRenames(DiffEntry.scan(walk)));