tests: check --[short]stat output after chmod
Add a test to check 'diff --stat' output with a text file after chmod, and the same for a binary file. This demonstrates that text and binary files are treated differently, which can be misleading. While at it, add tests to check --shortstat output, too. Reported-by: Martin Mareš <mj@ucw.cz> Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Zbigniew Jędrzejewski-Szmek committed
May 1, 2012 at 19:10 UTC
4434e6ba6c2de994bd28892abe9fb3bdf1641560
1 file changed
+37
t/t4006-diff-mode.sh
+37
@@ -25,4 +25,41 @@ test_expect_success 'chmod' '
25
test_cmp expected check
26
'
27
28
+test_expect_success 'prepare binary file' '
29
+ git commit -m rezrov &&
30
+ dd if=/dev/zero of=binbin bs=1024 count=1 &&
31
+ git add binbin &&
32
+ git commit -m binbin
33
+'
34
+
35
+test_expect_success '--stat output after text chmod' '
36
+ test_chmod -x rezrov &&
37
+ echo " 0 files changed" >expect &&
38
+ git diff HEAD --stat >actual &&
39
+ test_cmp expect actual
40
+'
41
+
42
+test_expect_success '--shortstat output after text chmod' '
43
+ git diff HEAD --shortstat >actual &&
44
+ test_cmp expect actual
45
+'
46
+
47
+test_expect_success '--stat output after binary chmod' '
48
+ test_chmod +x binbin &&
49
+ cat >expect <<-EOF &&
50
+ binbin | Bin 1024 -> 1024 bytes
51
+ 1 file changed, 0 insertions(+), 0 deletions(-)
52
+ EOF
53
+ git diff HEAD --stat >actual &&
54
+ test_cmp expect actual
55
+'
56
+
57
+test_expect_success '--shortstat output after binary chmod' '
58
+ cat >expect <<-EOF &&
59
+ 1 file changed, 0 insertions(+), 0 deletions(-)
60
+ EOF
61
+ git diff HEAD --shortstat >actual &&
62
+ test_cmp expect actual
63
+'
64
+
65
test_done