{"thread":{"id":"15236","subject":"[EGIT PATCH 1/3] Give NoRemoteRepositoryException better message in BasePackConnection","startedAt":"2008-08-28T01:36:08Z","lastAt":"2008-08-28T02:44:37Z","messageCount":10,"participants":["Marek Zawirski","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"88842","messageId":"1219887370-17265-1-git-send-email-marek.zawirski@gmail.com","threadId":"15236","inReplyTo":null,"subject":"[EGIT PATCH 1/3] Give NoRemoteRepositoryException better message in BasePackConnection","fromName":"Marek Zawirski","fromEmail":"marek.zawirski@gmail.com","sentAt":"2008-08-28T01:36:08Z","receivedAt":"2008-08-28T01:36:08Z","isPatch":true,"sender":{"key":"marek.zawirski@gmail.com","avatar":null},"body":"Reported-by: Robert <robert_no.spam_m@yahoo.fr>\nSigned-off-by: Marek Zawirski <marek.zawirski@gmail.com>\n---\n\nSee http://code.google.com/p/egit/issues/detail?id=16\n\n .../spearce/jgit/transport/BasePackConnection.java |   11 +++++++++--\n 1 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\nindex 14fffc3..de0c7b6 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\n@@ -129,8 +129,15 @@ private void readAdvertisedRefsImpl() throws IOException {\n \t\t\ttry {\n \t\t\t\tline = pckIn.readString();\n \t\t\t} catch (EOFException eof) {\n-\t\t\t\tif (avail.isEmpty())\n-\t\t\t\t\tthrow new NoRemoteRepositoryException(uri, \"not found.\");\n+\t\t\t\tif (avail.isEmpty()) {\n+\t\t\t\t\tString service = \"unknown\";\n+\t\t\t\t\tif (this instanceof PushConnection)\n+\t\t\t\t\t\tservice = \"push\";\n+\t\t\t\t\telse if (this instanceof FetchConnection)\n+\t\t\t\t\t\tservice = \"fetch\";\n+\t\t\t\t\tthrow new NoRemoteRepositoryException(uri, service\n+\t\t\t\t\t\t\t+ \" service not found.\");\n+\t\t\t\t}\n \t\t\t\tthrow eof;\n \t\t\t}\n \n-- \n1.5.6.3\n"},{"id":"88844","messageId":"1219887370-17265-2-git-send-email-marek.zawirski@gmail.com","threadId":"15236","inReplyTo":"1219887370-17265-1-git-send-email-marek.zawirski@gmail.com","subject":"[EGIT PATCH 2/3] Handle NoRemoteRepositoryException in PushOperation especially","fromName":"Marek Zawirski","fromEmail":"marek.zawirski@gmail.com","sentAt":"2008-08-28T01:36:09Z","receivedAt":"2008-08-28T01:36:09Z","isPatch":true,"sender":{"key":"marek.zawirski@gmail.com","avatar":null},"body":"We can give user better feedback for this special case, as it\nis common and not directly related to protocol error.\n\nReported-by: Robert <robert_no.spam_m@yahoo.fr>\nSigned-off-by: Marek Zawirski <marek.zawirski@gmail.com>\n---\n\nBeside of this change, we may consider removing URI part of\nTransportException from message, moving it to the field and providing\nAPI for getting this URI. That may allow us showing user cleaner\nmessages.\n\n .../src/org/spearce/egit/core/CoreText.java        |    3 +++\n .../src/org/spearce/egit/core/coretext.properties  |    1 +\n .../org/spearce/egit/core/op/PushOperation.java    |    5 +++++\n 3 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java b/org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java\nindex 35e17b9..a750117 100644\n--- a/org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java\n+++ b/org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java\n@@ -108,6 +108,9 @@\n \tpublic static String PushOperation_resultTransportError;\n \n \t/** */\n+\tpublic static String PushOperation_resultNoServiceError;\n+\n+\t/** */\n \tpublic static String PushOperation_taskNameDryRun;\n \n \t/** */\ndiff --git a/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties b/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\nindex 94cf4aa..04ca28f 100644\n--- a/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\n+++ b/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\n@@ -61,5 +61,6 @@ ListRemoteOperation_title=Getting remote branches information\n PushOperation_resultCancelled=Operation was cancelled.\n PushOperation_resultNotSupported=Can't push to {0}\n PushOperation_resultTransportError=Transport error occured during push operation: {0}\n+PushOperation_resultNoServiceError=Push service is not available: {0}\n PushOperation_taskNameDryRun=Trying pushing to remote repositories\n PushOperation_taskNameNormalRun=Pushing to remote repositories\ndiff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\nindex 8811800..a0f2e5c 100644\n--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\n+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\n@@ -16,6 +16,7 @@\n import org.eclipse.osgi.util.NLS;\n import org.spearce.egit.core.CoreText;\n import org.spearce.egit.core.EclipseGitProgressTransformer;\n+import org.spearce.jgit.errors.NoRemoteRepositoryException;\n import org.spearce.jgit.errors.NotSupportedException;\n import org.spearce.jgit.errors.TransportException;\n import org.spearce.jgit.lib.Repository;\n@@ -125,6 +126,10 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException {\n \t\t\t\tfinal PushResult pr = transport.push(gitSubMonitor,\n \t\t\t\t\t\tspecification.getRefUpdates(uri));\n \t\t\t\toperationResult.addOperationResult(uri, pr);\n+\t\t\t} catch (final NoRemoteRepositoryException e) {\n+\t\t\t\toperationResult.addOperationResult(uri, NLS.bind(\n+\t\t\t\t\t\tCoreText.PushOperation_resultNoServiceError, e\n+\t\t\t\t\t\t\t\t.getMessage()));\n \t\t\t} catch (final TransportException e) {\n \t\t\t\toperationResult.addOperationResult(uri, NLS.bind(\n \t\t\t\t\t\tCoreText.PushOperation_resultTransportError, e\n-- \n1.5.6.3\n"},{"id":"88843","messageId":"1219887370-17265-3-git-send-email-marek.zawirski@gmail.com","threadId":"15236","inReplyTo":"1219887370-17265-2-git-send-email-marek.zawirski@gmail.com","subject":"[EGIT PATCH 3/3] Show ErrorDialog fot fatal connection errors in ConfirmationPage","fromName":"Marek Zawirski","fromEmail":"marek.zawirski@gmail.com","sentAt":"2008-08-28T01:36:10Z","receivedAt":"2008-08-28T01:36:10Z","isPatch":true,"sender":{"key":"marek.zawirski@gmail.com","avatar":null},"body":"We already do the same in analogous RefSpecPage and PushWizard etc., so\nlet's do the same here.\n\nSigned-off-by: Marek Zawirski <marek.zawirski@gmail.com>\n---\n .../src/org/spearce/egit/ui/UIText.java            |    3 +++\n .../egit/ui/internal/push/ConfirmationPage.java    |   16 ++++++++++++++--\n .../src/org/spearce/egit/ui/uitext.properties      |    1 +\n 3 files changed, 18 insertions(+), 2 deletions(-)\n\ndiff --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\nindex b2cb340..b09cc10 100644\n--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java\n+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java\n@@ -518,6 +518,9 @@\n \tpublic static String PushWizard_windowTitleWithDestination;\n \n \t/** */\n+\tpublic static String ConfirmationPage_cantConnectToAnyTitle;\n+\n+\t/** */\n \tpublic static String ConfirmationPage_cantConnectToAny;\n \n \t/** */\ndiff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ConfirmationPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ConfirmationPage.java\nindex 08d21b3..6e925a7 100644\n--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ConfirmationPage.java\n+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ConfirmationPage.java\n@@ -13,6 +13,9 @@\n import java.util.Collection;\n import java.util.List;\n \n+import org.eclipse.core.runtime.IStatus;\n+import org.eclipse.core.runtime.Status;\n+import org.eclipse.jface.dialogs.ErrorDialog;\n import org.eclipse.jface.wizard.WizardPage;\n import org.eclipse.osgi.util.NLS;\n import org.eclipse.swt.SWT;\n@@ -24,6 +27,7 @@\n import org.spearce.egit.core.op.PushOperation;\n import org.spearce.egit.core.op.PushOperationResult;\n import org.spearce.egit.core.op.PushOperationSpecification;\n+import org.spearce.egit.ui.Activator;\n import org.spearce.egit.ui.UIText;\n import org.spearce.egit.ui.internal.components.RefSpecPage;\n import org.spearce.egit.ui.internal.components.RepositorySelection;\n@@ -204,8 +208,16 @@ setErrorMessage(NLS.bind(UIText.ConfirmationPage_errorUnexpected, e\n \t\t\tsetPageComplete(true);\n \t\t\tconfirmedResult = result;\n \t\t} else {\n-\t\t\tsetErrorMessage(NLS.bind(UIText.ConfirmationPage_cantConnectToAny,\n-\t\t\t\t\tresult.getErrorStringForAllURis()));\n+\t\t\tfinal String message = NLS.bind(\n+\t\t\t\t\tUIText.ConfirmationPage_cantConnectToAny, result\n+\t\t\t\t\t\t\t.getErrorStringForAllURis());\n+\t\t\tsetErrorMessage(message);\n+\t\t\tErrorDialog\n+\t\t\t\t\t.openError(getShell(),\n+\t\t\t\t\t\t\tUIText.ConfirmationPage_cantConnectToAnyTitle,\n+\t\t\t\t\t\t\tnull,\n+\t\t\t\t\t\t\tnew Status(IStatus.ERROR, Activator.getPluginId(),\n+\t\t\t\t\t\t\t\t\tmessage));\n \t\t}\n \t}\n }\ndiff --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\nindex 0590e30..22e29c2 100644\n--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties\n+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties\n@@ -199,6 +199,7 @@ PushWizard_unexpectedError=Unexpected error occurred.\n PushWizard_windowTitleDefault=Push To Another Repositories\n PushWizard_windowTitleWithDestination=Push To: {0}\n \n+ConfirmationPage_cantConnectToAnyTitle=Can't Connect\n ConfirmationPage_cantConnectToAny=Can't connect to any URI: {0}\n ConfirmationPage_description=Confirm following expected push result.\n ConfirmationPage_errorCantResolveSpecs=Can't resolve ref specifications locally or create tracking ref update: {0}\n-- \n1.5.6.3\n"},{"id":"88848","messageId":"20080828021936.GA8624@spearce.org","threadId":"15236","inReplyTo":"1219887370-17265-2-git-send-email-marek.zawirski@gmail.com","subject":"Re: [EGIT PATCH 2/3] Handle NoRemoteRepositoryException in PushOperation especially","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-08-28T02:19:36Z","receivedAt":"2008-08-28T02:19:36Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Marek Zawirski <marek.zawirski@gmail.com> wrote:\n> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties b/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\n> index 94cf4aa..04ca28f 100644\n> --- a/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\n> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\n> @@ -61,5 +61,6 @@ ListRemoteOperation_title=Getting remote branches information\n>  PushOperation_resultCancelled=Operation was cancelled.\n>  PushOperation_resultNotSupported=Can't push to {0}\n>  PushOperation_resultTransportError=Transport error occured during push operation: {0}\n> +PushOperation_resultNoServiceError=Push service is not available: {0}\n>  PushOperation_taskNameDryRun=Trying pushing to remote repositories\n>  PushOperation_taskNameNormalRun=Pushing to remote repositories\n> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\n> index 8811800..a0f2e5c 100644\n> --- a/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\n> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\n> @@ -125,6 +126,10 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException {\n>  \t\t\t\tfinal PushResult pr = transport.push(gitSubMonitor,\n>  \t\t\t\t\t\tspecification.getRefUpdates(uri));\n>  \t\t\t\toperationResult.addOperationResult(uri, pr);\n> +\t\t\t} catch (final NoRemoteRepositoryException e) {\n> +\t\t\t\toperationResult.addOperationResult(uri, NLS.bind(\n> +\t\t\t\t\t\tCoreText.PushOperation_resultNoServiceError, e\n> +\t\t\t\t\t\t\t\t.getMessage()));\n\nIsn't this when combined with the prior patch going to result in a message like:\n\n\tPush service is not available: git://repo.or.cz/egit.git push service is not available\n\nwhich is sort of redundant and confusingly redundant, isn't it?\n\n-- \nShawn.\n"},{"id":"88849","messageId":"20080828022149.GB8624@spearce.org","threadId":"15236","inReplyTo":"1219887370-17265-3-git-send-email-marek.zawirski@gmail.com","subject":"Re: [EGIT PATCH 3/3] Show ErrorDialog fot fatal connection errors in ConfirmationPage","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-08-28T02:21:49Z","receivedAt":"2008-08-28T02:21:49Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"> Subject: Re: [EGIT PATCH 3/3] Show ErrorDialog fot fatal connection errors\n\ntypo ----------------------------------------------*\n\n-- \nShawn.\n"},{"id":"88850","messageId":"48B60D74.3030105@gmail.com","threadId":"15236","inReplyTo":"20080828021936.GA8624@spearce.org","subject":"Re: [EGIT PATCH 2/3] Handle NoRemoteRepositoryException in PushOperation especially","fromName":"Marek Zawirski","fromEmail":"marek.zawirski@gmail.com","sentAt":"2008-08-28T02:29:08Z","receivedAt":"2008-08-28T02:29:08Z","isPatch":true,"sender":{"key":"marek.zawirski@gmail.com","avatar":null},"body":"Shawn O. Pearce wrote:\n> Marek Zawirski <marek.zawirski@gmail.com> wrote:\n>> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties b/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\n>> index 94cf4aa..04ca28f 100644\n>> --- a/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\n>> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties\n>> @@ -61,5 +61,6 @@ ListRemoteOperation_title=Getting remote branches information\n>>  PushOperation_resultCancelled=Operation was cancelled.\n>>  PushOperation_resultNotSupported=Can't push to {0}\n>>  PushOperation_resultTransportError=Transport error occured during push operation: {0}\n>> +PushOperation_resultNoServiceError=Push service is not available: {0}\n>>  PushOperation_taskNameDryRun=Trying pushing to remote repositories\n>>  PushOperation_taskNameNormalRun=Pushing to remote repositories\n>> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\n>> index 8811800..a0f2e5c 100644\n>> --- a/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\n>> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperation.java\n>> @@ -125,6 +126,10 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException {\n>>  \t\t\t\tfinal PushResult pr = transport.push(gitSubMonitor,\n>>  \t\t\t\t\t\tspecification.getRefUpdates(uri));\n>>  \t\t\t\toperationResult.addOperationResult(uri, pr);\n>> +\t\t\t} catch (final NoRemoteRepositoryException e) {\n>> +\t\t\t\toperationResult.addOperationResult(uri, NLS.bind(\n>> +\t\t\t\t\t\tCoreText.PushOperation_resultNoServiceError, e\n>> +\t\t\t\t\t\t\t\t.getMessage()));\n> \n> Isn't this when combined with the prior patch going to result in a message like:\n> \n> \tPush service is not available: git://repo.or.cz/egit.git push service is not available\n> \n> which is sort of redundant and confusingly redundant, isn't it?\n\nMore precisely:\nPush service is not available: git://repo.or.cz/egit.git push service \nnot found\n\nYeah, this commit may be removed as well, leaving user with info:\nTransport error occured during push operation: git://repo.or.cz/egit.git \npush service not found\n\n-- \nMarek Zawirski [zawir]\nmarek.zawirski@gmail.com\n"},{"id":"88851","messageId":"48B60DB2.3050409@gmail.com","threadId":"15236","inReplyTo":"20080828022149.GB8624@spearce.org","subject":"Re: [EGIT PATCH 3/3] Show ErrorDialog fot fatal connection errors in ConfirmationPage","fromName":"Marek Zawirski","fromEmail":"marek.zawirski@gmail.com","sentAt":"2008-08-28T02:30:10Z","receivedAt":"2008-08-28T02:30:10Z","isPatch":true,"sender":{"key":"marek.zawirski@gmail.com","avatar":null},"body":"Shawn O. Pearce wrote:\n>> Subject: Re: [EGIT PATCH 3/3] Show ErrorDialog fot fatal connection errors\n> \n> typo ----------------------------------------------*\n> \n\nAh, right - thanks. I believe that I don't need to resend that? Will \nedit/rebase on my repo.\n\n\n-- \nMarek Zawirski [zawir]\nmarek.zawirski@gmail.com\n"},{"id":"88857","messageId":"20080828023501.GC8624@spearce.org","threadId":"15236","inReplyTo":"1219887370-17265-1-git-send-email-marek.zawirski@gmail.com","subject":"Re: [EGIT PATCH 1/3] Give NoRemoteRepositoryException better message in BasePackConnection","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-08-28T02:35:01Z","receivedAt":"2008-08-28T02:35:01Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Marek Zawirski <marek.zawirski@gmail.com> wrote:\n> \n> See http://code.google.com/p/egit/issues/detail?id=16\n> \n> diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\n> index 14fffc3..de0c7b6 100644\n> --- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\n> +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\n> @@ -129,8 +129,15 @@ private void readAdvertisedRefsImpl() throws IOException {\n>  \t\t\ttry {\n>  \t\t\t\tline = pckIn.readString();\n>  \t\t\t} catch (EOFException eof) {\n> -\t\t\t\tif (avail.isEmpty())\n> -\t\t\t\t\tthrow new NoRemoteRepositoryException(uri, \"not found.\");\n> +\t\t\t\tif (avail.isEmpty()) {\n> +\t\t\t\t\tString service = \"unknown\";\n> +\t\t\t\t\tif (this instanceof PushConnection)\n> +\t\t\t\t\t\tservice = \"push\";\n> +\t\t\t\t\telse if (this instanceof FetchConnection)\n> +\t\t\t\t\t\tservice = \"fetch\";\n> +\t\t\t\t\tthrow new NoRemoteRepositoryException(uri, service\n> +\t\t\t\t\t\t\t+ \" service not found.\");\n> +\t\t\t\t}\n\nHmm.  I wonder if we could detect this better.  With the patch\nbelow I can get nice errors:\n\n  $ ./jgit.sh push git://repo.or.cz/egit.git refs/heads/master\n  fatal: git://repo.or.cz/egit.git: push not permitted\n\n  $ ./jgit.sh push git://repo.or.cz/fake.git refs/heads/master\n  fatal: git://repo.or.cz/fake.git: not found.\n\n--8<--\nDisambiguate \"push not supported\" from \"repository not found\"\n\nIf we are pushing to a remote repository the reason why we\nget no refs may be because push is not permitted, or it is\na bad URI and points to a non-existant repository.\n\nTo get a good error message for the user we need to open a\nfetch connection to see if fetch also fails.  If it failed\nwe know the URI is invalid; if fetch succeeds we know that\nthe repository is there but the user is just not allowed to\npush to it over this transport.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../spearce/jgit/transport/BasePackConnection.java |   10 +++++++-\n .../jgit/transport/BasePackPushConnection.java     |   25 ++++++++++++++++++++\n 2 files changed, 34 insertions(+), 1 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\nindex 14fffc3..e35f850 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java\n@@ -72,6 +72,9 @@\n \t/** Remote repository location. */\n \tprotected final URIish uri;\n \n+\t/** A transport connected to {@link #uri}. */\n+\tprotected final PackTransport transport;\n+\n \t/** Buffered input stream reading from the remote. */\n \tprotected InputStream in;\n \n@@ -93,6 +96,7 @@\n \tBasePackConnection(final PackTransport packTransport) {\n \t\tlocal = packTransport.local;\n \t\turi = packTransport.uri;\n+\t\ttransport = packTransport;\n \t}\n \n \tprotected void init(final InputStream myIn, final OutputStream myOut) {\n@@ -130,7 +134,7 @@ private void readAdvertisedRefsImpl() throws IOException {\n \t\t\t\tline = pckIn.readString();\n \t\t\t} catch (EOFException eof) {\n \t\t\t\tif (avail.isEmpty())\n-\t\t\t\t\tthrow new NoRemoteRepositoryException(uri, \"not found.\");\n+\t\t\t\t\tthrow noRepository();\n \t\t\t\tthrow eof;\n \t\t\t}\n \n@@ -178,6 +182,10 @@ if (prior != null)\n \t\tavailable(avail);\n \t}\n \n+\tprotected TransportException noRepository() {\n+\t\treturn new NoRemoteRepositoryException(uri, \"not found.\");\n+\t}\n+\n \tprotected boolean isCapableOf(final String option) {\n \t\treturn remoteCapablities.contains(option);\n \t}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java\nindex a2d5b6f..a6ab9c4 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java\n@@ -43,6 +43,8 @@\n import java.util.Collection;\n import java.util.Map;\n \n+import org.spearce.jgit.errors.NoRemoteRepositoryException;\n+import org.spearce.jgit.errors.NotSupportedException;\n import org.spearce.jgit.errors.PackProtocolException;\n import org.spearce.jgit.errors.TransportException;\n import org.spearce.jgit.lib.ObjectId;\n@@ -98,6 +100,29 @@ public void push(final ProgressMonitor monitor,\n \t\tdoPush(monitor, refUpdates);\n \t}\n \n+\t@Override\n+\tprotected TransportException noRepository() {\n+\t\t// Sadly we cannot tell the \"invalid URI\" case from \"push not allowed\".\n+\t\t// Opening a fetch connection can help us tell the difference, as any\n+\t\t// useful repository is going to support fetch if it also would allow\n+\t\t// push. So if fetch throws NoRemoteRepositoryException we know the\n+\t\t// URI is wrong. Otherwise we can correctly state push isn't allowed\n+\t\t// as the fetch connection opened successfully.\n+\t\t//\n+\t\ttry {\n+\t\t\ttransport.openFetch().close();\n+\t\t} catch (NotSupportedException e) {\n+\t\t\t// Fall through.\n+\t\t} catch (NoRemoteRepositoryException e) {\n+\t\t\t// Fetch concluded the repository doesn't exist.\n+\t\t\t//\n+\t\t\treturn e;\n+\t\t} catch (TransportException e) {\n+\t\t\t// Fall through.\n+\t\t}\n+\t\treturn new TransportException(uri, \"push not permitted\");\n+\t}\n+\n \tprotected void doPush(final ProgressMonitor monitor,\n \t\t\tfinal Map<String, RemoteRefUpdate> refUpdates)\n \t\t\tthrows TransportException {\n-- \n1.6.0.272.g9ab4\n\n\n-- \nShawn.\n"},{"id":"88858","messageId":"48B61016.7050401@gmail.com","threadId":"15236","inReplyTo":"20080828023501.GC8624@spearce.org","subject":"Re: [EGIT PATCH 1/3] Give NoRemoteRepositoryException better message in BasePackConnection","fromName":"Marek Zawirski","fromEmail":"marek.zawirski@gmail.com","sentAt":"2008-08-28T02:40:22Z","receivedAt":"2008-08-28T02:40:22Z","isPatch":true,"sender":{"key":"marek.zawirski@gmail.com","avatar":null},"body":"Shawn O. Pearce wrote:\n(...)\n> +\t@Override\n> +\tprotected TransportException noRepository() {\n> +\t\t// Sadly we cannot tell the \"invalid URI\" case from \"push not allowed\".\n> +\t\t// Opening a fetch connection can help us tell the difference, as any\n> +\t\t// useful repository is going to support fetch if it also would allow\n> +\t\t// push. So if fetch throws NoRemoteRepositoryException we know the\n> +\t\t// URI is wrong. Otherwise we can correctly state push isn't allowed\n> +\t\t// as the fetch connection opened successfully.\n> +\t\t//\n> +\t\ttry {\n> +\t\t\ttransport.openFetch().close();\n> +\t\t} catch (NotSupportedException e) {\n> +\t\t\t// Fall through.\n> +\t\t} catch (NoRemoteRepositoryException e) {\n> +\t\t\t// Fetch concluded the repository doesn't exist.\n> +\t\t\t//\n> +\t\t\treturn e;\n> +\t\t} catch (TransportException e) {\n> +\t\t\t// Fall through.\n> +\t\t}\n> +\t\treturn new TransportException(uri, \"push not permitted\");\n> +\t}\n> +\n\nNice idea, even if it's crazy and time-consuming, it's probably better \nthan my previous one.\n\n-- \nMarek Zawirski [zawir]\nmarek.zawirski@gmail.com\n"},{"id":"88860","messageId":"20080828024437.GD8624@spearce.org","threadId":"15236","inReplyTo":"48B61016.7050401@gmail.com","subject":"Re: [EGIT PATCH 1/3] Give NoRemoteRepositoryException better message in BasePackConnection","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-08-28T02:44:37Z","receivedAt":"2008-08-28T02:44:37Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Marek Zawirski <marek.zawirski@gmail.com> wrote:\n> Shawn O. Pearce wrote:\n> (...)\n>> +\t@Override\n>> +\tprotected TransportException noRepository() {\n>> +\t\t// Sadly we cannot tell the \"invalid URI\" case from \"push not allowed\".\n>> +\t\t// Opening a fetch connection can help us tell the difference, as any\n>> +\t\t// useful repository is going to support fetch if it also would allow\n>> +\t\t// push. So if fetch throws NoRemoteRepositoryException we know the\n>> +\t\t// URI is wrong. Otherwise we can correctly state push isn't allowed\n>> +\t\t// as the fetch connection opened successfully.\n>> +\t\t//\n>> +\t\ttry {\n>> +\t\t\ttransport.openFetch().close();\n>> +\t\t} catch (NotSupportedException e) {\n>> +\t\t\t// Fall through.\n>> +\t\t} catch (NoRemoteRepositoryException e) {\n>> +\t\t\t// Fetch concluded the repository doesn't exist.\n>> +\t\t\t//\n>> +\t\t\treturn e;\n>> +\t\t} catch (TransportException e) {\n>> +\t\t\t// Fall through.\n>> +\t\t}\n>> +\t\treturn new TransportException(uri, \"push not permitted\");\n>> +\t}\n>> +\n>\n> Nice idea, even if it's crazy and time-consuming, it's probably better  \n> than my previous one.\n\nI'm not too worried about the extra time used here.\n\nThis happens only after we have already opened a connection and\nreceived no refs at all from the remote peer.  So the user has\nalready had to wait to get this far.\n\nBy asking the same transport to open the fetch we can reuse an\nexisting SSH tunnel for the new command if this is an SSH connection,\nso the setup costs are a lot lower then the original connection.\n\nWe are already in a bad error condition; we cannot continue and\nthe user is about to get an error.  I would rather give them the\nbest error message we can determine than abort early and give them\nsomething misleading.\n\n-- \nShawn.\n"}]}