fetch: do not store peeled tag object names in FETCH_HEAD
[git/mingw.git] / t / t4047-diff-dirstat.sh
blob29e80a58cdcf43077bcc5bf42834aa8b4daad93d
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 changed/text | 2 +-
256 dst/copy/changed/text | 10 ++++++++++
257 dst/copy/rearranged/text | 10 ++++++++++
258 dst/copy/unchanged/text | 10 ++++++++++
259 dst/move/changed/text | 10 ++++++++++
260 dst/move/rearranged/text | 10 ++++++++++
261 dst/move/unchanged/text | 10 ++++++++++
262 rearranged/text | 2 +-
263 src/move/changed/text | 10 ----------
264 src/move/rearranged/text | 10 ----------
265 src/move/unchanged/text | 10 ----------
266 11 files changed, 62 insertions(+), 32 deletions(-)
269 cat <<EOF >expect_diff_stat_M
270 changed/text | 2 +-
271 dst/copy/changed/text | 10 ++++++++++
272 dst/copy/rearranged/text | 10 ++++++++++
273 dst/copy/unchanged/text | 10 ++++++++++
274 {src => dst}/move/changed/text | 2 +-
275 {src => dst}/move/rearranged/text | 2 +-
276 {src => dst}/move/unchanged/text | 0
277 rearranged/text | 2 +-
278 8 files changed, 34 insertions(+), 4 deletions(-)
281 cat <<EOF >expect_diff_stat_CC
282 changed/text | 2 +-
283 {src => dst}/copy/changed/text | 2 +-
284 {src => dst}/copy/rearranged/text | 2 +-
285 {src => dst}/copy/unchanged/text | 0
286 {src => dst}/move/changed/text | 2 +-
287 {src => dst}/move/rearranged/text | 2 +-
288 {src => dst}/move/unchanged/text | 0
289 rearranged/text | 2 +-
290 8 files changed, 6 insertions(+), 6 deletions(-)
293 test_expect_success 'sanity check setup (--stat)' '
294 git diff --stat HEAD^..HEAD >actual_diff_stat &&
295 test_cmp expect_diff_stat actual_diff_stat &&
296 git diff --stat -M HEAD^..HEAD >actual_diff_stat_M &&
297 test_cmp expect_diff_stat_M actual_diff_stat_M &&
298 git diff --stat -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_cmp /dev/null 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_cmp /dev/null 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_done