summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorPhilipp Thun2011-03-28 09:11:37 (EDT)
committer Mathias Kinzler2011-03-28 11:26:44 (EDT)
commit5ec25800330b36b803e46c0f431e9cb5e5345f8f (patch)
treecb37dc2b9dc09b227dfcc886df602ce99fa7d996
parente793abb3ab33760c15a8f09ac70c375a89c051ba (diff)
downloadegit-5ec25800330b36b803e46c0f431e9cb5e5345f8f.zip
egit-5ec25800330b36b803e46c0f431e9cb5e5345f8f.tar.gz
egit-5ec25800330b36b803e46c0f431e9cb5e5345f8f.tar.bz2
Clear history view when repository has been removedrefs/changes/45/2945/2
After removing a repository that was shown in the history view, it's data was still shown and clicking on a commit and/ or file led to NPEs. Bug: 332934 Change-Id: Ia1fcb56aa1622e1191dbb823ce26aa3a643f526d Signed-off-by: Philipp Thun <philipp.thun@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java32
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java2
2 files changed, 33 insertions, 1 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index a72b7d2..cb4f653 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -807,15 +807,35 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
@Override
public void setFocus() {
+ if (repoHasBeenRemoved(currentRepo))
+ clearHistoryPage();
+
graph.getControl().setFocus();
}
+ private boolean repoHasBeenRemoved(final Repository repo) {
+ return (repo != null && repo.getDirectory() != null && !repo
+ .getDirectory().exists());
+ }
+
+ private void clearHistoryPage() {
+ currentRepo = null;
+ name = ""; //$NON-NLS-1$
+ input = null;
+ commentViewer.setInput(null);
+ fileViewer.setInput(null);
+ setInput(null);
+ }
+
@Override
public Control getControl() {
return topControl;
}
public void refresh() {
+ if (repoHasBeenRemoved(currentRepo))
+ clearHistoryPage();
+
this.input = null;
inputSet();
}
@@ -1257,8 +1277,18 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
GitTraceLocation.HISTORYVIEW.getLocation());
cancelRefreshJob();
+
+ if (input == null)
+ return;
Repository db = input.getRepository();
- AnyObjectId headId = resolveHead(db, false);
+ if (repoHasBeenRemoved(db)) {
+ clearHistoryPage();
+ return;
+ }
+
+ AnyObjectId headId = resolveHead(db, true);
+ if (headId == null)
+ return;
List<String> paths = buildFilterPaths(input.getItems(), input
.getFileList(), db);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
index 55addf0..b95e1b7 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
@@ -74,6 +74,8 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
protected Repository getRepository(ExecutionEvent event)
throws ExecutionException {
Object input = getInput(event);
+ if (input == null)
+ return null;
if (input instanceof HistoryPageInput)
return ((HistoryPageInput) input).getRepository();
if (input instanceof RepositoryTreeNode)