| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git-diff check diffstat filepaths length when containing UTF-8 chars' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | |
| 8 | create_files () { |
| 9 | mkdir -p "d你好" && |
| 10 | touch "d你好/f再见" |
| 11 | } |
| 12 | |
| 13 | test_expect_success 'setup' ' |
| 14 | git init && |
| 15 | git config core.quotepath off && |
| 16 | git commit -m "Initial commit" --allow-empty && |
| 17 | create_files && |
| 18 | git add . && |
| 19 | git commit -m "Added files" |
| 20 | ' |
| 21 | |
| 22 | test_expect_success 'test name-width long enough for filepath' ' |
| 23 | git diff HEAD~1 HEAD --stat --stat-name-width=12 >out && |
| 24 | test_grep "d你好/f再见 |" out && |
| 25 | git diff HEAD~1 HEAD --stat --stat-name-width=11 >out && |
| 26 | test_grep "d你好/f再见 |" out |
| 27 | ' |
| 28 | |
| 29 | test_expect_success 'test name-width not long enough for dir name' ' |
| 30 | git diff HEAD~1 HEAD --stat --stat-name-width=10 >out && |
| 31 | test_grep ".../f再见 |" out && |
| 32 | git diff HEAD~1 HEAD --stat --stat-name-width=9 >out && |
| 33 | test_grep ".../f再见 |" out |
| 34 | ' |
| 35 | |
| 36 | test_expect_success 'test name-width not long enough for slash' ' |
| 37 | git diff HEAD~1 HEAD --stat --stat-name-width=8 >out && |
| 38 | test_grep "...f再见 |" out |
| 39 | ' |
| 40 | |
| 41 | test_expect_success 'test name-width not long enough for file name' ' |
| 42 | git diff HEAD~1 HEAD --stat --stat-name-width=7 >out && |
| 43 | test_grep "...再见 |" out && |
| 44 | git diff HEAD~1 HEAD --stat --stat-name-width=6 >out && |
| 45 | test_grep "...见 |" out && |
| 46 | git diff HEAD~1 HEAD --stat --stat-name-width=5 >out && |
| 47 | test_grep "...见 |" out && |
| 48 | git diff HEAD~1 HEAD --stat --stat-name-width=4 >out && |
| 49 | test_grep "... |" out |
| 50 | ' |
| 51 | |
| 52 | test_expect_success 'test name-width minimum length' ' |
| 53 | git diff HEAD~1 HEAD --stat --stat-name-width=3 >out && |
| 54 | test_grep "... |" out && |
| 55 | git diff HEAD~1 HEAD --stat --stat-name-width=2 >out && |
| 56 | test_grep "... |" out && |
| 57 | git diff HEAD~1 HEAD --stat --stat-name-width=1 >out && |
| 58 | test_grep "... |" out |
| 59 | ' |
| 60 | |
| 61 | test_done |