l10n: bg.po: Updated Bulgarian translation (4839t)
[git/debian.git] / t / t4047-diff-dirstat.sh
blob7fec2cb9cd783f5aeff27236c8e54ddb2241e1be
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" &&
252 git config diff.renames false
255 cat <<EOF >expect_diff_stat
256 1 1 changed/text
257 10 0 dst/copy/changed/text
258 10 0 dst/copy/rearranged/text
259 10 0 dst/copy/unchanged/text
260 10 0 dst/move/changed/text
261 10 0 dst/move/rearranged/text
262 10 0 dst/move/unchanged/text
263 1 1 rearranged/text
264 0 10 src/move/changed/text
265 0 10 src/move/rearranged/text
266 0 10 src/move/unchanged/text
269 cat <<EOF >expect_diff_stat_M
270 1 1 changed/text
271 10 0 dst/copy/changed/text
272 10 0 dst/copy/rearranged/text
273 10 0 dst/copy/unchanged/text
274 1 1 {src => dst}/move/changed/text
275 1 1 {src => dst}/move/rearranged/text
276 0 0 {src => dst}/move/unchanged/text
277 1 1 rearranged/text
280 cat <<EOF >expect_diff_stat_CC
281 1 1 changed/text
282 1 1 {src => dst}/copy/changed/text
283 1 1 {src => dst}/copy/rearranged/text
284 0 0 {src => dst}/copy/unchanged/text
285 1 1 {src => dst}/move/changed/text
286 1 1 {src => dst}/move/rearranged/text
287 0 0 {src => dst}/move/unchanged/text
288 1 1 rearranged/text
291 test_expect_success 'sanity check setup (--numstat)' '
292 git diff --numstat HEAD^..HEAD >actual_diff_stat &&
293 test_cmp expect_diff_stat actual_diff_stat &&
294 git diff --numstat -M HEAD^..HEAD >actual_diff_stat_M &&
295 test_cmp expect_diff_stat_M actual_diff_stat_M &&
296 git diff --numstat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
297 test_cmp expect_diff_stat_CC actual_diff_stat_CC
300 # changed/text and rearranged/text falls below default 3% threshold
301 cat <<EOF >expect_diff_dirstat
302 10.8% dst/copy/changed/
303 10.8% dst/copy/rearranged/
304 10.8% dst/copy/unchanged/
305 10.8% dst/move/changed/
306 10.8% dst/move/rearranged/
307 10.8% dst/move/unchanged/
308 10.8% src/move/changed/
309 10.8% src/move/rearranged/
310 10.8% src/move/unchanged/
313 # rearranged/text falls below default 3% threshold
314 cat <<EOF >expect_diff_dirstat_M
315 5.8% changed/
316 29.3% dst/copy/changed/
317 29.3% dst/copy/rearranged/
318 29.3% dst/copy/unchanged/
319 5.8% dst/move/changed/
322 # rearranged/text falls below default 3% threshold
323 cat <<EOF >expect_diff_dirstat_CC
324 32.6% changed/
325 32.6% dst/copy/changed/
326 32.6% dst/move/changed/
329 test_expect_success 'various ways to misspell --dirstat' '
330 test_must_fail git show --dirstat10 &&
331 test_must_fail git show --dirstat10,files &&
332 test_must_fail git show -X=20 &&
333 test_must_fail git show -X=20,cumulative
336 test_expect_success 'vanilla --dirstat' '
337 git diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
338 test_cmp expect_diff_dirstat actual_diff_dirstat &&
339 git diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
340 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
341 git diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
342 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
345 test_expect_success 'vanilla -X' '
346 git diff -X HEAD^..HEAD >actual_diff_dirstat &&
347 test_cmp expect_diff_dirstat actual_diff_dirstat &&
348 git diff -X -M HEAD^..HEAD >actual_diff_dirstat_M &&
349 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
350 git diff -X -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
351 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
354 test_expect_success 'explicit defaults: --dirstat=changes,noncumulative,3' '
355 git diff --dirstat=changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
356 test_cmp expect_diff_dirstat actual_diff_dirstat &&
357 git diff --dirstat=changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
358 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
359 git diff --dirstat=changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
360 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
363 test_expect_success 'explicit defaults: -Xchanges,noncumulative,3' '
364 git diff -Xchanges,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
365 test_cmp expect_diff_dirstat actual_diff_dirstat &&
366 git diff -Xchanges,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
367 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
368 git diff -Xchanges,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
369 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
372 test_expect_success 'later options override earlier options:' '
373 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
374 test_cmp expect_diff_dirstat actual_diff_dirstat &&
375 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
376 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
377 git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
378 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC &&
379 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 HEAD^..HEAD >actual_diff_dirstat &&
380 test_cmp expect_diff_dirstat actual_diff_dirstat &&
381 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
382 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
383 git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
384 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
387 test_expect_success 'non-defaults in config overridden by explicit defaults on command line' '
388 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
389 test_cmp expect_diff_dirstat actual_diff_dirstat &&
390 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
391 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
392 git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
393 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
396 cat <<EOF >expect_diff_dirstat
397 2.1% changed/
398 10.8% dst/copy/changed/
399 10.8% dst/copy/rearranged/
400 10.8% dst/copy/unchanged/
401 10.8% dst/move/changed/
402 10.8% dst/move/rearranged/
403 10.8% dst/move/unchanged/
404 0.0% rearranged/
405 10.8% src/move/changed/
406 10.8% src/move/rearranged/
407 10.8% src/move/unchanged/
410 cat <<EOF >expect_diff_dirstat_M
411 5.8% changed/
412 29.3% dst/copy/changed/
413 29.3% dst/copy/rearranged/
414 29.3% dst/copy/unchanged/
415 5.8% dst/move/changed/
416 0.1% dst/move/rearranged/
417 0.1% rearranged/
420 cat <<EOF >expect_diff_dirstat_CC
421 32.6% changed/
422 32.6% dst/copy/changed/
423 0.6% dst/copy/rearranged/
424 32.6% dst/move/changed/
425 0.6% dst/move/rearranged/
426 0.6% rearranged/
429 test_expect_success '--dirstat=0' '
430 git diff --dirstat=0 HEAD^..HEAD >actual_diff_dirstat &&
431 test_cmp expect_diff_dirstat actual_diff_dirstat &&
432 git diff --dirstat=0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
433 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
434 git diff --dirstat=0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
435 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
438 test_expect_success '-X0' '
439 git diff -X0 HEAD^..HEAD >actual_diff_dirstat &&
440 test_cmp expect_diff_dirstat actual_diff_dirstat &&
441 git diff -X0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
442 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
443 git diff -X0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
444 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
447 test_expect_success 'diff.dirstat=0' '
448 git -c diff.dirstat=0 diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
449 test_cmp expect_diff_dirstat actual_diff_dirstat &&
450 git -c diff.dirstat=0 diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
451 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
452 git -c diff.dirstat=0 diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
453 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
456 cat <<EOF >expect_diff_dirstat
457 2.1% changed/
458 10.8% dst/copy/changed/
459 10.8% dst/copy/rearranged/
460 10.8% dst/copy/unchanged/
461 32.5% dst/copy/
462 10.8% dst/move/changed/
463 10.8% dst/move/rearranged/
464 10.8% dst/move/unchanged/
465 32.5% dst/move/
466 65.1% dst/
467 0.0% rearranged/
468 10.8% src/move/changed/
469 10.8% src/move/rearranged/
470 10.8% src/move/unchanged/
471 32.5% src/move/
474 cat <<EOF >expect_diff_dirstat_M
475 5.8% changed/
476 29.3% dst/copy/changed/
477 29.3% dst/copy/rearranged/
478 29.3% dst/copy/unchanged/
479 88.0% dst/copy/
480 5.8% dst/move/changed/
481 0.1% dst/move/rearranged/
482 5.9% dst/move/
483 94.0% dst/
484 0.1% rearranged/
487 cat <<EOF >expect_diff_dirstat_CC
488 32.6% changed/
489 32.6% dst/copy/changed/
490 0.6% dst/copy/rearranged/
491 33.3% dst/copy/
492 32.6% dst/move/changed/
493 0.6% dst/move/rearranged/
494 33.3% dst/move/
495 66.6% dst/
496 0.6% rearranged/
499 test_expect_success '--dirstat=0 --cumulative' '
500 git diff --dirstat=0 --cumulative HEAD^..HEAD >actual_diff_dirstat &&
501 test_cmp expect_diff_dirstat actual_diff_dirstat &&
502 git diff --dirstat=0 --cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
503 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
504 git diff --dirstat=0 --cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
505 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
508 test_expect_success '--dirstat=0,cumulative' '
509 git diff --dirstat=0,cumulative HEAD^..HEAD >actual_diff_dirstat &&
510 test_cmp expect_diff_dirstat actual_diff_dirstat &&
511 git diff --dirstat=0,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
512 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
513 git diff --dirstat=0,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
514 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
517 test_expect_success '-X0,cumulative' '
518 git diff -X0,cumulative HEAD^..HEAD >actual_diff_dirstat &&
519 test_cmp expect_diff_dirstat actual_diff_dirstat &&
520 git diff -X0,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
521 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
522 git diff -X0,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
523 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
526 test_expect_success 'diff.dirstat=0,cumulative' '
527 git -c diff.dirstat=0,cumulative diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
528 test_cmp expect_diff_dirstat actual_diff_dirstat &&
529 git -c diff.dirstat=0,cumulative diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
530 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
531 git -c diff.dirstat=0,cumulative diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
532 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
535 test_expect_success 'diff.dirstat=0 & --dirstat=cumulative' '
536 git -c diff.dirstat=0 diff --dirstat=cumulative HEAD^..HEAD >actual_diff_dirstat &&
537 test_cmp expect_diff_dirstat actual_diff_dirstat &&
538 git -c diff.dirstat=0 diff --dirstat=cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
539 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
540 git -c diff.dirstat=0 diff --dirstat=cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
541 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
544 cat <<EOF >expect_diff_dirstat
545 9.0% changed/
546 9.0% dst/copy/changed/
547 9.0% dst/copy/rearranged/
548 9.0% dst/copy/unchanged/
549 9.0% dst/move/changed/
550 9.0% dst/move/rearranged/
551 9.0% dst/move/unchanged/
552 9.0% rearranged/
553 9.0% src/move/changed/
554 9.0% src/move/rearranged/
555 9.0% src/move/unchanged/
558 cat <<EOF >expect_diff_dirstat_M
559 14.2% changed/
560 14.2% dst/copy/changed/
561 14.2% dst/copy/rearranged/
562 14.2% dst/copy/unchanged/
563 14.2% dst/move/changed/
564 14.2% dst/move/rearranged/
565 14.2% rearranged/
568 cat <<EOF >expect_diff_dirstat_CC
569 16.6% changed/
570 16.6% dst/copy/changed/
571 16.6% dst/copy/rearranged/
572 16.6% dst/move/changed/
573 16.6% dst/move/rearranged/
574 16.6% rearranged/
577 test_expect_success '--dirstat-by-file' '
578 git diff --dirstat-by-file HEAD^..HEAD >actual_diff_dirstat &&
579 test_cmp expect_diff_dirstat actual_diff_dirstat &&
580 git diff --dirstat-by-file -M HEAD^..HEAD >actual_diff_dirstat_M &&
581 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
582 git diff --dirstat-by-file -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
583 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
586 test_expect_success '--dirstat=files' '
587 git diff --dirstat=files HEAD^..HEAD >actual_diff_dirstat &&
588 test_cmp expect_diff_dirstat actual_diff_dirstat &&
589 git diff --dirstat=files -M HEAD^..HEAD >actual_diff_dirstat_M &&
590 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
591 git diff --dirstat=files -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
592 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
595 test_expect_success 'diff.dirstat=files' '
596 git -c diff.dirstat=files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
597 test_cmp expect_diff_dirstat actual_diff_dirstat &&
598 git -c diff.dirstat=files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
599 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
600 git -c diff.dirstat=files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
601 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
604 cat <<EOF >expect_diff_dirstat
605 27.2% dst/copy/
606 27.2% dst/move/
607 27.2% src/move/
610 cat <<EOF >expect_diff_dirstat_M
611 14.2% changed/
612 14.2% dst/copy/changed/
613 14.2% dst/copy/rearranged/
614 14.2% dst/copy/unchanged/
615 14.2% dst/move/changed/
616 14.2% dst/move/rearranged/
617 14.2% rearranged/
620 cat <<EOF >expect_diff_dirstat_CC
621 16.6% changed/
622 16.6% dst/copy/changed/
623 16.6% dst/copy/rearranged/
624 16.6% dst/move/changed/
625 16.6% dst/move/rearranged/
626 16.6% rearranged/
629 test_expect_success '--dirstat-by-file=10' '
630 git diff --dirstat-by-file=10 HEAD^..HEAD >actual_diff_dirstat &&
631 test_cmp expect_diff_dirstat actual_diff_dirstat &&
632 git diff --dirstat-by-file=10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
633 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
634 git diff --dirstat-by-file=10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
635 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
638 test_expect_success '--dirstat=files,10' '
639 git diff --dirstat=files,10 HEAD^..HEAD >actual_diff_dirstat &&
640 test_cmp expect_diff_dirstat actual_diff_dirstat &&
641 git diff --dirstat=files,10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
642 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
643 git diff --dirstat=files,10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
644 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
647 test_expect_success 'diff.dirstat=10,files' '
648 git -c diff.dirstat=10,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
649 test_cmp expect_diff_dirstat actual_diff_dirstat &&
650 git -c diff.dirstat=10,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
651 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
652 git -c diff.dirstat=10,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
653 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
656 cat <<EOF >expect_diff_dirstat
657 9.0% changed/
658 9.0% dst/copy/changed/
659 9.0% dst/copy/rearranged/
660 9.0% dst/copy/unchanged/
661 27.2% dst/copy/
662 9.0% dst/move/changed/
663 9.0% dst/move/rearranged/
664 9.0% dst/move/unchanged/
665 27.2% dst/move/
666 54.5% dst/
667 9.0% rearranged/
668 9.0% src/move/changed/
669 9.0% src/move/rearranged/
670 9.0% src/move/unchanged/
671 27.2% src/move/
674 cat <<EOF >expect_diff_dirstat_M
675 14.2% changed/
676 14.2% dst/copy/changed/
677 14.2% dst/copy/rearranged/
678 14.2% dst/copy/unchanged/
679 42.8% dst/copy/
680 14.2% dst/move/changed/
681 14.2% dst/move/rearranged/
682 28.5% dst/move/
683 71.4% dst/
684 14.2% rearranged/
687 cat <<EOF >expect_diff_dirstat_CC
688 16.6% changed/
689 16.6% dst/copy/changed/
690 16.6% dst/copy/rearranged/
691 33.3% dst/copy/
692 16.6% dst/move/changed/
693 16.6% dst/move/rearranged/
694 33.3% dst/move/
695 66.6% dst/
696 16.6% rearranged/
699 test_expect_success '--dirstat-by-file --cumulative' '
700 git diff --dirstat-by-file --cumulative HEAD^..HEAD >actual_diff_dirstat &&
701 test_cmp expect_diff_dirstat actual_diff_dirstat &&
702 git diff --dirstat-by-file --cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
703 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
704 git diff --dirstat-by-file --cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
705 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
708 test_expect_success '--dirstat=files,cumulative' '
709 git diff --dirstat=files,cumulative HEAD^..HEAD >actual_diff_dirstat &&
710 test_cmp expect_diff_dirstat actual_diff_dirstat &&
711 git diff --dirstat=files,cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
712 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
713 git diff --dirstat=files,cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
714 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
717 test_expect_success 'diff.dirstat=cumulative,files' '
718 git -c diff.dirstat=cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
719 test_cmp expect_diff_dirstat actual_diff_dirstat &&
720 git -c diff.dirstat=cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
721 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
722 git -c diff.dirstat=cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
723 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
726 cat <<EOF >expect_diff_dirstat
727 27.2% dst/copy/
728 27.2% dst/move/
729 54.5% dst/
730 27.2% src/move/
733 cat <<EOF >expect_diff_dirstat_M
734 14.2% changed/
735 14.2% dst/copy/changed/
736 14.2% dst/copy/rearranged/
737 14.2% dst/copy/unchanged/
738 42.8% dst/copy/
739 14.2% dst/move/changed/
740 14.2% dst/move/rearranged/
741 28.5% dst/move/
742 71.4% dst/
743 14.2% rearranged/
746 cat <<EOF >expect_diff_dirstat_CC
747 16.6% changed/
748 16.6% dst/copy/changed/
749 16.6% dst/copy/rearranged/
750 33.3% dst/copy/
751 16.6% dst/move/changed/
752 16.6% dst/move/rearranged/
753 33.3% dst/move/
754 66.6% dst/
755 16.6% rearranged/
758 test_expect_success '--dirstat=files,cumulative,10' '
759 git diff --dirstat=files,cumulative,10 HEAD^..HEAD >actual_diff_dirstat &&
760 test_cmp expect_diff_dirstat actual_diff_dirstat &&
761 git diff --dirstat=files,cumulative,10 -M HEAD^..HEAD >actual_diff_dirstat_M &&
762 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
763 git diff --dirstat=files,cumulative,10 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
764 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
767 test_expect_success 'diff.dirstat=10,cumulative,files' '
768 git -c diff.dirstat=10,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
769 test_cmp expect_diff_dirstat actual_diff_dirstat &&
770 git -c diff.dirstat=10,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
771 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
772 git -c diff.dirstat=10,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
773 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
776 cat <<EOF >expect_diff_dirstat
777 27.2% dst/copy/
778 27.2% dst/move/
779 54.5% dst/
780 27.2% src/move/
783 cat <<EOF >expect_diff_dirstat_M
784 42.8% dst/copy/
785 28.5% dst/move/
786 71.4% dst/
789 cat <<EOF >expect_diff_dirstat_CC
790 33.3% dst/copy/
791 33.3% dst/move/
792 66.6% dst/
795 test_expect_success '--dirstat=files,cumulative,16.7' '
796 git diff --dirstat=files,cumulative,16.7 HEAD^..HEAD >actual_diff_dirstat &&
797 test_cmp expect_diff_dirstat actual_diff_dirstat &&
798 git diff --dirstat=files,cumulative,16.7 -M HEAD^..HEAD >actual_diff_dirstat_M &&
799 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
800 git diff --dirstat=files,cumulative,16.7 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
801 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
804 test_expect_success 'diff.dirstat=16.7,cumulative,files' '
805 git -c diff.dirstat=16.7,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
806 test_cmp expect_diff_dirstat actual_diff_dirstat &&
807 git -c diff.dirstat=16.7,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
808 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
809 git -c diff.dirstat=16.7,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
810 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
813 test_expect_success 'diff.dirstat=16.70,cumulative,files' '
814 git -c diff.dirstat=16.70,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
815 test_cmp expect_diff_dirstat actual_diff_dirstat &&
816 git -c diff.dirstat=16.70,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
817 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
818 git -c diff.dirstat=16.70,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
819 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
822 test_expect_success '--dirstat=files,cumulative,27.2' '
823 git diff --dirstat=files,cumulative,27.2 HEAD^..HEAD >actual_diff_dirstat &&
824 test_cmp expect_diff_dirstat actual_diff_dirstat &&
825 git diff --dirstat=files,cumulative,27.2 -M HEAD^..HEAD >actual_diff_dirstat_M &&
826 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
827 git diff --dirstat=files,cumulative,27.2 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
828 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
831 test_expect_success '--dirstat=files,cumulative,27.09' '
832 git diff --dirstat=files,cumulative,27.09 HEAD^..HEAD >actual_diff_dirstat &&
833 test_cmp expect_diff_dirstat actual_diff_dirstat &&
834 git diff --dirstat=files,cumulative,27.09 -M HEAD^..HEAD >actual_diff_dirstat_M &&
835 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
836 git diff --dirstat=files,cumulative,27.09 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
837 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
840 cat <<EOF >expect_diff_dirstat
841 10.6% dst/copy/changed/
842 10.6% dst/copy/rearranged/
843 10.6% dst/copy/unchanged/
844 10.6% dst/move/changed/
845 10.6% dst/move/rearranged/
846 10.6% dst/move/unchanged/
847 10.6% src/move/changed/
848 10.6% src/move/rearranged/
849 10.6% src/move/unchanged/
852 cat <<EOF >expect_diff_dirstat_M
853 5.2% changed/
854 26.3% dst/copy/changed/
855 26.3% dst/copy/rearranged/
856 26.3% dst/copy/unchanged/
857 5.2% dst/move/changed/
858 5.2% dst/move/rearranged/
859 5.2% rearranged/
862 cat <<EOF >expect_diff_dirstat_CC
863 16.6% changed/
864 16.6% dst/copy/changed/
865 16.6% dst/copy/rearranged/
866 16.6% dst/move/changed/
867 16.6% dst/move/rearranged/
868 16.6% rearranged/
871 test_expect_success '--dirstat=lines' '
872 git diff --dirstat=lines HEAD^..HEAD >actual_diff_dirstat &&
873 test_cmp expect_diff_dirstat actual_diff_dirstat &&
874 git diff --dirstat=lines -M HEAD^..HEAD >actual_diff_dirstat_M &&
875 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
876 git diff --dirstat=lines -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
877 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
880 test_expect_success 'diff.dirstat=lines' '
881 git -c diff.dirstat=lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
882 test_cmp expect_diff_dirstat actual_diff_dirstat &&
883 git -c diff.dirstat=lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
884 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
885 git -c diff.dirstat=lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
886 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
889 cat <<EOF >expect_diff_dirstat
890 2.1% changed/
891 10.6% dst/copy/changed/
892 10.6% dst/copy/rearranged/
893 10.6% dst/copy/unchanged/
894 10.6% dst/move/changed/
895 10.6% dst/move/rearranged/
896 10.6% dst/move/unchanged/
897 2.1% rearranged/
898 10.6% src/move/changed/
899 10.6% src/move/rearranged/
900 10.6% src/move/unchanged/
903 cat <<EOF >expect_diff_dirstat_M
904 5.2% changed/
905 26.3% dst/copy/changed/
906 26.3% dst/copy/rearranged/
907 26.3% dst/copy/unchanged/
908 5.2% dst/move/changed/
909 5.2% dst/move/rearranged/
910 5.2% rearranged/
913 cat <<EOF >expect_diff_dirstat_CC
914 16.6% changed/
915 16.6% dst/copy/changed/
916 16.6% dst/copy/rearranged/
917 16.6% dst/move/changed/
918 16.6% dst/move/rearranged/
919 16.6% rearranged/
922 test_expect_success '--dirstat=lines,0' '
923 git diff --dirstat=lines,0 HEAD^..HEAD >actual_diff_dirstat &&
924 test_cmp expect_diff_dirstat actual_diff_dirstat &&
925 git diff --dirstat=lines,0 -M HEAD^..HEAD >actual_diff_dirstat_M &&
926 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
927 git diff --dirstat=lines,0 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
928 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
931 test_expect_success 'diff.dirstat=0,lines' '
932 git -c diff.dirstat=0,lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
933 test_cmp expect_diff_dirstat actual_diff_dirstat &&
934 git -c diff.dirstat=0,lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
935 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
936 git -c diff.dirstat=0,lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
937 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
940 test_expect_success '--dirstat=future_param,lines,0 should fail loudly' '
941 test_must_fail git diff --dirstat=future_param,lines,0 HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
942 test_debug "cat actual_error" &&
943 test_must_be_empty actual_diff_dirstat &&
944 test_i18ngrep -q "future_param" actual_error &&
945 test_i18ngrep -q "\--dirstat" actual_error
948 test_expect_success '--dirstat=dummy1,cumulative,2dummy should report both unrecognized parameters' '
949 test_must_fail git diff --dirstat=dummy1,cumulative,2dummy HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
950 test_debug "cat actual_error" &&
951 test_must_be_empty actual_diff_dirstat &&
952 test_i18ngrep -q "dummy1" actual_error &&
953 test_i18ngrep -q "2dummy" actual_error &&
954 test_i18ngrep -q "\--dirstat" actual_error
957 test_expect_success 'diff.dirstat=future_param,0,lines should warn, but still work' '
958 git -c diff.dirstat=future_param,0,lines diff --dirstat HEAD^..HEAD >actual_diff_dirstat 2>actual_error &&
959 test_debug "cat actual_error" &&
960 test_cmp expect_diff_dirstat actual_diff_dirstat &&
961 test_i18ngrep -q "future_param" actual_error &&
962 test_i18ngrep -q "diff\\.dirstat" actual_error &&
964 git -c diff.dirstat=future_param,0,lines diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M 2>actual_error &&
965 test_debug "cat actual_error" &&
966 test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
967 test_i18ngrep -q "future_param" actual_error &&
968 test_i18ngrep -q "diff\\.dirstat" actual_error &&
970 git -c diff.dirstat=future_param,0,lines diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC 2>actual_error &&
971 test_debug "cat actual_error" &&
972 test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC &&
973 test_i18ngrep -q "future_param" actual_error &&
974 test_i18ngrep -q "diff\\.dirstat" actual_error
977 test_expect_success '--shortstat --dirstat should output only one dirstat' '
978 git diff --shortstat --dirstat=changes HEAD^..HEAD >out &&
979 grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_changes &&
980 test_line_count = 1 actual_diff_shortstat_dirstat_changes &&
982 git diff --shortstat --dirstat=lines HEAD^..HEAD >out &&
983 grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_lines &&
984 test_line_count = 1 actual_diff_shortstat_dirstat_lines &&
986 git diff --shortstat --dirstat=files HEAD^..HEAD >out &&
987 grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_files &&
988 test_line_count = 1 actual_diff_shortstat_dirstat_files
991 test_done