Skip to content

Commit de6029a

Browse files
ashumkingitster
authored andcommitted
pretty: Add failing tests: --format output should honor logOutputEncoding
One can set an alias $ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit --date=local" to see the log as a pretty tree (like *gitk* but in a terminal). However, log messages written in an encoding i18n.commitEncoding which differs from terminal encoding are shown corrupted even when i18n.logOutputEncoding and terminal encoding are the same (e.g. log messages committed on a Cygwin box with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa). To simplify an example we can say the following two commands are expected to give the same output to a terminal: $ git log --oneline --no-color $ git log --pretty=format:'%h %s' However, the former pays attention to i18n.logOutputEncoding configuration, while the latter does not when it formats "%s". The same corruption is true for $ git diff --submodule=log and $ git rev-list --pretty=format:%s HEAD and $ git reset --hard This patch adds failing tests for the next patch that fixes them. Signed-off-by: Alexey Shumkin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a742f2a commit de6029a

File tree

4 files changed

+199
-97
lines changed

4 files changed

+199
-97
lines changed

t/t4041-diff-submodule-option.sh

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22
#
33
# Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
4+
# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
45
#
56

67
test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
1011

1112
. ./test-lib.sh
1213

14+
# String "added" in German (translated with Google Translate), encoded in UTF-8,
15+
# used in sample commit log messages in add_file() function below.
16+
added=$(printf "hinzugef\303\274gt")
1317
add_file () {
1418
(
1519
cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
1923
echo "$name" >"$name" &&
2024
git add "$name" &&
2125
test_tick &&
22-
git commit -m "Add $name" || exit
26+
msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso-8859-1) &&
27+
git -c 'i18n.commitEncoding=iso-8859-1' commit -m "$msg_added_iso88591"
2328
done >/dev/null &&
2429
git rev-parse --short --verify HEAD
2530
)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
8994
commit_file sm1 &&
9095
head2=$(add_file sm1 foo3)
9196

92-
test_expect_success 'modified submodule(forward)' '
97+
test_expect_failure 'modified submodule(forward)' '
9398
git diff-index -p --submodule=log HEAD >actual &&
9499
cat >expected <<-EOF &&
95100
Submodule sm1 $head1..$head2:
96-
> Add foo3
101+
> Add foo3 ($added foo3)
97102
EOF
98103
test_cmp expected actual
99104
'
100105

101-
test_expect_success 'modified submodule(forward)' '
106+
test_expect_failure 'modified submodule(forward)' '
102107
git diff --submodule=log >actual &&
103108
cat >expected <<-EOF &&
104109
Submodule sm1 $head1..$head2:
105-
> Add foo3
110+
> Add foo3 ($added foo3)
106111
EOF
107112
test_cmp expected actual
108113
'
109114

110-
test_expect_success 'modified submodule(forward) --submodule' '
115+
test_expect_failure 'modified submodule(forward) --submodule' '
111116
git diff --submodule >actual &&
112117
cat >expected <<-EOF &&
113118
Submodule sm1 $head1..$head2:
114-
> Add foo3
119+
> Add foo3 ($added foo3)
115120
EOF
116121
test_cmp expected actual
117122
'
@@ -138,25 +143,25 @@ head3=$(
138143
git rev-parse --short --verify HEAD
139144
)
140145

141-
test_expect_success 'modified submodule(backward)' '
146+
test_expect_failure 'modified submodule(backward)' '
142147
git diff-index -p --submodule=log HEAD >actual &&
143148
cat >expected <<-EOF &&
144149
Submodule sm1 $head2..$head3 (rewind):
145-
< Add foo3
146-
< Add foo2
150+
< Add foo3 ($added foo3)
151+
< Add foo2 ($added foo2)
147152
EOF
148153
test_cmp expected actual
149154
'
150155

151156
head4=$(add_file sm1 foo4 foo5)
152-
test_expect_success 'modified submodule(backward and forward)' '
157+
test_expect_failure 'modified submodule(backward and forward)' '
153158
git diff-index -p --submodule=log HEAD >actual &&
154159
cat >expected <<-EOF &&
155160
Submodule sm1 $head2...$head4:
156-
> Add foo5
157-
> Add foo4
158-
< Add foo3
159-
< Add foo2
161+
> Add foo5 ($added foo5)
162+
> Add foo4 ($added foo4)
163+
< Add foo3 ($added foo3)
164+
< Add foo2 ($added foo2)
160165
EOF
161166
test_cmp expected actual
162167
'

0 commit comments

Comments
 (0)