From 4434e6ba6c2de994bd28892abe9fb3bdf1641560 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 1 May 2012 19:10:13 +0200 Subject: [PATCH] tests: check --[short]stat output after chmod MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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š Signed-off-by: Zbigniew Jędrzejewski-Szmek Signed-off-by: Junio C Hamano --- t/t4006-diff-mode.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh index b85f622e7c..392dfeff57 100755 --- a/t/t4006-diff-mode.sh +++ b/t/t4006-diff-mode.sh @@ -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 -- 2.11.4.GIT