/** * Show only commits that affect any of the specified paths. The path must * either name a file or a directory exactly and use <code>/</code> (slash) * as separator. Note that regex expressions or wildcards are not supported. * * @param path * a repository-relative path (with <code>/</code> as separator) * @return {@code this} */ public LogCommand addPath(String path) { checkCallable(); pathFilters.add(PathFilter.create(path)); return this; }
/** * Create a new tree filter for a user supplied path. * <p> * Path strings are relative to the root of the repository. If the user's * input should be assumed relative to a subdirectory of the repository the * caller must prepend the subdirectory's path prior to creating the filter. * <p> * Path strings use '/' to delimit directories on all platforms. * * @param path * the path to filter on. Must not be the empty string. All * trailing '/' characters will be trimmed before string's length * is checked or is used as part of the constructed filter. * @return a new filter for the requested path. * @throws java.lang.IllegalArgumentException * the path supplied was the empty string. */ public static PathFilter create(String path) { while (path.endsWith("/")) //$NON-NLS-1$ path = path.substring(0, path.length() - 1); if (path.length() == 0) throw new IllegalArgumentException(JGitText.get().emptyPathNotPermitted); return new PathFilter(path); }
private void filterOutOtherModulesChanges(String modulePath, List<String> childModules, RevWalk walk) { boolean isRootModule = ".".equals(modulePath); boolean isMultiModuleProject = !isRootModule || !childModules.isEmpty(); List<TreeFilter> treeFilters = new ArrayList<TreeFilter>(); treeFilters.add(TreeFilter.ANY_DIFF); if (isMultiModuleProject) { if (!isRootModule) { // for sub-modules, look for changes only in the sub-module path... treeFilters.add(PathFilter.create(modulePath)); } // ... but ignore any sub-modules of the current sub-module, because they can change independently of the current module for (String childModule : childModules) { String path = isRootModule ? childModule : modulePath + "/" + childModule; treeFilters.add(PathFilter.create(path).negate()); } } TreeFilter treeFilter = treeFilters.size() == 1 ? treeFilters.get(0) : AndTreeFilter.create(treeFilters); walk.setTreeFilter(treeFilter); } }
/** * Get result path * * @return path file path being processed */ public String getResultPath() { return resultPath.getPath(); }
/** {@inheritDoc} */ @Override public TreeFilter clone() { return new FollowFilter(path.clone(), cfg); }
/** * Get the path this filter matches. * * @return the path this filter matches. */ public String getPath() { return path.getPath(); }
/** {@inheritDoc} */ @Override public TreeFilter clone() { return new FollowFilter(path.clone(), cfg); }
/** * Create a new tree filter for a user supplied path. * <p> * Path strings are relative to the root of the repository. If the user's * input should be assumed relative to a subdirectory of the repository the * caller must prepend the subdirectory's path prior to creating the filter. * <p> * Path strings use '/' to delimit directories on all platforms. * * @param path * the path to filter on. Must not be the empty string. All * trailing '/' characters will be trimmed before string's length * is checked or is used as part of the constructed filter. * @param cfg * diff config specifying rename detection options. * @return a new filter for the requested path. * @throws java.lang.IllegalArgumentException * the path supplied was the empty string. * @since 3.0 */ public static FollowFilter create(String path, DiffConfig cfg) { return new FollowFilter(PathFilter.create(path), cfg); }
/** * Get source path * * @return path of the file being blamed */ public String getSourcePath() { return outCandidate.sourcePath.getPath(); }
/** {@inheritDoc} */ @Override public TreeFilter clone() { return new FollowFilter(path.clone(), cfg); }
PathFilter clusterFileFilter = new PathFilter() { public boolean accept(Path path) { return path.getName().startsWith("part"); } }; FileStatus[] fileStatusArray = fs.listStatus(path, clusterFileFilter);
/** * Create a collection of path filters from Java strings. * <p> * Path strings are relative to the root of the repository. If the user's * input should be assumed relative to a subdirectory of the repository the * caller must prepend the subdirectory's path prior to creating the filter. * <p> * Path strings use '/' to delimit directories on all platforms. * <p> * Paths may appear in any order within the collection. Sorting may be done * internally when the group is constructed if doing so will improve path * matching performance. * * @param paths * the paths to test against. Must have at least one entry. * @return a new filter for the list of paths supplied. */ public static TreeFilter createFromStrings(Collection<String> paths) { if (paths.isEmpty()) throw new IllegalArgumentException( JGitText.get().atLeastOnePathIsRequired); final PathFilter[] p = new PathFilter[paths.size()]; int i = 0; for (String s : paths) p[i++] = PathFilter.create(s); return create(p); }
@Override public TreeFilter clone() { return new FollowFilter(path.clone(), cfg); }
/** * Create a new tree filter for a user supplied path. * <p> * Path strings are relative to the root of the repository. If the user's * input should be assumed relative to a subdirectory of the repository the * caller must prepend the subdirectory's path prior to creating the filter. * <p> * Path strings use '/' to delimit directories on all platforms. * * @param path * the path to filter on. Must not be the empty string. All * trailing '/' characters will be trimmed before string's length * is checked or is used as part of the constructed filter. * @return a new filter for the requested path. * @throws IllegalArgumentException * the path supplied was the empty string. */ public static PathFilter create(String path) { while (path.endsWith("/")) //$NON-NLS-1$ path = path.substring(0, path.length() - 1); if (path.length() == 0) throw new IllegalArgumentException(JGitText.get().emptyPathNotPermitted); return new PathFilter(path); }
@Signature public Memory diff(ArrayMemory settings) throws GitAPIException { DiffCommand command = getWrappedObject().diff(); if (settings != null) { command.setCached(settings.valueOfIndex("cached").toBoolean()); Memory contextLines = settings.valueOfIndex("contextLines"); if (contextLines.isNotNull()) { command.setContextLines(contextLines.toInteger()); } Memory destPrefix = settings.valueOfIndex("destPrefix"); if (destPrefix.isNotNull()) { command.setDestinationPrefix(destPrefix.toString()); } Memory sourcePrefix = settings.valueOfIndex("sourcePrefix"); if (sourcePrefix.isNotNull()) { command.setSourcePrefix(sourcePrefix.toString()); } command.setShowNameAndStatusOnly(settings.valueOfIndex("showNameAndStatusOnly").toBoolean()); Memory pathFilter = settings.valueOfIndex("pathFilter"); if (pathFilter.isNotNull()) { command.setPathFilter(PathFilter.create(pathFilter.toString())); } } List<DiffEntry> call = command.call(); return GitUtils.valueOfDiffEntries(call); }