Skip to content

Commit

Permalink
tests: check --[short]stat output after chmod
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zbigniew Jędrzejewski-Szmek authored and Junio C Hamano committed May 1, 2012
1 parent ec57a82 commit 4434e6b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions t/t4006-diff-mode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,41 @@ test_expect_success 'chmod' '
test_cmp expected check
'

test_expect_success 'prepare binary file' '
git commit -m rezrov &&
dd if=/dev/zero of=binbin bs=1024 count=1 &&
git add binbin &&
git commit -m binbin
'

test_expect_success '--stat output after text chmod' '
test_chmod -x rezrov &&
echo " 0 files changed" >expect &&
git diff HEAD --stat >actual &&
test_cmp expect actual
'

test_expect_success '--shortstat output after text chmod' '
git diff HEAD --shortstat >actual &&
test_cmp expect actual
'

test_expect_success '--stat output after binary chmod' '
test_chmod +x binbin &&
cat >expect <<-EOF &&
binbin | Bin 1024 -> 1024 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
EOF
git diff HEAD --stat >actual &&
test_cmp expect actual
'

test_expect_success '--shortstat output after binary chmod' '
cat >expect <<-EOF &&
1 file changed, 0 insertions(+), 0 deletions(-)
EOF
git diff HEAD --shortstat >actual &&
test_cmp expect actual
'

test_done

0 comments on commit 4434e6b

Please sign in to comment.