tests: check --[short]stat output after chmod
[git/jnareb-git.git] / t / t4006-diff-mode.sh
blob392dfeff57d0b1030e14c78bac105ac0f7183eb8
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Test mode change diffs.
9 . ./test-lib.sh
11 sed_script='s/\(:100644 100755\) \('"$_x40"'\) \2 /\1 X X /'
13 test_expect_success 'setup' '
14 echo frotz >rezrov &&
15 git update-index --add rezrov &&
16 tree=`git write-tree` &&
17 echo $tree
20 test_expect_success 'chmod' '
21 test_chmod +x rezrov &&
22 git diff-index $tree >current &&
23 sed -e "$sed_script" <current >check &&
24 echo ":100644 100755 X X M rezrov" >expected &&
25 test_cmp expected check
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
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
42 test_expect_success '--shortstat output after text chmod' '
43 git diff HEAD --shortstat >actual &&
44 test_cmp expect actual
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
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
65 test_done