Subject: Re: git clone submodules recursive and reference

From: Jens Lehmann <[email-masked]>
Date: Sat, 21 Apr 2012 15:45:48 +0200

Am 20.04.2012 21:26, schrieb Samuel Maftoul:
>> Hmm, to me it looks like passing the --reference option to the clone
>> run in the submodules doesn't make much sense, as that would make
>> all submodules and the superproject use the same alternates. And as
>> far as I know sharing objects between different repositories is not
>> supported.

I take that back, I was thinking about the idea to store the objects
of all submodules in the superproject's object store and then access
them via alternates which was discussed some time ago. That won't
work out of the box because the submodule commits would be dangling
in the superprojects repo.

> I'm sharing objects between repositories by creating a bare
> repository, adding the remotes for the repositories and fetch them in
> this bare repo.

This sounds like a cool way to reduce the disk footprint of the
repos on our Jenkins server.

> So for me, it makes sense to pass the "--reference" to the submodules
> clone, if submodules remotes are added to this reference bare repo and
> objects are already fetched (and I'm in this case, as I use a lot of
> different projects that shares the same set of submodules).

How do you fetch then, do you fetch into the referenced repo first
and then do a fetch in the clones afterwards to just update the refs
there? Or is the bare repo just a starting point for the initial
clone?

>>> How can I force the clones for submodules to be executed with the
>>> --reference option ?
>>
>> You'd have to use "git clone" without the --recursive option and
>> then do a "git submodule update --init --reference ...".
> 
> Yes, this should make it, but I would have been more happy with a
> single command !

Hmm, me thinks we'd have to add a new option for that, and I'm not
sure it is worth it.