Bug 430908 - Pushing to a non-default remote sends wrong host info

Change-Id: I6be5294d91e267393a9a4e7e70445cdfb54e30bd
Signed-off-by: Bartosz Grabski <bartosz.grabski@pl.ibm.com>
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitPush.js b/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitPush.js
index 204c814..2b20d2d 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitPush.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitPush.js
@@ -165,7 +165,7 @@
 							function(options) {

 								var result = new Deferred();

 								

-								if (item.RemoteLocation.length === 1 && item.RemoteLocation[0].Children.length === 1) { //when we push next time - chance to switch saved remote

+								if (item.RemoteLocation.length === 1 && item.RemoteLocation[0].Children && item.RemoteLocation[0].Children.length === 1) { //when we push next time - chance to switch saved remote

 									result = progress.progress(gitService.getGitRemote(remoteLocation), "Getting git remote details " + item.Name);

 								} else {

 									var remotes = {};

@@ -212,6 +212,8 @@
 																			progress.progress(gitService.editCloneConfigurationProperty(locationToUpdate,target.parent.Name), "Updating configuration property " + target.parent.Name).then(

 																					function(){

 																						commandInvocation.targetBranch = target;

+																						commandInvocation.items.RemoteLocation = [];

+																						commandInvocation.items.RemoteLocation.push( {GitUrl: target.parent.GitUrl});

 																						handlePush(options, target.Location, "HEAD",target.Name, false);

 																					},

 																					handleError

@@ -230,7 +232,7 @@
 											}

 										});

 										

-										if (item.RemoteLocation.length === 1 && item.RemoteLocation[0].Children.length === 1) { //when we push next time - chance to switch saved remote

+										if (item.RemoteLocation.length === 1 && item.RemoteLocation[0].Children && item.RemoteLocation[0].Children.length === 1) { //when we push next time - chance to switch saved remote

 											var dialog2 = dialog;

 											

 											dialog = new mConfirmPush.ConfirmPushDialog({

diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js
index 4e42a72..3bde898 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js
@@ -117,6 +117,9 @@
 							commandService.registerCommandContribution(section.actionsNode.id, "eclipse.orion.git.merge", 100); //$NON-NLS-0$

 							commandService.registerCommandContribution(section.actionsNode.id, "eclipse.orion.git.rebase", 100); //$NON-NLS-0$

 							commandService.registerCommandContribution(section.actionsNode.id, "eclipse.orion.git.resetIndex", 100); //$NON-NLS-0$

+							

+							currentBranch.RemoteLocation[0].Children[0].GitUrl = currentBranch.RemoteLocation[0].GitUrl

+							

 							commandService.renderCommands(section.actionsNode.id, section.actionsNode.id,

 								currentBranch.RemoteLocation[0].Children[0], that, "button"); //$NON-NLS-0$

 						}