Raw
1 #!/bin/sh
2
3 test_description='git blame encoding conversion'
4
5 . ./test-lib.sh
6
7 if ! test_have_prereq ICONV
8 then
9 skip_all='skipping blame i18n tests; iconv not available'
10 test_done
11 fi
12
13 . "$TEST_DIRECTORY"/t8005/utf8.txt
14 . "$TEST_DIRECTORY"/t8005/euc-japan.txt
15 . "$TEST_DIRECTORY"/t8005/sjis.txt
16
17 test_expect_success 'setup the repository' '
18 # Create the file
19 echo "UTF-8 LINE" > file &&
20 git add file &&
21 git commit --author "$UTF8_NAME <utf8@localhost>" -m "$UTF8_MSG" &&
22
23 echo "EUC-JAPAN LINE" >> file &&
24 git add file &&
25 git config i18n.commitencoding eucJP &&
26 git commit --author "$EUC_JAPAN_NAME <euc-japan@localhost>" -m "$EUC_JAPAN_MSG" &&
27
28 echo "SJIS LINE" >> file &&
29 git add file &&
30 git config i18n.commitencoding SJIS &&
31 git commit --author "$SJIS_NAME <sjis@localhost>" -m "$SJIS_MSG"
32 '
33
34 cat >expected <<EOF
35 author $SJIS_NAME
36 summary $SJIS_MSG
37 author $SJIS_NAME
38 summary $SJIS_MSG
39 author $SJIS_NAME
40 summary $SJIS_MSG
41 EOF
42
43 filter_author_summary () {
44 sed -n -e '/^author /p' -e '/^summary /p' "$@"
45 }
46
47 test_expect_success !MINGW \
48 'blame respects i18n.commitencoding' '
49 git blame --incremental file >output &&
50 filter_author_summary output >actual &&
51 test_cmp expected actual
52 '
53
54 cat >expected <<EOF
55 author $EUC_JAPAN_NAME
56 summary $EUC_JAPAN_MSG
57 author $EUC_JAPAN_NAME
58 summary $EUC_JAPAN_MSG
59 author $EUC_JAPAN_NAME
60 summary $EUC_JAPAN_MSG
61 EOF
62
63 test_expect_success !MINGW \
64 'blame respects i18n.logoutputencoding' '
65 git config i18n.logoutputencoding eucJP &&
66 git blame --incremental file >output &&
67 filter_author_summary output >actual &&
68 test_cmp expected actual
69 '
70
71 cat >expected <<EOF
72 author $UTF8_NAME
73 summary $UTF8_MSG
74 author $UTF8_NAME
75 summary $UTF8_MSG
76 author $UTF8_NAME
77 summary $UTF8_MSG
78 EOF
79
80 test_expect_success !MINGW \
81 'blame respects --encoding=UTF-8' '
82 git blame --incremental --encoding=UTF-8 file >output &&
83 filter_author_summary output >actual &&
84 test_cmp expected actual
85 '
86
87 cat >expected <<EOF
88 author $SJIS_NAME
89 summary $SJIS_MSG
90 author $EUC_JAPAN_NAME
91 summary $EUC_JAPAN_MSG
92 author $UTF8_NAME
93 summary $UTF8_MSG
94 EOF
95
96 test_expect_success !MINGW \
97 'blame respects --encoding=none' '
98 git blame --incremental --encoding=none file >output &&
99 filter_author_summary output >actual &&
100 test_cmp expected actual
101 '
102
103 test_done