cloning submodules with children submodules

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

cloning submodules with children submodules

From: Paul Martinolich <hidden>
Date: 2016-06-15 22:43:53

It appears that git clone or git submodule init does not handle  
submodules under submodules.

Given this project tree:

modules/mod_A
modules/mod_B
modules/mod_b

proj_one/mod_A
proj_one/mod_B
proj_one/mod_B/mod_b

proj_two/mod_A
proj_two/mod_B
proj_two/mod_b

The cloning of proj_two works correctly.  However, for proj_one, mod_b  
is not under mod_B:

cloned proj_one

$ ls -a ./
.  ..  .git  .gitmodules  mod_A  mod_B	project.txt
$ ls -a ./mod_A
.  ..
$ ls -a ./mod_B
.  ..
$ more .gitmodules
[submodule "mod_A"]
	path = mod_A
	url = /home/martinol/test/modules/mod_A/.git
[submodule "mod_B"]
	path = mod_B
	url = /home/martinol/test/modules/mod_B/.git
Submodule 'mod_A' (/home/martinol/test/modules/mod_A/.git) registered  
for path 'mod_A'
Submodule 'mod_B' (/home/martinol/test/modules/mod_B/.git) registered  
for path 'mod_B'
Initialized empty Git repository in /home/martinol/test/user_a/ 
proj_one/mod_A/.git/
0 blocks
Submodule path 'mod_A': checked out  
'80298817a0789d039e1fb4a73c9635fce8e7cdd2'
Initialized empty Git repository in /home/martinol/test/user_a/ 
proj_one/mod_B/.git/
0 blocks
Submodule path 'mod_B': checked out  
'21b652610f5e9085f799c424d8a7ef685f5ec440'

submodule init/update proj_one

$ ls -a ./
.  ..  .git  .gitmodules  mod_A  mod_B	project.txt
$ ls -a ./mod_A
.  ..  .git  module.txt
$ ls -a ./mod_B
.  ..  .git  module.txt
$ more .gitmodules
[submodule "mod_A"]
	path = mod_A
	url = /home/martinol/test/modules/mod_A/.git
[submodule "mod_B"]
	path = mod_B
	url = /home/martinol/test/modules/mod_B/.git

public proj_one

$ cd ~/test/proj_one
$ ls -a ./
.  ..  .git  .gitmodules  mod_A  mod_B	project.txt
$ ls -a ./mod_B
.  ..  .git  .gitmodules  mod_b  module.txt
$ more .gitmodules
[submodule "mod_A"]
	path = mod_A
	url = /home/martinol/test/modules/mod_A/.git
[submodule "mod_B"]
	path = mod_B
	url = /home/martinol/test/modules/mod_B/.git
$ more mod_B/.gitmodules
[submodule "mod_b"]
	path = mod_b
	url = /home/martinol/test/modules/mod_b/.git

$ git --version
git version 1.5.3.6

I've attached a script that demonstrates this behavior.

Thanks, Paul

Re: cloning submodules with children submodules

From: Sven Verdoolaege <hidden>
Date: 2016-06-15 22:43:53

On Fri, Nov 23, 2007 at 01:17:15PM -0600, Paul Martinolich wrote:
It appears that git clone or git submodule init does not handle  
submodules under submodules.
I don't see why it wouldn't work.

You seem to think, however, that git submodule update would
call git submodule update/init inside any submodules it clones.
It doesn't.
The cloning of proj_two works correctly.  However, for proj_one, mod_b  
is not under mod_B:
You didn't commit the change to mod_B to proj_one.
Furthermore, you didn't push your changes to mod_B to
the repo you specified for mod_B in .gitmodules.

skimo

Re: cloning submodules with children submodules

From: Paul Martinolich <hidden>
Date: 2016-06-15 22:43:53

On Nov 23, 2007, at 1:49 PM, Sven Verdoolaege wrote:
You didn't commit the change to mod_B to proj_one.
Furthermore, you didn't push your changes to mod_B to
the repo you specified for mod_B in .gitmodules.
Thanks for the help.

It works with the changes below.

Paul

I changed the creation of mod_b under mod_B to:

#  add mod_b to mod_B and push the changes back to mod_B

cd $GITDIR/proj_one/mod_B
git submodule add $GITDIR/modules/mod_b
git commit -m 'add module mod_b under module mod_B for project proj_one'
git push

cd $GITDIR/proj_one
git add mod_B
git commit -m 'reflect module mod_B update for project proj_one'
git status

and when I cloned it to:

#  clone the proj_one project (user user_a)

mkdir -p $GITDIR/user_a
cd $GITDIR/user_a
git clone $GITDIR/proj_one
cd $GITDIR/user_a/proj_one

#  get mod_A and mod_B

git submodule init
git submodule update

#  now get mod_b in mod_B

cd mod_B
git submodule init
git submodule update
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help