[EGIT PATCH 3/6] Handle null remoteName in RefSpecPanel better

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Create more sensible "all branches" ref spec
(refs/remotes/choose_remote_name/*), and don't use RemoteConfig
contructor with null remoteName value, as this behavior is unspecified.

Signed-off-by: Marek Zawirski <marek.zawirski@xxxxxxxxx>
---
 .../src/org/spearce/egit/ui/UIText.java            |    3 ++
 .../egit/ui/internal/components/RefSpecPanel.java  |   30 +++++++++++++------
 .../src/org/spearce/egit/ui/uitext.properties      |    1 +
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
index b45d2e9..2bbe218 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
@@ -182,6 +182,9 @@
 	public static String RefSpecPanel_refChooseSomeWildcard;
 
 	/** */
+	public static String RefSpecPanel_refChooseRemoteName;
+
+	/** */
 	public static String RefSpecPanel_clickToChange;
 
 	/** */
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
index de82480..a2661ae 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
@@ -413,14 +413,18 @@ public void setAssistanceData(final Repository localRepo,
 		}
 
 		try {
-			final RemoteConfig rc = new RemoteConfig(localDb.getConfig(),
-					remoteName);
-			if (pushSpecs)
-				predefinedConfigured = rc.getPushRefSpecs();
-			else
-				predefinedConfigured = rc.getFetchRefSpecs();
-			for (final RefSpec spec : predefinedConfigured)
-				addRefSpec(spec);
+			if (remoteName == null)
+				predefinedConfigured = Collections.emptyList();
+			else {
+				final RemoteConfig rc = new RemoteConfig(localDb.getConfig(),
+						remoteName);
+				if (pushSpecs)
+					predefinedConfigured = rc.getPushRefSpecs();
+				else
+					predefinedConfigured = rc.getFetchRefSpecs();
+				for (final RefSpec spec : predefinedConfigured)
+					addRefSpec(spec);
+			}
 		} catch (URISyntaxException e) {
 			predefinedConfigured = null;
 			ErrorDialog.openError(panel.getShell(),
@@ -432,9 +436,15 @@ public void setAssistanceData(final Repository localRepo,
 		updateAddPredefinedButton(addConfiguredButton, predefinedConfigured);
 		if (pushSpecs)
 			predefinedBranches = Transport.REFSPEC_PUSH_ALL;
-		else
+		else {
+			final String r;
+			if (remoteName == null)
+				r = UIText.RefSpecPanel_refChooseRemoteName;
+			else
+				r = remoteName;
 			predefinedBranches = new RefSpec("refs/heads/*:refs/remotes/" //$NON-NLS-1$
-					+ remoteName + "/*"); //$NON-NLS-1$
+					+ r + "/*"); //$NON-NLS-1$
+		}
 		updateAddPredefinedButton(addBranchesButton, predefinedBranches);
 		setEnable(true);
 	}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
index 7fcc77b..c2b91f7 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
@@ -116,6 +116,7 @@ RefSpecPanel_predefinedTagsDescription=Add specification covering all tags.
 RefSpecPanel_push=push
 RefSpecPanel_refChooseSome=choose/some/ref
 RefSpecPanel_refChooseSomeWildcard=choose/some/ref/*
+RefSpecPanel_refChooseRemoteName=choose_remote_name
 RefSpecPanel_removeAll=Remove all specs
 RefSpecPanel_removeAllDescription=Remove all speficications.
 RefSpecPanel_removeDescription=Click to remove this specification.
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux