* Error when cloning with weird local directory
@ 2015-08-06 4:21 Chris Packham
2015-08-06 5:48 ` Torsten Bögershausen
0 siblings, 1 reply; 6+ messages in thread
From: Chris Packham @ 2015-08-06 4:21 UTC (permalink / raw)
To: GIT
Hi All,
A developer at $dayjob called me over to have a look at a git error he
was getting (names changed to protect the innocent).
$ git --version
git version 2.5.0
$ git clone ssh://example.com/repo.git
Cloning into 'repo'...
fatal: I don't handle protocol '/home/user/src/ssh'
After a bit of head scratching we found that he had a local directory
structure called 'ssh://example.com/repo.git' it wasn't a complete
repo but it had some of the things one expects to find in a .git
directory (info, objects, refs, etc). It had been there for a while
and we suspect was created by a scp gone wrong from the last time he
was dealing with repo.git.
I'm wondering if it's worth catching this kind of weirdness and
erroring out with a slightly more useful message. I'm also wondering
what would have happened if this repo was actually a full and complete
thing.
I'm not sure that there is a problem worth solving here. I can provide
an anonymized tarball of the directory structure in question if anyone
is interested. But maybe this is useful for future mailing list
searchers[1].
Thanks,
Chris
--
[1] - https://xkcd.com/979/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error when cloning with weird local directory
2015-08-06 4:21 Error when cloning with weird local directory Chris Packham
@ 2015-08-06 5:48 ` Torsten Bögershausen
2015-08-06 7:44 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Torsten Bögershausen @ 2015-08-06 5:48 UTC (permalink / raw)
To: Chris Packham, GIT
On 2015-08-06 06.21, Chris Packham wrote:
> Hi All,
>
> A developer at $dayjob called me over to have a look at a git error he
> was getting (names changed to protect the innocent).
>
> $ git --version
> git version 2.5.0
> $ git clone ssh://example.com/repo.git
> Cloning into 'repo'...
> fatal: I don't handle protocol '/home/user/src/ssh'
>
> After a bit of head scratching we found that he had a local directory
> structure called 'ssh://example.com/repo.git' it wasn't a complete
> repo but it had some of the things one expects to find in a .git
> directory (info, objects, refs, etc). It had been there for a while
> and we suspect was created by a scp gone wrong from the last time he
> was dealing with repo.git.
>
> I'm wondering if it's worth catching this kind of weirdness and
> erroring out with a slightly more useful message. I'm also wondering
> what would have happened if this repo was actually a full and complete
> thing.
>
> I'm not sure that there is a problem worth solving here. I can provide
> an anonymized tarball of the directory structure in question if anyone
> is interested. But maybe this is useful for future mailing list
> searchers[1].
>
> Thanks,
> Chris
This is indeed a bug:
It looks as if
static char *get_repo_path(const char *repo, int *is_bundle)
in built/clone.c
checks if there is a local directory structure looking like a
.git directory.
This is wrong.
There should be a check for the scheme first.
It is not the error message that is confusing, we should never get there,
but invoke ssh instead.
The bug is in clone.c
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error when cloning with weird local directory
2015-08-06 5:48 ` Torsten Bögershausen
@ 2015-08-06 7:44 ` Junio C Hamano
2015-08-06 7:50 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2015-08-06 7:44 UTC (permalink / raw)
To: Torsten Bögershausen; +Cc: Chris Packham, GIT
Torsten Bögershausen <tboegi@web.de> writes:
> It looks as if
> static char *get_repo_path(const char *repo, int *is_bundle)
> in built/clone.c
> checks if there is a local directory structure looking like a
> .git directory.
> This is wrong.
It is as designed, though, to allow cloning from a local directory
with any name.
> There should be a check for the scheme first.
That will be wrong.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error when cloning with weird local directory
2015-08-06 7:44 ` Junio C Hamano
@ 2015-08-06 7:50 ` Junio C Hamano
2015-08-08 6:26 ` Torsten Bögershausen
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2015-08-06 7:50 UTC (permalink / raw)
To: Torsten Bögershausen; +Cc: Chris Packham, GIT
Junio C Hamano <gitster@pobox.com> writes:
> Torsten Bögershausen <tboegi@web.de> writes:
>
>> It looks as if
>> static char *get_repo_path(const char *repo, int *is_bundle)
>> in built/clone.c
>> checks if there is a local directory structure looking like a
>> .git directory.
>> This is wrong.
>
> It is as designed, though, to allow cloning from a local directory
> with any name.
>
>> There should be a check for the scheme first.
>
> That will be wrong.
It matters mostly when dealing with scp-like syntax, word:path.
I _think_ taking notice of "word://" (with doubled slashes) and
treating it specially will not introduce any new issue; while it is
still OK for users to have a local directory called "word:", if they
meant a subdirectory of it, they wouldn't have typed double-slashes
there.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error when cloning with weird local directory
2015-08-06 7:50 ` Junio C Hamano
@ 2015-08-08 6:26 ` Torsten Bögershausen
2015-08-10 18:16 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Torsten Bögershausen @ 2015-08-08 6:26 UTC (permalink / raw)
To: Junio C Hamano, Torsten Bögershausen; +Cc: Chris Packham, GIT
On 2015-08-06 09.50, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Torsten Bögershausen <tboegi@web.de> writes:
>>
>>> It looks as if
>>> static char *get_repo_path(const char *repo, int *is_bundle)
>>> in built/clone.c
>>> checks if there is a local directory structure looking like a
>>> .git directory.
>>> This is wrong.
>>
>> It is as designed, though, to allow cloning from a local directory
>> with any name.
I see the point, but this is what I would expect as a user:
git clone ssh://host/path # Always ssh, never local
git clone ./ssh://host/path # Always local
git clone host:path # scp syntax, border case:
# if a git repo host:path exists on disc,
# use it
git clone ./host:path # local, not scp ('/' before ':')
Beside that, git fetch, git fetch-pack all use the transport helper from
transport.c:
transport
struct transport *transport_get(struct remote *remote, const char *url)
to let the URL being parsed and to make the decision if an URL without a scheme
is ssh or a local file.
So I think that git clone can be slighty more consistant here.
>>
>>> There should be a check for the scheme first.
>>
>> That will be wrong.
>
> It matters mostly when dealing with scp-like syntax, word:path.
>
> I _think_ taking notice of "word://" (with doubled slashes) and
> treating it specially will not introduce any new issue; while it is
> still OK for users to have a local directory called "word:", if they
> meant a subdirectory of it, they wouldn't have typed double-slashes
> there.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error when cloning with weird local directory
2015-08-08 6:26 ` Torsten Bögershausen
@ 2015-08-10 18:16 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2015-08-10 18:16 UTC (permalink / raw)
To: Torsten Bögershausen; +Cc: Chris Packham, GIT
Torsten Bögershausen <tboegi@web.de> writes:
> So I think that git clone can be slighty more consistant here.
Sure.
>> I _think_ taking notice of "word://" (with doubled slashes) and
>> treating it specially will not introduce any new issue; while it is
>> still OK for users to have a local directory called "word:", if they
>> meant a subdirectory of it, they wouldn't have typed double-slashes
>> there.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-08-10 18:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-06 4:21 Error when cloning with weird local directory Chris Packham
2015-08-06 5:48 ` Torsten Bögershausen
2015-08-06 7:44 ` Junio C Hamano
2015-08-06 7:50 ` Junio C Hamano
2015-08-08 6:26 ` Torsten Bögershausen
2015-08-10 18:16 ` Junio C Hamano
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).