Subject: Re: question about git-submodule

From: Eran Tromer <[email-masked]>
Date: Mon, 06 Aug 2007 13:23:19 -0400

On 2007-08-05 10:59, Sven Verdoolaege wrote:
>> BTW, is there any easy way to create a submodule directly inside the
>> supermodule's working tree, instead of cloning it as in the above example?
> 
> Do you want to use the submodule porcelain or just the plumbing?
> If you simply want to add a submodule locally, "git add" will do that for
> you just fine.  It's only when you want to make it easier for people who
> clone your superproject to get updates of the submodules that you
> should set up the information required by "git submodule" in .gitmodules
> (see end of module_add in git-submodule.sh).

If you just do "git add sub" (where sub is an existing repo subdir) then
any subsequent "git submodule update" predictably complains:
  No submodule mapping found in .gitmodules for path 'sub'

And if you wire up .gitmodules manually, then "git submodule update"
chokes on the "git-fetch" in modules_update().

So I suggest extending "git submodule add" to handle existing
subdirectories by simply using them as-is instead of creating a new
clone. And "git submodule update" shouldn't try fetching when the commit
is already present locally.

Speaking of which, currently "git submodule" clones/fetches *all*
branches on the remote repository, which seems quite excessive given
that the supermodule's content references just one submodule commit. By
default, "git submodule add" should fetch only the needed head, and "git
submodule update" should fetch only the commit sha1 (if needed).

  Eran