forked from cirosantilli/test-git-web-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shallow-submodule.sh
executable file
·201 lines (169 loc) · 4.85 KB
/
shallow-submodule.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/usr/bin/env bash
# New better tests:
# https://github.com/cirosantilli/test-shallow-submodule-mod
# https://github.com/cirosantilli/test-shallow-submodule-top-branch-shallow
# https://github.com/cirosantilli/test-shallow-submodule-top-sha
# Older tests:
# https://github.com/cirosantilli/test-submodule-mod
# https://github.com/cirosantilli/test-submodule-top
# https://github.com/cirosantilli/test-submodule-top-shallow
# https://github.com/cirosantilli/test-submodule-mod-branch
# https://github.com/cirosantilli/test-submodule-top-branch
set -ex
rm -rf tmp
mkdir tmp
cd tmp
rm -rf *
export GIT_AUTHOR_NAME="Ciro Santilli"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_AUTHOR_DATE='2000-01-01T00:00:00+0000'
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
mkdir mod
cd mod
git init
touch base
git add base
git commit -m base
touch master-1
git add master-1
git commit -m master-1
touch master-2
git add master-2
git commit -m master-2
git tag tag-master
touch master-3
git add master-3
git commit -m master-3
git checkout -b mybranch HEAD~3
touch mybranch-1
git add mybranch-1
git commit -m mybranch-1
touch mybranch-2
git add mybranch-2
git commit -m mybranch-2
git tag tag-mybranch
touch mybranch-3
git add mybranch-3
git commit -m mybranch-3
git checkout master
cd ..
mkdir top
cd top
git init
touch a
git add a
git commit -m 1
touch b
git add b
git commit -m 2
git submodule add ../mod/ mod
git add .gitmodules
git commit -m '.gitmodules'
cd ..
cp -rv top top-shallow
cd top-shallow
printf '\tshallow = true\n' >> .gitmodules
git add .gitmodules
git commit -m 'shallow'
cd ..
mkdir top-branch
cd top-branch
git init
touch a
git add a
git commit -m 1
touch b
git add b
git commit -m 2
git submodule add -b mybranch ../mod/ mod
git add .gitmodules
git commit -m '.gitmodules'
cd ..
cp -rv top-branch top-branch-shallow
cd top-branch-shallow
printf '\tshallow = true\n' >> .gitmodules
git add .gitmodules
git commit -m 'shallow'
cd ..
mkdir top-tag
cd top-tag
git init
touch a
git add a
git commit -m 1
touch b
git add b
git commit -m 2
git submodule add ../mod/ mod
cd mod
git checkout tag-mybranch
cd ..
git add .
git commit -m '.gitmodules'
cd ..
mkdir top-sha
cd top-sha
git init
touch a
git add a
git commit -m 1
touch b
git add b
git commit -m 2
git submodule add ../mod/ mod
cd mod
git checkout tag-mybranch~
cd ..
git add .
git commit -m '.gitmodules'
cd ..
rm -f results
git clone --depth 1 "file://$(pwd)/mod" mod-clone
git --git-dir mod-clone/.git log --oneline | wc -l >>results
# 1
git clone --depth 1 "file://$(pwd)/mod" mod-branch-clone
git --git-dir mod-branch-clone/.git log --oneline | wc -l >>results
# 1
## gitmodule
echo 'gitmodule' >>results
git clone --recurse-submodules "file://$(pwd)/top" top-clone
git --git-dir top-clone/.git/modules/mod log --oneline | wc -l >>results
# many
git clone --recurse-submodules "file://$(pwd)/top-shallow" top-shallow-clone
git --git-dir top-shallow-clone/.git/modules/mod log --oneline | wc -l >>results
# 1
git clone --recurse-submodules "file://$(pwd)/top-branch" top-branch-clone
git --git-dir top-branch-clone/.git/modules/mod log --oneline | wc -l >>results
# many
git clone --recurse-submodules "file://$(pwd)/top-branch-shallow" top-branch-shallow-clone
git --git-dir top-branch-shallow-clone/.git/modules/mod log --oneline | wc -l >>results
# many
git clone --recurse-submodules "file://$(pwd)/top-tag" top-tag-clone
git --git-dir top-tag-clone/.git/modules/mod log --oneline | wc -l >>results
# many
git clone --recurse-submodules "file://$(pwd)/top-sha" top-sha-clone
git --git-dir top-sha-clone/.git/modules/mod log --oneline | wc -l >>results
# many
## SS
echo 'ss' >>results
git clone --recurse-submodules --shallow-submodules "file://$(pwd)/top" top-clone-ss
git --git-dir top-clone-ss/.git/modules/mod log --oneline | wc -l >>results
# 1
git clone --recurse-submodules --shallow-submodules "file://$(pwd)/top-shallow" top-shallow-clone-ss
git --git-dir top-shallow-clone-ss/.git/modules/mod log --oneline | wc -l >>results
# 1
git clone --recurse-submodules --shallow-submodules "file://$(pwd)/top-branch" top-branch-clone-ss
git --git-dir top-branch-clone-ss/.git/modules/mod log --oneline | wc -l >>results
# 1
git clone --recurse-submodules --shallow-submodules "file://$(pwd)/top-branch-shallow" top-branch-shallow-clone-ss
git --git-dir top-branch-shallow-clone-ss/.git/modules/mod log --oneline | wc -l >>results
# 1
git clone --recurse-submodules --shallow-submodules "file://$(pwd)/top-tag" top-tag-clone-ss
git --git-dir top-tag-clone-ss/.git/modules/mod log --oneline | wc -l >>results
# 1
#git clone --recurse-submodules --shallow-submodules "file://$(pwd)/top-sha" top-sha-clone-ss
# error: Server does not allow request for unadvertised object
#git --git-dir top-sha-clone-ss/.git/modules/mod log --oneline | wc -l >>results
cat results