summaryrefslogtreecommitdiff
path: root/t/t4047-diff-dirstat.sh
blob: d0ed62c0dd14a78c7c9ef97354583dc380502775 (plain)
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
#!/bin/sh

test_description='diff --dirstat tests'
. ./test-lib.sh

# set up two commits where the second commit has these files
# (10 lines in each file):
#
#   unchanged/text           (unchanged from 1st commit)
#   changed/text             (changed 1st line)
#   rearranged/text          (swapped 1st and 2nd line)
#   dst/copy/unchanged/text  (copied from src/copy/unchanged/text, unchanged)
#   dst/copy/changed/text    (copied from src/copy/changed/text, changed)
#   dst/copy/rearranged/text (copied from src/copy/rearranged/text, rearranged)
#   dst/move/unchanged/text  (moved from src/move/unchanged/text, unchanged)
#   dst/move/changed/text    (moved from src/move/changed/text, changed)
#   dst/move/rearranged/text (moved from src/move/rearranged/text, rearranged)

test_expect_success 'setup' '
	mkdir unchanged &&
	mkdir changed &&
	mkdir rearranged &&
	mkdir src &&
	mkdir src/copy &&
	mkdir src/copy/unchanged &&
	mkdir src/copy/changed &&
	mkdir src/copy/rearranged &&
	mkdir src/move &&
	mkdir src/move/unchanged &&
	mkdir src/move/changed &&
	mkdir src/move/rearranged &&
	cat <<EOF >unchanged/text &&
unchanged       line #0
unchanged       line #1
unchanged       line #2
unchanged       line #3
unchanged       line #4
unchanged       line #5
unchanged       line #6
unchanged       line #7
unchanged       line #8
unchanged       line #9
EOF
	cat <<EOF >changed/text &&
changed         line #0
changed         line #1
changed         line #2
changed         line #3
changed         line #4
changed         line #5
changed         line #6
changed         line #7
changed         line #8
changed         line #9
EOF
	cat <<EOF >rearranged/text &&
rearranged      line #0
rearranged      line #1
rearranged      line #2
rearranged      line #3
rearranged      line #4
rearranged      line #5
rearranged      line #6
rearranged      line #7
rearranged      line #8
rearranged      line #9
EOF
	cat <<EOF >src/copy/unchanged/text &&
copy  unchanged line #0
copy  unchanged line #1
copy  unchanged line #2
copy  unchanged line #3
copy  unchanged line #4
copy  unchanged line #5
copy  unchanged line #6
copy  unchanged line #7
copy  unchanged line #8
copy  unchanged line #9
EOF
	cat <<EOF >src/copy/changed/text &&
copy    changed line #0
copy    changed line #1
copy    changed line #2
copy    changed line #3
copy    changed line #4
copy    changed line #5
copy    changed line #6
copy    changed line #7
copy    changed line #8
copy    changed line #9
EOF
	cat <<EOF >src/copy/rearranged/text &&
copy rearranged line #0
copy rearranged line #1
copy rearranged line #2
copy rearranged line #3
copy rearranged line #4
copy rearranged line #5
copy rearranged line #6
copy rearranged line #7
copy rearranged line #8
copy rearranged line #9
EOF
	cat <<EOF >src/move/unchanged/text &&
move  unchanged line #0
move  unchanged line #1
move  unchanged line #2
move  unchanged line #3
move  unchanged line #4
move  unchanged line #5
move  unchanged line #6
move  unchanged line #7
move  unchanged line #8
move  unchanged line #9
EOF
	cat <<EOF >src/move/changed/text &&
move    changed line #0
move    changed line #1
move    changed line #2
move    changed line #3
move    changed line #4
move    changed line #5
move    changed line #6
move    changed line #7
move    changed line #8
move    changed line #9
EOF
	cat <<EOF >src/move/rearranged/text &&
move rearranged line #0
move rearranged line #1
move rearranged line #2
move rearranged line #3
move rearranged line #4
move rearranged line #5
move rearranged line #6
move rearranged line #7
move rearranged line #8
move rearranged line #9
EOF
	git add . &&
	git commit -m "initial" &&
	mkdir dst &&
	mkdir dst/copy &&
	mkdir dst/copy/unchanged &&
	mkdir dst/copy/changed &&
	mkdir dst/copy/rearranged &&
	mkdir dst/move &&
	mkdir dst/move/unchanged &&
	mkdir dst/move/changed &&
	mkdir dst/move/rearranged &&
	cat <<EOF >changed/text &&
CHANGED XXXXXXX line #0
changed         line #1
changed         line #2
changed         line #3
changed         line #4
changed         line #5
changed         line #6
changed         line #7
changed         line #8
changed         line #9
EOF
	cat <<EOF >rearranged/text &&
rearranged      line #1
rearranged      line #0
rearranged      line #2
rearranged      line #3
rearranged      line #4
rearranged      line #5
rearranged      line #6
rearranged      line #7
rearranged      line #8
rearranged      line #9
EOF
	cat <<EOF >dst/copy/unchanged/text &&
copy  unchanged line #0
copy  unchanged line #1
copy  unchanged line #2
copy  unchanged line #3
copy  unchanged line #4
copy  unchanged line #5
copy  unchanged line #6
copy  unchanged line #7
copy  unchanged line #8
copy  unchanged line #9
EOF
	cat <<EOF >dst/copy/changed/text &&
copy XXXCHANGED line #0
copy    changed line #1
copy    changed line #2
copy    changed line #3
copy    changed line #4
copy    changed line #5
copy    changed line #6
copy    changed line #7
copy    changed line #8
copy    changed line #9
EOF
	cat <<EOF >dst/copy/rearranged/text &&
copy rearranged line #1
copy rearranged line #0
copy rearranged line #2
copy rearranged line #3
copy rearranged line #4
copy rearranged line #5
copy rearranged line #6
copy rearranged line #7
copy rearranged line #8
copy rearranged line #9
EOF
	cat <<EOF >dst/move/unchanged/text &&
move  unchanged line #0
move  unchanged line #1
move  unchanged line #2
move  unchanged line #3
move  unchanged line #4
move  unchanged line #5
move  unchanged line #6
move  unchanged line #7
move  unchanged line #8
move  unchanged line #9
EOF
	cat <<EOF >dst/move/changed/text &&
move XXXCHANGED line #0
move    changed line #1
move    changed line #2
move    changed line #3
move    changed line #4
move    changed line #5
move    changed line #6
move    changed line #7
move    changed line #8
move    changed line #9
EOF
	cat <<EOF >dst/move/rearranged/text &&
move rearranged line #1
move rearranged line #0
move rearranged line #2
move rearranged line #3
move rearranged line #4
move rearranged line #5
move rearranged line #6
move rearranged line #7
move rearranged line #8
move rearranged line #9
EOF
	git add . &&
	git rm -r src/move/unchanged &&
	git rm -r src/move/changed &&
	git rm -r src/move/rearranged &&
	git commit -m "changes"
'

cat <<EOF >expect_diff_stat
 changed/text             |    2 +-
 dst/copy/changed/text    |   10 ++++++++++
 dst/copy/rearranged/text |   10 ++++++++++
 dst/copy/unchanged/text  |   10 ++++++++++
 dst/move/changed/text    |   10 ++++++++++
 dst/move/rearranged/text |   10 ++++++++++
 dst/move/unchanged/text  |   10 ++++++++++
 rearranged/text          |    2 +-
 src/move/changed/text    |   10 ----------
 src/move/rearranged/text |   10 ----------
 src/move/unchanged/text  |   10 ----------
 11 files changed, 62 insertions(+), 32 deletions(-)
EOF

cat <<EOF >expect_diff_stat_M
 changed/text                      |    2 +-
 dst/copy/changed/text             |   10 ++++++++++
 dst/copy/rearranged/text          |   10 ++++++++++
 dst/copy/unchanged/text           |   10 ++++++++++
 {src => dst}/move/changed/text    |    2 +-
 {src => dst}/move/rearranged/text |    2 +-
 {src => dst}/move/unchanged/text  |    0
 rearranged/text                   |    2 +-
 8 files changed, 34 insertions(+), 4 deletions(-)
EOF

cat <<EOF >expect_diff_stat_CC
 changed/text                      |    2 +-
 {src => dst}/copy/changed/text    |    2 +-
 {src => dst}/copy/rearranged/text |    2 +-
 {src => dst}/copy/unchanged/text  |    0
 {src => dst}/move/changed/text    |    2 +-
 {src => dst}/move/rearranged/text |    2 +-
 {src => dst}/move/unchanged/text  |    0
 rearranged/text                   |    2 +-
 8 files changed, 6 insertions(+), 6 deletions(-)
EOF

test_expect_success 'sanity check setup (--stat)' '
	git diff --stat HEAD^..HEAD >actual_diff_stat &&
	test_cmp expect_diff_stat actual_diff_stat &&
	git diff --stat -M HEAD^..HEAD >actual_diff_stat_M &&
	test_cmp expect_diff_stat_M actual_diff_stat_M &&
	git diff --stat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
	test_cmp expect_diff_stat_CC actual_diff_stat_CC
'

# changed/text and rearranged/text falls below default 3% threshold
cat <<EOF >expect_diff_dirstat
  10.8% dst/copy/changed/
  10.8% dst/copy/rearranged/
  10.8% dst/copy/unchanged/
  10.8% dst/move/changed/
  10.8% dst/move/rearranged/
  10.8% dst/move/unchanged/
  10.8% src/move/changed/
  10.8% src/move/rearranged/
  10.8% src/move/unchanged/
EOF

# rearranged/text falls below default 3% threshold
cat <<EOF >expect_diff_dirstat_M
   5.8% changed/
  29.3% dst/copy/changed/
  29.3% dst/copy/rearranged/
  29.3% dst/copy/unchanged/
   5.8% dst/move/changed/
EOF

# rearranged/text falls below default 3% threshold
cat <<EOF >expect_diff_dirstat_CC
  32.6% changed/
  32.6% dst/copy/changed/
  32.6% dst/move/changed/
EOF

test_expect_success 'various ways to misspell --dirstat' '
	test_must_fail git show --dirstat10 &&
	test_must_fail git show --dirstat10,files &&
	test_must_fail git show -X=20 &&
	test_must_fail git show -X=20,cumulative
'

test_expect_success 'vanilla --dirstat' '
	git diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success 'vanilla -X' '
	git diff -X HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff -X -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff -X -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success 'explicit defaults: --dirstat=changes,noncumulative,3' '
	git diff --dirstat=changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success 'explicit defaults: -Xchanges,noncumulative,3' '
	git diff -Xchanges,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff -Xchanges,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff -Xchanges,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success 'later options override earlier options:' '
	git diff --dirstat=files,10,cumulative,changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
	git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

cat <<EOF >expect_diff_dirstat
   2.1% changed/
  10.8% dst/copy/changed/
  10.8% dst/copy/rearranged/
  10.8% dst/copy/unchanged/
  10.8% dst/move/changed/
  10.8% dst/move/rearranged/
  10.8% dst/move/unchanged/
   0.0% rearranged/
  10.8% src/move/changed/
  10.8% src/move/rearranged/
  10.8% src/move/unchanged/
EOF

cat <<EOF >expect_diff_dirstat_M
   5.8% changed/
  29.3% dst/copy/changed/
  29.3% dst/copy/rearranged/
  29.3% dst/copy/unchanged/
   5.8% dst/move/changed/
   0.1% dst/move/rearranged/
   0.1% rearranged/
EOF

cat <<EOF >expect_diff_dirstat_CC
  32.6% changed/
  32.6% dst/copy/changed/
   0.6% dst/copy/rearranged/
  32.6% dst/move/changed/
   0.6% dst/move/rearranged/
   0.6% rearranged/
EOF

test_expect_success '--dirstat=0' '
	git diff --dirstat=0 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success '-X0' '
	git diff -X0 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff -X0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff -X0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

cat <<EOF >expect_diff_dirstat
   2.1% changed/
  10.8% dst/copy/changed/
  10.8% dst/copy/rearranged/
  10.8% dst/copy/unchanged/
  32.5% dst/copy/
  10.8% dst/move/changed/
  10.8% dst/move/rearranged/
  10.8% dst/move/unchanged/
  32.5% dst/move/
  65.1% dst/
   0.0% rearranged/
  10.8% src/move/changed/
  10.8% src/move/rearranged/
  10.8% src/move/unchanged/
  32.5% src/move/
EOF

cat <<EOF >expect_diff_dirstat_M
   5.8% changed/
  29.3% dst/copy/changed/
  29.3% dst/copy/rearranged/
  29.3% dst/copy/unchanged/
  88.0% dst/copy/
   5.8% dst/move/changed/
   0.1% dst/move/rearranged/
   5.9% dst/move/
  94.0% dst/
   0.1% rearranged/
EOF

cat <<EOF >expect_diff_dirstat_CC
  32.6% changed/
  32.6% dst/copy/changed/
   0.6% dst/copy/rearranged/
  33.3% dst/copy/
  32.6% dst/move/changed/
   0.6% dst/move/rearranged/
  33.3% dst/move/
  66.6% dst/
   0.6% rearranged/
EOF

test_expect_success '--dirstat=0 --cumulative' '
	git diff --dirstat=0 --cumulative HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=0 --cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=0 --cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success '--dirstat=0,cumulative' '
	git diff --dirstat=0,cumulative HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=0,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=0,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success '-X0,cumulative' '
	git diff -X0,cumulative HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff -X0,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff -X0,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

cat <<EOF >expect_diff_dirstat
   9.0% changed/
   9.0% dst/copy/changed/
   9.0% dst/copy/rearranged/
   9.0% dst/copy/unchanged/
   9.0% dst/move/changed/
   9.0% dst/move/rearranged/
   9.0% dst/move/unchanged/
   9.0% rearranged/
   9.0% src/move/changed/
   9.0% src/move/rearranged/
   9.0% src/move/unchanged/
EOF

cat <<EOF >expect_diff_dirstat_M
  14.2% changed/
  14.2% dst/copy/changed/
  14.2% dst/copy/rearranged/
  14.2% dst/copy/unchanged/
  14.2% dst/move/changed/
  14.2% dst/move/rearranged/
  14.2% rearranged/
EOF

cat <<EOF >expect_diff_dirstat_CC
  16.6% changed/
  16.6% dst/copy/changed/
  16.6% dst/copy/rearranged/
  16.6% dst/move/changed/
  16.6% dst/move/rearranged/
  16.6% rearranged/
EOF

test_expect_success '--dirstat-by-file' '
	git diff --dirstat-by-file HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat-by-file -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat-by-file -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success '--dirstat=files' '
	git diff --dirstat=files HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=files -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=files -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

cat <<EOF >expect_diff_dirstat
  27.2% dst/copy/
  27.2% dst/move/
  27.2% src/move/
EOF

cat <<EOF >expect_diff_dirstat_M
  14.2% changed/
  14.2% dst/copy/changed/
  14.2% dst/copy/rearranged/
  14.2% dst/copy/unchanged/
  14.2% dst/move/changed/
  14.2% dst/move/rearranged/
  14.2% rearranged/
EOF

cat <<EOF >expect_diff_dirstat_CC
  16.6% changed/
  16.6% dst/copy/changed/
  16.6% dst/copy/rearranged/
  16.6% dst/move/changed/
  16.6% dst/move/rearranged/
  16.6% rearranged/
EOF

test_expect_success '--dirstat-by-file=10' '
	git diff --dirstat-by-file=10 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat-by-file=10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat-by-file=10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success '--dirstat=files,10' '
	git diff --dirstat=files,10 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=files,10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=files,10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

cat <<EOF >expect_diff_dirstat
   9.0% changed/
   9.0% dst/copy/changed/
   9.0% dst/copy/rearranged/
   9.0% dst/copy/unchanged/
  27.2% dst/copy/
   9.0% dst/move/changed/
   9.0% dst/move/rearranged/
   9.0% dst/move/unchanged/
  27.2% dst/move/
  54.5% dst/
   9.0% rearranged/
   9.0% src/move/changed/
   9.0% src/move/rearranged/
   9.0% src/move/unchanged/
  27.2% src/move/
EOF

cat <<EOF >expect_diff_dirstat_M
  14.2% changed/
  14.2% dst/copy/changed/
  14.2% dst/copy/rearranged/
  14.2% dst/copy/unchanged/
  42.8% dst/copy/
  14.2% dst/move/changed/
  14.2% dst/move/rearranged/
  28.5% dst/move/
  71.4% dst/
  14.2% rearranged/
EOF

cat <<EOF >expect_diff_dirstat_CC
  16.6% changed/
  16.6% dst/copy/changed/
  16.6% dst/copy/rearranged/
  33.3% dst/copy/
  16.6% dst/move/changed/
  16.6% dst/move/rearranged/
  33.3% dst/move/
  66.6% dst/
  16.6% rearranged/
EOF

test_expect_success '--dirstat-by-file --cumulative' '
	git diff --dirstat-by-file --cumulative HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat-by-file --cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat-by-file --cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_expect_success '--dirstat=files,cumulative' '
	git diff --dirstat=files,cumulative HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=files,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=files,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

cat <<EOF >expect_diff_dirstat
  27.2% dst/copy/
  27.2% dst/move/
  54.5% dst/
  27.2% src/move/
EOF

cat <<EOF >expect_diff_dirstat_M
  14.2% changed/
  14.2% dst/copy/changed/
  14.2% dst/copy/rearranged/
  14.2% dst/copy/unchanged/
  42.8% dst/copy/
  14.2% dst/move/changed/
  14.2% dst/move/rearranged/
  28.5% dst/move/
  71.4% dst/
  14.2% rearranged/
EOF

cat <<EOF >expect_diff_dirstat_CC
  16.6% changed/
  16.6% dst/copy/changed/
  16.6% dst/copy/rearranged/
  33.3% dst/copy/
  16.6% dst/move/changed/
  16.6% dst/move/rearranged/
  33.3% dst/move/
  66.6% dst/
  16.6% rearranged/
EOF

test_expect_success '--dirstat=files,cumulative,10' '
	git diff --dirstat=files,cumulative,10 HEAD^..HEAD >actual_diff_dirstat &&
	test_cmp expect_diff_dirstat actual_diff_dirstat &&
	git diff --dirstat=files,cumulative,10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
	test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
	git diff --dirstat=files,cumulative,10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
	test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'

test_done