Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce2010-12-08 03:11:05 +0000
committerShawn O. Pearce2010-12-08 18:03:20 +0000
commit18abb8195a67a0502a71e2420078dd95563e18c6 (patch)
tree882a0bf08deb2f679a0b7b014f27e9b066ce11b8
parenta66a7d90fd4c3ec3587d2f314e785ab5bba71b6f (diff)
downloadjgit-18abb8195a67a0502a71e2420078dd95563e18c6.tar.gz
jgit-18abb8195a67a0502a71e2420078dd95563e18c6.tar.xz
jgit-18abb8195a67a0502a71e2420078dd95563e18c6.zip
IndexDiff: Remove unnecessary changesExist flag
Instead of setting a boolean when a difference record is found, return false from diff() only if all of the collections are empty. When all of them are empty, no difference was found. Change-Id: I555fef37adb764ce253481751071c53ad12cf416 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
index 3c63e251b3..0ab096c3a3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
@@ -168,7 +168,6 @@ public class IndexDiff {
* @throws IOException
*/
public boolean diff() throws IOException {
- boolean changesExist = false;
dirCache = repository.readDirCache();
TreeWalk treeWalk = new TreeWalk(repository);
@@ -202,12 +201,10 @@ public class IndexDiff {
!= dirCacheIterator.getEntryRawMode()) {
// in repo, in index, content diff => changed
changed.add(treeWalk.getPathString());
- changesExist = true;
}
} else {
// in repo, not in index => removed
removed.add(treeWalk.getPathString());
- changesExist = true;
if (workingTreeIterator != null)
untracked.add(treeWalk.getPathString());
}
@@ -215,13 +212,11 @@ public class IndexDiff {
if (dirCacheIterator != null) {
// not in repo, in index => added
added.add(treeWalk.getPathString());
- changesExist = true;
} else {
// not in repo, not in index => untracked
if (workingTreeIterator != null
&& !workingTreeIterator.isEntryIgnored()) {
untracked.add(treeWalk.getPathString());
- changesExist = true;
}
}
}
@@ -230,18 +225,22 @@ public class IndexDiff {
if (workingTreeIterator == null) {
// in index, not in workdir => missing
missing.add(treeWalk.getPathString());
- changesExist = true;
} else {
if (workingTreeIterator.isModified(
dirCacheIterator.getDirCacheEntry(), true)) {
// in index, in workdir, content differs => modified
modified.add(treeWalk.getPathString());
- changesExist = true;
}
}
}
}
- return changesExist;
+
+ if (added.isEmpty() && changed.isEmpty() && removed.isEmpty()
+ && missing.isEmpty() && modified.isEmpty()
+ && untracked.isEmpty())
+ return false;
+ else
+ return true;
}
/**

Back to the top