summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorChristian Trutz <christian.trutz@gmail.com>2013-07-25 23:28:05 +0200
committerRobin Stocker <robin@nibor.org>2013-07-28 16:01:46 +0200
commitf677b07b9871f6b72f3fdb262dc2a5d56ba3718c (patch)
treea91ec7b1f9ff492d69276a6def1e6153d28494f9 /org.eclipse.jgit/src
parenta76a4acf87952249b94f4be29614565541eb8c46 (diff)
downloadjgit-f677b07b9871f6b72f3fdb262dc2a5d56ba3718c.tar.gz
jgit-f677b07b9871f6b72f3fdb262dc2a5d56ba3718c.zip
Add setter for ProgressMonitor to StatusCommand
This is useful if Git.status() is a long running command. Change-Id: I6bdbf347a688043d549c1f091fb4a264a6c7024e Signed-off-by: Christian Trutz <christian.trutz@gmail.com> Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java
index 182ffa84b1..20ba57d8db 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java
@@ -51,6 +51,7 @@ import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.IndexDiff;
+import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.WorkingTreeIterator;
@@ -69,6 +70,7 @@ import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
public class StatusCommand extends GitCommand<Status> {
private WorkingTreeIterator workingTreeIt;
private List<String> paths = null;
+ private ProgressMonitor progressMonitor = null;
/**
* @param repo
@@ -124,7 +126,11 @@ public class StatusCommand extends GitCommand<Status> {
IndexDiff diff = new IndexDiff(repo, Constants.HEAD, workingTreeIt);
if (paths != null)
diff.setFilter(PathFilterGroup.createFromStrings(paths));
- diff.diff();
+ if (progressMonitor == null)
+ diff.diff();
+ else
+ diff.diff(progressMonitor, ProgressMonitor.UNKNOWN,
+ ProgressMonitor.UNKNOWN, ""); //$NON-NLS-1$
return new Status(diff);
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
@@ -143,4 +149,17 @@ public class StatusCommand extends GitCommand<Status> {
this.workingTreeIt = workingTreeIt;
return this;
}
+
+ /**
+ * To set the {@link ProgressMonitor} which contains callback methods to
+ * inform you about the progress of this command.
+ *
+ * @param progressMonitor
+ * @return {@code this}
+ * @since 3.1
+ */
+ public StatusCommand setProgressMonitor(ProgressMonitor progressMonitor) {
+ this.progressMonitor = progressMonitor;
+ return this;
+ }
}