aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/AbstractTreeIterator.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/EmptyTreeIterator.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java7
6 files changed, 32 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java
index aa8d9fb85d..e685e0cad8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java
@@ -45,7 +45,6 @@
package org.eclipse.jgit.dircache;
import java.io.IOException;
-import java.util.Arrays;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.lib.Constants;
@@ -142,9 +141,16 @@ public class DirCacheIterator extends AbstractTreeIterator {
}
@Override
+ public boolean hasId() {
+ if (currentSubtree != null)
+ return currentSubtree.isValid();
+ return currentEntry != null;
+ }
+
+ @Override
public byte[] idBuffer() {
if (currentSubtree != null)
- return subtreeId;
+ return currentSubtree.isValid() ? subtreeId : zeroid;
if (currentEntry != null)
return currentEntry.idBuffer();
return zeroid;
@@ -218,8 +224,6 @@ public class DirCacheIterator extends AbstractTreeIterator {
if (s.isValid())
s.getObjectId().copyRawTo(subtreeId, 0);
- else
- Arrays.fill(subtreeId, (byte) 0);
mode = FileMode.TREE.getBits();
path = cep;
pathLen = pathOffset + s.nameLength();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/AbstractTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/AbstractTreeIterator.java
index eee62c63a5..79b57d1eb6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/AbstractTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/AbstractTreeIterator.java
@@ -369,6 +369,9 @@ public abstract class AbstractTreeIterator {
otherIterator.idBuffer(), otherIterator.idOffset());
}
+ /** @return true if the entry has a valid ObjectId. */
+ public abstract boolean hasId();
+
/**
* Get the object id of the current entry.
*
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java
index 01b8274253..1e49d380a8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java
@@ -234,6 +234,11 @@ public class CanonicalTreeParser extends AbstractTreeIterator {
}
@Override
+ public boolean hasId() {
+ return true;
+ }
+
+ @Override
public byte[] idBuffer() {
return raw;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/EmptyTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/EmptyTreeIterator.java
index 49d75871e8..8dbf80e6a8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/EmptyTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/EmptyTreeIterator.java
@@ -93,6 +93,11 @@ public class EmptyTreeIterator extends AbstractTreeIterator {
}
@Override
+ public boolean hasId() {
+ return false;
+ }
+
+ @Override
public ObjectId getEntryObjectId() {
return ObjectId.zeroId();
}
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;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index 51c3483699..5cc061bbb4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -195,6 +195,13 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
}
@Override
+ public boolean hasId() {
+ if (contentIdFromPtr == ptr)
+ return true;
+ return (mode & FileMode.TYPE_MASK) == FileMode.TYPE_FILE;
+ }
+
+ @Override
public byte[] idBuffer() {
if (contentIdFromPtr == ptr)
return contentId;