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