@@ -37,43 +37,47 @@ head1=$(add_file sm1 foo1 foo2)
3737test_expect_success ' added submodule' "
3838 git add sm1 &&
3939 git diff-index -p --submodule=log HEAD >actual &&
40- diff actual - <<-EOF
40+ cat >expected <<-EOF &&
4141Submodule sm1 0000000...$head1 (new submodule)
4242EOF
43+ test_cmp expected actual
4344"
4445
4546commit_file sm1 &&
4647head2=$( add_file sm1 foo3)
4748
4849test_expect_success ' modified submodule(forward)' "
4950 git diff-index -p --submodule=log HEAD >actual &&
50- diff actual - <<-EOF
51+ cat >expected <<-EOF &&
5152Submodule sm1 $head1 ..$head2 :
5253 > Add foo3
5354EOF
55+ test_cmp expected actual
5456"
5557
5658test_expect_success ' modified submodule(forward)' "
5759 git diff --submodule=log >actual &&
58- diff actual - <<-EOF
60+ cat >expected <<-EOF &&
5961Submodule sm1 $head1 ..$head2 :
6062 > Add foo3
6163EOF
64+ test_cmp expected actual
6265"
6366
6467test_expect_success ' modified submodule(forward) --submodule' "
6568 git diff --submodule >actual &&
66- diff actual - <<-EOF
69+ cat >expected <<-EOF &&
6770Submodule sm1 $head1 ..$head2 :
6871 > Add foo3
6972EOF
73+ test_cmp expected actual
7074"
7175
7276fullhead1=$( cd sm1; git rev-list --max-count=1 $head1 )
7377fullhead2=$( cd sm1; git rev-list --max-count=1 $head2 )
7478test_expect_success ' modified submodule(forward) --submodule=short' "
7579 git diff --submodule=short >actual &&
76- diff actual - <<-EOF
80+ cat >expected <<-EOF &&
7781diff --git a/sm1 b/sm1
7882index $head1 ..$head2 160000
7983--- a/sm1
@@ -82,6 +86,7 @@ index $head1..$head2 160000
8286-Subproject commit $fullhead1
8387+Subproject commit $fullhead2
8488EOF
89+ test_cmp expected actual
8590"
8691
8792commit_file sm1 &&
@@ -93,24 +98,26 @@ head3=$(
9398
9499test_expect_success ' modified submodule(backward)' "
95100 git diff-index -p --submodule=log HEAD >actual &&
96- diff actual - <<-EOF
101+ cat >expected <<-EOF &&
97102Submodule sm1 $head2 ..$head3 (rewind):
98103 < Add foo3
99104 < Add foo2
100105EOF
106+ test_cmp expected actual
101107"
102108
103109head4=$( add_file sm1 foo4 foo5) &&
104110head4_full=$( GIT_DIR=sm1/.git git rev-parse --verify HEAD)
105111test_expect_success ' modified submodule(backward and forward)' "
106112 git diff-index -p --submodule=log HEAD >actual &&
107- diff actual - <<-EOF
113+ cat >expected <<-EOF &&
108114Submodule sm1 $head2 ...$head4 :
109115 > Add foo5
110116 > Add foo4
111117 < Add foo3
112118 < Add foo2
113119EOF
120+ test_cmp expected actual
114121"
115122
116123commit_file sm1 &&
@@ -123,7 +130,7 @@ mv sm1-bak sm1
123130
124131test_expect_success ' typechanged submodule(submodule->blob), --cached' "
125132 git diff --submodule=log --cached >actual &&
126- diff actual - <<-EOF
133+ cat >expected <<-EOF &&
127134Submodule sm1 41fbea9...0000000 (submodule deleted)
128135diff --git a/sm1 b/sm1
129136new file mode 100644
@@ -133,11 +140,12 @@ index 0000000..9da5fb8
133140@@ -0,0 +1 @@
134141+sm1
135142EOF
143+ test_cmp expected actual
136144"
137145
138146test_expect_success ' typechanged submodule(submodule->blob)' "
139147 git diff --submodule=log >actual &&
140- diff actual - <<-EOF
148+ cat >expected <<-EOF &&
141149diff --git a/sm1 b/sm1
142150deleted file mode 100644
143151index 9da5fb8..0000000
@@ -147,13 +155,14 @@ index 9da5fb8..0000000
147155-sm1
148156Submodule sm1 0000000...$head4 (new submodule)
149157EOF
158+ test_cmp expected actual
150159"
151160
152161rm -rf sm1 &&
153162git checkout-index sm1
154163test_expect_success ' typechanged submodule(submodule->blob)' "
155164 git diff-index -p --submodule=log HEAD >actual &&
156- diff actual - <<-EOF
165+ cat >expected <<-EOF &&
157166Submodule sm1 $head4 ...0000000 (submodule deleted)
158167diff --git a/sm1 b/sm1
159168new file mode 100644
@@ -163,6 +172,7 @@ index 0000000..$head5
163172@@ -0,0 +1 @@
164173+sm1
165174EOF
175+ test_cmp expected actual
166176"
167177
168178rm -f sm1 &&
@@ -171,15 +181,16 @@ head6=$(add_file sm1 foo6 foo7)
171181fullhead6=$( cd sm1; git rev-list --max-count=1 $head6 )
172182test_expect_success ' nonexistent commit' "
173183 git diff-index -p --submodule=log HEAD >actual &&
174- diff actual - <<-EOF
184+ cat >expected <<-EOF &&
175185Submodule sm1 $head4 ...$head6 (commits not present)
176186EOF
187+ test_cmp expected actual
177188"
178189
179190commit_file
180191test_expect_success ' typechanged submodule(blob->submodule)' "
181192 git diff-index -p --submodule=log HEAD >actual &&
182- diff actual - <<-EOF
193+ cat >expected <<-EOF &&
183194diff --git a/sm1 b/sm1
184195deleted file mode 100644
185196index $head5 ..0000000
@@ -189,21 +200,24 @@ index $head5..0000000
189200-sm1
190201Submodule sm1 0000000...$head6 (new submodule)
191202EOF
203+ test_cmp expected actual
192204"
193205
194206commit_file sm1 &&
195207test_expect_success ' submodule is up to date' "
196208 git diff-index -p --submodule=log HEAD >actual &&
197- diff actual - <<-EOF
209+ cat >expected <<-EOF &&
198210EOF
211+ test_cmp expected actual
199212"
200213
201214test_expect_success ' submodule contains untracked content' "
202215 echo new > sm1/new-file &&
203216 git diff-index -p --submodule=log HEAD >actual &&
204- diff actual - <<-EOF
217+ cat >expected <<-EOF &&
205218Submodule sm1 contains untracked content
206219EOF
220+ test_cmp expected actual
207221"
208222
209223test_expect_success ' submodule contains untracked content (untracked ignored)' "
@@ -224,18 +238,20 @@ test_expect_success 'submodule contains untracked content (all ignored)' "
224238test_expect_success ' submodule contains untracked and modifed content' "
225239 echo new > sm1/foo6 &&
226240 git diff-index -p --submodule=log HEAD >actual &&
227- diff actual - <<-EOF
241+ cat >expected <<-EOF &&
228242Submodule sm1 contains untracked content
229243Submodule sm1 contains modified content
230244EOF
245+ test_cmp expected actual
231246"
232247
233248test_expect_success ' submodule contains untracked and modifed content (untracked ignored)' "
234249 echo new > sm1/foo6 &&
235250 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
236- diff actual - <<-EOF
251+ cat >expected <<-EOF &&
237252Submodule sm1 contains modified content
238253EOF
254+ test_cmp expected actual
239255"
240256
241257test_expect_success ' submodule contains untracked and modifed content (dirty ignored)' "
@@ -253,45 +269,50 @@ test_expect_success 'submodule contains untracked and modifed content (all ignor
253269test_expect_success ' submodule contains modifed content' "
254270 rm -f sm1/new-file &&
255271 git diff-index -p --submodule=log HEAD >actual &&
256- diff actual - <<-EOF
272+ cat >expected <<-EOF &&
257273Submodule sm1 contains modified content
258274EOF
275+ test_cmp expected actual
259276"
260277
261278(cd sm1; git commit -mchange foo6 > /dev/null) &&
262279head8=$( cd sm1; git rev-parse --verify HEAD | cut -c1-7) &&
263280test_expect_success ' submodule is modified' "
264281 git diff-index -p --submodule=log HEAD >actual &&
265- diff actual - <<-EOF
282+ cat >expected <<-EOF &&
266283Submodule sm1 $head6 ..$head8 :
267284 > change
268285EOF
286+ test_cmp expected actual
269287"
270288
271289test_expect_success ' modified submodule contains untracked content' "
272290 echo new > sm1/new-file &&
273291 git diff-index -p --submodule=log HEAD >actual &&
274- diff actual - <<-EOF
292+ cat >expected <<-EOF &&
275293Submodule sm1 contains untracked content
276294Submodule sm1 $head6 ..$head8 :
277295 > change
278296EOF
297+ test_cmp expected actual
279298"
280299
281300test_expect_success ' modified submodule contains untracked content (untracked ignored)' "
282301 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
283- diff actual - <<-EOF
302+ cat >expected <<-EOF &&
284303Submodule sm1 $head6 ..$head8 :
285304 > change
286305EOF
306+ test_cmp expected actual
287307"
288308
289309test_expect_success ' modified submodule contains untracked content (dirty ignored)' "
290310 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
291- diff actual - <<-EOF
311+ cat >expected <<-EOF &&
292312Submodule sm1 $head6 ..$head8 :
293313 > change
294314EOF
315+ test_cmp expected actual
295316"
296317
297318test_expect_success ' modified submodule contains untracked content (all ignored)' "
@@ -302,31 +323,34 @@ test_expect_success 'modified submodule contains untracked content (all ignored)
302323test_expect_success ' modified submodule contains untracked and modifed content' "
303324 echo modification >> sm1/foo6 &&
304325 git diff-index -p --submodule=log HEAD >actual &&
305- diff actual - <<-EOF
326+ cat >expected <<-EOF &&
306327Submodule sm1 contains untracked content
307328Submodule sm1 contains modified content
308329Submodule sm1 $head6 ..$head8 :
309330 > change
310331EOF
332+ test_cmp expected actual
311333"
312334
313335test_expect_success ' modified submodule contains untracked and modifed content (untracked ignored)' "
314336 echo modification >> sm1/foo6 &&
315337 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
316- diff actual - <<-EOF
338+ cat >expected <<-EOF &&
317339Submodule sm1 contains modified content
318340Submodule sm1 $head6 ..$head8 :
319341 > change
320342EOF
343+ test_cmp expected actual
321344"
322345
323346test_expect_success ' modified submodule contains untracked and modifed content (dirty ignored)' "
324347 echo modification >> sm1/foo6 &&
325348 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
326- diff actual - <<-EOF
349+ cat >expected <<-EOF &&
327350Submodule sm1 $head6 ..$head8 :
328351 > change
329352EOF
353+ test_cmp expected actual
330354"
331355
332356test_expect_success ' modified submodule contains untracked and modifed content (all ignored)' "
@@ -338,19 +362,21 @@ test_expect_success 'modified submodule contains untracked and modifed content (
338362test_expect_success ' modified submodule contains modifed content' "
339363 rm -f sm1/new-file &&
340364 git diff-index -p --submodule=log HEAD >actual &&
341- diff actual - <<-EOF
365+ cat >expected <<-EOF &&
342366Submodule sm1 contains modified content
343367Submodule sm1 $head6 ..$head8 :
344368 > change
345369EOF
370+ test_cmp expected actual
346371"
347372
348373rm -rf sm1
349374test_expect_success ' deleted submodule' "
350375 git diff-index -p --submodule=log HEAD >actual &&
351- diff actual - <<-EOF
376+ cat >expected <<-EOF &&
352377Submodule sm1 $head6 ...0000000 (submodule deleted)
353378EOF
379+ test_cmp expected actual
354380"
355381
356382test_create_repo sm2 &&
@@ -359,41 +385,45 @@ git add sm2
359385
360386test_expect_success ' multiple submodules' "
361387 git diff-index -p --submodule=log HEAD >actual &&
362- diff actual - <<-EOF
388+ cat >expected <<-EOF &&
363389Submodule sm1 $head6 ...0000000 (submodule deleted)
364390Submodule sm2 0000000...$head7 (new submodule)
365391EOF
392+ test_cmp expected actual
366393"
367394
368395test_expect_success ' path filter' "
369396 git diff-index -p --submodule=log HEAD sm2 >actual &&
370- diff actual - <<-EOF
397+ cat >expected <<-EOF &&
371398Submodule sm2 0000000...$head7 (new submodule)
372399EOF
400+ test_cmp expected actual
373401"
374402
375403commit_file sm2
376404test_expect_success ' given commit' "
377405 git diff-index -p --submodule=log HEAD^ >actual &&
378- diff actual - <<-EOF
406+ cat >expected <<-EOF &&
379407Submodule sm1 $head6 ...0000000 (submodule deleted)
380408Submodule sm2 0000000...$head7 (new submodule)
381409EOF
410+ test_cmp expected actual
382411"
383412
384413test_expect_success ' given commit --submodule' "
385414 git diff-index -p --submodule HEAD^ >actual &&
386- diff actual - <<-EOF
415+ cat >expected <<-EOF &&
387416Submodule sm1 $head6 ...0000000 (submodule deleted)
388417Submodule sm2 0000000...$head7 (new submodule)
389418EOF
419+ test_cmp expected actual
390420"
391421
392422fullhead7=$( cd sm2; git rev-list --max-count=1 $head7 )
393423
394424test_expect_success ' given commit --submodule=short' "
395425 git diff-index -p --submodule=short HEAD^ >actual &&
396- diff actual - <<-EOF
426+ cat >expected <<-EOF &&
397427diff --git a/sm1 b/sm1
398428deleted file mode 160000
399429index $head6 ..0000000
@@ -409,6 +439,7 @@ index 0000000..$head7
409439@@ -0,0 +1 @@
410440+Subproject commit $fullhead7
411441EOF
442+ test_cmp expected actual
412443"
413444
414445test_expect_success ' setup .git file for sm2' '
@@ -420,10 +451,11 @@ test_expect_success 'setup .git file for sm2' '
420451
421452test_expect_success ' diff --submodule with .git file' '
422453 git diff --submodule HEAD^ >actual &&
423- diff actual - <<-EOF
454+ cat >expected <<-EOF &&
424455Submodule sm1 $head6...0000000 (submodule deleted)
425456Submodule sm2 0000000...$head7 (new submodule)
426457EOF
458+ test_cmp expected actual
427459'
428460
429461test_done
0 commit comments