git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Marek Zawirski <marek.zawirski@gmail.com>
Cc: robin.rosenberg@dewire.com, git@vger.kernel.org
Subject: Re: [EGIT PATCH 1/3] Give NoRemoteRepositoryException better message in BasePackConnection
Date: Wed, 27 Aug 2008 19:44:37 -0700	[thread overview]
Message-ID: <20080828024437.GD8624@spearce.org> (raw)
In-Reply-To: <48B61016.7050401@gmail.com>

Marek Zawirski <marek.zawirski@gmail.com> wrote:
> Shawn O. Pearce wrote:
> (...)
>> +	@Override
>> +	protected TransportException noRepository() {
>> +		// Sadly we cannot tell the "invalid URI" case from "push not allowed".
>> +		// Opening a fetch connection can help us tell the difference, as any
>> +		// useful repository is going to support fetch if it also would allow
>> +		// push. So if fetch throws NoRemoteRepositoryException we know the
>> +		// URI is wrong. Otherwise we can correctly state push isn't allowed
>> +		// as the fetch connection opened successfully.
>> +		//
>> +		try {
>> +			transport.openFetch().close();
>> +		} catch (NotSupportedException e) {
>> +			// Fall through.
>> +		} catch (NoRemoteRepositoryException e) {
>> +			// Fetch concluded the repository doesn't exist.
>> +			//
>> +			return e;
>> +		} catch (TransportException e) {
>> +			// Fall through.
>> +		}
>> +		return new TransportException(uri, "push not permitted");
>> +	}
>> +
>
> Nice idea, even if it's crazy and time-consuming, it's probably better  
> than my previous one.

I'm not too worried about the extra time used here.

This happens only after we have already opened a connection and
received no refs at all from the remote peer.  So the user has
already had to wait to get this far.

By asking the same transport to open the fetch we can reuse an
existing SSH tunnel for the new command if this is an SSH connection,
so the setup costs are a lot lower then the original connection.

We are already in a bad error condition; we cannot continue and
the user is about to get an error.  I would rather give them the
best error message we can determine than abort early and give them
something misleading.

-- 
Shawn.

      reply	other threads:[~2008-08-28  2:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-28  1:36 [EGIT PATCH 1/3] Give NoRemoteRepositoryException better message in BasePackConnection Marek Zawirski
2008-08-28  1:36 ` [EGIT PATCH 2/3] Handle NoRemoteRepositoryException in PushOperation especially Marek Zawirski
2008-08-28  1:36   ` [EGIT PATCH 3/3] Show ErrorDialog fot fatal connection errors in ConfirmationPage Marek Zawirski
2008-08-28  2:21     ` Shawn O. Pearce
2008-08-28  2:30       ` Marek Zawirski
2008-08-28  2:19   ` [EGIT PATCH 2/3] Handle NoRemoteRepositoryException in PushOperation especially Shawn O. Pearce
2008-08-28  2:29     ` Marek Zawirski
2008-08-28  2:35 ` [EGIT PATCH 1/3] Give NoRemoteRepositoryException better message in BasePackConnection Shawn O. Pearce
2008-08-28  2:40   ` Marek Zawirski
2008-08-28  2:44     ` Shawn O. Pearce [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080828024437.GD8624@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=marek.zawirski@gmail.com \
    --cc=robin.rosenberg@dewire.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).