aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2010-08-11 19:36:05 (EDT)
committerDariusz Luksza2010-08-11 19:42:57 (EDT)
commit2087b5c863312ea3f728019cf0c27d5937eb0d0e (patch)
treecd06cbd33e0bbd8dc5addebe39894fa5ee49bf76
parent80c4652c22ce05151abfc4f5e4709a38befc6453 (diff)
downloadegit-2087b5c863312ea3f728019cf0c27d5937eb0d0e.zip
egit-2087b5c863312ea3f728019cf0c27d5937eb0d0e.tar.gz
egit-2087b5c863312ea3f728019cf0c27d5937eb0d0e.tar.bz2
Fix MissingObjectException in change setrefs/changes/88/1288/1
An MissingObjectException occurs when any node contains added (or deleted) resource. Change-Id: Iecc6f5ffd8e09421c759bf80d8848dfb7d57ff6c Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitTreeTraversal.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelTree.java24
3 files changed, 26 insertions, 8 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitTreeTraversal.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitTreeTraversal.java
index 467f18f..5b9be65 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitTreeTraversal.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitTreeTraversal.java
@@ -8,6 +8,8 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.synchronize.mapping;
+import static org.eclipse.jgit.lib.ObjectId.zeroId;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -47,6 +49,9 @@ class GitTreeTraversal extends ResourceTraversal {
private static IResource[] getResourcesImpl(Repository repo, IPath path,
AnyObjectId baseId, AnyObjectId remoteId) {
+ if (remoteId.equals(zeroId()))
+ return new IResource[0];
+
TreeWalk tw = new TreeWalk(repo);
List<IResource> result = new ArrayList<IResource>();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@@ -55,7 +60,8 @@ class GitTreeTraversal extends ResourceTraversal {
tw.setRecursive(false);
tw.setFilter(TreeFilter.ANY_DIFF);
try {
- tw.addTree(baseId);
+ if (!baseId.equals(zeroId()))
+ tw.addTree(baseId);
int actualNth = tw.addTree(remoteId);
while (tw.next()) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java
index 9e4c56a..5b8c92c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java
@@ -197,7 +197,7 @@ public class GitModelCommit extends GitModelObject {
if (baseNth > -1)
objBaseId = tw.getObjectId(baseNth);
else
- objBaseId = null;
+ objBaseId = ObjectId.zeroId();
ObjectId objRemoteId = tw.getObjectId(actualNth);
ObjectId objAncestorId = tw.getObjectId(ancestorNth);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelTree.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelTree.java
index e47a109..65ae9a2 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelTree.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelTree.java
@@ -8,6 +8,8 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.synchronize.model;
+import static org.eclipse.jgit.lib.ObjectId.zeroId;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -112,9 +114,17 @@ public class GitModelTree extends GitModelCommit {
List<GitModelObject> result = new ArrayList<GitModelObject>();
try {
- int ancestorNth = tw.addTree(ancestorId);
- int baseNth = tw.addTree(baseId);
- int remoteNth = tw.addTree(remoteId);
+ int ancestorNth = -1;
+ if (!ancestorId.equals(zeroId()))
+ ancestorNth = tw.addTree(ancestorId);
+
+ int baseNth = -1;
+ if (!baseId.equals(zeroId()))
+ baseNth = tw.addTree(baseId);
+
+ int remoteNth = -1;
+ if (!remoteId.equals(zeroId()))
+ remoteNth = tw.addTree(remoteId);
while (tw.next()) {
GitModelObject obj = createChildren(tw, ancestorNth, baseNth,
@@ -132,9 +142,11 @@ public class GitModelTree extends GitModelCommit {
private GitModelObject createChildren(TreeWalk tw, int ancestorNth,
int baseNth, int remoteNth) throws IOException {
String objName = tw.getNameString();
- ObjectId objBaseId = tw.getObjectId(baseNth);
- ObjectId objRemoteId = tw.getObjectId(remoteNth);
- ObjectId objAncestorId = tw.getObjectId(ancestorNth);
+ ObjectId objBaseId = baseNth != -1 ? tw.getObjectId(baseNth) : zeroId();
+ ObjectId objRemoteId = remoteNth != -1 ? tw.getObjectId(remoteNth)
+ : zeroId();
+ ObjectId objAncestorId = ancestorNth != -1 ? tw
+ .getObjectId(ancestorNth) : zeroId();
int objectType = tw.getFileMode(remoteNth).getObjectType();
if (objectType == Constants.OBJ_BLOB)