aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-09-01 12:31:37 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-09-02 11:38:39 -0700
commit6f00a3e651e91592e2eb4f239b243a0aa2fe4610 (patch)
tree7dc9f848bf103e6e8f6f8e3e2122b57bcbe0846f /org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
parent244b1580b5155099bfdf98692d76c1b2a6183126 (diff)
downloadjgit-6f00a3e651e91592e2eb4f239b243a0aa2fe4610.tar.gz
jgit-6f00a3e651e91592e2eb4f239b243a0aa2fe4610.zip
Fix TreeWalk bug comparing DirCache and WorkingTree with ANY_DIFF
When comparing a DirCache and a WorkingTree using ANY_DIFF we sometimes didn't recursive into a subtree of both sides gave us zeroId() back for the identity of a subtree. This happens when the DirCache doesn't have a valid cache tree for the subtree, as then it uses zeroId() for the ObjectId of the subtree, which then appears to be equal to the zeroId() of the WorkingTreeIterator's subtree. We work around this by adding a hasId() method that returns true only if this iterator has a valid ObjectId. The idEquals method on TreeWalk than only performs a compare between two iterators if both iterators have a valid id. Change-Id: I695f7fafbeb452e8c0703a05c02921fae0822d3f Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
index 16859646b6..992928bc43 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
@@ -683,8 +683,6 @@ public class TreeWalk {
final AbstractTreeIterator ch = currentHead;
final AbstractTreeIterator a = trees[nthA];
final AbstractTreeIterator b = trees[nthB];
- if (a.matches == ch && b.matches == ch)
- return a.idEqual(b);
if (a.matches != ch && b.matches != ch) {
// If neither tree matches the current path node then neither
// tree has this entry. In such case the ObjectId is zero(),
@@ -692,6 +690,10 @@ public class TreeWalk {
//
return true;
}
+ if (!a.hasId() || !b.hasId())
+ return false;
+ if (a.matches == ch && b.matches == ch)
+ return a.idEqual(b);
return false;
}