Merge branch 'ar/submodule-add-config'
[git/debian.git] / t / t4006-diff-mode.sh
blob6cdee2a2164d0bc7b3ce8105dc733388afb15b35
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\) \('"$OID_REGEX"'\) \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 one &&
30 test_commit --printf two binbin "\00\01\02\03\04\05\06"
33 test_expect_success '--stat output after text chmod' '
34 test_chmod -x rezrov &&
35 cat >expect <<-\EOF &&
36 rezrov | 0
37 1 file changed, 0 insertions(+), 0 deletions(-)
38 EOF
39 git diff HEAD --stat >actual &&
40 test_cmp expect actual
43 test_expect_success '--shortstat output after text chmod' '
44 tail -n 1 <expect >expect.short &&
45 git diff HEAD --shortstat >actual &&
46 test_cmp expect.short actual
49 test_expect_success '--stat output after binary chmod' '
50 test_chmod +x binbin &&
51 cat >expect <<-EOF &&
52 binbin | Bin
53 rezrov | 0
54 2 files changed, 0 insertions(+), 0 deletions(-)
55 EOF
56 git diff HEAD --stat >actual &&
57 test_cmp expect actual
60 test_expect_success '--shortstat output after binary chmod' '
61 tail -n 1 <expect >expect.short &&
62 git diff HEAD --shortstat >actual &&
63 test_cmp expect.short actual
66 test_done