5
5
6
6
test_description=' Summary support for submodules
7
7
8
- This test tries to verify the sanity of summary subcommand of git submodule.
8
+ This test script tries to verify the sanity of summary subcommand of git submodule.
9
9
'
10
+ # NEEDSWORK: This test script is old fashioned and may need a big cleanup due to
11
+ # various reasons, one of them being that there are lots of commands taking place
12
+ # outside of 'test_expect_success' block, which is no longer in good-style.
10
13
11
14
. ./test-lib.sh
12
15
@@ -16,12 +19,12 @@ add_file () {
16
19
owd=$( pwd)
17
20
cd " $sm "
18
21
for name; do
19
- echo " $name " > " $name " &&
22
+ echo " $name " > " $name " &&
20
23
git add " $name " &&
21
24
test_tick &&
22
25
git commit -m " Add $name "
23
26
done > /dev/null
24
- git rev-parse --verify HEAD | cut -c1-7
27
+ git rev-parse --short HEAD
25
28
cd " $owd "
26
29
}
27
30
commit_file () {
@@ -38,10 +41,10 @@ test_expect_success 'added submodule' "
38
41
git add sm1 &&
39
42
git submodule summary >actual &&
40
43
cat >expected <<-EOF &&
41
- * sm1 0000000...$head1 (2):
42
- > Add foo2
44
+ * sm1 0000000...$head1 (2):
45
+ > Add foo2
43
46
44
- EOF
47
+ EOF
45
48
test_cmp expected actual
46
49
"
47
50
@@ -52,10 +55,10 @@ test_expect_success 'added submodule (subdirectory)' "
52
55
git submodule summary >../actual
53
56
) &&
54
57
cat >expected <<-EOF &&
55
- * ../sm1 0000000...$head1 (2):
56
- > Add foo2
58
+ * ../sm1 0000000...$head1 (2):
59
+ > Add foo2
57
60
58
- EOF
61
+ EOF
59
62
test_cmp expected actual
60
63
"
61
64
@@ -73,10 +76,10 @@ test_expect_success 'added submodule (subdirectory with explicit path)' "
73
76
git submodule summary ../sm1 >../actual
74
77
) &&
75
78
cat >expected <<-EOF &&
76
- * ../sm1 0000000...$head1 (2):
77
- > Add foo2
79
+ * ../sm1 0000000...$head1 (2):
80
+ > Add foo2
78
81
79
- EOF
82
+ EOF
80
83
test_cmp expected actual
81
84
"
82
85
@@ -86,20 +89,20 @@ head2=$(add_file sm1 foo3)
86
89
test_expect_success ' modified submodule(forward)' "
87
90
git submodule summary >actual &&
88
91
cat >expected <<-EOF &&
89
- * sm1 $head1 ...$head2 (1):
90
- > Add foo3
92
+ * sm1 $head1 ...$head2 (1):
93
+ > Add foo3
91
94
92
- EOF
95
+ EOF
93
96
test_cmp expected actual
94
97
"
95
98
96
99
test_expect_success ' modified submodule(forward), --files' "
97
100
git submodule summary --files >actual &&
98
101
cat >expected <<-EOF &&
99
- * sm1 $head1 ...$head2 (1):
100
- > Add foo3
102
+ * sm1 $head1 ...$head2 (1):
103
+ > Add foo3
101
104
102
- EOF
105
+ EOF
103
106
test_cmp expected actual
104
107
"
105
108
@@ -110,10 +113,10 @@ test_expect_success 'no ignore=all setting has any effect' "
110
113
git config diff.ignoreSubmodules all &&
111
114
git submodule summary >actual &&
112
115
cat >expected <<-EOF &&
113
- * sm1 $head1 ...$head2 (1):
114
- > Add foo3
116
+ * sm1 $head1 ...$head2 (1):
117
+ > Add foo3
115
118
116
- EOF
119
+ EOF
117
120
test_cmp expected actual &&
118
121
git config --unset diff.ignoreSubmodules &&
119
122
git config --remove-section submodule.sm1 &&
@@ -125,17 +128,17 @@ commit_file sm1 &&
125
128
head3=$(
126
129
cd sm1 &&
127
130
git reset --hard HEAD~2 > /dev/null &&
128
- git rev-parse --verify HEAD | cut -c1-7
131
+ git rev-parse --short HEAD
129
132
)
130
133
131
134
test_expect_success ' modified submodule(backward)' "
132
135
git submodule summary >actual &&
133
136
cat >expected <<-EOF &&
134
- * sm1 $head2 ...$head3 (2):
135
- < Add foo3
136
- < Add foo2
137
+ * sm1 $head2 ...$head3 (2):
138
+ < Add foo3
139
+ < Add foo2
137
140
138
- EOF
141
+ EOF
139
142
test_cmp expected actual
140
143
"
141
144
@@ -144,25 +147,25 @@ head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
144
147
test_expect_success ' modified submodule(backward and forward)' "
145
148
git submodule summary >actual &&
146
149
cat >expected <<-EOF &&
147
- * sm1 $head2 ...$head4 (4):
148
- > Add foo5
149
- > Add foo4
150
- < Add foo3
151
- < Add foo2
150
+ * sm1 $head2 ...$head4 (4):
151
+ > Add foo5
152
+ > Add foo4
153
+ < Add foo3
154
+ < Add foo2
152
155
153
- EOF
156
+ EOF
154
157
test_cmp expected actual
155
158
"
156
159
157
160
test_expect_success ' --summary-limit' "
158
161
git submodule summary -n 3 >actual &&
159
162
cat >expected <<-EOF &&
160
- * sm1 $head2 ...$head4 (4):
161
- > Add foo5
162
- > Add foo4
163
- < Add foo3
163
+ * sm1 $head2 ...$head4 (4):
164
+ > Add foo5
165
+ > Add foo4
166
+ < Add foo3
164
167
165
- EOF
168
+ EOF
166
169
test_cmp expected actual
167
170
"
168
171
@@ -177,32 +180,32 @@ mv sm1-bak sm1
177
180
test_expect_success ' typechanged submodule(submodule->blob), --cached' "
178
181
git submodule summary --cached >actual &&
179
182
cat >expected <<-EOF &&
180
- * sm1 $head4 (submodule)->$head5 (blob) (3):
181
- < Add foo5
183
+ * sm1 $head4 (submodule)->$head5 (blob) (3):
184
+ < Add foo5
182
185
183
- EOF
184
- test_i18ncmp actual expected
186
+ EOF
187
+ test_i18ncmp expected actual
185
188
"
186
189
187
190
test_expect_success ' typechanged submodule(submodule->blob), --files' "
188
191
git submodule summary --files >actual &&
189
192
cat >expected <<-EOF &&
190
- * sm1 $head5 (blob)->$head4 (submodule) (3):
191
- > Add foo5
193
+ * sm1 $head5 (blob)->$head4 (submodule) (3):
194
+ > Add foo5
192
195
193
- EOF
194
- test_i18ncmp actual expected
196
+ EOF
197
+ test_i18ncmp expected actual
195
198
"
196
199
197
200
rm -rf sm1 &&
198
201
git checkout-index sm1
199
202
test_expect_success ' typechanged submodule(submodule->blob)' "
200
203
git submodule summary >actual &&
201
204
cat >expected <<-EOF &&
202
- * sm1 $head4 (submodule)->$head5 (blob):
205
+ * sm1 $head4 (submodule)->$head5 (blob):
203
206
204
- EOF
205
- test_i18ncmp actual expected
207
+ EOF
208
+ test_i18ncmp expected actual
206
209
"
207
210
208
211
rm -f sm1 &&
@@ -211,21 +214,21 @@ head6=$(add_file sm1 foo6 foo7)
211
214
test_expect_success ' nonexistent commit' "
212
215
git submodule summary >actual &&
213
216
cat >expected <<-EOF &&
214
- * sm1 $head4 ...$head6 :
215
- Warn: sm1 doesn't contain commit $head4_full
217
+ * sm1 $head4 ...$head6 :
218
+ Warn: sm1 doesn't contain commit $head4_full
216
219
217
- EOF
218
- test_i18ncmp actual expected
220
+ EOF
221
+ test_i18ncmp expected actual
219
222
"
220
223
221
224
commit_file
222
225
test_expect_success ' typechanged submodule(blob->submodule)' "
223
226
git submodule summary >actual &&
224
227
cat >expected <<-EOF &&
225
- * sm1 $head5 (blob)->$head6 (submodule) (2):
226
- > Add foo7
228
+ * sm1 $head5 (blob)->$head6 (submodule) (2):
229
+ > Add foo7
227
230
228
- EOF
231
+ EOF
229
232
test_i18ncmp expected actual
230
233
"
231
234
@@ -234,9 +237,9 @@ rm -rf sm1
234
237
test_expect_success ' deleted submodule' "
235
238
git submodule summary >actual &&
236
239
cat >expected <<-EOF &&
237
- * sm1 $head6 ...0000000:
240
+ * sm1 $head6 ...0000000:
238
241
239
- EOF
242
+ EOF
240
243
test_cmp expected actual
241
244
"
242
245
@@ -249,47 +252,47 @@ test_expect_success 'create second submodule' '
249
252
test_expect_success ' multiple submodules' "
250
253
git submodule summary >actual &&
251
254
cat >expected <<-EOF &&
252
- * sm1 $head6 ...0000000:
255
+ * sm1 $head6 ...0000000:
253
256
254
- * sm2 0000000...$head7 (2):
255
- > Add foo9
257
+ * sm2 0000000...$head7 (2):
258
+ > Add foo9
256
259
257
- EOF
260
+ EOF
258
261
test_cmp expected actual
259
262
"
260
263
261
264
test_expect_success ' path filter' "
262
265
git submodule summary sm2 >actual &&
263
266
cat >expected <<-EOF &&
264
- * sm2 0000000...$head7 (2):
265
- > Add foo9
267
+ * sm2 0000000...$head7 (2):
268
+ > Add foo9
266
269
267
- EOF
270
+ EOF
268
271
test_cmp expected actual
269
272
"
270
273
271
274
commit_file sm2
272
275
test_expect_success ' given commit' "
273
276
git submodule summary HEAD^ >actual &&
274
277
cat >expected <<-EOF &&
275
- * sm1 $head6 ...0000000:
278
+ * sm1 $head6 ...0000000:
276
279
277
- * sm2 0000000...$head7 (2):
278
- > Add foo9
280
+ * sm2 0000000...$head7 (2):
281
+ > Add foo9
279
282
280
- EOF
283
+ EOF
281
284
test_cmp expected actual
282
285
"
283
286
284
287
test_expect_success ' --for-status' "
285
288
git submodule summary --for-status HEAD^ >actual &&
286
- test_i18ncmp actual - << EOF
287
- * sm1 $head6 ...0000000:
289
+ test_i18ncmp - actual <<- EOF
290
+ * sm1 $head6 ...0000000:
288
291
289
- * sm2 0000000...$head7 (2):
290
- > Add foo9
292
+ * sm2 0000000...$head7 (2):
293
+ > Add foo9
291
294
292
- EOF
295
+ EOF
293
296
"
294
297
295
298
test_expect_success ' fail when using --files together with --cached' "
0 commit comments