diff options
| author | Dariusz Luksza | 2010-08-11 23:36:05 +0000 |
|---|---|---|
| committer | Dariusz Luksza | 2010-08-11 23:42:57 +0000 |
| commit | 2087b5c863312ea3f728019cf0c27d5937eb0d0e (patch) | |
| tree | cd06cbd33e0bbd8dc5addebe39894fa5ee49bf76 | |
| parent | 80c4652c22ce05151abfc4f5e4709a38befc6453 (diff) | |
| download | egit-2087b5c863312ea3f728019cf0c27d5937eb0d0e.tar.gz egit-2087b5c863312ea3f728019cf0c27d5937eb0d0e.tar.xz egit-2087b5c863312ea3f728019cf0c27d5937eb0d0e.zip | |
Fix MissingObjectException in change set
An MissingObjectException occurs when any node contains added (or
deleted) resource.
Change-Id: Iecc6f5ffd8e09421c759bf80d8848dfb7d57ff6c
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
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 467f18fbc3..5b9be65e25 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 9e4c56add5..5b8c92cd54 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 e47a109435..65ae9a2b0b 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) |
