# Submodules implementation

4 messages from 2010-02-23 to 2010-02-24. Participants: Christoph Bartoschek, Avery Pennarun, Junio C Hamano.
Thread: https://gitlist.dev/t/22784

## Christoph Bartoschek, 2010-02-23 23:50

Subject: Submodules implementation
Message-ID: <k76e57-g67.ln1@burns.bruehl.pontohonk.de>
URL: https://gitlist.dev/e/k76e57-g67.ln1%40burns.bruehl.pontohonk.de

```
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, 2010-02-23 23:59

Subject: Re: Submodules implementation
Message-ID: <32541b131002231559r49fc31e0i4ce46869d27190c8@mail.gmail.com>
URL: https://gitlist.dev/e/32541b131002231559r49fc31e0i4ce46869d27190c8%40mail.gmail.com
In-Reply-To: <k76e57-g67.ln1@burns.bruehl.pontohonk.de>

```
2010/2/23 Christoph Bartoschek <bartoschek@gmx.de>:
> 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.

> 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, 2010-02-24 00:15

Subject: Re: Submodules implementation
Message-ID: <201002240115.53771.bartoschek@gmx.de>
URL: https://gitlist.dev/e/201002240115.53771.bartoschek%40gmx.de
In-Reply-To: <32541b131002231559r49fc31e0i4ce46869d27190c8@mail.gmail.com>

```
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.

> 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, 2010-02-24 00:40

Subject: Re: Submodules implementation
Message-ID: <7vvddnwjmu.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vvddnwjmu.fsf%40alter.siamese.dyndns.org
In-Reply-To: <201002240115.53771.bartoschek@gmx.de>

```
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.

```
