Merge branch 'ab/config-based-hooks-base' into seen
[git] / t / t9835-git-p4-message-encoding.sh
1 #!/bin/sh
2
3 test_description='Clone repositories with non ASCII commit messages'
4
5 . ./lib-git-p4.sh
6
7 UTF8="$(printf "a-\303\244_o-\303\266_u-\303\274")"
8 ISO8859="$(printf "a-\344_o-\366_u-\374")"
9
10 test_expect_success 'start p4d' '
11         start_p4d
12 '
13
14 test_expect_success 'create commits in perforce' '
15         (
16                 cd "$cli" &&
17
18                 p4_add_user "${UTF8}" &&
19                 p4_add_user "${ISO8859}" &&
20
21                 >dummy-file1 &&
22                 P4USER="${UTF8}" p4 add dummy-file1 &&
23                 P4USER="${UTF8}" p4 submit -d "message ${UTF8}" &&
24
25                 >dummy-file2 &&
26                 P4USER="${ISO8859}" p4 add dummy-file2 &&
27                 P4USER="${ISO8859}" p4 submit -d "message ${ISO8859}"
28         )
29 '
30
31 test_expect_success 'check UTF-8 commit' '
32         (
33                 git p4 clone --destination="$git/1" //depot@1,1 &&
34                 git -C "$git/1" cat-file commit HEAD | grep -q "^message ${UTF8}$" &&
35                 git -C "$git/1" cat-file commit HEAD | grep -q "^author Dr. ${UTF8} <${UTF8}@example.com>"
36         )
37 '
38
39 test_expect_success 'check ISO-8859 commit' '
40         (
41                 git p4 clone --destination="$git/2" //depot@2,2 &&
42                 git -C "$git/2" cat-file commit HEAD > /tmp/dump.txt &&
43                 git -C "$git/2" cat-file commit HEAD | grep -q "^message ${ISO8859}$" &&
44                 git -C "$git/2" cat-file commit HEAD | grep -q "^author Dr. ${ISO8859} <${ISO8859}@example.com>"
45         )
46 '
47
48 test_done