Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-05-23 22:23:19 +0000
committerMatthias Sohn2016-05-31 06:47:59 +0000
commit5a8fb7a309fe1cac3c71ae617ed6f1f8de839031 (patch)
tree87b7188330c60cde582dd0d97c07f2b8f853ebc3
parent67c83db9698a091be9b9e643f424af75eb3b2a2c (diff)
downloadegit-5a8fb7a309fe1cac3c71ae617ed6f1f8de839031.tar.gz
egit-5a8fb7a309fe1cac3c71ae617ed6f1f8de839031.tar.xz
egit-5a8fb7a309fe1cac3c71ae617ed6f1f8de839031.zip
Fix NPE in SourceBranchPage/CloneDestinationPage.revalidate()
Bug: 494357 Change-Id: Ifedbd1ab0679d623732eb364ee574877a4c87b5d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/SourceBranchPage.java5
3 files changed, 22 insertions, 12 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java
index bdea5f2a66..2faf476278 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java
@@ -61,6 +61,7 @@ import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.CredentialsProvider;
@@ -125,8 +126,9 @@ public abstract class AbstractGitCloneWizard extends Wizard {
@Override
public void setVisible(boolean visible) {
- if (visible) {
- setSelection(getRepositorySelection());
+ RepositorySelection selection = getRepositorySelection();
+ if (selection != null && visible) {
+ setSelection(selection);
setCredentials(getCredentials());
}
super.setVisible(visible);
@@ -135,11 +137,13 @@ public abstract class AbstractGitCloneWizard extends Wizard {
cloneDestination = new CloneDestinationPage() {
@Override
public void setVisible(boolean visible) {
- if (visible)
- setSelection(getRepositorySelection(),
+ RepositorySelection selection = getRepositorySelection();
+ if (selection != null && visible) {
+ setSelection(selection,
validSource.getAvailableBranches(),
validSource.getSelectedBranches(),
validSource.getHEAD());
+ }
super.setVisible(visible);
}
};
@@ -295,8 +299,10 @@ public abstract class AbstractGitCloneWizard extends Wizard {
}
/**
- * @return the repository selected by the user
+ * @return the repository selected by the user or {@code null} if an error
+ * occurred
*/
+ @Nullable
protected RepositorySelection getRepositorySelection() {
try {
return (new RepositorySelection(new URIish(currentSearchResult.getGitRepositoryInfo().getCloneUri()), null));
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java
index 3f1affb578..096b7c95df 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java
@@ -32,6 +32,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
@@ -132,16 +133,17 @@ public class CloneDestinationPage extends WizardPage {
* @param head
* HEAD in source repository
*/
- public void setSelection(RepositorySelection repositorySelection, List<Ref> availableRefs, List<Ref> branches, Ref head){
+ public void setSelection(@NonNull RepositorySelection repositorySelection,
+ List<Ref> availableRefs, List<Ref> branches, Ref head) {
this.availableRefs.clear();
this.availableRefs.addAll(availableRefs);
checkPreviousPagesSelections(repositorySelection, branches, head);
- revalidate(repositorySelection,branches, head);
+ revalidate(repositorySelection, branches, head);
}
private void checkPreviousPagesSelections(
- RepositorySelection repositorySelection, List<Ref> branches,
- Ref head) {
+ @NonNull RepositorySelection repositorySelection,
+ List<Ref> branches, Ref head) {
if (!repositorySelection.equals(validatedRepoSelection)
|| !branches.equals(validatedSelectedBranches)
|| !head.equals(validatedHEAD))
@@ -436,7 +438,8 @@ public class CloneDestinationPage extends WizardPage {
return canCreateSubdir(parent.getParentFile());
}
- private void revalidate(RepositorySelection repoSelection, List<Ref> branches, Ref head) {
+ private void revalidate(@NonNull RepositorySelection repoSelection,
+ List<Ref> branches, Ref head) {
if (repoSelection.equals(validatedRepoSelection)
&& branches.equals(validatedSelectedBranches)
&& head.equals(validatedHEAD)) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/SourceBranchPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/SourceBranchPage.java
index cf3261bb91..9d3de0883b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/SourceBranchPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/SourceBranchPage.java
@@ -45,6 +45,7 @@ import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -234,7 +235,7 @@ class SourceBranchPage extends WizardPage {
checkPage();
}
- public void setSelection(RepositorySelection selection){
+ public void setSelection(@NonNull RepositorySelection selection) {
revalidate(selection);
}
@@ -289,7 +290,7 @@ class SourceBranchPage extends WizardPage {
}
}
- private void revalidate(final RepositorySelection newRepoSelection) {
+ private void revalidate(@NonNull final RepositorySelection newRepoSelection) {
if (newRepoSelection.equals(validatedRepoSelection)) {
// URI hasn't changed, no need to refill the page with new data
checkPage();

Back to the top