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