threads / discuss / 22784

Submodules implementation

Subject: Submodules implementation

## tl;dr

4 messages between Feb 23, 2010 and Feb 24, 2010.

replies: 3people: 3as markdown or json

Christoph Bartoschek· Feb 23, 2010, 23:50 UTC · lore
Hi,

what is the main reason that submodules are their own repositories linked into the enclosing one and not just additional pointers in the main repository?

My impression is that submodules as pointers to existing tree objects would make a design more easier to understand and more user friendly. Especially I see no need for most of the submodule commands. Maybe "git submodule add" but the other commands are already covered by existing ones.

Or is there a tool that uses such additional pointers for submodule management?

Thanks Christoph

Avery Pennarun· Feb 23, 2010, 23:59 UTC · re: Christoph Bartoschek · lore

Re: Submodules implementation

2010/2/23 Christoph Bartoschek <bartoschek@gmx.de>:
Show 6 quoted lines
> what is the main reason that submodules are their own repositories linked
> into the enclosing one and not just additional pointers in the main
> repository?
>
> My impression is that submodules as pointers to existing tree objects would
> make a design more easier to understand and more user friendly.

The data format itself implements submodules as simply pointers to commits (not trees) located at a particular point in the supermodule. This is very elegant and simple.

Show 5 quoted lines
> Especially I see no need for most of the submodule commands. Maybe "git
> submodule add" but the other commands are already covered by existing ones.
>
> Or is there a tool that uses such additional pointers for submodule
> management?

The implementation of submodule tools, particularly 'git submodule', is the reason that these submodule pointers are implemented as separate repositories. I think the reasons are that a) it seemed expedient at the time, and b) it's one valid way (although not the only way) of thinking about what it means to have one repo point at a commit.

By comparison, my git-subtree tool (http://github.com/apenwarr/git-subtree) is the opposite: its data storage format isn't very elegant (it just has a tree stored inside another tree, as if there were no submodule at all) but its implementation makes it easier for end users (since they don't have to deal with separate repositories).

The ideal tool would be elegant *and* easy to use, but it doesn't exist.
Have fun,
Avery
Christoph Bartoschek· Feb 24, 2010, 00:15 UTC · re: Avery Pennarun · lore

Re: Submodules implementation

Am Mittwoch 24 Februar 2010 schrieb Avery Pennarun:
> The data format itself implements submodules as simply pointers to
> commits (not trees) located at a particular point in the supermodule.
> This is very elegant and simple.

I see that in the submodule there is a .git directory with its own objects. This does not look like as if the submodule objects are part of the superproject.

Show 6 quoted lines
> By comparison, my git-subtree tool
> (http://github.com/apenwarr/git-subtree) is the opposite: its data
> storage format isn't very elegant (it just has a tree stored inside
> another tree, as if there were no submodule at all) but its
> implementation makes it easier for end users (since they don't have to
> deal with separate repositories).

This is exaclty how I would expect it. The tree of the submodule has its root somewhere in the tree of the superproject. Then there are commits for the superproject that point to the root of the whole tree and commits for the submodules that point to nodes in the tree. A combined tree looks much more elegant for me.

I'll take a look at your tool.
Christop
Junio C Hamano· Feb 24, 2010, 00:40 UTC · re: Christoph Bartoschek · lore

Re: Submodules implementation

Christoph Bartoschek <bartoschek@gmx.de> writes:
> I see that in the submodule there is a .git directory with its own objects.  
> This does not look like as if the submodule objects are part of the 
> superproject.

Because they largely aren't. submodules are freestanding projects on their own right.

One of the primary design decisions was to support the use of a superproject without having to clone/checkout all the submodules.

You may want to check earlier design discussion thread:
  http://thread.gmane.org/gmane.comp.version-control.git/31941/focus=32944

It is a huge thread and some of the messages there might be nothing more than uninformed and unworkable handwaving, except for the ones from Linus and some others.

← back to recent threads