summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorDariusz Luksza2010-06-21 17:57:35 (EDT)
committer Dariusz Luksza2010-06-21 18:43:19 (EDT)
commit02a3f9d4e537892fb6116789ea1ac26247da84c8 (patch)
tree9c2d3fcc8093d0b9b9b950cf74fa460c4ae69e94
parentd495cf79b9ead3f7f7ce353e674e6b93ca771fa6 (diff)
downloadegit-02a3f9d4e537892fb6116789ea1ac26247da84c8.zip
egit-02a3f9d4e537892fb6116789ea1ac26247da84c8.tar.gz
egit-02a3f9d4e537892fb6116789ea1ac26247da84c8.tar.bz2
Prevent from NullPointerException'srefs/changes/11/911/2
Prevent from NPE when argument of GitResourceVariantTree.members() doesn't exist in repository. Change-Id: Iedfd286721e5a5add3ddf96b0ee83e70aa327631 Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java12
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java20
2 files changed, 24 insertions, 8 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java
index 3eec66b..240f828 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java
@@ -164,9 +164,11 @@ abstract class GitResourceVariantTree extends AbstractResourceVariantTree {
Tree tree = getRevTree(resource);
ObjectId objId = getRevObjId(resource);
- trees.put(db, tree);
- // walk the tree to retrieve information
- walk(db, objId, tree);
+ if (objId != null && tree != null) {
+ trees.put(db, tree);
+ // walk the tree to retrieve information
+ walk(db, objId, tree);
+ }
}
}
@@ -387,6 +389,10 @@ abstract class GitResourceVariantTree extends AbstractResourceVariantTree {
Repository repo = gsd.getRepository();
try {
Tree tree = gsd.mapSrcTree();
+
+ if (tree == null)
+ return new IResource[0];
+
IResource[] members = ((IContainer) resource).members();
Set<IResource> membersSet = getAllMembers(repo, tree, members);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java
index 4f66e4e..b29f509 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java
@@ -160,17 +160,27 @@ public class GitSynchronizeData {
private Tree mapTree(String rev) throws IOException {
if (rev.startsWith(Constants.R_TAGS)) {
Tag tag = repo.mapTag(rev);
- Commit commit = repo.mapCommit(tag.getObjId());
- return commit.getTree();
+ if (tag != null) {
+ Commit commit = repo.mapCommit(tag.getObjId());
+ if (commit != null)
+ return commit.getTree();
+ }
+ return null;
} else
return repo.mapTree(rev);
}
private ObjectId getObjecId(String rev) throws IOException {
if (rev.startsWith(Constants.R_TAGS)) {
- return repo.mapTag(rev).getObjId();
- } else
- return repo.mapCommit(rev).getCommitId();
+ Tag mapTag = repo.mapTag(rev);
+ if (mapTag != null)
+ return mapTag.getObjId();
+ } else {
+ Commit mapCommit = repo.mapCommit(rev);
+ if (mapCommit != null)
+ return mapCommit.getCommitId();
+ }
+ return null;
}
}