1#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
56
test_description='commit and log output encodings'
78
. ./test-lib.sh
910
compare_with () {
11git-show -s "$1" | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current &&
12diff -u current "$2"
13}
1415
test_expect_success setup '
16: >F &&
17git-add F &&
18T=$(git-write-tree) &&
19C=$(git-commit-tree $T <../t3900/1-UTF-8.txt) &&
20git-update-ref HEAD $C &&
21git-tag C0
22'
2324
test_expect_success 'no encoding header for base case' '
25E=$(git-cat-file commit C0 | sed -ne "s/^encoding //p") &&
26test z = "z$E"
27'
2829
for H in ISO-8859-1 EUCJP ISO-2022-JP
30do
31test_expect_success "$H setup" '
32git-repo-config i18n.commitencoding $H &&
33git-checkout -b $H C0 &&
34echo $H >F &&
35git-commit -a -F ../t3900/$H.txt
36'
37done
3839
for H in ISO-8859-1 EUCJP ISO-2022-JP
40do
41test_expect_success "check encoding header for $H" '
42E=$(git-cat-file commit '$H' | sed -ne "s/^encoding //p") &&
43test "z$E" = "z'$H'"
44'
45done
4647
test_expect_success 'repo-config to remove customization' '
48git-repo-config --unset-all i18n.commitencoding &&
49if Z=$(git-repo-config --get-all i18n.commitencoding)
50then
51echo Oops, should have failed.
52false
53else
54test z = "z$Z"
55fi &&
56git-repo-config i18n.commitencoding utf-8
57'
5859
test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
60compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
61'
6263
for H in EUCJP ISO-2022-JP
64do
65test_expect_success "$H should be shown in UTF-8 now" '
66compare_with '$H' ../t3900/2-UTF-8.txt
67'
68done
6970
test_expect_success 'repo-config to add customization' '
71git-repo-config --unset-all i18n.commitencoding &&
72if Z=$(git-repo-config --get-all i18n.commitencoding)
73then
74echo Oops, should have failed.
75false
76else
77test z = "z$Z"
78fi
79'
8081
for H in ISO-8859-1 EUCJP ISO-2022-JP
82do
83test_expect_success "$H should be shown in itself now" '
84git-repo-config i18n.commitencoding '$H' &&
85compare_with '$H' ../t3900/'$H'.txt
86'
87done
8889
test_expect_success 'repo-config to tweak customization' '
90git-repo-config i18n.logoutputencoding utf-8
91'
9293
test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
94compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
95'
9697
for H in EUCJP ISO-2022-JP
98do
99test_expect_success "$H should be shown in UTF-8 now" '
100compare_with '$H' ../t3900/2-UTF-8.txt
101'
102done
103104
for J in EUCJP ISO-2022-JP
105do
106git-repo-config i18n.logoutputencoding $J
107for H in EUCJP ISO-2022-JP
108do
109test_expect_success "$H should be shown in $J now" '
110compare_with '$H' ../t3900/'$J'.txt
111'
112done
113done
114115
test_done