summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2013-07-19 13:37:58 +0200
committerChris Aniszczyk <caniszczyk@gmail.com>2013-07-21 21:39:53 -0500
commit06dd0e9e27a342f74ec97648ab1fbf101af383a4 (patch)
tree0b1235cca24e9b048be7b727893a94d4aca527bf /org.eclipse.jgit.pgm/src
parentf5be93d003759f6c933d33d56c8a18fa9e66766b (diff)
downloadjgit-06dd0e9e27a342f74ec97648ab1fbf101af383a4.tar.gz
jgit-06dd0e9e27a342f74ec97648ab1fbf101af383a4.zip
Add path option to StatusCommand
Allow filtering of the status. Only files which match given paths are inspected and only their state is reported. Change-Id: I3c4b1b46bf297cd4ebdb4997cfa14c8752a36411 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
index 45cfd92ffd..0214ed00e0 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
@@ -52,11 +52,13 @@ import java.util.List;
import java.util.Map;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.StatusCommand;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.IndexDiff.StageState;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.pgm.internal.CLIText;
+import org.kohsuke.args4j.Option;
@Command(usage = "usage_Status", common = true)
class Status extends TextBuiltin {
@@ -69,6 +71,9 @@ class Status extends TextBuiltin {
protected final String statusFileListFormatUnmerged = CLIText.get().statusFileListFormatUnmerged;
+ @Option(name = "--", metaVar = "metaVar_path", multiValued = true)
+ protected List<String> filterPaths;
+
@Override
protected void run() throws Exception {
// Print current branch name
@@ -81,7 +86,11 @@ class Status extends TextBuiltin {
} else
outw.println(CLIText.formatLine(CLIText.get().notOnAnyBranch));
// List changes
- org.eclipse.jgit.api.Status status = new Git(db).status().call();
+ StatusCommand statusCommand = new Git(db).status();
+ if (filterPaths != null && filterPaths.size() > 0)
+ for (String path : filterPaths)
+ statusCommand.addPath(path);
+ org.eclipse.jgit.api.Status status = statusCommand.call();
Collection<String> added = status.getAdded();
Collection<String> changed = status.getChanged();
Collection<String> removed = status.getRemoved();