Skip to content

Commit 4434e6b

Browse files
keszybzgitster
authored andcommitted
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š <[email protected]> Signed-off-by: Zbigniew Jędrzejewski-Szmek <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ec57a82 commit 4434e6b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

t/t4006-diff-mode.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,41 @@ test_expect_success 'chmod' '
2525
test_cmp expected check
2626
'
2727

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+
2865
test_done

0 commit comments

Comments
 (0)