| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2005 Junio C Hamano |
| 4 | # |
| 5 | |
| 6 | test_description='Test mode change diffs. |
| 7 | |
| 8 | ' |
| 9 | |
| 10 | . ./test-lib.sh |
| 11 | |
| 12 | sed_script='s/\(:100644 100755\) \('"$OID_REGEX"'\) \2 /\1 X X /' |
| 13 | |
| 14 | test_expect_success 'setup' ' |
| 15 | echo frotz >rezrov && |
| 16 | git update-index --add rezrov && |
| 17 | tree=$(git write-tree) && |
| 18 | echo $tree |
| 19 | ' |
| 20 | |
| 21 | test_expect_success 'chmod' ' |
| 22 | test_chmod +x rezrov && |
| 23 | git diff-index $tree >current && |
| 24 | sed -e "$sed_script" <current >check && |
| 25 | echo ":100644 100755 X X M rezrov" >expected && |
| 26 | test_cmp expected check |
| 27 | ' |
| 28 | |
| 29 | test_expect_success 'prepare binary file' ' |
| 30 | git commit -m one && |
| 31 | test_commit --printf two binbin "\00\01\02\03\04\05\06" |
| 32 | ' |
| 33 | |
| 34 | test_expect_success '--stat output after text chmod' ' |
| 35 | test_chmod -x rezrov && |
| 36 | cat >expect <<-\EOF && |
| 37 | rezrov | 0 |
| 38 | 1 file changed, 0 insertions(+), 0 deletions(-) |
| 39 | EOF |
| 40 | git diff HEAD --stat >actual && |
| 41 | test_cmp expect actual |
| 42 | ' |
| 43 | |
| 44 | test_expect_success '--shortstat output after text chmod' ' |
| 45 | tail -n 1 <expect >expect.short && |
| 46 | git diff HEAD --shortstat >actual && |
| 47 | test_cmp expect.short actual |
| 48 | ' |
| 49 | |
| 50 | test_expect_success '--stat output after binary chmod' ' |
| 51 | test_chmod +x binbin && |
| 52 | cat >expect <<-EOF && |
| 53 | binbin | Bin |
| 54 | rezrov | 0 |
| 55 | 2 files changed, 0 insertions(+), 0 deletions(-) |
| 56 | EOF |
| 57 | git diff HEAD --stat >actual && |
| 58 | test_cmp expect actual |
| 59 | ' |
| 60 | |
| 61 | test_expect_success '--shortstat output after binary chmod' ' |
| 62 | tail -n 1 <expect >expect.short && |
| 63 | git diff HEAD --shortstat >actual && |
| 64 | test_cmp expect.short actual |
| 65 | ' |
| 66 | |
| 67 | test_done |