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 <Alex.Crezoff@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a742f2a0a7
commit
de6029a2d7
@ -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 German (translated with Google Translate), encoded in UTF-8,
|
||||
# used in sample commit log messages in add_file() function below.
|
||||
added=$(printf "hinzugef\303\274gt")
|
||||
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_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso-8859-1) &&
|
||||
git -c 'i18n.commitEncoding=iso-8859-1' commit -m "$msg_added_iso88591"
|
||||
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
|
||||
'
|
||||
|
Reference in New Issue
Block a user