Subject: Re: Possible submodule or submodule documentation issue

From: Jens Lehmann <[email-masked]>
Date: Wed, 28 Dec 2011 20:47:40 +0100

Am 27.12.2011 20:24, schrieb Bill Zaumen:
> For the 'add' command, the man page for get-submodule states
> 
> "<repository> is the URL of the new submodule’s origin repository. This
> may be either an absolute URL, or (if it begins with ./ or ../), the
> location relative to the superproject’s origin repository."
> 
> and
> 
> "In either case, the given URL is recorded into .gitmodules for use by
> subsequent users cloning the superproject. If the URL is given relative
> to the superproject’s repository, the presumption is the superproject
> and submodule repositories will be kept together in the same relative
> location, and only the superproject’s URL needs to be provided:
> git-submodule will correctly locate the submodule using the relative URL
> in .gitmodules."
> 
> Based on that documentation, I tried the following sequence of commands:
> 
> git init --bare library.git
> git init --bare library-pkg.git
> git clone library.git
> cd library;
> echo hello > hello
> git add hello
> git commit -m "initial"
> git push origin master
> cd ..
> git clone library-pkg.git

I assume you did forget to add a "cd library-pkg" here.

> echo goodbye > goodbye
> git add goodbye
> git submodule add ./library.git src   <FAILS>

With Git 1.7.1 I get the following error message:

fatal: '/tmp/library-pkg.git/library.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Clone of '/tmp/library-pkg.git/library.git' into submodule path 'src' failed

Which is rather what I would have expected: Using "./library.git src"
implies the library living *inside* the "library-pkg.git" repo, not
next to it (and the error message shows that). "../library.git" is the
correct relative path, so the next command works as expected.

> git submodule add ../library.git src  <WORKS>
> git commit -a -m "initial pkg"
> git push origin master
> 
> The documentation as written suggests that the first use of 
> "git submodule add" is the one that should have worked because
> library.git is in the same directory as the origin repository
> library-pgk.git .  I didn't try moving the two .git directories
> to a server to see if the behavior is the same in that case (my
> test was using the local file system).

Hmm, the documentation says "the location relative to the
superproject’s origin repository", not the directory containing
it. This means you have to use ".." first to get out of the
repository itself, no?