diff --git a/plugins/git4idea/src/git4idea/jgit/GitHttpAdapter.java b/plugins/git4idea/src/git4idea/jgit/GitHttpAdapter.java index a4c7b1b6aa29..b452d54b7865 100644 --- a/plugins/git4idea/src/git4idea/jgit/GitHttpAdapter.java +++ b/plugins/git4idea/src/git4idea/jgit/GitHttpAdapter.java @@ -341,43 +341,45 @@ public final class GitHttpAdapter { // don't "eat" one password entering attempt //noinspection AssignmentToForLoopParameter i--; - command.cleanup(); } + command.cleanup(); } catch (JGitInternalException e) { - if (authError(e)) { - if (provider.wasCancelled()) { // if user cancels the dialog, just return - return GeneralResult.CANCELLED; + try { + if (authError(e)) { + if (provider.wasCancelled()) { // if user cancels the dialog, just return + return GeneralResult.CANCELLED; + } + // otherwise give more tries to enter password } - // otherwise give more tries to enter password + else if (!httpTransportErrorFixTried && isTransportExceptionForHttp(e, url)) { + url = url.replaceFirst("http", "https"); + command.setUrl(url); + provider.setUrl(url); + httpTransportErrorFixTried = true; + // don't "eat" one password entering attempt + //noinspection AssignmentToForLoopParameter + i--; + } + else if (!noRemoteWithoutGitErrorFixTried && isNoRemoteWithoutDotGitError(e, url)) { + url = addDotGitToUrl(url); + command.setUrl(url); + provider.setUrl(url); + noRemoteWithoutGitErrorFixTried = true; + // don't "eat" one password entering attempt + //noinspection AssignmentToForLoopParameter + i--; + } + else if (smartHttpPushNotSupported(e)) { + throw new SmartPushNotSupportedException(e.getCause().getMessage()); + } + else { + throw e; + } + } + finally { command.cleanup(); } - else if (!httpTransportErrorFixTried && isTransportExceptionForHttp(e, url)) { - url = url.replaceFirst("http", "https"); - command.setUrl(url); - provider.setUrl(url); - httpTransportErrorFixTried = true; - // don't "eat" one password entering attempt - //noinspection AssignmentToForLoopParameter - i--; - command.cleanup(); - } - else if (!noRemoteWithoutGitErrorFixTried && isNoRemoteWithoutDotGitError(e, url)) { - url = addDotGitToUrl(url); - command.setUrl(url); - provider.setUrl(url); - noRemoteWithoutGitErrorFixTried = true; - // don't "eat" one password entering attempt - //noinspection AssignmentToForLoopParameter - i--; - command.cleanup(); - } - else if (smartHttpPushNotSupported(e)) { - throw new SmartPushNotSupportedException(e.getCause().getMessage()); - } - else { - throw e; - } } } return GeneralResult.NOT_AUTHORIZED; @@ -415,7 +417,7 @@ public final class GitHttpAdapter { private static boolean isNoRemoteWithoutDotGitError(Throwable e, String url) { Throwable cause = e.getCause(); - if (!(cause instanceof NoRemoteRepositoryException) && !(cause.getCause() instanceof NoRemoteRepositoryException)) { + if (cause == null || (!(cause instanceof NoRemoteRepositoryException) && !(cause.getCause() instanceof NoRemoteRepositoryException))) { return false; } return !url.toLowerCase().endsWith(GitUtil.DOT_GIT); diff --git a/plugins/git4idea/src/git4idea/jgit/GitHttpRemoteCommand.java b/plugins/git4idea/src/git4idea/jgit/GitHttpRemoteCommand.java index 55b9c1f74b5a..3d2a9653440b 100644 --- a/plugins/git4idea/src/git4idea/jgit/GitHttpRemoteCommand.java +++ b/plugins/git4idea/src/git4idea/jgit/GitHttpRemoteCommand.java @@ -196,7 +196,7 @@ interface GitHttpRemoteCommand { } @Override - public void run() throws InvalidRemoteException, URISyntaxException { + public void run() throws InvalidRemoteException, URISyntaxException, org.eclipse.jgit.api.errors.TransportException { PushCommand pushCommand = myGit.push(); pushCommand.setRemote(myRemoteName); pushCommand.setRefSpecs(myPushSpecs); @@ -304,7 +304,9 @@ interface GitHttpRemoteCommand { Original code constructs the remoteConfig based on .git/config. */ @NotNull - private Iterable call(PushCommand pushCommand, RemoteConfig remoteConfig) throws JGitInternalException, InvalidRemoteException { + private Iterable call(PushCommand pushCommand, RemoteConfig remoteConfig) + throws JGitInternalException, InvalidRemoteException, org.eclipse.jgit.api.errors.TransportException + { ArrayList pushResults = new ArrayList(3); List refSpecs = pushCommand.getRefSpecs(); @@ -359,9 +361,7 @@ interface GitHttpRemoteCommand { pushResults.add(result); } catch (TransportException e) { - throw new JGitInternalException( - JGitText.get().exceptionCaughtDuringExecutionOfPushCommand, - e); + throw new org.eclipse.jgit.api.errors.TransportException(e.getMessage(), e); } finally { transport.close(); @@ -371,6 +371,9 @@ interface GitHttpRemoteCommand { catch (URISyntaxException e) { throw new InvalidRemoteException(MessageFormat.format( JGitText.get().invalidRemote, remote)); + } catch (TransportException e) { + throw new org.eclipse.jgit.api.errors.TransportException( + e.getMessage(), e); } catch (NotSupportedException e) { throw new JGitInternalException(