3 test_description
='diff --dirstat tests'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 # set up two commits where the second commit has these files
9 # (10 lines in each file):
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)
21 test_expect_success
'setup' '
27 mkdir src/copy/unchanged &&
28 mkdir src/copy/changed &&
29 mkdir src/copy/rearranged &&
31 mkdir src/move/unchanged &&
32 mkdir src/move/changed &&
33 mkdir src/move/rearranged &&
34 cat <<EOF >unchanged/text &&
46 cat <<EOF >changed/text &&
58 cat <<EOF >rearranged/text &&
70 cat <<EOF >src/copy/unchanged/text &&
71 copy unchanged line #0
72 copy unchanged line #1
73 copy unchanged line #2
74 copy unchanged line #3
75 copy unchanged line #4
76 copy unchanged line #5
77 copy unchanged line #6
78 copy unchanged line #7
79 copy unchanged line #8
80 copy unchanged line #9
82 cat <<EOF >src/copy/changed/text &&
94 cat <<EOF >src/copy/rearranged/text &&
95 copy rearranged line #0
96 copy rearranged line #1
97 copy rearranged line #2
98 copy rearranged line #3
99 copy rearranged line #4
100 copy rearranged line #5
101 copy rearranged line #6
102 copy rearranged line #7
103 copy rearranged line #8
104 copy rearranged line #9
106 cat <<EOF >src/move/unchanged/text &&
107 move unchanged line #0
108 move unchanged line #1
109 move unchanged line #2
110 move unchanged line #3
111 move unchanged line #4
112 move unchanged line #5
113 move unchanged line #6
114 move unchanged line #7
115 move unchanged line #8
116 move unchanged line #9
118 cat <<EOF >src/move/changed/text &&
130 cat <<EOF >src/move/rearranged/text &&
131 move rearranged line #0
132 move rearranged line #1
133 move rearranged line #2
134 move rearranged line #3
135 move rearranged line #4
136 move rearranged line #5
137 move rearranged line #6
138 move rearranged line #7
139 move rearranged line #8
140 move rearranged line #9
143 git commit -m "initial" &&
146 mkdir dst/copy/unchanged &&
147 mkdir dst/copy/changed &&
148 mkdir dst/copy/rearranged &&
150 mkdir dst/move/unchanged &&
151 mkdir dst/move/changed &&
152 mkdir dst/move/rearranged &&
153 cat <<EOF >changed/text &&
154 CHANGED XXXXXXX line #0
165 cat <<EOF >rearranged/text &&
177 cat <<EOF >dst/copy/unchanged/text &&
178 copy unchanged line #0
179 copy unchanged line #1
180 copy unchanged line #2
181 copy unchanged line #3
182 copy unchanged line #4
183 copy unchanged line #5
184 copy unchanged line #6
185 copy unchanged line #7
186 copy unchanged line #8
187 copy unchanged line #9
189 cat <<EOF >dst/copy/changed/text &&
190 copy XXXCHANGED line #0
201 cat <<EOF >dst/copy/rearranged/text &&
202 copy rearranged line #1
203 copy rearranged line #0
204 copy rearranged line #2
205 copy rearranged line #3
206 copy rearranged line #4
207 copy rearranged line #5
208 copy rearranged line #6
209 copy rearranged line #7
210 copy rearranged line #8
211 copy rearranged line #9
213 cat <<EOF >dst/move/unchanged/text &&
214 move unchanged line #0
215 move unchanged line #1
216 move unchanged line #2
217 move unchanged line #3
218 move unchanged line #4
219 move unchanged line #5
220 move unchanged line #6
221 move unchanged line #7
222 move unchanged line #8
223 move unchanged line #9
225 cat <<EOF >dst/move/changed/text &&
226 move XXXCHANGED line #0
237 cat <<EOF >dst/move/rearranged/text &&
238 move rearranged line #1
239 move rearranged line #0
240 move rearranged line #2
241 move rearranged line #3
242 move rearranged line #4
243 move rearranged line #5
244 move rearranged line #6
245 move rearranged line #7
246 move rearranged line #8
247 move rearranged line #9
250 git rm -r src/move/unchanged &&
251 git rm -r src/move/changed &&
252 git rm -r src/move/rearranged &&
253 git commit -m "changes" &&
254 git config diff.renames false
257 cat <<EOF >expect_diff_stat
259 10 0 dst/copy/changed/text
260 10 0 dst/copy/rearranged/text
261 10 0 dst/copy/unchanged/text
262 10 0 dst/move/changed/text
263 10 0 dst/move/rearranged/text
264 10 0 dst/move/unchanged/text
266 0 10 src/move/changed/text
267 0 10 src/move/rearranged/text
268 0 10 src/move/unchanged/text
271 cat <<EOF >expect_diff_stat_M
273 10 0 dst/copy/changed/text
274 10 0 dst/copy/rearranged/text
275 10 0 dst/copy/unchanged/text
276 1 1 {src => dst}/move/changed/text
277 1 1 {src => dst}/move/rearranged/text
278 0 0 {src => dst}/move/unchanged/text
282 cat <<EOF >expect_diff_stat_CC
284 1 1 {src => dst}/copy/changed/text
285 1 1 {src => dst}/copy/rearranged/text
286 0 0 {src => dst}/copy/unchanged/text
287 1 1 {src => dst}/move/changed/text
288 1 1 {src => dst}/move/rearranged/text
289 0 0 {src => dst}/move/unchanged/text
293 test_expect_success
'sanity check setup (--numstat)' '
294 git diff --numstat HEAD^..HEAD >actual_diff_stat &&
295 test_cmp expect_diff_stat actual_diff_stat &&
296 git diff --numstat -M HEAD^..HEAD >actual_diff_stat_M &&
297 test_cmp expect_diff_stat_M actual_diff_stat_M &&
298 git diff --numstat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
299 test_cmp expect_diff_stat_CC actual_diff_stat_CC
302 # changed/text and rearranged/text falls below default 3% threshold
303 cat <<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/
315 # rearranged/text falls below default 3% threshold
316 cat <<EOF >expect_diff_dirstat_M
318 29.3% dst/copy/changed/
319 29.3% dst/copy/rearranged/
320 29.3% dst/copy/unchanged/
321 5.8% dst/move/changed/
324 # rearranged/text falls below default 3% threshold
325 cat <<EOF >expect_diff_dirstat_CC
327 32.6% dst/copy/changed/
328 32.6% dst/move/changed/
331 test_expect_success
'various ways to misspell --dirstat' '
332 test_must_fail git show --dirstat10 &&
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
338 test_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
347 test_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
356 test_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
365 test_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
374 test_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 &&
380 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC &&
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
389 test_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
398 cat <<EOF >expect_diff_dirstat
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/
407 10.8% src/move/changed/
408 10.8% src/move/rearranged/
409 10.8% src/move/unchanged/
412 cat <<EOF >expect_diff_dirstat_M
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/
422 cat <<EOF >expect_diff_dirstat_CC
424 32.6% dst/copy/changed/
425 0.6% dst/copy/rearranged/
426 32.6% dst/move/changed/
427 0.6% dst/move/rearranged/
431 test_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
440 test_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
449 test_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
458 cat <<EOF >expect_diff_dirstat
460 10.8% dst/copy/changed/
461 10.8% dst/copy/rearranged/
462 10.8% dst/copy/unchanged/
464 10.8% dst/move/changed/
465 10.8% dst/move/rearranged/
466 10.8% dst/move/unchanged/
470 10.8% src/move/changed/
471 10.8% src/move/rearranged/
472 10.8% src/move/unchanged/
476 cat <<EOF >expect_diff_dirstat_M
478 29.3% dst/copy/changed/
479 29.3% dst/copy/rearranged/
480 29.3% dst/copy/unchanged/
482 5.8% dst/move/changed/
483 0.1% dst/move/rearranged/
489 cat <<EOF >expect_diff_dirstat_CC
491 32.6% dst/copy/changed/
492 0.6% dst/copy/rearranged/
494 32.6% dst/move/changed/
495 0.6% dst/move/rearranged/
501 test_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
510 test_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
519 test_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
528 test_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
537 test_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
546 cat <<EOF >expect_diff_dirstat
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/
555 9.0% src/move/changed/
556 9.0% src/move/rearranged/
557 9.0% src/move/unchanged/
560 cat <<EOF >expect_diff_dirstat_M
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/
570 cat <<EOF >expect_diff_dirstat_CC
572 16.6% dst/copy/changed/
573 16.6% dst/copy/rearranged/
574 16.6% dst/move/changed/
575 16.6% dst/move/rearranged/
579 test_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
588 test_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
597 test_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
606 cat <<EOF >expect_diff_dirstat
612 cat <<EOF >expect_diff_dirstat_M
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/
622 cat <<EOF >expect_diff_dirstat_CC
624 16.6% dst/copy/changed/
625 16.6% dst/copy/rearranged/
626 16.6% dst/move/changed/
627 16.6% dst/move/rearranged/
631 test_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
640 test_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
649 test_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
658 cat <<EOF >expect_diff_dirstat
660 9.0% dst/copy/changed/
661 9.0% dst/copy/rearranged/
662 9.0% dst/copy/unchanged/
664 9.0% dst/move/changed/
665 9.0% dst/move/rearranged/
666 9.0% dst/move/unchanged/
670 9.0% src/move/changed/
671 9.0% src/move/rearranged/
672 9.0% src/move/unchanged/
676 cat <<EOF >expect_diff_dirstat_M
678 14.2% dst/copy/changed/
679 14.2% dst/copy/rearranged/
680 14.2% dst/copy/unchanged/
682 14.2% dst/move/changed/
683 14.2% dst/move/rearranged/
689 cat <<EOF >expect_diff_dirstat_CC
691 16.6% dst/copy/changed/
692 16.6% dst/copy/rearranged/
694 16.6% dst/move/changed/
695 16.6% dst/move/rearranged/
701 test_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
710 test_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
719 test_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
728 cat <<EOF >expect_diff_dirstat
735 cat <<EOF >expect_diff_dirstat_M
737 14.2% dst/copy/changed/
738 14.2% dst/copy/rearranged/
739 14.2% dst/copy/unchanged/
741 14.2% dst/move/changed/
742 14.2% dst/move/rearranged/
748 cat <<EOF >expect_diff_dirstat_CC
750 16.6% dst/copy/changed/
751 16.6% dst/copy/rearranged/
753 16.6% dst/move/changed/
754 16.6% dst/move/rearranged/
760 test_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
769 test_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
778 cat <<EOF >expect_diff_dirstat
785 cat <<EOF >expect_diff_dirstat_M
791 cat <<EOF >expect_diff_dirstat_CC
797 test_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
806 test_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
815 test_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
824 test_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
833 test_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
842 cat <<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/
854 cat <<EOF >expect_diff_dirstat_M
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/
864 cat <<EOF >expect_diff_dirstat_CC
866 16.6% dst/copy/changed/
867 16.6% dst/copy/rearranged/
868 16.6% dst/move/changed/
869 16.6% dst/move/rearranged/
873 test_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
882 test_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
891 cat <<EOF >expect_diff_dirstat
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/
900 10.6% src/move/changed/
901 10.6% src/move/rearranged/
902 10.6% src/move/unchanged/
905 cat <<EOF >expect_diff_dirstat_M
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/
915 cat <<EOF >expect_diff_dirstat_CC
917 16.6% dst/copy/changed/
918 16.6% dst/copy/rearranged/
919 16.6% dst/move/changed/
920 16.6% dst/move/rearranged/
924 test_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
933 test_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
942 test_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" &&
945 test_must_be_empty actual_diff_dirstat &&
946 test_grep -q "future_param" actual_error &&
947 test_grep -q "\--dirstat" actual_error
950 test_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" &&
953 test_must_be_empty actual_diff_dirstat &&
954 test_grep -q "dummy1" actual_error &&
955 test_grep -q "2dummy" actual_error &&
956 test_grep -q "\--dirstat" actual_error
959 test_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 &&
963 test_grep -q "future_param" actual_error &&
964 test_grep -q "diff\\.dirstat" actual_error &&
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 &&
969 test_grep -q "future_param" actual_error &&
970 test_grep -q "diff\\.dirstat" actual_error &&
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 &&
975 test_grep -q "future_param" actual_error &&
976 test_grep -q "diff\\.dirstat" actual_error
979 test_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 &&
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 &&
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