Add contrib/credentials/netrc with GPG support
[git.git] / t / t4047-diff-dirstat.sh
blobed7e093366bcbdaa177bac4294a07fc52d4233ed
1 #!/bin/sh
3 test_description='diff --dirstat tests'
4 . ./test-lib.sh
6 # set up two commits where the second commit has these files
7 # (10 lines in each file):
9 # unchanged/text (unchanged from 1st commit)
10 # changed/text (changed 1st line)
11 # rearranged/text (swapped 1st and 2nd line)
12 # dst/copy/unchanged/text (copied from src/copy/unchanged/text, unchanged)
13 # dst/copy/changed/text (copied from src/copy/changed/text, changed)
14 # dst/copy/rearranged/text (copied from src/copy/rearranged/text, rearranged)
15 # dst/move/unchanged/text (moved from src/move/unchanged/text, unchanged)
16 # dst/move/changed/text (moved from src/move/changed/text, changed)
17 # dst/move/rearranged/text (moved from src/move/rearranged/text, rearranged)
19 test_expect_success 'setup' '
20 mkdir unchanged &&
21 mkdir changed &&
22 mkdir rearranged &&
23 mkdir src &&
24 mkdir src/copy &&
25 mkdir src/copy/unchanged &&
26 mkdir src/copy/changed &&
27 mkdir src/copy/rearranged &&
28 mkdir src/move &&
29 mkdir src/move/unchanged &&
30 mkdir src/move/changed &&
31 mkdir src/move/rearranged &&
32 cat <<EOF >unchanged/text &&
33 unchanged line #0
34 unchanged line #1
35 unchanged line #2
36 unchanged line #3
37 unchanged line #4
38 unchanged line #5
39 unchanged line #6
40 unchanged line #7
41 unchanged line #8
42 unchanged line #9
43 EOF
44 cat <<EOF >changed/text &&
45 changed line #0
46 changed line #1
47 changed line #2
48 changed line #3
49 changed line #4
50 changed line #5
51 changed line #6
52 changed line #7
53 changed line #8
54 changed line #9
55 EOF
56 cat <<EOF >rearranged/text &&
57 rearranged line #0
58 rearranged line #1
59 rearranged line #2
60 rearranged line #3
61 rearranged line #4
62 rearranged line #5
63 rearranged line #6
64 rearranged line #7
65 rearranged line #8
66 rearranged line #9
67 EOF
68 cat <<EOF >src/copy/unchanged/text &&
69 copy unchanged line #0
70 copy unchanged line #1
71 copy unchanged line #2
72 copy unchanged line #3
73 copy unchanged line #4
74 copy unchanged line #5
75 copy unchanged line #6
76 copy unchanged line #7
77 copy unchanged line #8
78 copy unchanged line #9
79 EOF
80 cat <<EOF >src/copy/changed/text &&
81 copy changed line #0
82 copy changed line #1
83 copy changed line #2
84 copy changed line #3
85 copy changed line #4
86 copy changed line #5
87 copy changed line #6
88 copy changed line #7
89 copy changed line #8
90 copy changed line #9
91 EOF
92 cat <<EOF >src/copy/rearranged/text &&
93 copy rearranged line #0
94 copy rearranged line #1
95 copy rearranged line #2
96 copy rearranged line #3
97 copy rearranged line #4
98 copy rearranged line #5
99 copy rearranged line #6
100 copy rearranged line #7
101 copy rearranged line #8
102 copy rearranged line #9
104 cat <<EOF >src/move/unchanged/text &&
105 move unchanged line #0
106 move unchanged line #1
107 move unchanged line #2
108 move unchanged line #3
109 move unchanged line #4
110 move unchanged line #5
111 move unchanged line #6
112 move unchanged line #7
113 move unchanged line #8
114 move unchanged line #9
116 cat <<EOF >src/move/changed/text &&
117 move changed line #0
118 move changed line #1
119 move changed line #2
120 move changed line #3
121 move changed line #4
122 move changed line #5
123 move changed line #6
124 move changed line #7
125 move changed line #8
126 move changed line #9
128 cat <<EOF >src/move/rearranged/text &&
129 move rearranged line #0
130 move rearranged line #1
131 move rearranged line #2
132 move rearranged line #3
133 move rearranged line #4
134 move rearranged line #5
135 move rearranged line #6
136 move rearranged line #7
137 move rearranged line #8
138 move rearranged line #9
140 git add . &&
141 git commit -m "initial" &&
142 mkdir dst &&
143 mkdir dst/copy &&
144 mkdir dst/copy/unchanged &&
145 mkdir dst/copy/changed &&
146 mkdir dst/copy/rearranged &&
147 mkdir dst/move &&
148 mkdir dst/move/unchanged &&
149 mkdir dst/move/changed &&
150 mkdir dst/move/rearranged &&
151 cat <<EOF >changed/text &&
152 CHANGED XXXXXXX line #0
153 changed line #1
154 changed line #2
155 changed line #3
156 changed line #4
157 changed line #5
158 changed line #6
159 changed line #7
160 changed line #8
161 changed line #9
163 cat <<EOF >rearranged/text &&
164 rearranged line #1
165 rearranged line #0
166 rearranged line #2
167 rearranged line #3
168 rearranged line #4
169 rearranged line #5
170 rearranged line #6
171 rearranged line #7
172 rearranged line #8
173 rearranged line #9
175 cat <<EOF >dst/copy/unchanged/text &&
176 copy unchanged line #0
177 copy unchanged line #1
178 copy unchanged line #2
179 copy unchanged line #3
180 copy unchanged line #4
181 copy unchanged line #5
182 copy unchanged line #6
183 copy unchanged line #7
184 copy unchanged line #8
185 copy unchanged line #9
187 cat <<EOF >dst/copy/changed/text &&
188 copy XXXCHANGED line #0
189 copy changed line #1
190 copy changed line #2
191 copy changed line #3
192 copy changed line #4
193 copy changed line #5
194 copy changed line #6
195 copy changed line #7
196 copy changed line #8
197 copy changed line #9
199 cat <<EOF >dst/copy/rearranged/text &&
200 copy rearranged line #1
201 copy rearranged line #0
202 copy rearranged line #2
203 copy rearranged line #3
204 copy rearranged line #4
205 copy rearranged line #5
206 copy rearranged line #6
207 copy rearranged line #7
208 copy rearranged line #8
209 copy rearranged line #9
211 cat <<EOF >dst/move/unchanged/text &&
212 move unchanged line #0
213 move unchanged line #1
214 move unchanged line #2
215 move unchanged line #3
216 move unchanged line #4
217 move unchanged line #5
218 move unchanged line #6
219 move unchanged line #7
220 move unchanged line #8
221 move unchanged line #9
223 cat <<EOF >dst/move/changed/text &&
224 move XXXCHANGED line #0
225 move changed line #1
226 move changed line #2
227 move changed line #3
228 move changed line #4
229 move changed line #5
230 move changed line #6
231 move changed line #7
232 move changed line #8
233 move changed line #9
235 cat <<EOF >dst/move/rearranged/text &&
236 move rearranged line #1
237 move rearranged line #0
238 move rearranged line #2
239 move rearranged line #3
240 move rearranged line #4
241 move rearranged line #5
242 move rearranged line #6
243 move rearranged line #7
244 move rearranged line #8
245 move rearranged line #9
247 git add . &&
248 git rm -r src/move/unchanged &&
249 git rm -r src/move/changed &&
250 git rm -r src/move/rearranged &&
251 git commit -m "changes"
254 cat <<EOF >expect_diff_stat
255 1 1 changed/text
256 10 0 dst/copy/changed/text
257 10 0 dst/copy/rearranged/text
258 10 0 dst/copy/unchanged/text
259 10 0 dst/move/changed/text
260 10 0 dst/move/rearranged/text
261 10 0 dst/move/unchanged/text
262 1 1 rearranged/text
263 0 10 src/move/changed/text
264 0 10 src/move/rearranged/text
265 0 10 src/move/unchanged/text
268 cat <<EOF >expect_diff_stat_M
269 1 1 changed/text
270 10 0 dst/copy/changed/text
271 10 0 dst/copy/rearranged/text
272 10 0 dst/copy/unchanged/text
273 1 1 {src => dst}/move/changed/text
274 1 1 {src => dst}/move/rearranged/text
275 0 0 {src => dst}/move/unchanged/text
276 1 1 rearranged/text
279 cat <<EOF >expect_diff_stat_CC
280 1 1 changed/text
281 1 1 {src => dst}/copy/changed/text
282 1 1 {src => dst}/copy/rearranged/text
283 0 0 {src => dst}/copy/unchanged/text
284 1 1 {src => dst}/move/changed/text
285 1 1 {src => dst}/move/rearranged/text
286 0 0 {src => dst}/move/unchanged/text
287 1 1 rearranged/text
290 test_expect_success 'sanity check setup (--numstat)' '
291 git diff --numstat HEAD^..HEAD >actual_diff_stat &&
292 test_cmp expect_diff_stat actual_diff_stat &&
293 git diff --numstat -M HEAD^..HEAD >actual_diff_stat_M &&
294 test_cmp expect_diff_stat_M actual_diff_stat_M &&
295 git diff --numstat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
296 test_cmp expect_diff_stat_CC actual_diff_stat_CC
299 # changed/text and rearranged/text falls below default 3% threshold
300 cat <<EOF >expect_diff_dirstat
301 10.8% dst/copy/changed/
302 10.8% dst/copy/rearranged/
303 10.8% dst/copy/unchanged/
304 10.8% dst/move/changed/
305 10.8% dst/move/rearranged/
306 10.8% dst/move/unchanged/
307 10.8% src/move/changed/
308 10.8% src/move/rearranged/
309 10.8% src/move/unchanged/
312 # rearranged/text falls below default 3% threshold
313 cat <<EOF >expect_diff_dirstat_M
314 5.8% changed/
315 29.3% dst/copy/changed/
316 29.3% dst/copy/rearranged/
317 29.3% dst/copy/unchanged/
318 5.8% dst/move/changed/
321 # rearranged/text falls below default 3% threshold
322 cat <<EOF >expect_diff_dirstat_CC
323 32.6% changed/
324 32.6% dst/copy/changed/
325 32.6% dst/move/changed/
328 test_expect_success 'various ways to misspell --dirstat' '
329 test_must_fail git show --dirstat10 &&
330 test_must_fail git show --dirstat10,files &&
331 test_must_fail git show -X=20 &&
332 test_must_fail git show -X=20,cumulative
335 test_expect_success 'vanilla --dirstat' '
336 git diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
337 test_cmp expect_diff_dirstat actual_diff_dirstat &&
338 git diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
339 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
340 git diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
341 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
344 test_expect_success 'vanilla -X' '
345 git diff -X HEAD^..HEAD >actual_diff_dirstat &&
346 test_cmp expect_diff_dirstat actual_diff_dirstat &&
347 git diff -X -M HEAD^..HEAD >actual_diff_dirstat_M &&
348 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
349 git diff -X -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
350 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
353 test_expect_success 'explicit defaults: --dirstat=changes,noncumulative,3' '
354 git diff --dirstat=changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
355 test_cmp expect_diff_dirstat actual_diff_dirstat &&
356 git diff --dirstat=changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
357 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
358 git diff --dirstat=changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
359 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
362 test_expect_success 'explicit defaults: -Xchanges,noncumulative,3' '
363 git diff -Xchanges,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
364 test_cmp expect_diff_dirstat actual_diff_dirstat &&
365 git diff -Xchanges,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
366 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
367 git diff -Xchanges,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
368 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
371 test_expect_success 'later options override earlier options:' '
372 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
373 test_cmp expect_diff_dirstat actual_diff_dirstat &&
374 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
375 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
376 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
377 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
378 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 HEAD^..HEAD >actual_diff_dirstat &&
379 test_cmp expect_diff_dirstat actual_diff_dirstat &&
380 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
381 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
382 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
383 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
386 test_expect_success 'non-defaults in config overridden by explicit defaults on command line' '
387 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
388 test_cmp expect_diff_dirstat actual_diff_dirstat &&
389 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
390 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
391 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
392 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
395 cat <<EOF >expect_diff_dirstat
396 2.1% changed/
397 10.8% dst/copy/changed/
398 10.8% dst/copy/rearranged/
399 10.8% dst/copy/unchanged/
400 10.8% dst/move/changed/
401 10.8% dst/move/rearranged/
402 10.8% dst/move/unchanged/
403 0.0% rearranged/
404 10.8% src/move/changed/
405 10.8% src/move/rearranged/
406 10.8% src/move/unchanged/
409 cat <<EOF >expect_diff_dirstat_M
410 5.8% changed/
411 29.3% dst/copy/changed/
412 29.3% dst/copy/rearranged/
413 29.3% dst/copy/unchanged/
414 5.8% dst/move/changed/
415 0.1% dst/move/rearranged/
416 0.1% rearranged/
419 cat <<EOF >expect_diff_dirstat_CC
420 32.6% changed/
421 32.6% dst/copy/changed/
422 0.6% dst/copy/rearranged/
423 32.6% dst/move/changed/
424 0.6% dst/move/rearranged/
425 0.6% rearranged/
428 test_expect_success '--dirstat=0' '
429 git diff --dirstat=0 HEAD^..HEAD >actual_diff_dirstat &&
430 test_cmp expect_diff_dirstat actual_diff_dirstat &&
431 git diff --dirstat=0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
432 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
433 git diff --dirstat=0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
434 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
437 test_expect_success '-X0' '
438 git diff -X0 HEAD^..HEAD >actual_diff_dirstat &&
439 test_cmp expect_diff_dirstat actual_diff_dirstat &&
440 git diff -X0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
441 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
442 git diff -X0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
443 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
446 test_expect_success 'diff.dirstat=0' '
447 git -c diff.dirstat=0 diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
448 test_cmp expect_diff_dirstat actual_diff_dirstat &&
449 git -c diff.dirstat=0 diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
450 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
451 git -c diff.dirstat=0 diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
452 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
455 cat <<EOF >expect_diff_dirstat
456 2.1% changed/
457 10.8% dst/copy/changed/
458 10.8% dst/copy/rearranged/
459 10.8% dst/copy/unchanged/
460 32.5% dst/copy/
461 10.8% dst/move/changed/
462 10.8% dst/move/rearranged/
463 10.8% dst/move/unchanged/
464 32.5% dst/move/
465 65.1% dst/
466 0.0% rearranged/
467 10.8% src/move/changed/
468 10.8% src/move/rearranged/
469 10.8% src/move/unchanged/
470 32.5% src/move/
473 cat <<EOF >expect_diff_dirstat_M
474 5.8% changed/
475 29.3% dst/copy/changed/
476 29.3% dst/copy/rearranged/
477 29.3% dst/copy/unchanged/
478 88.0% dst/copy/
479 5.8% dst/move/changed/
480 0.1% dst/move/rearranged/
481 5.9% dst/move/
482 94.0% dst/
483 0.1% rearranged/
486 cat <<EOF >expect_diff_dirstat_CC
487 32.6% changed/
488 32.6% dst/copy/changed/
489 0.6% dst/copy/rearranged/
490 33.3% dst/copy/
491 32.6% dst/move/changed/
492 0.6% dst/move/rearranged/
493 33.3% dst/move/
494 66.6% dst/
495 0.6% rearranged/
498 test_expect_success '--dirstat=0 --cumulative' '
499 git diff --dirstat=0 --cumulative HEAD^..HEAD >actual_diff_dirstat &&
500 test_cmp expect_diff_dirstat actual_diff_dirstat &&
501 git diff --dirstat=0 --cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
502 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
503 git diff --dirstat=0 --cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
504 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
507 test_expect_success '--dirstat=0,cumulative' '
508 git diff --dirstat=0,cumulative HEAD^..HEAD >actual_diff_dirstat &&
509 test_cmp expect_diff_dirstat actual_diff_dirstat &&
510 git diff --dirstat=0,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
511 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
512 git diff --dirstat=0,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
513 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
516 test_expect_success '-X0,cumulative' '
517 git diff -X0,cumulative HEAD^..HEAD >actual_diff_dirstat &&
518 test_cmp expect_diff_dirstat actual_diff_dirstat &&
519 git diff -X0,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
520 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
521 git diff -X0,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
522 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
525 test_expect_success 'diff.dirstat=0,cumulative' '
526 git -c diff.dirstat=0,cumulative diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
527 test_cmp expect_diff_dirstat actual_diff_dirstat &&
528 git -c diff.dirstat=0,cumulative diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
529 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
530 git -c diff.dirstat=0,cumulative diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
531 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
534 test_expect_success 'diff.dirstat=0 & --dirstat=cumulative' '
535 git -c diff.dirstat=0 diff --dirstat=cumulative HEAD^..HEAD >actual_diff_dirstat &&
536 test_cmp expect_diff_dirstat actual_diff_dirstat &&
537 git -c diff.dirstat=0 diff --dirstat=cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
538 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
539 git -c diff.dirstat=0 diff --dirstat=cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
540 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
543 cat <<EOF >expect_diff_dirstat
544 9.0% changed/
545 9.0% dst/copy/changed/
546 9.0% dst/copy/rearranged/
547 9.0% dst/copy/unchanged/
548 9.0% dst/move/changed/
549 9.0% dst/move/rearranged/
550 9.0% dst/move/unchanged/
551 9.0% rearranged/
552 9.0% src/move/changed/
553 9.0% src/move/rearranged/
554 9.0% src/move/unchanged/
557 cat <<EOF >expect_diff_dirstat_M
558 14.2% changed/
559 14.2% dst/copy/changed/
560 14.2% dst/copy/rearranged/
561 14.2% dst/copy/unchanged/
562 14.2% dst/move/changed/
563 14.2% dst/move/rearranged/
564 14.2% rearranged/
567 cat <<EOF >expect_diff_dirstat_CC
568 16.6% changed/
569 16.6% dst/copy/changed/
570 16.6% dst/copy/rearranged/
571 16.6% dst/move/changed/
572 16.6% dst/move/rearranged/
573 16.6% rearranged/
576 test_expect_success '--dirstat-by-file' '
577 git diff --dirstat-by-file HEAD^..HEAD >actual_diff_dirstat &&
578 test_cmp expect_diff_dirstat actual_diff_dirstat &&
579 git diff --dirstat-by-file -M HEAD^..HEAD >actual_diff_dirstat_M &&
580 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
581 git diff --dirstat-by-file -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
582 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
585 test_expect_success '--dirstat=files' '
586 git diff --dirstat=files HEAD^..HEAD >actual_diff_dirstat &&
587 test_cmp expect_diff_dirstat actual_diff_dirstat &&
588 git diff --dirstat=files -M HEAD^..HEAD >actual_diff_dirstat_M &&
589 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
590 git diff --dirstat=files -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
591 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
594 test_expect_success 'diff.dirstat=files' '
595 git -c diff.dirstat=files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
596 test_cmp expect_diff_dirstat actual_diff_dirstat &&
597 git -c diff.dirstat=files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
598 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
599 git -c diff.dirstat=files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
600 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
603 cat <<EOF >expect_diff_dirstat
604 27.2% dst/copy/
605 27.2% dst/move/
606 27.2% src/move/
609 cat <<EOF >expect_diff_dirstat_M
610 14.2% changed/
611 14.2% dst/copy/changed/
612 14.2% dst/copy/rearranged/
613 14.2% dst/copy/unchanged/
614 14.2% dst/move/changed/
615 14.2% dst/move/rearranged/
616 14.2% rearranged/
619 cat <<EOF >expect_diff_dirstat_CC
620 16.6% changed/
621 16.6% dst/copy/changed/
622 16.6% dst/copy/rearranged/
623 16.6% dst/move/changed/
624 16.6% dst/move/rearranged/
625 16.6% rearranged/
628 test_expect_success '--dirstat-by-file=10' '
629 git diff --dirstat-by-file=10 HEAD^..HEAD >actual_diff_dirstat &&
630 test_cmp expect_diff_dirstat actual_diff_dirstat &&
631 git diff --dirstat-by-file=10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
632 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
633 git diff --dirstat-by-file=10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
634 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
637 test_expect_success '--dirstat=files,10' '
638 git diff --dirstat=files,10 HEAD^..HEAD >actual_diff_dirstat &&
639 test_cmp expect_diff_dirstat actual_diff_dirstat &&
640 git diff --dirstat=files,10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
641 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
642 git diff --dirstat=files,10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
643 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
646 test_expect_success 'diff.dirstat=10,files' '
647 git -c diff.dirstat=10,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
648 test_cmp expect_diff_dirstat actual_diff_dirstat &&
649 git -c diff.dirstat=10,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
650 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
651 git -c diff.dirstat=10,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
652 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
655 cat <<EOF >expect_diff_dirstat
656 9.0% changed/
657 9.0% dst/copy/changed/
658 9.0% dst/copy/rearranged/
659 9.0% dst/copy/unchanged/
660 27.2% dst/copy/
661 9.0% dst/move/changed/
662 9.0% dst/move/rearranged/
663 9.0% dst/move/unchanged/
664 27.2% dst/move/
665 54.5% dst/
666 9.0% rearranged/
667 9.0% src/move/changed/
668 9.0% src/move/rearranged/
669 9.0% src/move/unchanged/
670 27.2% src/move/
673 cat <<EOF >expect_diff_dirstat_M
674 14.2% changed/
675 14.2% dst/copy/changed/
676 14.2% dst/copy/rearranged/
677 14.2% dst/copy/unchanged/
678 42.8% dst/copy/
679 14.2% dst/move/changed/
680 14.2% dst/move/rearranged/
681 28.5% dst/move/
682 71.4% dst/
683 14.2% rearranged/
686 cat <<EOF >expect_diff_dirstat_CC
687 16.6% changed/
688 16.6% dst/copy/changed/
689 16.6% dst/copy/rearranged/
690 33.3% dst/copy/
691 16.6% dst/move/changed/
692 16.6% dst/move/rearranged/
693 33.3% dst/move/
694 66.6% dst/
695 16.6% rearranged/
698 test_expect_success '--dirstat-by-file --cumulative' '
699 git diff --dirstat-by-file --cumulative HEAD^..HEAD >actual_diff_dirstat &&
700 test_cmp expect_diff_dirstat actual_diff_dirstat &&
701 git diff --dirstat-by-file --cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
702 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
703 git diff --dirstat-by-file --cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
704 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
707 test_expect_success '--dirstat=files,cumulative' '
708 git diff --dirstat=files,cumulative HEAD^..HEAD >actual_diff_dirstat &&
709 test_cmp expect_diff_dirstat actual_diff_dirstat &&
710 git diff --dirstat=files,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
711 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
712 git diff --dirstat=files,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
713 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
716 test_expect_success 'diff.dirstat=cumulative,files' '
717 git -c diff.dirstat=cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
718 test_cmp expect_diff_dirstat actual_diff_dirstat &&
719 git -c diff.dirstat=cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
720 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
721 git -c diff.dirstat=cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
722 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
725 cat <<EOF >expect_diff_dirstat
726 27.2% dst/copy/
727 27.2% dst/move/
728 54.5% dst/
729 27.2% src/move/
732 cat <<EOF >expect_diff_dirstat_M
733 14.2% changed/
734 14.2% dst/copy/changed/
735 14.2% dst/copy/rearranged/
736 14.2% dst/copy/unchanged/
737 42.8% dst/copy/
738 14.2% dst/move/changed/
739 14.2% dst/move/rearranged/
740 28.5% dst/move/
741 71.4% dst/
742 14.2% rearranged/
745 cat <<EOF >expect_diff_dirstat_CC
746 16.6% changed/
747 16.6% dst/copy/changed/
748 16.6% dst/copy/rearranged/
749 33.3% dst/copy/
750 16.6% dst/move/changed/
751 16.6% dst/move/rearranged/
752 33.3% dst/move/
753 66.6% dst/
754 16.6% rearranged/
757 test_expect_success '--dirstat=files,cumulative,10' '
758 git diff --dirstat=files,cumulative,10 HEAD^..HEAD >actual_diff_dirstat &&
759 test_cmp expect_diff_dirstat actual_diff_dirstat &&
760 git diff --dirstat=files,cumulative,10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
761 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
762 git diff --dirstat=files,cumulative,10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
763 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
766 test_expect_success 'diff.dirstat=10,cumulative,files' '
767 git -c diff.dirstat=10,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
768 test_cmp expect_diff_dirstat actual_diff_dirstat &&
769 git -c diff.dirstat=10,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
770 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
771 git -c diff.dirstat=10,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
772 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
775 cat <<EOF >expect_diff_dirstat
776 27.2% dst/copy/
777 27.2% dst/move/
778 54.5% dst/
779 27.2% src/move/
782 cat <<EOF >expect_diff_dirstat_M
783 42.8% dst/copy/
784 28.5% dst/move/
785 71.4% dst/
788 cat <<EOF >expect_diff_dirstat_CC
789 33.3% dst/copy/
790 33.3% dst/move/
791 66.6% dst/
794 test_expect_success '--dirstat=files,cumulative,16.7' '
795 git diff --dirstat=files,cumulative,16.7 HEAD^..HEAD >actual_diff_dirstat &&
796 test_cmp expect_diff_dirstat actual_diff_dirstat &&
797 git diff --dirstat=files,cumulative,16.7 -M HEAD^..HEAD >actual_diff_dirstat_M &&
798 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
799 git diff --dirstat=files,cumulative,16.7 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
800 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
803 test_expect_success 'diff.dirstat=16.7,cumulative,files' '
804 git -c diff.dirstat=16.7,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
805 test_cmp expect_diff_dirstat actual_diff_dirstat &&
806 git -c diff.dirstat=16.7,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
807 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
808 git -c diff.dirstat=16.7,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
809 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
812 test_expect_success 'diff.dirstat=16.70,cumulative,files' '
813 git -c diff.dirstat=16.70,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
814 test_cmp expect_diff_dirstat actual_diff_dirstat &&
815 git -c diff.dirstat=16.70,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
816 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
817 git -c diff.dirstat=16.70,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
818 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
821 test_expect_success '--dirstat=files,cumulative,27.2' '
822 git diff --dirstat=files,cumulative,27.2 HEAD^..HEAD >actual_diff_dirstat &&
823 test_cmp expect_diff_dirstat actual_diff_dirstat &&
824 git diff --dirstat=files,cumulative,27.2 -M HEAD^..HEAD >actual_diff_dirstat_M &&
825 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
826 git diff --dirstat=files,cumulative,27.2 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
827 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
830 test_expect_success '--dirstat=files,cumulative,27.09' '
831 git diff --dirstat=files,cumulative,27.09 HEAD^..HEAD >actual_diff_dirstat &&
832 test_cmp expect_diff_dirstat actual_diff_dirstat &&
833 git diff --dirstat=files,cumulative,27.09 -M HEAD^..HEAD >actual_diff_dirstat_M &&
834 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
835 git diff --dirstat=files,cumulative,27.09 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
836 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
839 cat <<EOF >expect_diff_dirstat
840 10.6% dst/copy/changed/
841 10.6% dst/copy/rearranged/
842 10.6% dst/copy/unchanged/
843 10.6% dst/move/changed/
844 10.6% dst/move/rearranged/
845 10.6% dst/move/unchanged/
846 10.6% src/move/changed/
847 10.6% src/move/rearranged/
848 10.6% src/move/unchanged/
851 cat <<EOF >expect_diff_dirstat_M
852 5.2% changed/
853 26.3% dst/copy/changed/
854 26.3% dst/copy/rearranged/
855 26.3% dst/copy/unchanged/
856 5.2% dst/move/changed/
857 5.2% dst/move/rearranged/
858 5.2% rearranged/
861 cat <<EOF >expect_diff_dirstat_CC
862 16.6% changed/
863 16.6% dst/copy/changed/
864 16.6% dst/copy/rearranged/
865 16.6% dst/move/changed/
866 16.6% dst/move/rearranged/
867 16.6% rearranged/
870 test_expect_success '--dirstat=lines' '
871 git diff --dirstat=lines HEAD^..HEAD >actual_diff_dirstat &&
872 test_cmp expect_diff_dirstat actual_diff_dirstat &&
873 git diff --dirstat=lines -M HEAD^..HEAD >actual_diff_dirstat_M &&
874 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
875 git diff --dirstat=lines -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
876 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
879 test_expect_success 'diff.dirstat=lines' '
880 git -c diff.dirstat=lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
881 test_cmp expect_diff_dirstat actual_diff_dirstat &&
882 git -c diff.dirstat=lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
883 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
884 git -c diff.dirstat=lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
885 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
888 cat <<EOF >expect_diff_dirstat
889 2.1% changed/
890 10.6% dst/copy/changed/
891 10.6% dst/copy/rearranged/
892 10.6% dst/copy/unchanged/
893 10.6% dst/move/changed/
894 10.6% dst/move/rearranged/
895 10.6% dst/move/unchanged/
896 2.1% rearranged/
897 10.6% src/move/changed/
898 10.6% src/move/rearranged/
899 10.6% src/move/unchanged/
902 cat <<EOF >expect_diff_dirstat_M
903 5.2% changed/
904 26.3% dst/copy/changed/
905 26.3% dst/copy/rearranged/
906 26.3% dst/copy/unchanged/
907 5.2% dst/move/changed/
908 5.2% dst/move/rearranged/
909 5.2% rearranged/
912 cat <<EOF >expect_diff_dirstat_CC
913 16.6% changed/
914 16.6% dst/copy/changed/
915 16.6% dst/copy/rearranged/
916 16.6% dst/move/changed/
917 16.6% dst/move/rearranged/
918 16.6% rearranged/
921 test_expect_success '--dirstat=lines,0' '
922 git diff --dirstat=lines,0 HEAD^..HEAD >actual_diff_dirstat &&
923 test_cmp expect_diff_dirstat actual_diff_dirstat &&
924 git diff --dirstat=lines,0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
925 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
926 git diff --dirstat=lines,0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
927 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
930 test_expect_success 'diff.dirstat=0,lines' '
931 git -c diff.dirstat=0,lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
932 test_cmp expect_diff_dirstat actual_diff_dirstat &&
933 git -c diff.dirstat=0,lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
934 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
935 git -c diff.dirstat=0,lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
936 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
939 test_expect_success '--dirstat=future_param,lines,0 should fail loudly' '
940 test_must_fail git diff --dirstat=future_param,lines,0 HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
941 test_debug "cat actual_error" &&
942 test_cmp /dev/null actual_diff_dirstat &&
943 test_i18ngrep -q "future_param" actual_error &&
944 test_i18ngrep -q "\--dirstat" actual_error
947 test_expect_success '--dirstat=dummy1,cumulative,2dummy should report both unrecognized parameters' '
948 test_must_fail git diff --dirstat=dummy1,cumulative,2dummy HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
949 test_debug "cat actual_error" &&
950 test_cmp /dev/null actual_diff_dirstat &&
951 test_i18ngrep -q "dummy1" actual_error &&
952 test_i18ngrep -q "2dummy" actual_error &&
953 test_i18ngrep -q "\--dirstat" actual_error
956 test_expect_success 'diff.dirstat=future_param,0,lines should warn, but still work' '
957 git -c diff.dirstat=future_param,0,lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
958 test_debug "cat actual_error" &&
959 test_cmp expect_diff_dirstat actual_diff_dirstat &&
960 test_i18ngrep -q "future_param" actual_error &&
961 test_i18ngrep -q "diff\\.dirstat" actual_error &&
963 git -c diff.dirstat=future_param,0,lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M 2>actual_error &&
964 test_debug "cat actual_error" &&
965 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
966 test_i18ngrep -q "future_param" actual_error &&
967 test_i18ngrep -q "diff\\.dirstat" actual_error &&
969 git -c diff.dirstat=future_param,0,lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC 2>actual_error &&
970 test_debug "cat actual_error" &&
971 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC &&
972 test_i18ngrep -q "future_param" actual_error &&
973 test_i18ngrep -q "diff\\.dirstat" actual_error
976 test_done