]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4047-diff-dirstat.sh
Merge branch 'ps/ref-tests-update'
[thirdparty/git.git] / t / t4047-diff-dirstat.sh
CommitLineData
5502039d
JH
1#!/bin/sh
2
3test_description='diff --dirstat tests'
83973981
JH
4
5TEST_PASSES_SANITIZE_LEAK=true
5502039d
JH
6. ./test-lib.sh
7
8# set up two commits where the second commit has these files
9# (10 lines in each file):
10#
11# unchanged/text (unchanged from 1st commit)
12# changed/text (changed 1st line)
13# rearranged/text (swapped 1st and 2nd line)
14# dst/copy/unchanged/text (copied from src/copy/unchanged/text, unchanged)
15# dst/copy/changed/text (copied from src/copy/changed/text, changed)
16# dst/copy/rearranged/text (copied from src/copy/rearranged/text, rearranged)
17# dst/move/unchanged/text (moved from src/move/unchanged/text, unchanged)
18# dst/move/changed/text (moved from src/move/changed/text, changed)
19# dst/move/rearranged/text (moved from src/move/rearranged/text, rearranged)
20
21test_expect_success 'setup' '
22 mkdir unchanged &&
23 mkdir changed &&
24 mkdir rearranged &&
25 mkdir src &&
26 mkdir src/copy &&
27 mkdir src/copy/unchanged &&
28 mkdir src/copy/changed &&
29 mkdir src/copy/rearranged &&
30 mkdir src/move &&
31 mkdir src/move/unchanged &&
32 mkdir src/move/changed &&
33 mkdir src/move/rearranged &&
34 cat <<EOF >unchanged/text &&
35unchanged line #0
36unchanged line #1
37unchanged line #2
38unchanged line #3
39unchanged line #4
40unchanged line #5
41unchanged line #6
42unchanged line #7
43unchanged line #8
44unchanged line #9
45EOF
46 cat <<EOF >changed/text &&
47changed line #0
48changed line #1
49changed line #2
50changed line #3
51changed line #4
52changed line #5
53changed line #6
54changed line #7
55changed line #8
56changed line #9
57EOF
58 cat <<EOF >rearranged/text &&
59rearranged line #0
60rearranged line #1
61rearranged line #2
62rearranged line #3
63rearranged line #4
64rearranged line #5
65rearranged line #6
66rearranged line #7
67rearranged line #8
68rearranged line #9
69EOF
70 cat <<EOF >src/copy/unchanged/text &&
71copy unchanged line #0
72copy unchanged line #1
73copy unchanged line #2
74copy unchanged line #3
75copy unchanged line #4
76copy unchanged line #5
77copy unchanged line #6
78copy unchanged line #7
79copy unchanged line #8
80copy unchanged line #9
81EOF
82 cat <<EOF >src/copy/changed/text &&
83copy changed line #0
84copy changed line #1
85copy changed line #2
86copy changed line #3
87copy changed line #4
88copy changed line #5
89copy changed line #6
90copy changed line #7
91copy changed line #8
92copy changed line #9
93EOF
94 cat <<EOF >src/copy/rearranged/text &&
95copy rearranged line #0
96copy rearranged line #1
97copy rearranged line #2
98copy rearranged line #3
99copy rearranged line #4
100copy rearranged line #5
101copy rearranged line #6
102copy rearranged line #7
103copy rearranged line #8
104copy rearranged line #9
105EOF
106 cat <<EOF >src/move/unchanged/text &&
107move unchanged line #0
108move unchanged line #1
109move unchanged line #2
110move unchanged line #3
111move unchanged line #4
112move unchanged line #5
113move unchanged line #6
114move unchanged line #7
115move unchanged line #8
116move unchanged line #9
117EOF
118 cat <<EOF >src/move/changed/text &&
119move changed line #0
120move changed line #1
121move changed line #2
122move changed line #3
123move changed line #4
124move changed line #5
125move changed line #6
126move changed line #7
127move changed line #8
128move changed line #9
129EOF
130 cat <<EOF >src/move/rearranged/text &&
131move rearranged line #0
132move rearranged line #1
133move rearranged line #2
134move rearranged line #3
135move rearranged line #4
136move rearranged line #5
137move rearranged line #6
138move rearranged line #7
139move rearranged line #8
140move rearranged line #9
141EOF
142 git add . &&
143 git commit -m "initial" &&
144 mkdir dst &&
145 mkdir dst/copy &&
146 mkdir dst/copy/unchanged &&
147 mkdir dst/copy/changed &&
148 mkdir dst/copy/rearranged &&
149 mkdir dst/move &&
150 mkdir dst/move/unchanged &&
151 mkdir dst/move/changed &&
152 mkdir dst/move/rearranged &&
153 cat <<EOF >changed/text &&
154CHANGED XXXXXXX line #0
155changed line #1
156changed line #2
157changed line #3
158changed line #4
159changed line #5
160changed line #6
161changed line #7
162changed line #8
163changed line #9
164EOF
165 cat <<EOF >rearranged/text &&
166rearranged line #1
167rearranged line #0
168rearranged line #2
169rearranged line #3
170rearranged line #4
171rearranged line #5
172rearranged line #6
173rearranged line #7
174rearranged line #8
175rearranged line #9
176EOF
177 cat <<EOF >dst/copy/unchanged/text &&
178copy unchanged line #0
179copy unchanged line #1
180copy unchanged line #2
181copy unchanged line #3
182copy unchanged line #4
183copy unchanged line #5
184copy unchanged line #6
185copy unchanged line #7
186copy unchanged line #8
187copy unchanged line #9
188EOF
189 cat <<EOF >dst/copy/changed/text &&
190copy XXXCHANGED line #0
191copy changed line #1
192copy changed line #2
193copy changed line #3
194copy changed line #4
195copy changed line #5
196copy changed line #6
197copy changed line #7
198copy changed line #8
199copy changed line #9
200EOF
201 cat <<EOF >dst/copy/rearranged/text &&
202copy rearranged line #1
203copy rearranged line #0
204copy rearranged line #2
205copy rearranged line #3
206copy rearranged line #4
207copy rearranged line #5
208copy rearranged line #6
209copy rearranged line #7
210copy rearranged line #8
211copy rearranged line #9
212EOF
213 cat <<EOF >dst/move/unchanged/text &&
214move unchanged line #0
215move unchanged line #1
216move unchanged line #2
217move unchanged line #3
218move unchanged line #4
219move unchanged line #5
220move unchanged line #6
221move unchanged line #7
222move unchanged line #8
223move unchanged line #9
224EOF
225 cat <<EOF >dst/move/changed/text &&
226move XXXCHANGED line #0
227move changed line #1
228move changed line #2
229move changed line #3
230move changed line #4
231move changed line #5
232move changed line #6
233move changed line #7
234move changed line #8
235move changed line #9
236EOF
237 cat <<EOF >dst/move/rearranged/text &&
238move rearranged line #1
239move rearranged line #0
240move rearranged line #2
241move rearranged line #3
242move rearranged line #4
243move rearranged line #5
244move rearranged line #6
245move rearranged line #7
246move rearranged line #8
247move rearranged line #9
248EOF
249 git add . &&
250 git rm -r src/move/unchanged &&
251 git rm -r src/move/changed &&
252 git rm -r src/move/rearranged &&
5404c116
MM
253 git commit -m "changes" &&
254 git config diff.renames false
5502039d
JH
255'
256
257cat <<EOF >expect_diff_stat
6dd88832
JN
2581 1 changed/text
25910 0 dst/copy/changed/text
26010 0 dst/copy/rearranged/text
26110 0 dst/copy/unchanged/text
26210 0 dst/move/changed/text
26310 0 dst/move/rearranged/text
26410 0 dst/move/unchanged/text
2651 1 rearranged/text
2660 10 src/move/changed/text
2670 10 src/move/rearranged/text
2680 10 src/move/unchanged/text
5502039d
JH
269EOF
270
271cat <<EOF >expect_diff_stat_M
6dd88832
JN
2721 1 changed/text
27310 0 dst/copy/changed/text
27410 0 dst/copy/rearranged/text
27510 0 dst/copy/unchanged/text
2761 1 {src => dst}/move/changed/text
2771 1 {src => dst}/move/rearranged/text
2780 0 {src => dst}/move/unchanged/text
2791 1 rearranged/text
5502039d
JH
280EOF
281
282cat <<EOF >expect_diff_stat_CC
6dd88832
JN
2831 1 changed/text
2841 1 {src => dst}/copy/changed/text
2851 1 {src => dst}/copy/rearranged/text
2860 0 {src => dst}/copy/unchanged/text
2871 1 {src => dst}/move/changed/text
2881 1 {src => dst}/move/rearranged/text
2890 0 {src => dst}/move/unchanged/text
2901 1 rearranged/text
5502039d
JH
291EOF
292
6dd88832
JN
293test_expect_success 'sanity check setup (--numstat)' '
294 git diff --numstat HEAD^..HEAD >actual_diff_stat &&
5502039d 295 test_cmp expect_diff_stat actual_diff_stat &&
6dd88832 296 git diff --numstat -M HEAD^..HEAD >actual_diff_stat_M &&
5502039d 297 test_cmp expect_diff_stat_M actual_diff_stat_M &&
6dd88832 298 git diff --numstat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
5502039d
JH
299 test_cmp expect_diff_stat_CC actual_diff_stat_CC
300'
301
302# changed/text and rearranged/text falls below default 3% threshold
303cat <<EOF >expect_diff_dirstat
304 10.8% dst/copy/changed/
305 10.8% dst/copy/rearranged/
306 10.8% dst/copy/unchanged/
307 10.8% dst/move/changed/
308 10.8% dst/move/rearranged/
309 10.8% dst/move/unchanged/
310 10.8% src/move/changed/
311 10.8% src/move/rearranged/
312 10.8% src/move/unchanged/
313EOF
314
315# rearranged/text falls below default 3% threshold
316cat <<EOF >expect_diff_dirstat_M
317 5.8% changed/
318 29.3% dst/copy/changed/
319 29.3% dst/copy/rearranged/
320 29.3% dst/copy/unchanged/
321 5.8% dst/move/changed/
322EOF
323
324# rearranged/text falls below default 3% threshold
325cat <<EOF >expect_diff_dirstat_CC
326 32.6% changed/
327 32.6% dst/copy/changed/
328 32.6% dst/move/changed/
329EOF
330
331test_expect_success 'various ways to misspell --dirstat' '
332 test_must_fail git show --dirstat10 &&
333f3fb0
JH
333 test_must_fail git show --dirstat10,files &&
334 test_must_fail git show -X=20 &&
335 test_must_fail git show -X=20,cumulative
5502039d
JH
336'
337
338test_expect_success 'vanilla --dirstat' '
339 git diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
340 test_cmp expect_diff_dirstat actual_diff_dirstat &&
341 git diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
342 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
343 git diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
344 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
345'
346
347test_expect_success 'vanilla -X' '
348 git diff -X HEAD^..HEAD >actual_diff_dirstat &&
349 test_cmp expect_diff_dirstat actual_diff_dirstat &&
350 git diff -X -M HEAD^..HEAD >actual_diff_dirstat_M &&
351 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
352 git diff -X -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
353 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
354'
355
333f3fb0
JH
356test_expect_success 'explicit defaults: --dirstat=changes,noncumulative,3' '
357 git diff --dirstat=changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
358 test_cmp expect_diff_dirstat actual_diff_dirstat &&
359 git diff --dirstat=changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
360 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
361 git diff --dirstat=changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
362 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
363'
364
365test_expect_success 'explicit defaults: -Xchanges,noncumulative,3' '
366 git diff -Xchanges,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
367 test_cmp expect_diff_dirstat actual_diff_dirstat &&
368 git diff -Xchanges,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
369 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
370 git diff -Xchanges,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
371 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
372'
373
374test_expect_success 'later options override earlier options:' '
375 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
376 test_cmp expect_diff_dirstat actual_diff_dirstat &&
377 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
378 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
379 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
8fb26872 380 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC &&
333f3fb0
JH
381 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 HEAD^..HEAD >actual_diff_dirstat &&
382 test_cmp expect_diff_dirstat actual_diff_dirstat &&
383 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
384 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
385 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
386 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
387'
388
2d174951
JH
389test_expect_success 'non-defaults in config overridden by explicit defaults on command line' '
390 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
391 test_cmp expect_diff_dirstat actual_diff_dirstat &&
392 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
393 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
394 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
395 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
396'
397
5502039d
JH
398cat <<EOF >expect_diff_dirstat
399 2.1% changed/
400 10.8% dst/copy/changed/
401 10.8% dst/copy/rearranged/
402 10.8% dst/copy/unchanged/
403 10.8% dst/move/changed/
404 10.8% dst/move/rearranged/
405 10.8% dst/move/unchanged/
58a8756a 406 0.0% rearranged/
5502039d
JH
407 10.8% src/move/changed/
408 10.8% src/move/rearranged/
409 10.8% src/move/unchanged/
410EOF
411
412cat <<EOF >expect_diff_dirstat_M
413 5.8% changed/
414 29.3% dst/copy/changed/
415 29.3% dst/copy/rearranged/
416 29.3% dst/copy/unchanged/
417 5.8% dst/move/changed/
418 0.1% dst/move/rearranged/
419 0.1% rearranged/
420EOF
421
422cat <<EOF >expect_diff_dirstat_CC
423 32.6% changed/
424 32.6% dst/copy/changed/
425 0.6% dst/copy/rearranged/
426 32.6% dst/move/changed/
427 0.6% dst/move/rearranged/
428 0.6% rearranged/
429EOF
430
431test_expect_success '--dirstat=0' '
432 git diff --dirstat=0 HEAD^..HEAD >actual_diff_dirstat &&
433 test_cmp expect_diff_dirstat actual_diff_dirstat &&
434 git diff --dirstat=0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
435 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
436 git diff --dirstat=0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
437 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
438'
439
440test_expect_success '-X0' '
441 git diff -X0 HEAD^..HEAD >actual_diff_dirstat &&
442 test_cmp expect_diff_dirstat actual_diff_dirstat &&
443 git diff -X0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
444 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
445 git diff -X0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
446 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
447'
448
2d174951
JH
449test_expect_success 'diff.dirstat=0' '
450 git -c diff.dirstat=0 diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
451 test_cmp expect_diff_dirstat actual_diff_dirstat &&
452 git -c diff.dirstat=0 diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
453 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
454 git -c diff.dirstat=0 diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
455 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
456'
457
5502039d
JH
458cat <<EOF >expect_diff_dirstat
459 2.1% changed/
460 10.8% dst/copy/changed/
461 10.8% dst/copy/rearranged/
462 10.8% dst/copy/unchanged/
463 32.5% dst/copy/
464 10.8% dst/move/changed/
465 10.8% dst/move/rearranged/
466 10.8% dst/move/unchanged/
467 32.5% dst/move/
468 65.1% dst/
58a8756a 469 0.0% rearranged/
5502039d
JH
470 10.8% src/move/changed/
471 10.8% src/move/rearranged/
472 10.8% src/move/unchanged/
473 32.5% src/move/
474EOF
475
476cat <<EOF >expect_diff_dirstat_M
477 5.8% changed/
478 29.3% dst/copy/changed/
479 29.3% dst/copy/rearranged/
480 29.3% dst/copy/unchanged/
481 88.0% dst/copy/
482 5.8% dst/move/changed/
483 0.1% dst/move/rearranged/
484 5.9% dst/move/
485 94.0% dst/
486 0.1% rearranged/
487EOF
488
489cat <<EOF >expect_diff_dirstat_CC
490 32.6% changed/
491 32.6% dst/copy/changed/
492 0.6% dst/copy/rearranged/
493 33.3% dst/copy/
494 32.6% dst/move/changed/
495 0.6% dst/move/rearranged/
496 33.3% dst/move/
497 66.6% dst/
498 0.6% rearranged/
499EOF
500
501test_expect_success '--dirstat=0 --cumulative' '
502 git diff --dirstat=0 --cumulative HEAD^..HEAD >actual_diff_dirstat &&
503 test_cmp expect_diff_dirstat actual_diff_dirstat &&
504 git diff --dirstat=0 --cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
505 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
506 git diff --dirstat=0 --cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
507 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
508'
509
333f3fb0
JH
510test_expect_success '--dirstat=0,cumulative' '
511 git diff --dirstat=0,cumulative HEAD^..HEAD >actual_diff_dirstat &&
512 test_cmp expect_diff_dirstat actual_diff_dirstat &&
513 git diff --dirstat=0,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
514 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
515 git diff --dirstat=0,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
516 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
517'
518
519test_expect_success '-X0,cumulative' '
520 git diff -X0,cumulative HEAD^..HEAD >actual_diff_dirstat &&
521 test_cmp expect_diff_dirstat actual_diff_dirstat &&
522 git diff -X0,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
523 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
524 git diff -X0,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
525 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
526'
527
2d174951
JH
528test_expect_success 'diff.dirstat=0,cumulative' '
529 git -c diff.dirstat=0,cumulative diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
530 test_cmp expect_diff_dirstat actual_diff_dirstat &&
531 git -c diff.dirstat=0,cumulative diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
532 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
533 git -c diff.dirstat=0,cumulative diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
534 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
535'
536
537test_expect_success 'diff.dirstat=0 & --dirstat=cumulative' '
538 git -c diff.dirstat=0 diff --dirstat=cumulative HEAD^..HEAD >actual_diff_dirstat &&
539 test_cmp expect_diff_dirstat actual_diff_dirstat &&
540 git -c diff.dirstat=0 diff --dirstat=cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
541 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
542 git -c diff.dirstat=0 diff --dirstat=cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
543 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
544'
545
5502039d
JH
546cat <<EOF >expect_diff_dirstat
547 9.0% changed/
548 9.0% dst/copy/changed/
549 9.0% dst/copy/rearranged/
550 9.0% dst/copy/unchanged/
551 9.0% dst/move/changed/
552 9.0% dst/move/rearranged/
553 9.0% dst/move/unchanged/
554 9.0% rearranged/
555 9.0% src/move/changed/
556 9.0% src/move/rearranged/
557 9.0% src/move/unchanged/
558EOF
559
560cat <<EOF >expect_diff_dirstat_M
561 14.2% changed/
562 14.2% dst/copy/changed/
563 14.2% dst/copy/rearranged/
564 14.2% dst/copy/unchanged/
565 14.2% dst/move/changed/
566 14.2% dst/move/rearranged/
567 14.2% rearranged/
568EOF
569
570cat <<EOF >expect_diff_dirstat_CC
571 16.6% changed/
572 16.6% dst/copy/changed/
573 16.6% dst/copy/rearranged/
574 16.6% dst/move/changed/
575 16.6% dst/move/rearranged/
576 16.6% rearranged/
577EOF
578
579test_expect_success '--dirstat-by-file' '
580 git diff --dirstat-by-file HEAD^..HEAD >actual_diff_dirstat &&
581 test_cmp expect_diff_dirstat actual_diff_dirstat &&
582 git diff --dirstat-by-file -M HEAD^..HEAD >actual_diff_dirstat_M &&
583 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
584 git diff --dirstat-by-file -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
585 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
586'
587
333f3fb0
JH
588test_expect_success '--dirstat=files' '
589 git diff --dirstat=files HEAD^..HEAD >actual_diff_dirstat &&
590 test_cmp expect_diff_dirstat actual_diff_dirstat &&
591 git diff --dirstat=files -M HEAD^..HEAD >actual_diff_dirstat_M &&
592 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
593 git diff --dirstat=files -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
594 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
595'
596
2d174951
JH
597test_expect_success 'diff.dirstat=files' '
598 git -c diff.dirstat=files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
599 test_cmp expect_diff_dirstat actual_diff_dirstat &&
600 git -c diff.dirstat=files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
601 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
602 git -c diff.dirstat=files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
603 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
604'
605
5502039d
JH
606cat <<EOF >expect_diff_dirstat
607 27.2% dst/copy/
608 27.2% dst/move/
609 27.2% src/move/
610EOF
611
612cat <<EOF >expect_diff_dirstat_M
613 14.2% changed/
614 14.2% dst/copy/changed/
615 14.2% dst/copy/rearranged/
616 14.2% dst/copy/unchanged/
617 14.2% dst/move/changed/
618 14.2% dst/move/rearranged/
619 14.2% rearranged/
620EOF
621
622cat <<EOF >expect_diff_dirstat_CC
623 16.6% changed/
624 16.6% dst/copy/changed/
625 16.6% dst/copy/rearranged/
626 16.6% dst/move/changed/
627 16.6% dst/move/rearranged/
628 16.6% rearranged/
629EOF
630
631test_expect_success '--dirstat-by-file=10' '
632 git diff --dirstat-by-file=10 HEAD^..HEAD >actual_diff_dirstat &&
633 test_cmp expect_diff_dirstat actual_diff_dirstat &&
634 git diff --dirstat-by-file=10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
635 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
636 git diff --dirstat-by-file=10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
637 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
638'
639
333f3fb0
JH
640test_expect_success '--dirstat=files,10' '
641 git diff --dirstat=files,10 HEAD^..HEAD >actual_diff_dirstat &&
642 test_cmp expect_diff_dirstat actual_diff_dirstat &&
643 git diff --dirstat=files,10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
644 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
645 git diff --dirstat=files,10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
646 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
647'
648
2d174951
JH
649test_expect_success 'diff.dirstat=10,files' '
650 git -c diff.dirstat=10,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
651 test_cmp expect_diff_dirstat actual_diff_dirstat &&
652 git -c diff.dirstat=10,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
653 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
654 git -c diff.dirstat=10,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
655 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
656'
657
5502039d
JH
658cat <<EOF >expect_diff_dirstat
659 9.0% changed/
660 9.0% dst/copy/changed/
661 9.0% dst/copy/rearranged/
662 9.0% dst/copy/unchanged/
663 27.2% dst/copy/
664 9.0% dst/move/changed/
665 9.0% dst/move/rearranged/
666 9.0% dst/move/unchanged/
667 27.2% dst/move/
668 54.5% dst/
669 9.0% rearranged/
670 9.0% src/move/changed/
671 9.0% src/move/rearranged/
672 9.0% src/move/unchanged/
673 27.2% src/move/
674EOF
675
676cat <<EOF >expect_diff_dirstat_M
677 14.2% changed/
678 14.2% dst/copy/changed/
679 14.2% dst/copy/rearranged/
680 14.2% dst/copy/unchanged/
681 42.8% dst/copy/
682 14.2% dst/move/changed/
683 14.2% dst/move/rearranged/
684 28.5% dst/move/
685 71.4% dst/
686 14.2% rearranged/
687EOF
688
689cat <<EOF >expect_diff_dirstat_CC
690 16.6% changed/
691 16.6% dst/copy/changed/
692 16.6% dst/copy/rearranged/
693 33.3% dst/copy/
694 16.6% dst/move/changed/
695 16.6% dst/move/rearranged/
696 33.3% dst/move/
697 66.6% dst/
698 16.6% rearranged/
699EOF
700
701test_expect_success '--dirstat-by-file --cumulative' '
702 git diff --dirstat-by-file --cumulative HEAD^..HEAD >actual_diff_dirstat &&
703 test_cmp expect_diff_dirstat actual_diff_dirstat &&
704 git diff --dirstat-by-file --cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
705 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
706 git diff --dirstat-by-file --cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
707 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
708'
709
333f3fb0
JH
710test_expect_success '--dirstat=files,cumulative' '
711 git diff --dirstat=files,cumulative HEAD^..HEAD >actual_diff_dirstat &&
712 test_cmp expect_diff_dirstat actual_diff_dirstat &&
713 git diff --dirstat=files,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
714 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
715 git diff --dirstat=files,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
716 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
717'
718
2d174951
JH
719test_expect_success 'diff.dirstat=cumulative,files' '
720 git -c diff.dirstat=cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
721 test_cmp expect_diff_dirstat actual_diff_dirstat &&
722 git -c diff.dirstat=cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
723 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
724 git -c diff.dirstat=cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
725 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
726'
727
333f3fb0
JH
728cat <<EOF >expect_diff_dirstat
729 27.2% dst/copy/
730 27.2% dst/move/
731 54.5% dst/
732 27.2% src/move/
733EOF
734
735cat <<EOF >expect_diff_dirstat_M
736 14.2% changed/
737 14.2% dst/copy/changed/
738 14.2% dst/copy/rearranged/
739 14.2% dst/copy/unchanged/
740 42.8% dst/copy/
741 14.2% dst/move/changed/
742 14.2% dst/move/rearranged/
743 28.5% dst/move/
744 71.4% dst/
745 14.2% rearranged/
746EOF
747
748cat <<EOF >expect_diff_dirstat_CC
749 16.6% changed/
750 16.6% dst/copy/changed/
751 16.6% dst/copy/rearranged/
752 33.3% dst/copy/
753 16.6% dst/move/changed/
754 16.6% dst/move/rearranged/
755 33.3% dst/move/
756 66.6% dst/
757 16.6% rearranged/
758EOF
759
760test_expect_success '--dirstat=files,cumulative,10' '
761 git diff --dirstat=files,cumulative,10 HEAD^..HEAD >actual_diff_dirstat &&
762 test_cmp expect_diff_dirstat actual_diff_dirstat &&
763 git diff --dirstat=files,cumulative,10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
764 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
765 git diff --dirstat=files,cumulative,10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
766 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
767'
768
2d174951
JH
769test_expect_success 'diff.dirstat=10,cumulative,files' '
770 git -c diff.dirstat=10,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
771 test_cmp expect_diff_dirstat actual_diff_dirstat &&
772 git -c diff.dirstat=10,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
773 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
774 git -c diff.dirstat=10,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
775 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
776'
777
712d2c7d
JH
778cat <<EOF >expect_diff_dirstat
779 27.2% dst/copy/
780 27.2% dst/move/
781 54.5% dst/
782 27.2% src/move/
783EOF
784
785cat <<EOF >expect_diff_dirstat_M
786 42.8% dst/copy/
787 28.5% dst/move/
788 71.4% dst/
789EOF
790
791cat <<EOF >expect_diff_dirstat_CC
792 33.3% dst/copy/
793 33.3% dst/move/
794 66.6% dst/
795EOF
796
797test_expect_success '--dirstat=files,cumulative,16.7' '
798 git diff --dirstat=files,cumulative,16.7 HEAD^..HEAD >actual_diff_dirstat &&
799 test_cmp expect_diff_dirstat actual_diff_dirstat &&
800 git diff --dirstat=files,cumulative,16.7 -M HEAD^..HEAD >actual_diff_dirstat_M &&
801 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
802 git diff --dirstat=files,cumulative,16.7 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
803 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
804'
805
806test_expect_success 'diff.dirstat=16.7,cumulative,files' '
807 git -c diff.dirstat=16.7,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
808 test_cmp expect_diff_dirstat actual_diff_dirstat &&
809 git -c diff.dirstat=16.7,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
810 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
811 git -c diff.dirstat=16.7,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
812 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
813'
814
815test_expect_success 'diff.dirstat=16.70,cumulative,files' '
816 git -c diff.dirstat=16.70,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
817 test_cmp expect_diff_dirstat actual_diff_dirstat &&
818 git -c diff.dirstat=16.70,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
819 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
820 git -c diff.dirstat=16.70,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
821 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
822'
823
824test_expect_success '--dirstat=files,cumulative,27.2' '
825 git diff --dirstat=files,cumulative,27.2 HEAD^..HEAD >actual_diff_dirstat &&
826 test_cmp expect_diff_dirstat actual_diff_dirstat &&
827 git diff --dirstat=files,cumulative,27.2 -M HEAD^..HEAD >actual_diff_dirstat_M &&
828 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
829 git diff --dirstat=files,cumulative,27.2 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
830 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
831'
832
833test_expect_success '--dirstat=files,cumulative,27.09' '
834 git diff --dirstat=files,cumulative,27.09 HEAD^..HEAD >actual_diff_dirstat &&
835 test_cmp expect_diff_dirstat actual_diff_dirstat &&
836 git diff --dirstat=files,cumulative,27.09 -M HEAD^..HEAD >actual_diff_dirstat_M &&
837 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
838 git diff --dirstat=files,cumulative,27.09 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
839 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
840'
841
1c57a627
JH
842cat <<EOF >expect_diff_dirstat
843 10.6% dst/copy/changed/
844 10.6% dst/copy/rearranged/
845 10.6% dst/copy/unchanged/
846 10.6% dst/move/changed/
847 10.6% dst/move/rearranged/
848 10.6% dst/move/unchanged/
849 10.6% src/move/changed/
850 10.6% src/move/rearranged/
851 10.6% src/move/unchanged/
852EOF
853
854cat <<EOF >expect_diff_dirstat_M
855 5.2% changed/
856 26.3% dst/copy/changed/
857 26.3% dst/copy/rearranged/
858 26.3% dst/copy/unchanged/
859 5.2% dst/move/changed/
860 5.2% dst/move/rearranged/
861 5.2% rearranged/
862EOF
863
864cat <<EOF >expect_diff_dirstat_CC
865 16.6% changed/
866 16.6% dst/copy/changed/
867 16.6% dst/copy/rearranged/
868 16.6% dst/move/changed/
869 16.6% dst/move/rearranged/
870 16.6% rearranged/
871EOF
872
873test_expect_success '--dirstat=lines' '
874 git diff --dirstat=lines HEAD^..HEAD >actual_diff_dirstat &&
875 test_cmp expect_diff_dirstat actual_diff_dirstat &&
876 git diff --dirstat=lines -M HEAD^..HEAD >actual_diff_dirstat_M &&
877 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
878 git diff --dirstat=lines -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
879 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
880'
881
882test_expect_success 'diff.dirstat=lines' '
883 git -c diff.dirstat=lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
884 test_cmp expect_diff_dirstat actual_diff_dirstat &&
885 git -c diff.dirstat=lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
886 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
887 git -c diff.dirstat=lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
888 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
889'
890
891cat <<EOF >expect_diff_dirstat
892 2.1% changed/
893 10.6% dst/copy/changed/
894 10.6% dst/copy/rearranged/
895 10.6% dst/copy/unchanged/
896 10.6% dst/move/changed/
897 10.6% dst/move/rearranged/
898 10.6% dst/move/unchanged/
899 2.1% rearranged/
900 10.6% src/move/changed/
901 10.6% src/move/rearranged/
902 10.6% src/move/unchanged/
903EOF
904
905cat <<EOF >expect_diff_dirstat_M
906 5.2% changed/
907 26.3% dst/copy/changed/
908 26.3% dst/copy/rearranged/
909 26.3% dst/copy/unchanged/
910 5.2% dst/move/changed/
911 5.2% dst/move/rearranged/
912 5.2% rearranged/
913EOF
914
915cat <<EOF >expect_diff_dirstat_CC
916 16.6% changed/
917 16.6% dst/copy/changed/
918 16.6% dst/copy/rearranged/
919 16.6% dst/move/changed/
920 16.6% dst/move/rearranged/
921 16.6% rearranged/
922EOF
923
924test_expect_success '--dirstat=lines,0' '
925 git diff --dirstat=lines,0 HEAD^..HEAD >actual_diff_dirstat &&
926 test_cmp expect_diff_dirstat actual_diff_dirstat &&
927 git diff --dirstat=lines,0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
928 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
929 git diff --dirstat=lines,0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
930 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
931'
932
933test_expect_success 'diff.dirstat=0,lines' '
934 git -c diff.dirstat=0,lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
935 test_cmp expect_diff_dirstat actual_diff_dirstat &&
936 git -c diff.dirstat=0,lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
937 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
938 git -c diff.dirstat=0,lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
939 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
940'
941
51670fc8
JH
942test_expect_success '--dirstat=future_param,lines,0 should fail loudly' '
943 test_must_fail git diff --dirstat=future_param,lines,0 HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
944 test_debug "cat actual_error" &&
ec21ac8c 945 test_must_be_empty actual_diff_dirstat &&
6789275d
JH
946 test_grep -q "future_param" actual_error &&
947 test_grep -q "\--dirstat" actual_error
51670fc8
JH
948'
949
950test_expect_success '--dirstat=dummy1,cumulative,2dummy should report both unrecognized parameters' '
951 test_must_fail git diff --dirstat=dummy1,cumulative,2dummy HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
952 test_debug "cat actual_error" &&
ec21ac8c 953 test_must_be_empty actual_diff_dirstat &&
6789275d
JH
954 test_grep -q "dummy1" actual_error &&
955 test_grep -q "2dummy" actual_error &&
956 test_grep -q "\--dirstat" actual_error
51670fc8
JH
957'
958
959test_expect_success 'diff.dirstat=future_param,0,lines should warn, but still work' '
960 git -c diff.dirstat=future_param,0,lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
961 test_debug "cat actual_error" &&
962 test_cmp expect_diff_dirstat actual_diff_dirstat &&
6789275d
JH
963 test_grep -q "future_param" actual_error &&
964 test_grep -q "diff\\.dirstat" actual_error &&
51670fc8
JH
965
966 git -c diff.dirstat=future_param,0,lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M 2>actual_error &&
967 test_debug "cat actual_error" &&
968 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
6789275d
JH
969 test_grep -q "future_param" actual_error &&
970 test_grep -q "diff\\.dirstat" actual_error &&
51670fc8
JH
971
972 git -c diff.dirstat=future_param,0,lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC 2>actual_error &&
973 test_debug "cat actual_error" &&
974 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC &&
6789275d
JH
975 test_grep -q "future_param" actual_error &&
976 test_grep -q "diff\\.dirstat" actual_error
51670fc8
JH
977'
978
ab27389a
MK
979test_expect_success '--shortstat --dirstat should output only one dirstat' '
980 git diff --shortstat --dirstat=changes HEAD^..HEAD >out &&
981 grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_changes &&
982 test_line_count = 1 actual_diff_shortstat_dirstat_changes &&
983
984 git diff --shortstat --dirstat=lines HEAD^..HEAD >out &&
985 grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_lines &&
986 test_line_count = 1 actual_diff_shortstat_dirstat_lines &&
987
988 git diff --shortstat --dirstat=files HEAD^..HEAD >out &&
989 grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_files &&
990 test_line_count = 1 actual_diff_shortstat_dirstat_files
991'
992
5502039d 993test_done