Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-01-04 00:48:01 +0000
committerKevin Sawicki2012-01-04 00:48:01 +0000
commit3d15298011b769ef9797ba7a71ccb8fa538810e1 (patch)
tree37c07ac2507d085202c89b7d8d5997956d8669aa
parentd57c00e03696571afd92baf76cce03275b158bef (diff)
downloadjgit-3d15298011b769ef9797ba7a71ccb8fa538810e1.tar.gz
jgit-3d15298011b769ef9797ba7a71ccb8fa538810e1.tar.xz
jgit-3d15298011b769ef9797ba7a71ccb8fa538810e1.zip
Add helper for determining if status is clean
This checks if all collections that Status exposes are empty or not Change-Id: I0c342ab70dc36c1fd70acb4f8a924bb207d62f47
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/Status.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/Status.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/Status.java
index e1491da374..8ebd279aa7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/Status.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/Status.java
@@ -60,7 +60,9 @@ import org.eclipse.jgit.lib.IndexDiff;
* {@link #getChanged()}
*/
public class Status {
- private IndexDiff diff;
+ private final IndexDiff diff;
+
+ private final boolean clean;
/**
* @param diff
@@ -68,6 +70,21 @@ public class Status {
public Status(IndexDiff diff) {
super();
this.diff = diff;
+ clean = diff.getAdded().isEmpty() //
+ && diff.getChanged().isEmpty() //
+ && diff.getRemoved().isEmpty() //
+ && diff.getMissing().isEmpty() //
+ && diff.getModified().isEmpty() //
+ && diff.getUntracked().isEmpty() //
+ && diff.getConflicting().isEmpty();
+ }
+
+ /**
+ * @return true if no differences exist between the working-tree, the index,
+ * and the current HEAD, false if differences do exist
+ */
+ public boolean isClean() {
+ return clean;
}
/**

Back to the top