setup: fix leaking repository format
[alt-git.git] / t / t4047-diff-dirstat.sh
blob70224c3da1494262eb4b2a46c58e001d74f37a9e
1 #!/bin/sh
3 test_description='diff --dirstat tests'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
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' '
22 mkdir unchanged &&
23 mkdir changed &&
24 mkdir rearranged &&
25 mkdir src &&
26 mkdir src/copy &&
27 mkdir src/copy/unchanged &&
28 mkdir src/copy/changed &&
29 mkdir src/copy/rearranged &&
30 mkdir src/move &&
31 mkdir src/move/unchanged &&
32 mkdir src/move/changed &&
33 mkdir src/move/rearranged &&
34 cat <<EOF >unchanged/text &&
35 unchanged line #0
36 unchanged line #1
37 unchanged line #2
38 unchanged line #3
39 unchanged line #4
40 unchanged line #5
41 unchanged line #6
42 unchanged line #7
43 unchanged line #8
44 unchanged line #9
45 EOF
46 cat <<EOF >changed/text &&
47 changed line #0
48 changed line #1
49 changed line #2
50 changed line #3
51 changed line #4
52 changed line #5
53 changed line #6
54 changed line #7
55 changed line #8
56 changed line #9
57 EOF
58 cat <<EOF >rearranged/text &&
59 rearranged line #0
60 rearranged line #1
61 rearranged line #2
62 rearranged line #3
63 rearranged line #4
64 rearranged line #5
65 rearranged line #6
66 rearranged line #7
67 rearranged line #8
68 rearranged line #9
69 EOF
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
81 EOF
82 cat <<EOF >src/copy/changed/text &&
83 copy changed line #0
84 copy changed line #1
85 copy changed line #2
86 copy changed line #3
87 copy changed line #4
88 copy changed line #5
89 copy changed line #6
90 copy changed line #7
91 copy changed line #8
92 copy changed line #9
93 EOF
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 &&
119 move changed line #0
120 move changed line #1
121 move changed line #2
122 move changed line #3
123 move changed line #4
124 move changed line #5
125 move changed line #6
126 move changed line #7
127 move changed line #8
128 move changed line #9
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
142 git add . &&
143 git commit -m "initial" &&
144 mkdir dst &&
145 mkdir dst/copy &&
146 mkdir dst/copy/unchanged &&
147 mkdir dst/copy/changed &&
148 mkdir dst/copy/rearranged &&
149 mkdir dst/move &&
150 mkdir dst/move/unchanged &&
151 mkdir dst/move/changed &&
152 mkdir dst/move/rearranged &&
153 cat <<EOF >changed/text &&
154 CHANGED XXXXXXX line #0
155 changed line #1
156 changed line #2
157 changed line #3
158 changed line #4
159 changed line #5
160 changed line #6
161 changed line #7
162 changed line #8
163 changed line #9
165 cat <<EOF >rearranged/text &&
166 rearranged line #1
167 rearranged line #0
168 rearranged line #2
169 rearranged line #3
170 rearranged line #4
171 rearranged line #5
172 rearranged line #6
173 rearranged line #7
174 rearranged line #8
175 rearranged line #9
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
191 copy changed line #1
192 copy changed line #2
193 copy changed line #3
194 copy changed line #4
195 copy changed line #5
196 copy changed line #6
197 copy changed line #7
198 copy changed line #8
199 copy changed line #9
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
227 move changed line #1
228 move changed line #2
229 move changed line #3
230 move changed line #4
231 move changed line #5
232 move changed line #6
233 move changed line #7
234 move changed line #8
235 move changed line #9
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
249 git add . &&
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
258 1 1 changed/text
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
265 1 1 rearranged/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
272 1 1 changed/text
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
279 1 1 rearranged/text
282 cat <<EOF >expect_diff_stat_CC
283 1 1 changed/text
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
290 1 1 rearranged/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
317 5.8% changed/
318 29.3% dst/copy/changed/
319 29.3% dst/copy/rearranged/
320 29.3% dst/copy/unchanged/
321 5.8% dst/move/changed/
324 # rearranged/text falls below default 3% threshold
325 cat <<EOF >expect_diff_dirstat_CC
326 32.6% changed/
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
399 2.1% changed/
400 10.8% dst/copy/changed/
401 10.8% dst/copy/rearranged/
402 10.8% dst/copy/unchanged/
403 10.8% dst/move/changed/
404 10.8% dst/move/rearranged/
405 10.8% dst/move/unchanged/
406 0.0% rearranged/
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
413 5.8% changed/
414 29.3% dst/copy/changed/
415 29.3% dst/copy/rearranged/
416 29.3% dst/copy/unchanged/
417 5.8% dst/move/changed/
418 0.1% dst/move/rearranged/
419 0.1% rearranged/
422 cat <<EOF >expect_diff_dirstat_CC
423 32.6% changed/
424 32.6% dst/copy/changed/
425 0.6% dst/copy/rearranged/
426 32.6% dst/move/changed/
427 0.6% dst/move/rearranged/
428 0.6% rearranged/
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
459 2.1% changed/
460 10.8% dst/copy/changed/
461 10.8% dst/copy/rearranged/
462 10.8% dst/copy/unchanged/
463 32.5% dst/copy/
464 10.8% dst/move/changed/
465 10.8% dst/move/rearranged/
466 10.8% dst/move/unchanged/
467 32.5% dst/move/
468 65.1% dst/
469 0.0% rearranged/
470 10.8% src/move/changed/
471 10.8% src/move/rearranged/
472 10.8% src/move/unchanged/
473 32.5% src/move/
476 cat <<EOF >expect_diff_dirstat_M
477 5.8% changed/
478 29.3% dst/copy/changed/
479 29.3% dst/copy/rearranged/
480 29.3% dst/copy/unchanged/
481 88.0% dst/copy/
482 5.8% dst/move/changed/
483 0.1% dst/move/rearranged/
484 5.9% dst/move/
485 94.0% dst/
486 0.1% rearranged/
489 cat <<EOF >expect_diff_dirstat_CC
490 32.6% changed/
491 32.6% dst/copy/changed/
492 0.6% dst/copy/rearranged/
493 33.3% dst/copy/
494 32.6% dst/move/changed/
495 0.6% dst/move/rearranged/
496 33.3% dst/move/
497 66.6% dst/
498 0.6% rearranged/
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
547 9.0% changed/
548 9.0% dst/copy/changed/
549 9.0% dst/copy/rearranged/
550 9.0% dst/copy/unchanged/
551 9.0% dst/move/changed/
552 9.0% dst/move/rearranged/
553 9.0% dst/move/unchanged/
554 9.0% rearranged/
555 9.0% src/move/changed/
556 9.0% src/move/rearranged/
557 9.0% src/move/unchanged/
560 cat <<EOF >expect_diff_dirstat_M
561 14.2% changed/
562 14.2% dst/copy/changed/
563 14.2% dst/copy/rearranged/
564 14.2% dst/copy/unchanged/
565 14.2% dst/move/changed/
566 14.2% dst/move/rearranged/
567 14.2% rearranged/
570 cat <<EOF >expect_diff_dirstat_CC
571 16.6% changed/
572 16.6% dst/copy/changed/
573 16.6% dst/copy/rearranged/
574 16.6% dst/move/changed/
575 16.6% dst/move/rearranged/
576 16.6% rearranged/
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
607 27.2% dst/copy/
608 27.2% dst/move/
609 27.2% src/move/
612 cat <<EOF >expect_diff_dirstat_M
613 14.2% changed/
614 14.2% dst/copy/changed/
615 14.2% dst/copy/rearranged/
616 14.2% dst/copy/unchanged/
617 14.2% dst/move/changed/
618 14.2% dst/move/rearranged/
619 14.2% rearranged/
622 cat <<EOF >expect_diff_dirstat_CC
623 16.6% changed/
624 16.6% dst/copy/changed/
625 16.6% dst/copy/rearranged/
626 16.6% dst/move/changed/
627 16.6% dst/move/rearranged/
628 16.6% rearranged/
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
659 9.0% changed/
660 9.0% dst/copy/changed/
661 9.0% dst/copy/rearranged/
662 9.0% dst/copy/unchanged/
663 27.2% dst/copy/
664 9.0% dst/move/changed/
665 9.0% dst/move/rearranged/
666 9.0% dst/move/unchanged/
667 27.2% dst/move/
668 54.5% dst/
669 9.0% rearranged/
670 9.0% src/move/changed/
671 9.0% src/move/rearranged/
672 9.0% src/move/unchanged/
673 27.2% src/move/
676 cat <<EOF >expect_diff_dirstat_M
677 14.2% changed/
678 14.2% dst/copy/changed/
679 14.2% dst/copy/rearranged/
680 14.2% dst/copy/unchanged/
681 42.8% dst/copy/
682 14.2% dst/move/changed/
683 14.2% dst/move/rearranged/
684 28.5% dst/move/
685 71.4% dst/
686 14.2% rearranged/
689 cat <<EOF >expect_diff_dirstat_CC
690 16.6% changed/
691 16.6% dst/copy/changed/
692 16.6% dst/copy/rearranged/
693 33.3% dst/copy/
694 16.6% dst/move/changed/
695 16.6% dst/move/rearranged/
696 33.3% dst/move/
697 66.6% dst/
698 16.6% rearranged/
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
729 27.2% dst/copy/
730 27.2% dst/move/
731 54.5% dst/
732 27.2% src/move/
735 cat <<EOF >expect_diff_dirstat_M
736 14.2% changed/
737 14.2% dst/copy/changed/
738 14.2% dst/copy/rearranged/
739 14.2% dst/copy/unchanged/
740 42.8% dst/copy/
741 14.2% dst/move/changed/
742 14.2% dst/move/rearranged/
743 28.5% dst/move/
744 71.4% dst/
745 14.2% rearranged/
748 cat <<EOF >expect_diff_dirstat_CC
749 16.6% changed/
750 16.6% dst/copy/changed/
751 16.6% dst/copy/rearranged/
752 33.3% dst/copy/
753 16.6% dst/move/changed/
754 16.6% dst/move/rearranged/
755 33.3% dst/move/
756 66.6% dst/
757 16.6% rearranged/
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
779 27.2% dst/copy/
780 27.2% dst/move/
781 54.5% dst/
782 27.2% src/move/
785 cat <<EOF >expect_diff_dirstat_M
786 42.8% dst/copy/
787 28.5% dst/move/
788 71.4% dst/
791 cat <<EOF >expect_diff_dirstat_CC
792 33.3% dst/copy/
793 33.3% dst/move/
794 66.6% dst/
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
855 5.2% changed/
856 26.3% dst/copy/changed/
857 26.3% dst/copy/rearranged/
858 26.3% dst/copy/unchanged/
859 5.2% dst/move/changed/
860 5.2% dst/move/rearranged/
861 5.2% rearranged/
864 cat <<EOF >expect_diff_dirstat_CC
865 16.6% changed/
866 16.6% dst/copy/changed/
867 16.6% dst/copy/rearranged/
868 16.6% dst/move/changed/
869 16.6% dst/move/rearranged/
870 16.6% rearranged/
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
892 2.1% changed/
893 10.6% dst/copy/changed/
894 10.6% dst/copy/rearranged/
895 10.6% dst/copy/unchanged/
896 10.6% dst/move/changed/
897 10.6% dst/move/rearranged/
898 10.6% dst/move/unchanged/
899 2.1% rearranged/
900 10.6% src/move/changed/
901 10.6% src/move/rearranged/
902 10.6% src/move/unchanged/
905 cat <<EOF >expect_diff_dirstat_M
906 5.2% changed/
907 26.3% dst/copy/changed/
908 26.3% dst/copy/rearranged/
909 26.3% dst/copy/unchanged/
910 5.2% dst/move/changed/
911 5.2% dst/move/rearranged/
912 5.2% rearranged/
915 cat <<EOF >expect_diff_dirstat_CC
916 16.6% changed/
917 16.6% dst/copy/changed/
918 16.6% dst/copy/rearranged/
919 16.6% dst/move/changed/
920 16.6% dst/move/rearranged/
921 16.6% rearranged/
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_i18ngrep -q "future_param" actual_error &&
947 test_i18ngrep -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_i18ngrep -q "dummy1" actual_error &&
955 test_i18ngrep -q "2dummy" actual_error &&
956 test_i18ngrep -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_i18ngrep -q "future_param" actual_error &&
964 test_i18ngrep -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_i18ngrep -q "future_param" actual_error &&
970 test_i18ngrep -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_i18ngrep -q "future_param" actual_error &&
976 test_i18ngrep -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
993 test_done