{"thread":{"id":"40026","subject":"Error when cloning with weird local directory","startedAt":"2015-08-06T04:21:06Z","lastAt":"2015-08-10T18:16:07Z","messageCount":6,"participants":["Chris Packham","Torsten Bögershausen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"267554","messageId":"CAFOYHZByteuPZwRvw9tzFWOD6vguw4wPK1J6rLZZvHzyZRBtSA@mail.gmail.com","threadId":"40026","inReplyTo":null,"subject":"Error when cloning with weird local directory","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2015-08-06T04:21:06Z","receivedAt":"2015-08-06T04:21:06Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"Hi All,\n\nA developer at $dayjob called me over to have a look at a git error he\nwas getting (names changed to protect the innocent).\n\n  $ git --version\n  git version 2.5.0\n  $ git clone ssh://example.com/repo.git\n  Cloning into 'repo'...\n  fatal: I don't handle protocol '/home/user/src/ssh'\n\nAfter a bit of head scratching we found that he had a local directory\nstructure called 'ssh://example.com/repo.git' it wasn't a complete\nrepo but it had some of the things one expects to find in a .git\ndirectory (info, objects, refs, etc). It had been there for a while\nand we suspect was created by a scp gone wrong from the last time he\nwas dealing with repo.git.\n\nI'm wondering if it's worth catching this kind of weirdness and\nerroring out with a slightly more useful message. I'm also wondering\nwhat would have happened if this repo was actually a full and complete\nthing.\n\nI'm not sure that there is a problem worth solving here. I can provide\nan anonymized tarball of the directory structure in question if anyone\nis interested. But maybe this is useful for future mailing list\nsearchers[1].\n\nThanks,\nChris\n--\n[1] - https://xkcd.com/979/\n"},{"id":"267559","messageId":"55C2F54A.7070702@web.de","threadId":"40026","inReplyTo":"CAFOYHZByteuPZwRvw9tzFWOD6vguw4wPK1J6rLZZvHzyZRBtSA@mail.gmail.com","subject":"Re: Error when cloning with weird local directory","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-08-06T05:48:58Z","receivedAt":"2015-08-06T05:48:58Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2015-08-06 06.21, Chris Packham wrote:\n> Hi All,\n> \n> A developer at $dayjob called me over to have a look at a git error he\n> was getting (names changed to protect the innocent).\n> \n>   $ git --version\n>   git version 2.5.0\n>   $ git clone ssh://example.com/repo.git\n>   Cloning into 'repo'...\n>   fatal: I don't handle protocol '/home/user/src/ssh'\n> \n> After a bit of head scratching we found that he had a local directory\n> structure called 'ssh://example.com/repo.git' it wasn't a complete\n> repo but it had some of the things one expects to find in a .git\n> directory (info, objects, refs, etc). It had been there for a while\n> and we suspect was created by a scp gone wrong from the last time he\n> was dealing with repo.git.\n> \n> I'm wondering if it's worth catching this kind of weirdness and\n> erroring out with a slightly more useful message. I'm also wondering\n> what would have happened if this repo was actually a full and complete\n> thing.\n> \n> I'm not sure that there is a problem worth solving here. I can provide\n> an anonymized tarball of the directory structure in question if anyone\n> is interested. But maybe this is useful for future mailing list\n> searchers[1].\n> \n> Thanks,\n> Chris\nThis is indeed a bug:\n\nIt looks as if\nstatic char *get_repo_path(const char *repo, int *is_bundle)\nin built/clone.c\nchecks if there is a local directory structure looking like a\n.git directory.\nThis is wrong.\nThere should be a check for the scheme first.\n\n\nIt is not the error message that is confusing, we should never get there,\nbut invoke ssh instead.\n\nThe bug is in clone.c\n"},{"id":"267562","messageId":"xmqqtwsczws6.fsf@gitster.dls.corp.google.com","threadId":"40026","inReplyTo":"55C2F54A.7070702@web.de","subject":"Re: Error when cloning with weird local directory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-06T07:44:09Z","receivedAt":"2015-08-06T07:44:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> It looks as if\n> static char *get_repo_path(const char *repo, int *is_bundle)\n> in built/clone.c\n> checks if there is a local directory structure looking like a\n> .git directory.\n> This is wrong.\n\nIt is as designed, though, to allow cloning from a local directory\nwith any name.\n\n> There should be a check for the scheme first.\n\nThat will be wrong.\n"},{"id":"267563","messageId":"xmqqpp30zwhu.fsf@gitster.dls.corp.google.com","threadId":"40026","inReplyTo":"xmqqtwsczws6.fsf@gitster.dls.corp.google.com","subject":"Re: Error when cloning with weird local directory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-06T07:50:21Z","receivedAt":"2015-08-06T07:50:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Torsten Bögershausen <tboegi@web.de> writes:\n>\n>> It looks as if\n>> static char *get_repo_path(const char *repo, int *is_bundle)\n>> in built/clone.c\n>> checks if there is a local directory structure looking like a\n>> .git directory.\n>> This is wrong.\n>\n> It is as designed, though, to allow cloning from a local directory\n> with any name.\n>\n>> There should be a check for the scheme first.\n>\n> That will be wrong.\n\nIt matters mostly when dealing with scp-like syntax, word:path.\n\nI _think_ taking notice of \"word://\" (with doubled slashes) and\ntreating it specially will not introduce any new issue; while it is\nstill OK for users to have a local directory called \"word:\", if they\nmeant a subdirectory of it, they wouldn't have typed double-slashes\nthere.\n"},{"id":"267650","messageId":"55C5A111.6050902@web.de","threadId":"40026","inReplyTo":"xmqqpp30zwhu.fsf@gitster.dls.corp.google.com","subject":"Re: Error when cloning with weird local directory","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-08-08T06:26:25Z","receivedAt":"2015-08-08T06:26:25Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2015-08-06 09.50, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> Torsten Bögershausen <tboegi@web.de> writes:\n>>\n>>> It looks as if\n>>> static char *get_repo_path(const char *repo, int *is_bundle)\n>>> in built/clone.c\n>>> checks if there is a local directory structure looking like a\n>>> .git directory.\n>>> This is wrong.\n>>\n>> It is as designed, though, to allow cloning from a local directory\n>> with any name.\nI see the point, but this is what I would expect as a user:\n\ngit clone ssh://host/path         # Always ssh, never local\ngit clone ./ssh://host/path       # Always local\ngit clone host:path               # scp syntax, border case:\n                                  # if a git repo host:path exists on disc,\n                                  # use it\ngit clone ./host:path             # local, not scp ('/' before ':')\n\nBeside that, git fetch, git fetch-pack all use the transport helper from\ntransport.c:\ntransport\nstruct transport *transport_get(struct remote *remote, const char *url)\n\nto let the URL being parsed and to make the decision if an URL without a scheme\nis ssh or a local file.\n\nSo I think that git clone can be slighty more consistant here.\n\n\n\n\n>>\n>>> There should be a check for the scheme first.\n>>\n>> That will be wrong.\n> \n> It matters mostly when dealing with scp-like syntax, word:path.\n> \n> I _think_ taking notice of \"word://\" (with doubled slashes) and\n> treating it specially will not introduce any new issue; while it is\n> still OK for users to have a local directory called \"word:\", if they\n> meant a subdirectory of it, they wouldn't have typed double-slashes\n> there.\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n"},{"id":"267786","messageId":"xmqqegjbuhzs.fsf@gitster.dls.corp.google.com","threadId":"40026","inReplyTo":"55C5A111.6050902@web.de","subject":"Re: Error when cloning with weird local directory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-10T18:16:07Z","receivedAt":"2015-08-10T18:16:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> So I think that git clone can be slighty more consistant here.\n\nSure.\n\n>> I _think_ taking notice of \"word://\" (with doubled slashes) and\n>> treating it specially will not introduce any new issue; while it is\n>> still OK for users to have a local directory called \"word:\", if they\n>> meant a subdirectory of it, they wouldn't have typed double-slashes\n>> there.\n"}]}