Skip to content

Commit 82349f8

Browse files
committed
shallow-submodule.sh
1 parent ecdf883 commit 82349f8

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.bzr
2+
tmp

shallow-submodule.sh

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
3+
# https://github.com/cirosantilli/test-submodule-mod
4+
# https://github.com/cirosantilli/test-submodule-top
5+
# https://github.com/cirosantilli/test-submodule-top-shallow
6+
# https://github.com/cirosantilli/test-submodule-mod-branch
7+
# https://github.com/cirosantilli/test-submodule-top-branch
8+
# https://github.com/cirosantilli/test-submodule-top-branch-shallow
9+
10+
set -ex
11+
12+
rm -rf tmp
13+
mkdir tmp
14+
cd tmp
15+
rm -rf *
16+
17+
mkdir mod
18+
cd mod/
19+
git init
20+
touch a
21+
git add a
22+
git commit -m 1
23+
touch b
24+
git add b
25+
git commit -m 2
26+
cd ..
27+
28+
mkdir top
29+
cd top
30+
git init
31+
touch a
32+
git add a
33+
git commit -m 1
34+
touch b
35+
git add b
36+
git commit -m 2
37+
git submodule add ../mod/ mod
38+
git add .gitmodules
39+
git commit -m '.gitmodules'
40+
cd ..
41+
42+
cp -rv top top-shallow
43+
cd top-shallow
44+
printf '\tshallow = true\n' >> .gitmodules
45+
git add .gitmodules
46+
git commit -m 'shallow'
47+
cd ..
48+
49+
mkdir mod-branch
50+
cd mod-branch/
51+
git init
52+
touch a
53+
git add a
54+
git commit -m 1
55+
touch b
56+
git add b
57+
git commit -m 2
58+
git checkout -b mybranch HEAD~
59+
touch c
60+
git add c
61+
git commit -m 3
62+
cd ..
63+
64+
mkdir top-branch
65+
cd top-branch
66+
git init
67+
touch a
68+
git add a
69+
git commit -m 1
70+
touch b
71+
git add b
72+
git commit -m 2
73+
git submodule add -b mybranch ../mod-branch/ mod
74+
git add .gitmodules
75+
git commit -m '.gitmodules'
76+
cd ..
77+
78+
cp -rv top-branch top-branch-shallow
79+
cd top-branch-shallow
80+
printf '\tshallow = true\n' >> .gitmodules
81+
git add .gitmodules
82+
git commit -m 'shallow'
83+
cd ..
84+
85+
git clone --depth 1 --recursive "file://$(pwd)/top" top-clone
86+
git --git-dir top-clone/.git/modules/mod log
87+
# two commits
88+
89+
git clone --depth 1 --recursive "file://$(pwd)/top-shallow" top-shallow-clone
90+
git --git-dir top-shallow-clone/.git/modules/mod log
91+
# one commit
92+
93+
git clone --depth 1 --recursive "file://$(pwd)/top-branch" top-branch-clone
94+
git --git-dir top-branch-clone/.git/modules/mod log
95+
# two commits
96+
97+
git clone --depth 1 --recursive "file://$(pwd)/top-branch-shallow" top-branch-shallow-clone
98+
git --git-dir top-branch-shallow-clone/.git/modules/mod log
99+
# locally: one commit
100+
# github 2017-11, git 2.14.1: two commits

0 commit comments

Comments
 (0)