]>
Commit | Line | Data |
---|---|---|
aab57205 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2008 Eric Wong | |
4 | ||
5 | test_description='git svn honors i18n.commitEncoding in config' | |
6 | ||
7 | . ./lib-git-svn.sh | |
8 | ||
9 | compare_git_head_with () { | |
10 | nr=`wc -l < "$1"` | |
11 | a=7 | |
12 | b=$(($a + $nr - 1)) | |
13 | git cat-file commit HEAD | sed -ne "$a,${b}p" >current && | |
14 | test_cmp current "$1" | |
15 | } | |
16 | ||
17 | compare_svn_head_with () { | |
18 | LC_ALL=en_US.UTF-8 svn log --limit 1 `git svn info --url` | \ | |
26d6cc55 | 19 | sed -e 1,3d -e "/^-\{1,\}\$/d" >current && |
aab57205 EW |
20 | test_cmp current "$1" |
21 | } | |
22 | ||
23 | for H in ISO-8859-1 EUCJP ISO-2022-JP | |
24 | do | |
25 | test_expect_success "$H setup" ' | |
26 | mkdir $H && | |
27 | svn import -m "$H test" $H "$svnrepo"/$H && | |
28 | git svn clone "$svnrepo"/$H $H | |
29 | ' | |
30 | done | |
31 | ||
32 | for H in ISO-8859-1 EUCJP ISO-2022-JP | |
33 | do | |
34 | test_expect_success "$H commit on git side" ' | |
35 | ( | |
36 | cd $H && | |
37 | git config i18n.commitencoding $H && | |
38 | git checkout -b t refs/remotes/git-svn && | |
39 | echo $H >F && | |
40 | git add F && | |
41 | git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt && | |
42 | E=$(git cat-file commit HEAD | sed -ne "s/^encoding //p") && | |
43 | test "z$E" = "z$H" | |
44 | compare_git_head_with "$TEST_DIRECTORY"/t3900/$H.txt | |
45 | ) | |
46 | ' | |
47 | done | |
48 | ||
49 | for H in ISO-8859-1 EUCJP ISO-2022-JP | |
50 | do | |
51 | test_expect_success "$H dcommit to svn" ' | |
52 | ( | |
53 | cd $H && | |
54 | git svn dcommit && | |
55 | git cat-file commit HEAD | grep git-svn-id: && | |
56 | E=$(git cat-file commit HEAD | sed -ne "s/^encoding //p") && | |
57 | test "z$E" = "z$H" && | |
58 | compare_git_head_with "$TEST_DIRECTORY"/t3900/$H.txt | |
59 | ) | |
60 | ' | |
61 | done | |
62 | ||
63 | test_expect_success 'ISO-8859-1 should match UTF-8 in svn' ' | |
64 | ( | |
65 | cd ISO-8859-1 && | |
66 | compare_svn_head_with "$TEST_DIRECTORY"/t3900/1-UTF-8.txt | |
67 | ) | |
68 | ' | |
69 | ||
70 | for H in EUCJP ISO-2022-JP | |
71 | do | |
72 | test_expect_success '$H should match UTF-8 in svn' ' | |
73 | ( | |
74 | cd $H && | |
75 | compare_svn_head_with "$TEST_DIRECTORY"/t3900/2-UTF-8.txt | |
76 | ) | |
77 | ' | |
78 | done | |
79 | ||
80 | test_done |