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 format %s.
Log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.
The same corruption is true for
$ git diff --submodule=log
and
$ git rev-list --pretty=format:%s HEAD
and
$ git reset --hard
Signed-off-by: Alexey Shumkin alex.crez...@gmail.com
---
t/t4041-diff-submodule-option.sh | 35 +
t/t4205-log-pretty-formats.sh| 149 ---
t/t6006-rev-list-format.sh | 85 +++---
t/t7102-reset.sh | 29 +++-
4 files changed, 200 insertions(+), 98 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..22bf4df 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#
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.
. ./test-lib.sh
+# String added in Russian, encoded in UTF-8, used in
+# sample commit log messages in add_file() function below.
+added=$(printf
\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275)
add_file () {
(
cd $1
@@ -19,7 +23,8 @@ add_file () {
echo $name $name
git add $name
test_tick
- git commit -m Add $name || exit
+ msg_added_iso88595=$(echo Add $name ($added $name) |
iconv -f utf-8 -t iso88595)
+ git -c 'i18n.commitEncoding=iso88595' commit -m
$msg_added_iso88595
done /dev/null
git rev-parse --short --verify HEAD
)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect
plumbing' '
commit_file sm1
head2=$(add_file sm1 foo3)
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
git diff-index -p --submodule=log HEAD actual
cat expected -EOF
Submodule sm1 $head1..$head2:
- Add foo3
+ Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
git diff --submodule=log actual
cat expected -EOF
Submodule sm1 $head1..$head2:
- Add foo3
+ Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
git diff --submodule actual
cat expected -EOF
Submodule sm1 $head1..$head2:
- Add foo3
+ Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
@@ -138,25 +143,25 @@ head3=$(
git rev-parse --short --verify HEAD
)
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
git diff-index -p --submodule=log HEAD actual
cat expected -EOF
Submodule sm1 $head2..$head3 (rewind):
- Add foo3
- Add foo2
+ Add foo3 ($added foo3)
+ Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
git diff-index -p --submodule=log HEAD actual
cat expected -EOF
Submodule sm1 $head2...$head4:
- Add foo5
- Add foo4
- Add foo3
- Add foo2
+ Add foo5 ($added foo5)
+ Add foo4 ($added foo4)
+ Add foo3 ($added foo3)
+ Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 6d8d457..6a56019 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,43 @@
#!/bin/sh
#
# Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#
test_description='Test pretty formats'
. ./test-lib.sh
+commit_msg() {
+ # String initial commit partly in Russian, encoded in UTF-8,
+ # used as a commit log message below.
+ msg=$(printf initial