Skip to content

Commit 3cbff01

Browse files
committed
Merge branch 'ss/t7401-modernize'
Test clean-up. * ss/t7401-modernize: t7401: add a NEEDSWORK t7401: change indentation for enhanced readability t7401: change syntax of test_i18ncmp calls for clarity t7401: use 'short' instead of 'verify' and cut in rev-parse calls t7401: modernize style
2 parents 9c31b19 + 2a0d1a5 commit 3cbff01

File tree

1 file changed

+76
-73
lines changed

1 file changed

+76
-73
lines changed

t/t7401-submodule-summary.sh

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
test_description='Summary support for submodules
77
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.
99
'
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.
1013

1114
. ./test-lib.sh
1215

@@ -16,12 +19,12 @@ add_file () {
1619
owd=$(pwd)
1720
cd "$sm"
1821
for name; do
19-
echo "$name" > "$name" &&
22+
echo "$name" >"$name" &&
2023
git add "$name" &&
2124
test_tick &&
2225
git commit -m "Add $name"
2326
done >/dev/null
24-
git rev-parse --verify HEAD | cut -c1-7
27+
git rev-parse --short HEAD
2528
cd "$owd"
2629
}
2730
commit_file () {
@@ -38,10 +41,10 @@ test_expect_success 'added submodule' "
3841
git add sm1 &&
3942
git submodule summary >actual &&
4043
cat >expected <<-EOF &&
41-
* sm1 0000000...$head1 (2):
42-
> Add foo2
44+
* sm1 0000000...$head1 (2):
45+
> Add foo2
4346
44-
EOF
47+
EOF
4548
test_cmp expected actual
4649
"
4750

@@ -52,10 +55,10 @@ test_expect_success 'added submodule (subdirectory)' "
5255
git submodule summary >../actual
5356
) &&
5457
cat >expected <<-EOF &&
55-
* ../sm1 0000000...$head1 (2):
56-
> Add foo2
58+
* ../sm1 0000000...$head1 (2):
59+
> Add foo2
5760
58-
EOF
61+
EOF
5962
test_cmp expected actual
6063
"
6164

@@ -73,10 +76,10 @@ test_expect_success 'added submodule (subdirectory with explicit path)' "
7376
git submodule summary ../sm1 >../actual
7477
) &&
7578
cat >expected <<-EOF &&
76-
* ../sm1 0000000...$head1 (2):
77-
> Add foo2
79+
* ../sm1 0000000...$head1 (2):
80+
> Add foo2
7881
79-
EOF
82+
EOF
8083
test_cmp expected actual
8184
"
8285

@@ -86,20 +89,20 @@ head2=$(add_file sm1 foo3)
8689
test_expect_success 'modified submodule(forward)' "
8790
git submodule summary >actual &&
8891
cat >expected <<-EOF &&
89-
* sm1 $head1...$head2 (1):
90-
> Add foo3
92+
* sm1 $head1...$head2 (1):
93+
> Add foo3
9194
92-
EOF
95+
EOF
9396
test_cmp expected actual
9497
"
9598

9699
test_expect_success 'modified submodule(forward), --files' "
97100
git submodule summary --files >actual &&
98101
cat >expected <<-EOF &&
99-
* sm1 $head1...$head2 (1):
100-
> Add foo3
102+
* sm1 $head1...$head2 (1):
103+
> Add foo3
101104
102-
EOF
105+
EOF
103106
test_cmp expected actual
104107
"
105108

@@ -110,10 +113,10 @@ test_expect_success 'no ignore=all setting has any effect' "
110113
git config diff.ignoreSubmodules all &&
111114
git submodule summary >actual &&
112115
cat >expected <<-EOF &&
113-
* sm1 $head1...$head2 (1):
114-
> Add foo3
116+
* sm1 $head1...$head2 (1):
117+
> Add foo3
115118
116-
EOF
119+
EOF
117120
test_cmp expected actual &&
118121
git config --unset diff.ignoreSubmodules &&
119122
git config --remove-section submodule.sm1 &&
@@ -125,17 +128,17 @@ commit_file sm1 &&
125128
head3=$(
126129
cd sm1 &&
127130
git reset --hard HEAD~2 >/dev/null &&
128-
git rev-parse --verify HEAD | cut -c1-7
131+
git rev-parse --short HEAD
129132
)
130133

131134
test_expect_success 'modified submodule(backward)' "
132135
git submodule summary >actual &&
133136
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
137140
138-
EOF
141+
EOF
139142
test_cmp expected actual
140143
"
141144

@@ -144,25 +147,25 @@ head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
144147
test_expect_success 'modified submodule(backward and forward)' "
145148
git submodule summary >actual &&
146149
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
152155
153-
EOF
156+
EOF
154157
test_cmp expected actual
155158
"
156159

157160
test_expect_success '--summary-limit' "
158161
git submodule summary -n 3 >actual &&
159162
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
164167
165-
EOF
168+
EOF
166169
test_cmp expected actual
167170
"
168171

@@ -177,32 +180,32 @@ mv sm1-bak sm1
177180
test_expect_success 'typechanged submodule(submodule->blob), --cached' "
178181
git submodule summary --cached >actual &&
179182
cat >expected <<-EOF &&
180-
* sm1 $head4(submodule)->$head5(blob) (3):
181-
< Add foo5
183+
* sm1 $head4(submodule)->$head5(blob) (3):
184+
< Add foo5
182185
183-
EOF
184-
test_i18ncmp actual expected
186+
EOF
187+
test_i18ncmp expected actual
185188
"
186189

187190
test_expect_success 'typechanged submodule(submodule->blob), --files' "
188191
git submodule summary --files >actual &&
189192
cat >expected <<-EOF &&
190-
* sm1 $head5(blob)->$head4(submodule) (3):
191-
> Add foo5
193+
* sm1 $head5(blob)->$head4(submodule) (3):
194+
> Add foo5
192195
193-
EOF
194-
test_i18ncmp actual expected
196+
EOF
197+
test_i18ncmp expected actual
195198
"
196199

197200
rm -rf sm1 &&
198201
git checkout-index sm1
199202
test_expect_success 'typechanged submodule(submodule->blob)' "
200203
git submodule summary >actual &&
201204
cat >expected <<-EOF &&
202-
* sm1 $head4(submodule)->$head5(blob):
205+
* sm1 $head4(submodule)->$head5(blob):
203206
204-
EOF
205-
test_i18ncmp actual expected
207+
EOF
208+
test_i18ncmp expected actual
206209
"
207210

208211
rm -f sm1 &&
@@ -211,21 +214,21 @@ head6=$(add_file sm1 foo6 foo7)
211214
test_expect_success 'nonexistent commit' "
212215
git submodule summary >actual &&
213216
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
216219
217-
EOF
218-
test_i18ncmp actual expected
220+
EOF
221+
test_i18ncmp expected actual
219222
"
220223

221224
commit_file
222225
test_expect_success 'typechanged submodule(blob->submodule)' "
223226
git submodule summary >actual &&
224227
cat >expected <<-EOF &&
225-
* sm1 $head5(blob)->$head6(submodule) (2):
226-
> Add foo7
228+
* sm1 $head5(blob)->$head6(submodule) (2):
229+
> Add foo7
227230
228-
EOF
231+
EOF
229232
test_i18ncmp expected actual
230233
"
231234

@@ -234,9 +237,9 @@ rm -rf sm1
234237
test_expect_success 'deleted submodule' "
235238
git submodule summary >actual &&
236239
cat >expected <<-EOF &&
237-
* sm1 $head6...0000000:
240+
* sm1 $head6...0000000:
238241
239-
EOF
242+
EOF
240243
test_cmp expected actual
241244
"
242245

@@ -249,47 +252,47 @@ test_expect_success 'create second submodule' '
249252
test_expect_success 'multiple submodules' "
250253
git submodule summary >actual &&
251254
cat >expected <<-EOF &&
252-
* sm1 $head6...0000000:
255+
* sm1 $head6...0000000:
253256
254-
* sm2 0000000...$head7 (2):
255-
> Add foo9
257+
* sm2 0000000...$head7 (2):
258+
> Add foo9
256259
257-
EOF
260+
EOF
258261
test_cmp expected actual
259262
"
260263

261264
test_expect_success 'path filter' "
262265
git submodule summary sm2 >actual &&
263266
cat >expected <<-EOF &&
264-
* sm2 0000000...$head7 (2):
265-
> Add foo9
267+
* sm2 0000000...$head7 (2):
268+
> Add foo9
266269
267-
EOF
270+
EOF
268271
test_cmp expected actual
269272
"
270273

271274
commit_file sm2
272275
test_expect_success 'given commit' "
273276
git submodule summary HEAD^ >actual &&
274277
cat >expected <<-EOF &&
275-
* sm1 $head6...0000000:
278+
* sm1 $head6...0000000:
276279
277-
* sm2 0000000...$head7 (2):
278-
> Add foo9
280+
* sm2 0000000...$head7 (2):
281+
> Add foo9
279282
280-
EOF
283+
EOF
281284
test_cmp expected actual
282285
"
283286

284287
test_expect_success '--for-status' "
285288
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:
288291
289-
* sm2 0000000...$head7 (2):
290-
> Add foo9
292+
* sm2 0000000...$head7 (2):
293+
> Add foo9
291294
292-
EOF
295+
EOF
293296
"
294297

295298
test_expect_success 'fail when using --files together with --cached' "

0 commit comments

Comments
 (0)