Re: [PATCH] clone: fix repo name when cloning a server's root

2015-07-27 Thread Duy Nguyen
On Mon, Jul 27, 2015 at 6:48 PM, Patrick Steinhardt  wrote:
> When cloning a repository from a server's root, that is the URL's
> path component is a '/' only, we fail to generate a sensible
> repository name when the URL contains authentication data. This
> is especially bad when cloning URLs like
> 'ssh://user:pas...@example.com/', which results in a repository
> 'pas...@example.com' being created.
>
> Improve the behavior by also regarding '@'-signs as a separator
> when scanning the URL. In the mentioned case this would instead
> result in a directory 'example.com' being created.

My initial reaction was, if you put password on the command line, you
deserve it. However, as we improve this heuristics, perhaps it's
better to export parse_connect_url() from connect.c and use it here?
We would have more robust parsing. You can create a repo named
example.com given the url ssh://user:p...@example.com:123/. Maybe it's
overkill?

> Signed-off-by: Patrick Steinhardt 
> ---
> I was not able to come by with a useful test as that would
> require being able to clone a root directory. I couldn't find
> anything in the current tests that looks like what I want to do.
> Does anybody have an idea on how to achieve this?

There's t/t1509/prepare-chroot.sh that will prepare a chroot for this
purpose. You'll need linux, busybox and chroot permission.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] clone: fix repo name when cloning a server's root

2015-07-27 Thread Patrick Steinhardt
On Mon, Jul 27, 2015 at 07:51:30PM +0700, Duy Nguyen wrote:
> On Mon, Jul 27, 2015 at 6:48 PM, Patrick Steinhardt  wrote:
> > When cloning a repository from a server's root, that is the URL's
> > path component is a '/' only, we fail to generate a sensible
> > repository name when the URL contains authentication data. This
> > is especially bad when cloning URLs like
> > 'ssh://user:pas...@example.com/', which results in a repository
> > 'pas...@example.com' being created.
> >
> > Improve the behavior by also regarding '@'-signs as a separator
> > when scanning the URL. In the mentioned case this would instead
> > result in a directory 'example.com' being created.
> 
> My initial reaction was, if you put password on the command line, you
> deserve it. However, as we improve this heuristics, perhaps it's
> better to export parse_connect_url() from connect.c and use it here?
> We would have more robust parsing. You can create a repo named
> example.com given the url ssh://user:p...@example.com:123/. Maybe it's
> overkill?

Sure, specifying passwords on command line should not be done
easily. Still those heuristics fail for everything that does
not include an additional [:/] when the URL's path is empty. So I
guess using parse_connect_url() would be the most sane solution
for this, as it will also fix the case when you specify a port,
which would currently use the port as directory name. I'll whip
up a new version that uses parse_connect_url().

> > Signed-off-by: Patrick Steinhardt 
> > ---
> > I was not able to come by with a useful test as that would
> > require being able to clone a root directory. I couldn't find
> > anything in the current tests that looks like what I want to do.
> > Does anybody have an idea on how to achieve this?
> 
> There's t/t1509/prepare-chroot.sh that will prepare a chroot for this
> purpose. You'll need linux, busybox and chroot permission.

Thanks for the hint.

Patrick


signature.asc
Description: Digital signature


Re: [PATCH] clone: fix repo name when cloning a server's root

2015-07-27 Thread Junio C Hamano
Duy Nguyen  writes:

>> I was not able to come by with a useful test as that would
>> require being able to clone a root directory. I couldn't find
>> anything in the current tests that looks like what I want to do.
>> Does anybody have an idea on how to achieve this?
>
> There's t/t1509/prepare-chroot.sh that will prepare a chroot for this
> purpose. You'll need linux, busybox and chroot permission.

If you do not use ssh:// or file://, it should be trivial to
arrange, no?  http://site/repo will typically not be serving
/repo from the root of the filesystem.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html