Re: [PATCH] submodule add: improve message when resolving a relative url fails
From: Phil Hord <hidden>
Date: 2016-06-15 22:51:40
On 06/01/2011 11:55 AM, Marc Branchaud wrote:
On 11-05-31 06:04 PM, Phil Hord wrote:quoted
On 05/31/2011 04:57 PM, Marc Branchaud wrote:quoted
- The current code rewrites the URL so that any relative path is either rejected or munged into an absolute remote URL.I don't see the URL getting munged away from being relative. Can you point to an example?I reached this conclusion because if I go into my clone of git.git and do git submodule add ../MyThing where ../MyThing is a regular git repo, I get Cloning into MyThing... fatal: The remote end hung up unexpectedly Clone of 'git://git.kernel.org/pub/scm/git/MyThing' into submodule path 'MyThing' failed So it seemed the relative URL became an absolute URL. Looking more closely at a working example, I can see that (as you show below) the URL in the super-repo's .gitmodules file retains the relative path, but the submodule's remote.origin.url is an absolute path. In any case, "submodule add" isn't doing what I expected: make my local MyThing repo a submodule of my git.git clone.
I thought I understood this workflow better than I actually did. I
think I understand more now, and I'm somewhat disappointed. But I also
failed to pick up the ball on this old discussion.
If you do this, I think it will work like you were hoping:
:: ( mkdir MyThing && cd MyThing && git init )
Initialized empty Git repository in /opc/git/MyThing/.git/
:: git submodule add ../MyThing
Adding existing repo at 'MyThing' to the index
I haven't examined the code, but I think this is how it works. 'git
submodule add' takes a URL and a local path. When you omit the local
path, git infers one from the URL. So these two commands are equivalent:
:: git submodule add ../MyThing
:: git submodule add ../MyThing MyThing
If the path you provide (explicitly or implicitly) already contains a
git repo, it is assumed to be "the" submodule repo and git uses it. If
it does not contain a git repo, git attempts to clone it from the
(remote) URL.
Furthermore, the relative path only works for URLs. It does not work
for local filesystems.
Phil