summaryrefslogtreecommitdiff
path: root/t/t7102-reset.sh
diff options
context:
space:
mode:
authorAlexey Shumkin <Alex.Crezoff@gmail.com>2013-06-26 14:19:49 +0400
committerJunio C Hamano <gitster@pobox.com>2013-06-26 11:40:27 -0700
commitde6029a2d7734a93a9e27b9c4471862a47dd8123 (patch)
tree2932d4fa44ffdf809c9f85ea109bffdda7183ec1 /t/t7102-reset.sh
parenta742f2a0a7e57bb7d3f55cb8312c3f4cc4dc68fb (diff)
downloadgit-de6029a2d7734a93a9e27b9c4471862a47dd8123.tar.gz
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>
Diffstat (limited to 't/t7102-reset.sh')
-rwxr-xr-xt/t7102-reset.sh29
1 files changed, 27 insertions, 2 deletions
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 05dfb27cfa..51157a7fa3 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,17 @@ Documented tests for git reset'
. ./test-lib.sh
+commit_msg () {
+ # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+ # encoded in UTF-8, used as a commit log message below.
+ msg=$(printf "modify 2nd file (ge\303\244ndert)")
+ if test -n "$1"
+ then
+ msg=$(echo $msg | iconv -f utf-8 -t $1)
+ fi
+ echo $msg
+}
+
test_expect_success 'creating initial files and commits' '
test_tick &&
echo "1st file" >first &&
@@ -28,7 +39,7 @@ test_expect_success 'creating initial files and commits' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git commit -a -m "modify 2nd file" &&
+ git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +55,20 @@ check_changes () {
done | test_cmp .cat_expect -
}
+test_expect_failure 'reset --hard message' '
+ hex=$(git log -1 --format="%h") &&
+ git reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg) > .expected &&
+ test_cmp .expected .actual
+'
+
+test_expect_success 'reset --hard message (iso-8859-1 logoutencoding)' '
+ hex=$(git log -1 --format="%h") &&
+ git -c "i18n.logOutputEncoding=iso-8859-1" reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg iso-8859-1) > .expected &&
+ test_cmp .expected .actual
+'
+
>.diff_expect
>.cached_expect
cat >.cat_expect <<EOF
@@ -304,7 +329,7 @@ test_expect_success 'redoing the last two commits should succeed' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git commit -a -m "modify 2nd file" &&
+ git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
check_changes $head5
'