interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t8005-blame-i18n.sh

103 lines · 2261 bytes Raw Blame History
1#!/bin/sh
2
3test_description='git blame encoding conversion'
4
5. ./test-lib.sh
6
7if ! test_have_prereq ICONV
8then
9 skip_all='skipping blame i18n tests; iconv not available'
10 test_done
11fi
12
13. "$TEST_DIRECTORY"/t8005/utf8.txt
14. "$TEST_DIRECTORY"/t8005/euc-japan.txt
15. "$TEST_DIRECTORY"/t8005/sjis.txt
16
17test_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
34cat >expected <<EOF
35author $SJIS_NAME
36summary $SJIS_MSG
37author $SJIS_NAME
38summary $SJIS_MSG
39author $SJIS_NAME
40summary $SJIS_MSG
41EOF
42
43filter_author_summary () {
44 sed -n -e '/^author /p' -e '/^summary /p' "$@"
45}
46
47test_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
54cat >expected <<EOF
55author $EUC_JAPAN_NAME
56summary $EUC_JAPAN_MSG
57author $EUC_JAPAN_NAME
58summary $EUC_JAPAN_MSG
59author $EUC_JAPAN_NAME
60summary $EUC_JAPAN_MSG
61EOF
62
63test_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
71cat >expected <<EOF
72author $UTF8_NAME
73summary $UTF8_MSG
74author $UTF8_NAME
75summary $UTF8_MSG
76author $UTF8_NAME
77summary $UTF8_MSG
78EOF
79
80test_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
87cat >expected <<EOF
88author $SJIS_NAME
89summary $SJIS_MSG
90author $EUC_JAPAN_NAME
91summary $EUC_JAPAN_MSG
92author $UTF8_NAME
93summary $UTF8_MSG
94EOF
95
96test_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
103test_done