Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-03-14 19:18:55 -0400
committerMatthias Sohn2016-03-14 19:27:28 -0400
commitae215605a2dea2c1b13011e5e82fa29d9e3fe46a (patch)
tree0fa43fcb87d6f909508252916ca84237fda2f85a
parente47bced605873c5e82705f9a8184f540d1dbb586 (diff)
downloadegit-ae215605a2dea2c1b13011e5e82fa29d9e3fe46a.tar.gz
egit-ae215605a2dea2c1b13011e5e82fa29d9e3fe46a.tar.xz
egit-ae215605a2dea2c1b13011e5e82fa29d9e3fe46a.zip
Fix NPE in RepositoriesViewPropertyTester
Bug: 489602 Change-Id: If35a2b22aeb34cf15afcf33410d34c7b22308f62 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java48
1 files changed, 26 insertions, 22 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java
index d4cc1352b..6930020b1 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java
@@ -48,14 +48,22 @@ public class RepositoriesViewPropertyTester extends PropertyTester {
return false;
RepositoryTreeNode node = (RepositoryTreeNode) receiver;
- if (property.equals("isBare")) //$NON-NLS-1$
- return node.getRepository().isBare();
+ Repository repository = node.getRepository();
+ if (repository == null) {
+ return false;
+ }
+
+ if (property.equals("isBare")) { //$NON-NLS-1$
+ return repository.isBare();
+ }
- if (property.equals("containsHead")) //$NON-NLS-1$
- return containsHead(node);
+ if (property.equals("containsHead")) {//$NON-NLS-1$
+ return containsHead(repository);
+ }
- if (ResourcePropertyTester.testRepositoryState(node.getRepository(), property))
+ if (ResourcePropertyTester.testRepositoryState(repository, property)) {
return true;
+ }
if (property.equals("isRefCheckedOut")) { //$NON-NLS-1$
if (!(node.getObject() instanceof Ref))
@@ -63,20 +71,18 @@ public class RepositoriesViewPropertyTester extends PropertyTester {
Ref ref = (Ref) node.getObject();
try {
if (ref.getName().startsWith(Constants.R_REFS)) {
- return ref.getName().equals(
- node.getRepository().getFullBranch());
+ return ref.getName().equals(repository.getFullBranch());
} else if (ref.getName().equals(Constants.HEAD)) {
return true;
} else {
String leafname = ref.getLeaf().getName();
if (leafname.startsWith(Constants.R_REFS)
- && leafname.equals(node.getRepository()
- .getFullBranch())) {
+ && leafname.equals(repository.getFullBranch())) {
return true;
} else {
ObjectId objectId = ref.getLeaf().getObjectId();
- return objectId != null && objectId.equals(
- node.getRepository().resolve(Constants.HEAD));
+ return objectId != null && objectId
+ .equals(repository.resolve(Constants.HEAD));
}
}
} catch (IOException e) {
@@ -95,8 +101,8 @@ public class RepositoriesViewPropertyTester extends PropertyTester {
RemoteConfig rconfig;
try {
- rconfig = new RemoteConfig(
- node.getRepository().getConfig(), configName);
+ rconfig = new RemoteConfig(repository.getConfig(),
+ configName);
} catch (URISyntaxException e2) {
return false;
}
@@ -111,8 +117,8 @@ public class RepositoriesViewPropertyTester extends PropertyTester {
RemoteConfig rconfig;
try {
- rconfig = new RemoteConfig(
- node.getRepository().getConfig(), configName);
+ rconfig = new RemoteConfig(repository.getConfig(),
+ configName);
} catch (URISyntaxException e2) {
return false;
}
@@ -123,15 +129,13 @@ public class RepositoriesViewPropertyTester extends PropertyTester {
}
}
if (property.equals("canStash")) { //$NON-NLS-1$
- Repository rep = node.getRepository();
- return rep.getRepositoryState().canCommit();
+ return repository.getRepositoryState().canCommit();
}
if (property.equals("canMerge")) { //$NON-NLS-1$
- Repository rep = node.getRepository();
- if (rep.getRepositoryState() != RepositoryState.SAFE)
+ if (repository.getRepositoryState() != RepositoryState.SAFE)
return false;
try {
- String branch = rep.getFullBranch();
+ String branch = repository.getFullBranch();
if (branch == null)
return false; // fail gracefully...
return branch.startsWith(Constants.R_HEADS);
@@ -148,9 +152,9 @@ public class RepositoriesViewPropertyTester extends PropertyTester {
return false;
}
- private boolean containsHead(RepositoryTreeNode node) {
+ private boolean containsHead(Repository repository) {
try {
- return node.getRepository().resolve(Constants.HEAD) != null;
+ return repository.resolve(Constants.HEAD) != null;
} catch (IOException e) {
return false;
}

Back to the top