From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Shumkin Subject: =?UTF-8?q?=5BPATCH=20v3=201/2=5D=20pretty=3A=20Add=20failing=20tests=3A=20user=20format=20ignores=20i18n=2ElogOutputEncoding=20setting?= Date: Tue, 20 Sep 2011 12:21:31 +0400 Message-ID: <1316506892-6072-1-git-send-email-zapped@mail.ru> References: <7v1uvptjhr.fsf@alter.siamese.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Alexey Shumkin , Junio C Hamano To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Sep 20 10:21:54 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R5vaT-0005hb-3g for gcvg-git-2@lo.gmane.org; Tue, 20 Sep 2011 10:21:53 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754504Ab1ITIVq convert rfc822-to-quoted-printable (ORCPT ); Tue, 20 Sep 2011 04:21:46 -0400 Received: from smtp18.mail.ru ([94.100.176.155]:60119 "EHLO smtp18.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754496Ab1ITIVo (ORCPT ); Tue, 20 Sep 2011 04:21:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=fGy3BCQAQBE/254bLBFg2T6WV8SJ/sc53Ogbuyg+WfU=; b=jcTitg8ceB+PZRWjiPUdTpPssVLwHJSUlg9RqS4W2Ga5hhbC2pKUryfTRGRb5NDe0WsUQxK55IEGdpvSzRze3Th6XCg3GzKkgRW1gLodmcEe7prt4xNj67Hea3ceXl9a; Received: from [91.77.19.104] (port=32228 helo=zappedws) by smtp18.mail.ru with asmtp id 1R5vaC-0008KO-00; Tue, 20 Sep 2011 12:21:36 +0400 Received: from Alex by zappedws with local (Exim 4.76) (envelope-from ) id 1R5vaA-0001ao-S6; Tue, 20 Sep 2011 12:21:34 +0400 X-Mailer: git-send-email 1.7.6.3.4.gf71f In-Reply-To: <7v1uvptjhr.fsf@alter.siamese.dyndns.org> X-Spam: Not detected Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: The following two commands are expected to give the same output to a te= rminal: $ git log --oneline --no-color $ git log --pretty=3Dformat:'%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=3Dlog and $ git rev-list --pretty=3Dformat:%s HEAD Signed-off-by: Alexey Shumkin --- t/t4041-diff-submodule-option.sh | 56 ++++++------ t/t4205-log-pretty-formats.sh | 22 ++++- t/t6006-rev-list-format.sh | 192 +++++++++++++++++++++++-------= -------- 3 files changed, 164 insertions(+), 106 deletions(-) diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-= option.sh index bf9a752..b0cec5e 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= ) # =20 test_description=3D'Support for verbose submodule differences in git d= iff @@ -10,6 +11,7 @@ This test tries to verify the sanity of the --submodu= le option of git diff. =20 . ./test-lib.sh =20 +added=3D$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320= \265\320\275") add_file () { sm=3D$1 shift @@ -19,8 +21,11 @@ add_file () { echo "$name" > "$name" && git add "$name" && test_tick && - git commit -m "Add $name" + msg_added_cp1251=3D$(echo "Add $name ($added $name)" | iconv -f utf-= 8 -t cp1251) &&=20 + git config i18n.commitEncoding cp1251 && + git commit -m "$msg_added_cp1251" done >/dev/null + git config --unset i18n.commitEncoding git rev-parse --verify HEAD | cut -c1-7 cd "$owd" } @@ -48,28 +53,25 @@ head2=3D$(add_file sm1 foo3) =20 test_expect_success 'modified submodule(forward)' " git diff-index -p --submodule=3Dlog HEAD >actual && - cat >expected <<-EOF && -Submodule sm1 $head1..$head2: - > Add foo3 -EOF + printf \"Submodule sm1 $head1..$head2:\n\ + > Add foo3 ($added foo3)\n\ +\" > expected && test_cmp expected actual " =20 test_expect_success 'modified submodule(forward)' " git diff --submodule=3Dlog >actual && - cat >expected <<-EOF && -Submodule sm1 $head1..$head2: - > Add foo3 -EOF + printf \"Submodule sm1 $head1..$head2:\n\ + > Add foo3 ($added foo3)\n\ +\" > expected && test_cmp expected actual " =20 test_expect_success 'modified submodule(forward) --submodule' " git diff --submodule >actual && - cat >expected <<-EOF && -Submodule sm1 $head1..$head2: - > Add foo3 -EOF + printf \"Submodule sm1 $head1..$head2:\n\ + > Add foo3 ($added foo3)\n\ +\" > expected && test_cmp expected actual " =20 @@ -98,11 +100,10 @@ head3=3D$( =20 test_expect_success 'modified submodule(backward)' " git diff-index -p --submodule=3Dlog HEAD >actual && - cat >expected <<-EOF && -Submodule sm1 $head2..$head3 (rewind): - < Add foo3 - < Add foo2 -EOF + printf \"Submodule sm1 $head2..$head3 (rewind):\n\ + < Add foo3 ($added foo3)\n\ + < Add foo2 ($added foo2)\n\ +\" > expected && test_cmp expected actual " =20 @@ -110,13 +111,12 @@ head4=3D$(add_file sm1 foo4 foo5) && head4_full=3D$(GIT_DIR=3Dsm1/.git git rev-parse --verify HEAD) test_expect_success 'modified submodule(backward and forward)' " git diff-index -p --submodule=3Dlog HEAD >actual && - cat >expected <<-EOF && -Submodule sm1 $head2...$head4: - > Add foo5 - > Add foo4 - < Add foo3 - < Add foo2 -EOF + printf \"Submodule sm1 $head2...$head4:\n\ + > Add foo5 ($added foo5)\n\ + > Add foo4 ($added foo4)\n\ + < Add foo3 ($added foo3)\n\ + < Add foo2 ($added foo2)\n\ +\" > expected && test_cmp expected actual " =20 @@ -131,10 +131,10 @@ mv sm1-bak sm1 test_expect_success 'typechanged submodule(submodule->blob), --cached'= " git diff --submodule=3Dlog --cached >actual && cat >expected <<-EOF && -Submodule sm1 41fbea9...0000000 (submodule deleted) +Submodule sm1 $head4...0000000 (submodule deleted) diff --git a/sm1 b/sm1 new file mode 100644 -index 0000000..9da5fb8 +index 0000000..$head5 --- /dev/null +++ b/sm1 @@ -0,0 +1 @@ @@ -148,7 +148,7 @@ test_expect_success 'typechanged submodule(submodul= e->blob)' " cat >expected <<-EOF && diff --git a/sm1 b/sm1 deleted file mode 100644 -index 9da5fb8..0000000 +index $head5..0000000 --- a/sm1 +++ /dev/null @@ -1 +0,0 @@ diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats= =2Esh index 2ae9faa..9da6835 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -1,6 +1,7 @@ #!/bin/sh # # Copyright (c) 2010, Will Palmer +# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding test= s) # =20 test_description=3D'Test pretty formats' @@ -11,10 +12,13 @@ test_expect_success 'set up basic repos' ' >bar && git add foo && test_tick && - git commit -m initial && + git config i18n.commitEncoding cp1251 && + msg_commit_cp1251=3D$(printf "initial \320\272\320\276\320\274\320\27= 4\320\270\321\202" | iconv -f utf-8 -t cp1251) && + git commit -m "$msg_commit_cp1251" && git add bar && test_tick && - git commit -m "add bar" + git commit -m "add bar" && + git config --unset i18n.commitEncoding ' =20 test_expect_success 'alias builtin format' ' @@ -38,6 +42,20 @@ test_expect_success 'alias user-defined format' ' test_cmp expected actual ' =20 +test_expect_success 'alias user-defined tformat with %s (cp1251 encodi= ng)' ' + git config i18n.logOutputEncoding cp1251 && + git log --oneline >expected-s && + git log --pretty=3D"tformat:%h %s" >actual-s && + git config --unset i18n.logOutputEncoding && + test_cmp expected-s actual-s +' + +test_expect_success 'alias user-defined tformat with %s (utf-8 encodin= g)' ' + git log --oneline >expected-s && + git log --pretty=3D"tformat:%h %s" >actual-s && + test_cmp expected-s actual-s +' + test_expect_success 'alias user-defined tformat' ' git log --pretty=3D"tformat:%h" >expected && git config pretty.test-alias "tformat:%h" && diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index d918cc0..8d99635 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -1,13 +1,34 @@ #!/bin/sh =20 +# Copyright (c) 2009 Jens Lehmann +# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests= ) + test_description=3D'git rev-list --pretty=3Dformat test' =20 . ./test-lib.sh =20 test_tick +added=3D$(printf "added (\320\264\320\276\320\261\320\260\320\262\320\= 273\320\265\320\275) foo") +added_cp1251=3D$(echo "$added" | iconv -f utf-8 -t cp1251) +changed=3D$(printf "changed (\320\264\320\276\320\261\320\260\320\262\= 320\273\320\265\320\275) foo") +changed_cp1251=3D$(echo "$changed" | iconv -f utf-8 -t cp1251) + test_expect_success 'setup' ' -touch foo && git add foo && git commit -m "added foo" && - echo changed >foo && git commit -a -m "changed foo" + touch foo && + git add foo && + git config i18n.commitEncoding cp1251 && + git commit -m "$added_cp1251" && + head1=3D$(git rev-parse --verify HEAD) && + head1_7=3D$(echo $head1 | cut -c1-7) && + echo "$changed" > foo && + git commit -a -m "$changed_cp1251" && + head2=3D$(git rev-parse --verify HEAD) && + head2_7=3D$(echo $head2 | cut -c1-7) && + tree2=3D$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") && + tree2_7=3D$(echo $tree2 | cut -c1-7) && + head2_parent=3D$(git cat-file -p HEAD | grep parent | cut -f 2 -d" ")= && + head2_parent_7=3D$(echo $head2_parent | cut -c1-7) && + git config --unset i18n.commitEncoding ' =20 # usage: test_format name format_string commit-msg <<'EOF' +iconv -f utf-8 -t cp1251 > commit-msg <foo && git commit -a -F commit-msg + git config i18n.commitencoding cp1251 && + echo change2 >foo && git commit -a -F commit-msg && + head3=3D$(git rev-parse --verify HEAD) && + head3_7=3D$(echo $head3 | cut -c1-7) ' =20 -test_format complex-encoding %e <<'EOF' -commit f58db70b055c5718631e5c61528b28b12090cdea -iso8859-1 -commit 131a310eb913d107dd3c09a65d1651175898735d -commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 +test_format complex-encoding %e <expect commit f58db70b055c5718631e5c61528b28b12090cdea && + echo >expect commit $head3 && echo >>expect fooQbar && git rev-list -1 --format=3Dfoo%x00bar HEAD >actual.nul && nul_to_q actual && @@ -210,12 +250,12 @@ test_expect_success 'add LF before non-empty (2)'= ' =20 test_expect_success 'add SP before non-empty (1)' ' git show -s --pretty=3Dformat:"%s% bThanks" HEAD^^ >actual && - test $(wc -w actual && - test $(wc -w