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