{"thread":{"id":"27912","subject":"[PATCH] pretty: user format ignores i18n.logOutputEncoding setting","startedAt":"2011-07-25T10:31:14Z","lastAt":"2011-09-20T08:20:16Z","messageCount":12,"participants":["Alexey Shumkin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"171985","messageId":"1311589875-12569-1-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"loom.20110722T094944-284@post.gmane.org","subject":"[PATCH] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"alex.crezoff@gmail.com","sentAt":"2011-07-25T10:31:14Z","receivedAt":"2011-07-25T10:31:14Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"\nStarted here http://thread.gmane.org/gmane.comp.version-control.git/177634\n"},{"id":"171984","messageId":"1311589875-12569-2-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"1311589875-12569-1-git-send-email-zapped@mail.ru","subject":"[PATCH] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"alex.crezoff@gmail.com","sentAt":"2011-07-25T10:31:15Z","receivedAt":"2011-07-25T10:31:15Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"git log --graph --oneline\nand\ngit log --graph --pretty=format:'%C(yellow)%h %Creset%s'\ngive different outputs on Linux UTF-8 console\nwhen commit messages contain non-UTF-8 characters\n(e.g. commits made on Windows)\n\nFix it.\n\nSigned-off-by: Alexey Shumkin <zapped@mail.ru>\n---\n log-tree.c                    |    1 +\n t/t4205-log-pretty-formats.sh |   20 ++++++++++++++++++--\n 2 files changed, 19 insertions(+), 2 deletions(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex e945701..39913d7 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)\n \tctx.preserve_subject = opt->preserve_subject;\n \tctx.reflog_info = opt->reflog_info;\n \tctx.fmt = opt->commit_format;\n+\tctx.output_encoding = get_log_output_encoding();\n \tpretty_print_commit(&ctx, commit, &msgbuf);\n \n \tif (opt->add_signoff)\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex 2ae9faa..24e787a 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -11,10 +11,12 @@ test_expect_success 'set up basic repos' '\n \t>bar &&\n \tgit add foo &&\n \ttest_tick &&\n-\tgit commit -m initial &&\n+\tgit config i18n.commitEncoding cp1251 &&\n+\tprintf \"initial \\320\\272\\320\\276\\320\\274\\320\\274\\320\\270\\321\\202\" | iconv -t cp1251 -f utf-8 | xargs -I{} git commit -m \"{}\" &&\n \tgit add bar &&\n \ttest_tick &&\n-\tgit commit -m \"add bar\"\n+\tgit commit -m \"add bar\" &&\n+\tgit config --unset i18n.commitEncoding\n '\n \n test_expect_success 'alias builtin format' '\n@@ -38,6 +40,20 @@ test_expect_success 'alias user-defined format' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'alias user-defined tformat with %s (native encoding)' '\n+\tgit config i18n.logOutputEncoding cp1251 &&\n+\tgit log --oneline >expected-s &&\n+\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n+\tgit config --unset i18n.logOutputEncoding &&\n+\ttest_cmp expected-s actual-s\n+'\n+\n+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '\n+\tgit log --oneline >expected-s &&\n+\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n+\ttest_cmp expected-s actual-s\n+'\n+\n test_expect_success 'alias user-defined tformat' '\n \tgit log --pretty=\"tformat:%h\" >expected &&\n \tgit config pretty.test-alias \"tformat:%h\" &&\n-- \n1.7.6.dirty\n"},{"id":"172006","messageId":"7vwrf6qh49.fsf@alter.siamese.dyndns.org","threadId":"27912","inReplyTo":"1311589875-12569-2-git-send-email-zapped@mail.ru","subject":"Re: [PATCH] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-07-25T19:45:26Z","receivedAt":"2011-07-25T19:45:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexey Shumkin <alex.crezoff@gmail.com> writes:\n\n> git log --graph --oneline\n> and\n> git log --graph --pretty=format:'%C(yellow)%h %Creset%s'\n> give different outputs on Linux UTF-8 console\n> when commit messages contain non-UTF-8 characters\n\n(content) \"different\" is not specific enough to describe a problem (in\nsome cases, difference in command line arguments is the way to obtain\ndifferent results), especially if you do not state that they \"should\" be\nthe same to begin with, and preferrably under what condition they should\nbe the same.\n\n(content) Do you really need all of the above options to observe the\nbreakage, or can you drop --graph?  If so, drop it from the proposed\ncommit log message, as it is distracting without merit.\n\n(content) Do you really mean SP before %Creset, not after?\n\n(style) Somehow I find this hard to read. Perhaps make the two \"sample\ncommands\" stand out more from the surrounding text?  E.g.\n\n-- >8 --\nThe following two ought to give the same output to a terminal:\n\n\t$ git log --oneline\n        $ git log --pretty=format:'%C(yellow)%h %creset%s'\n\nHowever, the former pays attention to i18n.logOutputEncoding\nconfiguration, while the latter does not when it format \"%s\". A log\nmessages written in an encoding i18n.commitEncoding that is not UTF-8\nis shown corrupted with the latter even when i18n.logOutputEncoding is set\nto convert to UTF-8.\n\nSigned-off-by: ...\n-- 8< --\n\n(question) Does this change affect other commands, most notably\nformat-patch, and if so how?\n\n> diff --git a/log-tree.c b/log-tree.c\n> index e945701..39913d7 100644\n> --- a/log-tree.c\n> +++ b/log-tree.c\n> @@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)\n>  \tctx.preserve_subject = opt->preserve_subject;\n>  \tctx.reflog_info = opt->reflog_info;\n>  \tctx.fmt = opt->commit_format;\n> +\tctx.output_encoding = get_log_output_encoding();\n>  \tpretty_print_commit(&ctx, commit, &msgbuf);\n>  \n>  \tif (opt->add_signoff)\n> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\n> index 2ae9faa..24e787a 100755\n> --- a/t/t4205-log-pretty-formats.sh\n> +++ b/t/t4205-log-pretty-formats.sh\n> @@ -11,10 +11,12 @@ test_expect_success 'set up basic repos' '\n>  \t>bar &&\n>  \tgit add foo &&\n>  \ttest_tick &&\n> -\tgit commit -m initial &&\n> +\tgit config i18n.commitEncoding cp1251 &&\n> +\tprintf \"initial \\320\\272\\320\\276\\320\\274\\320\\274\\320\\270\\321\\202\" | iconv -t cp1251 -f utf-8 | xargs -I{} git commit -m \"{}\" &&\n>  \tgit add bar &&\n>  \ttest_tick &&\n> -\tgit commit -m \"add bar\"\n> +\tgit commit -m \"add bar\" &&\n> +\tgit config --unset i18n.commitEncoding\n>  '\n>  \n>  test_expect_success 'alias builtin format' '\n> @@ -38,6 +40,20 @@ test_expect_success 'alias user-defined format' '\n>  \ttest_cmp expected actual\n>  '\n>  \n> +test_expect_success 'alias user-defined tformat with %s (native encoding)' '\n> +\tgit config i18n.logOutputEncoding cp1251 &&\n> +\tgit log --oneline >expected-s &&\n> +\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n> +\tgit config --unset i18n.logOutputEncoding &&\n> +\ttest_cmp expected-s actual-s\n> +'\n> +\n> +test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '\n> +\tgit log --oneline >expected-s &&\n> +\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n> +\ttest_cmp expected-s actual-s\n> +'\n> +\n>  test_expect_success 'alias user-defined tformat' '\n>  \tgit log --pretty=\"tformat:%h\" >expected &&\n>  \tgit config pretty.test-alias \"tformat:%h\" &&\n"},{"id":"172060","messageId":"20110726171844.68b6e8ff@ashu.dyn.rarus.ru","threadId":"27912","inReplyTo":"7vwrf6qh49.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"ashu@rarus.ru","sentAt":"2011-07-26T13:18:44Z","receivedAt":"2011-07-26T13:18:44Z","isPatch":true,"sender":{"key":"ashu@rarus.ru","avatar":null},"body":"В Mon, 25 Jul 2011 12:45:26 -0700\nJunio C Hamano <gitster@pobox.com> пишет:\n\n> Alexey Shumkin <alex.crezoff@gmail.com> writes:\n> \n> > git log --graph --oneline\n> > and\n> > git log --graph --pretty=format:'%C(yellow)%h %Creset%s'\n> > give different outputs on Linux UTF-8 console\n> > when commit messages contain non-UTF-8 characters\n> \n> (content) \"different\" is not specific enough to describe a problem (in\n> some cases, difference in command line arguments is the way to obtain\n> different results), especially if you do not state that they \"should\"\n> be the same to begin with, and preferrably under what condition they\n> should be the same.\nOk, I'll fix the description\n\n> (content) Do you really need all of the above options to observe the\n> breakage, or can you drop --graph?  If so, drop it from the proposed\n> commit log message, as it is distracting without merit.\nYou're right. I do not. I just observed the error with such parameters,\nso I wrote them, but they are not neccessary for the error appearance.\n\n> (content) Do you really mean SP before %Creset, not after?\nRealy do, but it does not matter here\n\n> (style) Somehow I find this hard to read. Perhaps make the two \"sample\n> commands\" stand out more from the surrounding text?  E.g.\n> \n> -- >8 --\n> The following two ought to give the same output to a terminal:\n> \n> \t$ git log --oneline\n>         $ git log --pretty=format:'%C(yellow)%h %creset%s'\n> \n> However, the former pays attention to i18n.logOutputEncoding\n> configuration, while the latter does not when it format \"%s\". A log\n> messages written in an encoding i18n.commitEncoding that is not UTF-8\n> is shown corrupted with the latter even when i18n.logOutputEncoding\n> is set to convert to UTF-8.\n> \n> Signed-off-by: ...\n> -- 8< --\nI'm sorry. I'm newbie in a patch distribution and collaborative work on\nEnlgish (it is not my native language). So thanks for the correction.\n\n> (question) Does this change affect other commands, most notably\n> format-patch, and if so how?\nI'll discover this, thanks for pointing me a direction.\n"},{"id":"175156","messageId":"1315557806-5555-1-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"7vwrf6qh49.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-09T08:43:24Z","receivedAt":"2011-09-09T08:43:24Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"I discovered two more commands affected with this bug.\nSo I reroll this patch and tests for it.\n\n>>(question) Does this change affect other commands, most notably\nformat-patch, and if so how?\nNo, it does not affect format-patc\n\n---\n\n builtin/rev-list.c               |    1 +\n builtin/shortlog.c               |    1 +\n log-tree.c                       |    1 +\n submodule.c                      |    3 +\n t/t4041-diff-submodule-option.sh |   44 +++++----\n t/t4205-log-pretty-formats.sh    |   22 ++++-\n t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------\n 7 files changed, 167 insertions(+), 97 deletions(-)\n"},{"id":"175158","messageId":"1315557806-5555-2-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"1315557806-5555-1-git-send-email-zapped@mail.ru","subject":"[PATCH 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-09T08:43:25Z","receivedAt":"2011-09-09T08:43:25Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"The following two ought to give the same output to a terminal:\n\n\t$ git log --oneline --no-color\n\t$ git log --pretty=format:'%h %s'\n\nHowever, the former pays attention to i18n.logOutputEncoding\nconfiguration, while the latter does not when it format \"%s\". A log\nmessages written in an encoding i18n.commitEncoding that differs\nfrom terminal encoding are shown corrupted with the latter even\nwhen i18n.logOutputEncoding and terminal encoding are the same.\n\nThe same corruption is true for\n\t$ git diff --submodule=log\nand\n\t$ git rev-list --pretty=format:%s HEAD\n\nSigned-off-by: Alexey Shumkin <zapped@mail.ru>\n---\n t/t4041-diff-submodule-option.sh |   44 +++++----\n t/t4205-log-pretty-formats.sh    |   22 ++++-\n t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------\n 3 files changed, 161 insertions(+), 97 deletions(-)\n\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex bf9a752..4460cff 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -1,6 +1,7 @@\n #!/bin/sh\n #\n # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin\n+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)\n #\n \n test_description='Support for verbose submodule differences in git diff\n@@ -10,6 +11,7 @@ This test tries to verify the sanity of the --submodule option of git diff.\n \n . ./test-lib.sh\n \n+added=$(printf \"\\320\\264\\320\\276\\320\\261\\320\\260\\320\\262\\320\\273\\320\\265\\320\\275\")\n add_file () {\n \tsm=$1\n \tshift\n@@ -19,8 +21,12 @@ add_file () {\n \t\techo \"$name\" > \"$name\" &&\n \t\tgit add \"$name\" &&\n \t\ttest_tick &&\n-\t\tgit commit -m \"Add $name\"\n+\t\tgit config i18n.commitEncoding cp1251 &&\n+\t\techo \"Add $name ($added $name)\" \\\n+\t\t\t| iconv -f utf-8 -t cp1251 \\\n+\t\t\t| xargs -I{} git commit -m \"{}\"\n \tdone >/dev/null\n+\tgit config --unset i18n.commitEncoding\n \tgit rev-parse --verify HEAD | cut -c1-7\n \tcd \"$owd\"\n }\n@@ -37,7 +43,7 @@ head1=$(add_file sm1 foo1 foo2)\n test_expect_success 'added submodule' \"\n \tgit add sm1 &&\n \tgit diff-index -p --submodule=log HEAD >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 0000000...$head1 (new submodule)\n EOF\n \ttest_cmp expected actual\n@@ -48,27 +54,27 @@ head2=$(add_file sm1 foo3)\n \n test_expect_success 'modified submodule(forward)' \"\n \tgit diff-index -p --submodule=log HEAD >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head1..$head2:\n-  > Add foo3\n+  > Add foo3 ($added foo3)\n EOF\n \ttest_cmp expected actual\n \"\n \n test_expect_success 'modified submodule(forward)' \"\n \tgit diff --submodule=log >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head1..$head2:\n-  > Add foo3\n+  > Add foo3 ($added foo3)\n EOF\n \ttest_cmp expected actual\n \"\n \n test_expect_success 'modified submodule(forward) --submodule' \"\n \tgit diff --submodule >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head1..$head2:\n-  > Add foo3\n+  > Add foo3 ($added foo3)\n EOF\n \ttest_cmp expected actual\n \"\n@@ -98,10 +104,10 @@ head3=$(\n \n test_expect_success 'modified submodule(backward)' \"\n \tgit diff-index -p --submodule=log HEAD >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head2..$head3 (rewind):\n-  < Add foo3\n-  < Add foo2\n+  < Add foo3 ($added foo3)\n+  < Add foo2 ($added foo2)\n EOF\n \ttest_cmp expected actual\n \"\n@@ -110,12 +116,12 @@ head4=$(add_file sm1 foo4 foo5) &&\n head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)\n test_expect_success 'modified submodule(backward and forward)' \"\n \tgit diff-index -p --submodule=log HEAD >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head2...$head4:\n-  > Add foo5\n-  > Add foo4\n-  < Add foo3\n-  < Add foo2\n+  > Add foo5 ($added foo5)\n+  > Add foo4 ($added foo4)\n+  < Add foo3 ($added foo3)\n+  < Add foo2 ($added foo2)\n EOF\n \ttest_cmp expected actual\n \"\n@@ -131,10 +137,10 @@ mv sm1-bak sm1\n test_expect_success 'typechanged submodule(submodule->blob), --cached' \"\n \tgit diff --submodule=log --cached >actual &&\n \tcat >expected <<-EOF &&\n-Submodule sm1 41fbea9...0000000 (submodule deleted)\n+Submodule sm1 $head4...0000000 (submodule deleted)\n diff --git a/sm1 b/sm1\n new file mode 100644\n-index 0000000..9da5fb8\n+index 0000000..$head5\n --- /dev/null\n +++ b/sm1\n @@ -0,0 +1 @@\n@@ -148,7 +154,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' \"\n \tcat >expected <<-EOF &&\n diff --git a/sm1 b/sm1\n deleted file mode 100644\n-index 9da5fb8..0000000\n+index $head5..0000000\n --- a/sm1\n +++ /dev/null\n @@ -1 +0,0 @@\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex 2ae9faa..96e0229 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -1,6 +1,7 @@\n #!/bin/sh\n #\n # Copyright (c) 2010, Will Palmer\n+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)\n #\n \n test_description='Test pretty formats'\n@@ -11,10 +12,13 @@ test_expect_success 'set up basic repos' '\n \t>bar &&\n \tgit add foo &&\n \ttest_tick &&\n-\tgit commit -m initial &&\n+\tgit config i18n.commitEncoding cp1251 &&\n+\tprintf \"initial \\320\\272\\320\\276\\320\\274\\320\\274\\320\\270\\321\\202\" \\\n+\t\t| iconv -f utf-8 -t cp1251 | xargs -I{} git commit -m \"{}\" &&\n \tgit add bar &&\n \ttest_tick &&\n-\tgit commit -m \"add bar\"\n+\tgit commit -m \"add bar\" &&\n+\tgit config --unset i18n.commitEncoding\n '\n \n test_expect_success 'alias builtin format' '\n@@ -38,6 +42,20 @@ test_expect_success 'alias user-defined format' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '\n+\tgit config i18n.logOutputEncoding cp1251 &&\n+\tgit log --oneline >expected-s &&\n+\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n+\tgit config --unset i18n.logOutputEncoding &&\n+\ttest_cmp expected-s actual-s\n+'\n+\n+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '\n+\tgit log --oneline >expected-s &&\n+\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n+\ttest_cmp expected-s actual-s\n+'\n+\n test_expect_success 'alias user-defined tformat' '\n \tgit log --pretty=\"tformat:%h\" >expected &&\n \tgit config pretty.test-alias \"tformat:%h\" &&\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex d918cc0..8d99635 100755\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -1,13 +1,34 @@\n #!/bin/sh\n \n+# Copyright (c) 2009 Jens Lehmann\n+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)\n+\n test_description='git rev-list --pretty=format test'\n \n . ./test-lib.sh\n \n test_tick\n+added=$(printf \"added (\\320\\264\\320\\276\\320\\261\\320\\260\\320\\262\\320\\273\\320\\265\\320\\275) foo\")\n+added_cp1251=$(echo \"$added\" | iconv -f utf-8 -t cp1251)\n+changed=$(printf \"changed (\\320\\264\\320\\276\\320\\261\\320\\260\\320\\262\\320\\273\\320\\265\\320\\275) foo\")\n+changed_cp1251=$(echo \"$changed\" | iconv -f utf-8 -t cp1251)\n+\n test_expect_success 'setup' '\n-touch foo && git add foo && git commit -m \"added foo\" &&\n-  echo changed >foo && git commit -a -m \"changed foo\"\n+\ttouch foo &&\n+\tgit add foo &&\n+\tgit config i18n.commitEncoding cp1251 &&\n+\tgit commit -m \"$added_cp1251\" &&\n+\thead1=$(git rev-parse --verify HEAD) &&\n+\thead1_7=$(echo $head1 | cut -c1-7) &&\n+\techo \"$changed\" > foo &&\n+\tgit commit -a -m \"$changed_cp1251\" &&\n+\thead2=$(git rev-parse --verify HEAD) &&\n+\thead2_7=$(echo $head2 | cut -c1-7) &&\n+\ttree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d\" \") &&\n+\ttree2_7=$(echo $tree2 | cut -c1-7) &&\n+\thead2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d\" \") &&\n+\thead2_parent_7=$(echo $head2_parent | cut -c1-7) &&\n+\tgit config --unset i18n.commitEncoding\n '\n \n # usage: test_format name format_string <expected_output\n@@ -19,49 +40,49 @@ test_cmp expect.$1 output.$1\n \"\n }\n \n-test_format percent %%h <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format percent %%h <<EOF\n+commit $head2\n %h\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n %h\n EOF\n \n-test_format hash %H%n%h <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-131a310eb913d107dd3c09a65d1651175898735d\n-131a310\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-86c75cf\n+test_format hash %H%n%h <<EOF\n+commit $head2\n+$head2\n+$head2_7\n+commit $head1\n+$head1\n+$head1_7\n EOF\n \n-test_format tree %T%n%t <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-fe722612f26da5064c32ca3843aa154bdb0b08a0\n-fe72261\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format tree %T%n%t <<EOF\n+commit $head2\n+$tree2\n+$tree2_7\n+commit $head1\n 4d5fcadc293a348e88f777dc0920f11e7d71441c\n 4d5fcad\n EOF\n \n-test_format parents %P%n%p <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-86c75cf\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format parents %P%n%p <<EOF\n+commit $head2\n+$head1\n+$head2_parent_7\n+commit $head1\n \n \n EOF\n \n # we don't test relative here\n-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF\n+commit $head2\n A U Thor\n author@example.com\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n A U Thor\n author@example.com\n Thu Apr 7 15:13:13 2005 -0700\n@@ -69,14 +90,14 @@ Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n EOF\n \n-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF\n+commit $head2\n C O Mitter\n committer@example.com\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n C O Mitter\n committer@example.com\n Thu Apr 7 15:13:13 2005 -0700\n@@ -84,86 +105,105 @@ Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n EOF\n \n-test_format encoding %e <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format encoding %e <<EOF\n+commit $head2\n+commit $head1\n EOF\n \n-test_format subject %s <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-changed foo\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-added foo\n+expected=$(printf \"commit $head2\\n\\\n+$changed\\n\\\n+commit $head1\\n\\\n+$added\n+\")\n+\n+test_format subject %s <<EOF\n+$expected\n EOF\n \n-test_format body %b <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format body %b <<EOF\n+commit $head2\n+commit $head1\n EOF\n \n-test_format raw-body %B <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-changed foo\n+expected=$(printf \"commit $head2\\n\\\n+$changed\\n\\\n+\\n\\\n+commit $head1\\n\\\n+$added\n+\")\n \n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-added foo\n+test_format raw-body %B <<EOF\n+$expected\n \n EOF\n \n-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF\n+commit $head2\n \u001b[31mfoo\u001b[32mbar\u001b[34mbaz\u001b[mxyzzy\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n \u001b[31mfoo\u001b[32mbar\u001b[34mbaz\u001b[mxyzzy\n EOF\n \n-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF\n+commit $head2\n \u001b[1;31;43mfoo\u001b[m\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n \u001b[1;31;43mfoo\u001b[m\n EOF\n \n-cat >commit-msg <<'EOF'\n+iconv -f utf-8 -t cp1251 > commit-msg <<EOF\n Test printing of complex bodies\n \n This commit message is much longer than the others,\n-and it will be encoded in iso8859-1. We should therefore\n-include an iso8859 character: ¡bueno!\n+and it will be encoded in cp1251. We should therefore\n+include an cp1251 character: так вот!\n EOF\n+\n test_expect_success 'setup complex body' '\n-git config i18n.commitencoding iso8859-1 &&\n-  echo change2 >foo && git commit -a -F commit-msg\n+\tgit config i18n.commitencoding cp1251 &&\n+\techo change2 >foo && git commit -a -F commit-msg &&\n+\thead3=$(git rev-parse --verify HEAD) &&\n+\thead3_7=$(echo $head3 | cut -c1-7)\n '\n \n-test_format complex-encoding %e <<'EOF'\n-commit f58db70b055c5718631e5c61528b28b12090cdea\n-iso8859-1\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format complex-encoding %e <<EOF\n+commit $head3\n+cp1251\n+commit $head2\n+cp1251\n+commit $head1\n+cp1251\n EOF\n \n-test_format complex-subject %s <<'EOF'\n-commit f58db70b055c5718631e5c61528b28b12090cdea\n-Test printing of complex bodies\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-changed foo\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-added foo\n+# unset commit encoding config\n+# otherwise %e does not print encoding value\n+# and following test fails\n+git config --unset i18n.commitencoding\n+\n+expected=$(printf \"commit $head3\\n\\\n+Test printing of complex bodies\\n\\\n+commit $head2\\n\\\n+$changed\\n\\\n+commit $head1\\n\\\n+$added\n+\")\n+\n+test_format complex-subject %s <<EOF\n+$expected\n EOF\n \n-test_format complex-body %b <<'EOF'\n-commit f58db70b055c5718631e5c61528b28b12090cdea\n+test_format complex-body %b <<EOF\n+commit $head3\n This commit message is much longer than the others,\n-and it will be encoded in iso8859-1. We should therefore\n-include an iso8859 character: ¡bueno!\n+and it will be encoded in cp1251. We should therefore\n+include an cp1251 character: так вот!\n \n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head2\n+commit $head1\n EOF\n \n test_expect_success '%x00 shows NUL' '\n-\techo  >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&\n+\techo  >expect commit $head3 &&\n \techo >>expect fooQbar &&\n \tgit rev-list -1 --format=foo%x00bar HEAD >actual.nul &&\n \tnul_to_q <actual.nul >actual &&\n@@ -210,12 +250,12 @@ test_expect_success 'add LF before non-empty (2)' '\n \n test_expect_success 'add SP before non-empty (1)' '\n \tgit show -s --pretty=format:\"%s% bThanks\" HEAD^^ >actual &&\n-\ttest $(wc -w <actual) = 2\n+\ttest $(wc -w <actual) = 3\n '\n \n test_expect_success 'add SP before non-empty (2)' '\n \tgit show -s --pretty=format:\"%s% sThanks\" HEAD^^ >actual &&\n-\ttest $(wc -w <actual) = 4\n+\ttest $(wc -w <actual) = 6\n '\n \n test_expect_success '--abbrev' '\n-- \n1.7.6.1.g8f21c\n"},{"id":"175157","messageId":"1315557806-5555-3-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"1315557806-5555-1-git-send-email-zapped@mail.ru","subject":"[PATCH 2/2] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-09T08:43:26Z","receivedAt":"2011-09-09T08:43:26Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"The following two ought to give the same output to a terminal:\n\n\t$ git log --oneline --no-color\n\t$ git log --pretty=format:'%h %s'\n\nHowever, the former pays attention to i18n.logOutputEncoding\nconfiguration, while the latter does not when it format \"%s\". A log\nmessages written in an encoding i18n.commitEncoding that differs\nfrom terminal encoding are shown corrupted with the latter even\nwhen i18n.logOutputEncoding and terminal encoding are the same.\n\nThe same corruption is true for\n\t$ git diff --submodule=log\nand\n\t$ git rev-list --pretty=format:%s HEAD\n\nSigned-off-by: Alexey Shumkin <zapped@mail.ru>\n---\n builtin/rev-list.c |    1 +\n builtin/shortlog.c |    1 +\n log-tree.c         |    1 +\n submodule.c        |    3 +++\n 4 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 56727e8..831077d 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -105,6 +105,7 @@ static void show_commit(struct commit *commit, void *data)\n \t\tctx.abbrev = revs->abbrev;\n \t\tctx.date_mode = revs->date_mode;\n \t\tctx.fmt = revs->commit_format;\n+\t\tctx.output_encoding = get_log_output_encoding();\n \t\tpretty_print_commit(&ctx, commit, &buf);\n \t\tif (revs->graph) {\n \t\t\tif (buf.len) {\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 37f3193..eba4086 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -163,6 +163,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)\n \t\tctx.subject = \"\";\n \t\tctx.after_subject = \"\";\n \t\tctx.date_mode = DATE_NORMAL;\n+\t\tctx.output_encoding = get_log_output_encoding();\n \t\tpretty_print_commit(&ctx, commit, &ufbuf);\n \t\tbuffer = ufbuf.buf;\n \t} else if (*buffer) {\ndiff --git a/log-tree.c b/log-tree.c\nindex e945701..39913d7 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)\n \tctx.preserve_subject = opt->preserve_subject;\n \tctx.reflog_info = opt->reflog_info;\n \tctx.fmt = opt->commit_format;\n+\tctx.output_encoding = get_log_output_encoding();\n \tpretty_print_commit(&ctx, commit, &msgbuf);\n \n \tif (opt->add_signoff)\ndiff --git a/submodule.c b/submodule.c\nindex b6dec70..26efef4 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -213,10 +213,13 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,\n \tstatic const char format[] = \"  %m %s\";\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct commit *commit;\n+\tconst char *log_output_encoding;\n \n+\tlog_output_encoding = get_log_output_encoding();\n \twhile ((commit = get_revision(rev))) {\n \t\tstruct pretty_print_context ctx = {0};\n \t\tctx.date_mode = rev->date_mode;\n+\t\tctx.output_encoding = log_output_encoding;\n \t\tstrbuf_setlen(&sb, 0);\n \t\tif (commit->object.flags & SYMMETRIC_LEFT) {\n \t\t\tif (del)\n-- \n1.7.6.1.g8f21c\n"},{"id":"175159","messageId":"1315558437-6295-1-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"7vwrf6qh49.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-09T08:53:55Z","receivedAt":"2011-09-09T08:53:55Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"Ooops! previuos message haven't Cc-ed to Junio.\nThis one is CC-ed.\nI discovered two more commands affected with this bug.\nSo I reroll this patch and tests for it.\n\n>>(question) Does this change affect other commands, most notably  \n>>format-patch, and if so how?\nNo, it does not affect format-patch\n\n---\n\n builtin/rev-list.c               |    1 +\n builtin/shortlog.c               |    1 +\n log-tree.c                       |    1 +\n submodule.c                      |    3 +\n t/t4041-diff-submodule-option.sh |   44 +++++----\n t/t4205-log-pretty-formats.sh    |   22 ++++-\n t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------\n 7 files changed, 167 insertions(+), 97 deletions(-)\n"},{"id":"175160","messageId":"1315558437-6295-2-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"1315558437-6295-1-git-send-email-zapped@mail.ru","subject":"[PATCH 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-09T08:53:56Z","receivedAt":"2011-09-09T08:53:56Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"The following two ought to give the same output to a terminal:\n\n\t$ git log --oneline --no-color\n\t$ git log --pretty=format:'%h %s'\n\nHowever, the former pays attention to i18n.logOutputEncoding\nconfiguration, while the latter does not when it format \"%s\". A log\nmessages written in an encoding i18n.commitEncoding that differs\nfrom terminal encoding are shown corrupted with the latter even\nwhen i18n.logOutputEncoding and terminal encoding are the same.\n\nThe same corruption is true for\n\t$ git diff --submodule=log\nand\n\t$ git rev-list --pretty=format:%s HEAD\n\nSigned-off-by: Alexey Shumkin <zapped@mail.ru>\n---\n t/t4041-diff-submodule-option.sh |   44 +++++----\n t/t4205-log-pretty-formats.sh    |   22 ++++-\n t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------\n 3 files changed, 161 insertions(+), 97 deletions(-)\n\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex bf9a752..4460cff 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -1,6 +1,7 @@\n #!/bin/sh\n #\n # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin\n+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)\n #\n \n test_description='Support for verbose submodule differences in git diff\n@@ -10,6 +11,7 @@ This test tries to verify the sanity of the --submodule option of git diff.\n \n . ./test-lib.sh\n \n+added=$(printf \"\\320\\264\\320\\276\\320\\261\\320\\260\\320\\262\\320\\273\\320\\265\\320\\275\")\n add_file () {\n \tsm=$1\n \tshift\n@@ -19,8 +21,12 @@ add_file () {\n \t\techo \"$name\" > \"$name\" &&\n \t\tgit add \"$name\" &&\n \t\ttest_tick &&\n-\t\tgit commit -m \"Add $name\"\n+\t\tgit config i18n.commitEncoding cp1251 &&\n+\t\techo \"Add $name ($added $name)\" \\\n+\t\t\t| iconv -f utf-8 -t cp1251 \\\n+\t\t\t| xargs -I{} git commit -m \"{}\"\n \tdone >/dev/null\n+\tgit config --unset i18n.commitEncoding\n \tgit rev-parse --verify HEAD | cut -c1-7\n \tcd \"$owd\"\n }\n@@ -37,7 +43,7 @@ head1=$(add_file sm1 foo1 foo2)\n test_expect_success 'added submodule' \"\n \tgit add sm1 &&\n \tgit diff-index -p --submodule=log HEAD >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 0000000...$head1 (new submodule)\n EOF\n \ttest_cmp expected actual\n@@ -48,27 +54,27 @@ head2=$(add_file sm1 foo3)\n \n test_expect_success 'modified submodule(forward)' \"\n \tgit diff-index -p --submodule=log HEAD >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head1..$head2:\n-  > Add foo3\n+  > Add foo3 ($added foo3)\n EOF\n \ttest_cmp expected actual\n \"\n \n test_expect_success 'modified submodule(forward)' \"\n \tgit diff --submodule=log >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head1..$head2:\n-  > Add foo3\n+  > Add foo3 ($added foo3)\n EOF\n \ttest_cmp expected actual\n \"\n \n test_expect_success 'modified submodule(forward) --submodule' \"\n \tgit diff --submodule >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head1..$head2:\n-  > Add foo3\n+  > Add foo3 ($added foo3)\n EOF\n \ttest_cmp expected actual\n \"\n@@ -98,10 +104,10 @@ head3=$(\n \n test_expect_success 'modified submodule(backward)' \"\n \tgit diff-index -p --submodule=log HEAD >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head2..$head3 (rewind):\n-  < Add foo3\n-  < Add foo2\n+  < Add foo3 ($added foo3)\n+  < Add foo2 ($added foo2)\n EOF\n \ttest_cmp expected actual\n \"\n@@ -110,12 +116,12 @@ head4=$(add_file sm1 foo4 foo5) &&\n head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)\n test_expect_success 'modified submodule(backward and forward)' \"\n \tgit diff-index -p --submodule=log HEAD >actual &&\n-\tcat >expected <<-EOF &&\n+\tcat >expected <<EOF\n Submodule sm1 $head2...$head4:\n-  > Add foo5\n-  > Add foo4\n-  < Add foo3\n-  < Add foo2\n+  > Add foo5 ($added foo5)\n+  > Add foo4 ($added foo4)\n+  < Add foo3 ($added foo3)\n+  < Add foo2 ($added foo2)\n EOF\n \ttest_cmp expected actual\n \"\n@@ -131,10 +137,10 @@ mv sm1-bak sm1\n test_expect_success 'typechanged submodule(submodule->blob), --cached' \"\n \tgit diff --submodule=log --cached >actual &&\n \tcat >expected <<-EOF &&\n-Submodule sm1 41fbea9...0000000 (submodule deleted)\n+Submodule sm1 $head4...0000000 (submodule deleted)\n diff --git a/sm1 b/sm1\n new file mode 100644\n-index 0000000..9da5fb8\n+index 0000000..$head5\n --- /dev/null\n +++ b/sm1\n @@ -0,0 +1 @@\n@@ -148,7 +154,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' \"\n \tcat >expected <<-EOF &&\n diff --git a/sm1 b/sm1\n deleted file mode 100644\n-index 9da5fb8..0000000\n+index $head5..0000000\n --- a/sm1\n +++ /dev/null\n @@ -1 +0,0 @@\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex 2ae9faa..96e0229 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -1,6 +1,7 @@\n #!/bin/sh\n #\n # Copyright (c) 2010, Will Palmer\n+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)\n #\n \n test_description='Test pretty formats'\n@@ -11,10 +12,13 @@ test_expect_success 'set up basic repos' '\n \t>bar &&\n \tgit add foo &&\n \ttest_tick &&\n-\tgit commit -m initial &&\n+\tgit config i18n.commitEncoding cp1251 &&\n+\tprintf \"initial \\320\\272\\320\\276\\320\\274\\320\\274\\320\\270\\321\\202\" \\\n+\t\t| iconv -f utf-8 -t cp1251 | xargs -I{} git commit -m \"{}\" &&\n \tgit add bar &&\n \ttest_tick &&\n-\tgit commit -m \"add bar\"\n+\tgit commit -m \"add bar\" &&\n+\tgit config --unset i18n.commitEncoding\n '\n \n test_expect_success 'alias builtin format' '\n@@ -38,6 +42,20 @@ test_expect_success 'alias user-defined format' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '\n+\tgit config i18n.logOutputEncoding cp1251 &&\n+\tgit log --oneline >expected-s &&\n+\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n+\tgit config --unset i18n.logOutputEncoding &&\n+\ttest_cmp expected-s actual-s\n+'\n+\n+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '\n+\tgit log --oneline >expected-s &&\n+\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n+\ttest_cmp expected-s actual-s\n+'\n+\n test_expect_success 'alias user-defined tformat' '\n \tgit log --pretty=\"tformat:%h\" >expected &&\n \tgit config pretty.test-alias \"tformat:%h\" &&\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex d918cc0..8d99635 100755\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -1,13 +1,34 @@\n #!/bin/sh\n \n+# Copyright (c) 2009 Jens Lehmann\n+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)\n+\n test_description='git rev-list --pretty=format test'\n \n . ./test-lib.sh\n \n test_tick\n+added=$(printf \"added (\\320\\264\\320\\276\\320\\261\\320\\260\\320\\262\\320\\273\\320\\265\\320\\275) foo\")\n+added_cp1251=$(echo \"$added\" | iconv -f utf-8 -t cp1251)\n+changed=$(printf \"changed (\\320\\264\\320\\276\\320\\261\\320\\260\\320\\262\\320\\273\\320\\265\\320\\275) foo\")\n+changed_cp1251=$(echo \"$changed\" | iconv -f utf-8 -t cp1251)\n+\n test_expect_success 'setup' '\n-touch foo && git add foo && git commit -m \"added foo\" &&\n-  echo changed >foo && git commit -a -m \"changed foo\"\n+\ttouch foo &&\n+\tgit add foo &&\n+\tgit config i18n.commitEncoding cp1251 &&\n+\tgit commit -m \"$added_cp1251\" &&\n+\thead1=$(git rev-parse --verify HEAD) &&\n+\thead1_7=$(echo $head1 | cut -c1-7) &&\n+\techo \"$changed\" > foo &&\n+\tgit commit -a -m \"$changed_cp1251\" &&\n+\thead2=$(git rev-parse --verify HEAD) &&\n+\thead2_7=$(echo $head2 | cut -c1-7) &&\n+\ttree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d\" \") &&\n+\ttree2_7=$(echo $tree2 | cut -c1-7) &&\n+\thead2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d\" \") &&\n+\thead2_parent_7=$(echo $head2_parent | cut -c1-7) &&\n+\tgit config --unset i18n.commitEncoding\n '\n \n # usage: test_format name format_string <expected_output\n@@ -19,49 +40,49 @@ test_cmp expect.$1 output.$1\n \"\n }\n \n-test_format percent %%h <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format percent %%h <<EOF\n+commit $head2\n %h\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n %h\n EOF\n \n-test_format hash %H%n%h <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-131a310eb913d107dd3c09a65d1651175898735d\n-131a310\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-86c75cf\n+test_format hash %H%n%h <<EOF\n+commit $head2\n+$head2\n+$head2_7\n+commit $head1\n+$head1\n+$head1_7\n EOF\n \n-test_format tree %T%n%t <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-fe722612f26da5064c32ca3843aa154bdb0b08a0\n-fe72261\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format tree %T%n%t <<EOF\n+commit $head2\n+$tree2\n+$tree2_7\n+commit $head1\n 4d5fcadc293a348e88f777dc0920f11e7d71441c\n 4d5fcad\n EOF\n \n-test_format parents %P%n%p <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-86c75cf\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format parents %P%n%p <<EOF\n+commit $head2\n+$head1\n+$head2_parent_7\n+commit $head1\n \n \n EOF\n \n # we don't test relative here\n-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF\n+commit $head2\n A U Thor\n author@example.com\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n A U Thor\n author@example.com\n Thu Apr 7 15:13:13 2005 -0700\n@@ -69,14 +90,14 @@ Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n EOF\n \n-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF\n+commit $head2\n C O Mitter\n committer@example.com\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n C O Mitter\n committer@example.com\n Thu Apr 7 15:13:13 2005 -0700\n@@ -84,86 +105,105 @@ Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n EOF\n \n-test_format encoding %e <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format encoding %e <<EOF\n+commit $head2\n+commit $head1\n EOF\n \n-test_format subject %s <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-changed foo\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-added foo\n+expected=$(printf \"commit $head2\\n\\\n+$changed\\n\\\n+commit $head1\\n\\\n+$added\n+\")\n+\n+test_format subject %s <<EOF\n+$expected\n EOF\n \n-test_format body %b <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format body %b <<EOF\n+commit $head2\n+commit $head1\n EOF\n \n-test_format raw-body %B <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-changed foo\n+expected=$(printf \"commit $head2\\n\\\n+$changed\\n\\\n+\\n\\\n+commit $head1\\n\\\n+$added\n+\")\n \n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-added foo\n+test_format raw-body %B <<EOF\n+$expected\n \n EOF\n \n-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF\n+commit $head2\n \u001b[31mfoo\u001b[32mbar\u001b[34mbaz\u001b[mxyzzy\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n \u001b[31mfoo\u001b[32mbar\u001b[34mbaz\u001b[mxyzzy\n EOF\n \n-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF\n+commit $head2\n \u001b[1;31;43mfoo\u001b[m\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head1\n \u001b[1;31;43mfoo\u001b[m\n EOF\n \n-cat >commit-msg <<'EOF'\n+iconv -f utf-8 -t cp1251 > commit-msg <<EOF\n Test printing of complex bodies\n \n This commit message is much longer than the others,\n-and it will be encoded in iso8859-1. We should therefore\n-include an iso8859 character: ¡bueno!\n+and it will be encoded in cp1251. We should therefore\n+include an cp1251 character: так вот!\n EOF\n+\n test_expect_success 'setup complex body' '\n-git config i18n.commitencoding iso8859-1 &&\n-  echo change2 >foo && git commit -a -F commit-msg\n+\tgit config i18n.commitencoding cp1251 &&\n+\techo change2 >foo && git commit -a -F commit-msg &&\n+\thead3=$(git rev-parse --verify HEAD) &&\n+\thead3_7=$(echo $head3 | cut -c1-7)\n '\n \n-test_format complex-encoding %e <<'EOF'\n-commit f58db70b055c5718631e5c61528b28b12090cdea\n-iso8859-1\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+test_format complex-encoding %e <<EOF\n+commit $head3\n+cp1251\n+commit $head2\n+cp1251\n+commit $head1\n+cp1251\n EOF\n \n-test_format complex-subject %s <<'EOF'\n-commit f58db70b055c5718631e5c61528b28b12090cdea\n-Test printing of complex bodies\n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-changed foo\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-added foo\n+# unset commit encoding config\n+# otherwise %e does not print encoding value\n+# and following test fails\n+git config --unset i18n.commitencoding\n+\n+expected=$(printf \"commit $head3\\n\\\n+Test printing of complex bodies\\n\\\n+commit $head2\\n\\\n+$changed\\n\\\n+commit $head1\\n\\\n+$added\n+\")\n+\n+test_format complex-subject %s <<EOF\n+$expected\n EOF\n \n-test_format complex-body %b <<'EOF'\n-commit f58db70b055c5718631e5c61528b28b12090cdea\n+test_format complex-body %b <<EOF\n+commit $head3\n This commit message is much longer than the others,\n-and it will be encoded in iso8859-1. We should therefore\n-include an iso8859 character: ¡bueno!\n+and it will be encoded in cp1251. We should therefore\n+include an cp1251 character: так вот!\n \n-commit 131a310eb913d107dd3c09a65d1651175898735d\n-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+commit $head2\n+commit $head1\n EOF\n \n test_expect_success '%x00 shows NUL' '\n-\techo  >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&\n+\techo  >expect commit $head3 &&\n \techo >>expect fooQbar &&\n \tgit rev-list -1 --format=foo%x00bar HEAD >actual.nul &&\n \tnul_to_q <actual.nul >actual &&\n@@ -210,12 +250,12 @@ test_expect_success 'add LF before non-empty (2)' '\n \n test_expect_success 'add SP before non-empty (1)' '\n \tgit show -s --pretty=format:\"%s% bThanks\" HEAD^^ >actual &&\n-\ttest $(wc -w <actual) = 2\n+\ttest $(wc -w <actual) = 3\n '\n \n test_expect_success 'add SP before non-empty (2)' '\n \tgit show -s --pretty=format:\"%s% sThanks\" HEAD^^ >actual &&\n-\ttest $(wc -w <actual) = 4\n+\ttest $(wc -w <actual) = 6\n '\n \n test_expect_success '--abbrev' '\n-- \n1.7.6.1.g8f21c\n"},{"id":"175161","messageId":"1315558437-6295-3-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"1315558437-6295-1-git-send-email-zapped@mail.ru","subject":"[PATCH 2/2] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-09T08:53:57Z","receivedAt":"2011-09-09T08:53:57Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"The following two ought to give the same output to a terminal:\n\n\t$ git log --oneline --no-color\n\t$ git log --pretty=format:'%h %s'\n\nHowever, the former pays attention to i18n.logOutputEncoding\nconfiguration, while the latter does not when it format \"%s\". A log\nmessages written in an encoding i18n.commitEncoding that differs\nfrom terminal encoding are shown corrupted with the latter even\nwhen i18n.logOutputEncoding and terminal encoding are the same.\n\nThe same corruption is true for\n\t$ git diff --submodule=log\nand\n\t$ git rev-list --pretty=format:%s HEAD\n\nSigned-off-by: Alexey Shumkin <zapped@mail.ru>\n---\n builtin/rev-list.c |    1 +\n builtin/shortlog.c |    1 +\n log-tree.c         |    1 +\n submodule.c        |    3 +++\n 4 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 56727e8..831077d 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -105,6 +105,7 @@ static void show_commit(struct commit *commit, void *data)\n \t\tctx.abbrev = revs->abbrev;\n \t\tctx.date_mode = revs->date_mode;\n \t\tctx.fmt = revs->commit_format;\n+\t\tctx.output_encoding = get_log_output_encoding();\n \t\tpretty_print_commit(&ctx, commit, &buf);\n \t\tif (revs->graph) {\n \t\t\tif (buf.len) {\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 37f3193..eba4086 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -163,6 +163,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)\n \t\tctx.subject = \"\";\n \t\tctx.after_subject = \"\";\n \t\tctx.date_mode = DATE_NORMAL;\n+\t\tctx.output_encoding = get_log_output_encoding();\n \t\tpretty_print_commit(&ctx, commit, &ufbuf);\n \t\tbuffer = ufbuf.buf;\n \t} else if (*buffer) {\ndiff --git a/log-tree.c b/log-tree.c\nindex e945701..39913d7 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)\n \tctx.preserve_subject = opt->preserve_subject;\n \tctx.reflog_info = opt->reflog_info;\n \tctx.fmt = opt->commit_format;\n+\tctx.output_encoding = get_log_output_encoding();\n \tpretty_print_commit(&ctx, commit, &msgbuf);\n \n \tif (opt->add_signoff)\ndiff --git a/submodule.c b/submodule.c\nindex b6dec70..26efef4 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -213,10 +213,13 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,\n \tstatic const char format[] = \"  %m %s\";\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct commit *commit;\n+\tconst char *log_output_encoding;\n \n+\tlog_output_encoding = get_log_output_encoding();\n \twhile ((commit = get_revision(rev))) {\n \t\tstruct pretty_print_context ctx = {0};\n \t\tctx.date_mode = rev->date_mode;\n+\t\tctx.output_encoding = log_output_encoding;\n \t\tstrbuf_setlen(&sb, 0);\n \t\tif (commit->object.flags & SYMMETRIC_LEFT) {\n \t\t\tif (del)\n-- \n1.7.6.1.g8f21c\n"},{"id":"175249","messageId":"7v1uvptjhr.fsf@alter.siamese.dyndns.org","threadId":"27912","inReplyTo":"1315558437-6295-2-git-send-email-zapped@mail.ru","subject":"Re: [PATCH 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-09T22:54:08Z","receivedAt":"2011-09-09T22:54:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexey Shumkin <zapped@mail.ru> writes:\n\n> The following two ought to give the same output to a terminal:\n>\n> \t$ git log --oneline --no-color\n> \t$ git log --pretty=format:'%h %s'\n>\n> However, the former pays attention to i18n.logOutputEncoding\n> configuration, while the latter does not when it format \"%s\". A log\n> messages written in an encoding i18n.commitEncoding that differs\n> from terminal encoding are shown corrupted with the latter even\n> when i18n.logOutputEncoding and terminal encoding are the same.\n\nYou seem to have inherited bad grammar from some example; I wonder\nwhere... ;-)\n\n> @@ -19,8 +21,12 @@ add_file () {\n>  \t\techo \"$name\" > \"$name\" &&\n>  \t\tgit add \"$name\" &&\n>  \t\ttest_tick &&\n> -\t\tgit commit -m \"Add $name\"\n> +\t\tgit config i18n.commitEncoding cp1251 &&\n> +\t\techo \"Add $name ($added $name)\" \\\n> +\t\t\t| iconv -f utf-8 -t cp1251 \\\n> +\t\t\t| xargs -I{} git commit -m \"{}\"\n\nDon't do this. Format it this way instead if you want to use multi-line:\n\n\techo \"...\" |\n        iconv ... |\n        xargs ...\n\nI also am not sure if -I{} in xargs is all that portable. Why isn't it\nmore like this, which would be far easier to read?\n\n\tmsg_in_cp1251=$(echo \"Add ...\" | iconv ...) &&\n        git commit -m \"$msg_in_cp1251\" &&\n        ...\n\nAlso do not break the && chain.\n\n>  \tdone >/dev/null\n> +\tgit config --unset i18n.commitEncoding\n>  \tgit rev-parse --verify HEAD | cut -c1-7\n>  \tcd \"$owd\"\n>  }\n"},{"id":"175841","messageId":"1316506818-5968-1-git-send-email-zapped@mail.ru","threadId":"27912","inReplyTo":"7v1uvptjhr.fsf@alter.siamese.dyndns.org","subject":"[PATCH v3 0/2] pretty: user format ignores i18n.logOutputEncoding setting","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-20T08:20:16Z","receivedAt":"2011-09-20T08:20:16Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":">>You seem to have inherited bad grammar from some example; I wonder\n>>where... ;-)\nI rephrased... I made an attempt to as least ;)\n\n>>Format it this way instead if you want to use multi-line:\n>>\techo \"...\" |\n>>    iconv ... |\n>>    xargs ...\ndone\n\nAlexey Shumkin (2):\n  pretty: Add failing tests: user format ignores i18n.logOutputEncoding\n    setting\n  pretty: user format ignores i18n.logOutputEncoding setting\n\n builtin/rev-list.c               |    1 +\n builtin/shortlog.c               |    1 +\n log-tree.c                       |    1 +\n submodule.c                      |    3 +\n t/t4041-diff-submodule-option.sh |   56 ++++++------\n t/t4205-log-pretty-formats.sh    |   22 ++++-\n t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------\n 7 files changed, 170 insertions(+), 106 deletions(-)\n\n-- \n1.7.6.3.4.gf71f\n"}]}