]>
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 () { | |
1ef626b4 EW |
18 | # extract just the log message and strip out committer info. |
19 | # don't use --limit here since svn 1.1.x doesn't have it, | |
20 | LC_ALL=en_US.UTF-8 svn log `git svn info --url` | perl -w -e ' | |
21 | use bytes; | |
22 | $/ = ("-"x72) . "\n"; | |
23 | my @x = <STDIN>; | |
24 | @x = split(/\n/, $x[1]); | |
25 | splice(@x, 0, 2); | |
26 | $x[-1] = ""; | |
27 | print join("\n", @x); | |
28 | ' > current && | |
aab57205 EW |
29 | test_cmp current "$1" |
30 | } | |
31 | ||
5ae93dfd | 32 | for H in ISO8859-1 eucJP ISO-2022-JP |
aab57205 EW |
33 | do |
34 | test_expect_success "$H setup" ' | |
35 | mkdir $H && | |
da083d68 | 36 | svn_cmd import -m "$H test" $H "$svnrepo"/$H && |
aab57205 EW |
37 | git svn clone "$svnrepo"/$H $H |
38 | ' | |
39 | done | |
40 | ||
5ae93dfd | 41 | for H in ISO8859-1 eucJP ISO-2022-JP |
aab57205 EW |
42 | do |
43 | test_expect_success "$H commit on git side" ' | |
44 | ( | |
45 | cd $H && | |
46 | git config i18n.commitencoding $H && | |
47 | git checkout -b t refs/remotes/git-svn && | |
48 | echo $H >F && | |
49 | git add F && | |
50 | git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt && | |
51 | E=$(git cat-file commit HEAD | sed -ne "s/^encoding //p") && | |
52 | test "z$E" = "z$H" | |
53 | compare_git_head_with "$TEST_DIRECTORY"/t3900/$H.txt | |
54 | ) | |
55 | ' | |
56 | done | |
57 | ||
5ae93dfd | 58 | for H in ISO8859-1 eucJP ISO-2022-JP |
aab57205 EW |
59 | do |
60 | test_expect_success "$H dcommit to svn" ' | |
61 | ( | |
62 | cd $H && | |
63 | git svn dcommit && | |
64 | git cat-file commit HEAD | grep git-svn-id: && | |
65 | E=$(git cat-file commit HEAD | sed -ne "s/^encoding //p") && | |
66 | test "z$E" = "z$H" && | |
67 | compare_git_head_with "$TEST_DIRECTORY"/t3900/$H.txt | |
68 | ) | |
69 | ' | |
70 | done | |
71 | ||
c66c0cbc | 72 | if locale -a |grep -q en_US.utf8; then |
7b7247b0 JS |
73 | test_set_prereq UTF8 |
74 | else | |
75 | say "UTF-8 locale not available, test skipped" | |
76 | fi | |
77 | ||
78 | test_expect_success UTF8 'ISO-8859-1 should match UTF-8 in svn' ' | |
aab57205 | 79 | ( |
5ae93dfd | 80 | cd ISO8859-1 && |
c66c0cbc | 81 | compare_svn_head_with "$TEST_DIRECTORY"/t3900/1-UTF-8.txt |
aab57205 | 82 | ) |
7b7247b0 | 83 | ' |
c66c0cbc | 84 | |
5ae93dfd | 85 | for H in eucJP ISO-2022-JP |
7b7247b0 JS |
86 | do |
87 | test_expect_success UTF8 "$H should match UTF-8 in svn" ' | |
c66c0cbc MV |
88 | ( |
89 | cd $H && | |
90 | compare_svn_head_with "$TEST_DIRECTORY"/t3900/2-UTF-8.txt | |
91 | ) | |
7b7247b0 JS |
92 | ' |
93 | done | |
aab57205 EW |
94 | |
95 | test_done |