private List<DiffEntry> updateFollowFilter(List<DiffEntry> files) { String oldPath = ((FollowFilter) pathFilter).getPath(); for (DiffEntry ent : files) { if (isRename(ent) && ent.getNewPath().equals(oldPath)) { pathFilter = FollowFilter.create(ent.getOldPath(), diffCfg); return Collections.singletonList(ent); } } return Collections.emptyList(); }
private static @NonNull DiffEntry diffFile(Repository repo, String oldCommit, String newCommit, String path) throws IOException, GitAPIException { Config config = new Config(); config.setBoolean("diff", null, "renames", true); DiffConfig diffConfig = config.get(DiffConfig.KEY); try (Git git = new Git(repo)) { List<DiffEntry> diffList = git.diff(). setOldTree(prepareTreeParser(repo, oldCommit)). setNewTree(prepareTreeParser(repo, newCommit)). setPathFilter(FollowFilter.create(path, diffConfig)). call(); if (diffList.size() == 0) return null; if (diffList.size() > 1) throw new RuntimeException("invalid diff"); return diffList.get(0); } } }
private static @NonNull DiffEntry diffFile(Repository repo, String oldCommit, String newCommit, String path) throws IOException, GitAPIException { Config config = new Config(); config.setBoolean("diff", null, "renames", true); DiffConfig diffConfig = config.get(DiffConfig.KEY); try (Git git = new Git(repo)) { List<DiffEntry> diffList = git.diff(). setOldTree(prepareTreeParser(repo, oldCommit)). setNewTree(prepareTreeParser(repo, newCommit)). setPathFilter(FollowFilter.create(path, diffConfig)). call(); if (diffList.size() == 0) return null; if (diffList.size() > 1) throw new RuntimeException("invalid diff"); return diffList.get(0); } } }
private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { TreeWalk tw = pathFilter; FollowFilter oldFilter = (FollowFilter) tw.getFilter(); tw.setFilter(TreeFilter.ANY_DIFF); tw.reset(trees); List<DiffEntry> files = DiffEntry.scan(tw); RenameDetector rd = new RenameDetector(tw.getObjectReader(), cfg); rd.addAll(files); files = rd.compute(); TreeFilter newFilter = oldFilter; for (DiffEntry ent : files) { if (isRename(ent) && ent.getNewPath().equals(oldFilter.getPath())) { newFilter = FollowFilter.create(ent.getOldPath(), cfg); RenameCallback callback = oldFilter.getRenameCallback(); if (callback != null) { callback.renamed(ent); // forward the callback to the new follow filter ((FollowFilter) newFilter).setRenameCallback(callback); } break; } } tw.setFilter(newFilter); }
private FollowFilter createFollowFilter(String path, DiffConfig diffConfig) { FollowFilter followFilter = FollowFilter.create(path, diffConfig); followFilter.setRenameCallback(new RenameCallback() { @Override public void renamed(DiffEntry entry) { if (fileViewerInterestingPaths != null) { fileViewerInterestingPaths.add(entry.getOldPath()); fileViewerInterestingPaths.add(entry.getNewPath()); } } }); return followFilter; }
private List<DiffEntry> updateFollowFilter(List<DiffEntry> files) { String oldPath = ((FollowFilter) pathFilter).getPath(); for (DiffEntry ent : files) { if (isRename(ent) && ent.getNewPath().equals(oldPath)) { pathFilter = FollowFilter.create(ent.getOldPath(), diffCfg); return Collections.singletonList(ent); } } return Collections.emptyList(); }
private List<DiffEntry> updateFollowFilter(List<DiffEntry> files) { String oldPath = ((FollowFilter) pathFilter).getPath(); for (DiffEntry ent : files) { if (isRename(ent) && ent.getNewPath().equals(oldPath)) { pathFilter = FollowFilter.create(ent.getOldPath(), diffCfg); return Collections.singletonList(ent); } } return Collections.emptyList(); }
private TreeFilter createTreeFilter() { if (filterResources == null) return TreeFilter.ALL; List<TreeFilter> filters = new ArrayList<TreeFilter>(); for (IResource resource : filterResources) { RepositoryMapping mapping = RepositoryMapping.getMapping(resource); if (mapping != null) { DiffConfig diffConfig = mapping.getRepository().getConfig().get(DiffConfig.KEY); String path = mapping.getRepoRelativePath(resource); if (path != null && !"".equals(path)) { //$NON-NLS-1$ if (resource.getType() == IResource.FILE) filters.add(FollowFilter.create(path, diffConfig)); else filters.add(AndTreeFilter.create( PathFilter.create(path), TreeFilter.ANY_DIFF)); } } } if (filters.isEmpty()) return TreeFilter.ALL; else if (filters.size() == 1) return filters.get(0); else return OrTreeFilter.create(filters); } }
private TreeRevFilter createTreeRevFilter(final RevWalk rw, String curPath, final RenameCallback renameCallback) { final FollowFilter followFilter = FollowFilter.create(curPath, git.getRepository().getConfig().get(DiffConfig.KEY)); followFilter.setRenameCallback(renameCallback); final TreeRevFilter revFilter = new TreeRevFilter(rw, followFilter); return revFilter; }
DiffConfig diffConfig = repository.getConfig().get( DiffConfig.KEY); FollowFilter filter = FollowFilter.create(path, diffConfig); rw.setTreeFilter(filter);
walk.setTreeFilter(FollowFilter.create(followPath, db.getConfig().get(DiffConfig.KEY))); } else if (pathFilter != TreeFilter.ALL) {
private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { TreeWalk tw = pathFilter; FollowFilter oldFilter = (FollowFilter) tw.getFilter(); tw.setFilter(TreeFilter.ANY_DIFF); tw.reset(trees); List<DiffEntry> files = DiffEntry.scan(tw); RenameDetector rd = new RenameDetector(tw.getObjectReader(), cfg); rd.addAll(files); files = rd.compute(); TreeFilter newFilter = oldFilter; for (DiffEntry ent : files) { if (isRename(ent) && ent.getNewPath().equals(oldFilter.getPath())) { newFilter = FollowFilter.create(ent.getOldPath(), cfg); RenameCallback callback = oldFilter.getRenameCallback(); if (callback != null) { callback.renamed(ent); // forward the callback to the new follow filter ((FollowFilter) newFilter).setRenameCallback(callback); } break; } } tw.setFilter(newFilter); }
private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { TreeWalk tw = pathFilter; FollowFilter oldFilter = (FollowFilter) tw.getFilter(); tw.setFilter(TreeFilter.ANY_DIFF); tw.reset(trees); List<DiffEntry> files = DiffEntry.scan(tw); RenameDetector rd = new RenameDetector(tw.getObjectReader(), cfg); rd.addAll(files); files = rd.compute(); TreeFilter newFilter = oldFilter; for (DiffEntry ent : files) { if (isRename(ent) && ent.getNewPath().equals(oldFilter.getPath())) { newFilter = FollowFilter.create(ent.getOldPath(), cfg); RenameCallback callback = oldFilter.getRenameCallback(); if (callback != null) { callback.renamed(ent); // forward the callback to the new follow filter ((FollowFilter) newFilter).setRenameCallback(callback); } break; } } tw.setFilter(newFilter); }
private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { TreeWalk tw = pathFilter; FollowFilter oldFilter = (FollowFilter) tw.getFilter(); tw.setFilter(TreeFilter.ANY_DIFF); tw.reset(trees); List<DiffEntry> files = DiffEntry.scan(tw); RenameDetector rd = new RenameDetector(tw.getObjectReader(), cfg); rd.addAll(files); files = rd.compute(); TreeFilter newFilter = oldFilter; for (DiffEntry ent : files) { if (isRename(ent) && ent.getNewPath().equals(oldFilter.getPath())) { newFilter = FollowFilter.create(ent.getOldPath(), cfg); RenameCallback callback = oldFilter.getRenameCallback(); if (callback != null) { callback.renamed(ent); // forward the callback to the new follow filter ((FollowFilter) newFilter).setRenameCallback(callback); } break; } } tw.setFilter(newFilter); }