diff options
| author | Philipp Thun | 2011-03-28 13:11:37 +0000 |
|---|---|---|
| committer | Mathias Kinzler | 2011-03-28 15:26:44 +0000 |
| commit | 5ec25800330b36b803e46c0f431e9cb5e5345f8f (patch) | |
| tree | cb37dc2b9dc09b227dfcc886df602ce99fa7d996 | |
| parent | e793abb3ab33760c15a8f09ac70c375a89c051ba (diff) | |
| download | egit-5ec25800330b36b803e46c0f431e9cb5e5345f8f.tar.gz egit-5ec25800330b36b803e46c0f431e9cb5e5345f8f.tar.xz egit-5ec25800330b36b803e46c0f431e9cb5e5345f8f.zip | |
Clear history view when repository has been removed
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>
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 a72b7d237c..cb4f653b30 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 55addf0002..b95e1b7991 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) |
