From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Shumkin Subject: =?UTF-8?q?=5BPATCH=201/2=5D=20pretty=3A=20Add=20failing=20tests=3A=20user=20format=20ignores=20i18n=2ElogOutputEncoding=20setting?= Date: Fri, 9 Sep 2011 12:53:56 +0400 Message-ID: <1315558437-6295-2-git-send-email-zapped@mail.ru> References: <7vwrf6qh49.fsf@alter.siamese.dyndns.org> <1315558437-6295-1-git-send-email-zapped@mail.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Junio C Hamano , Alexey Shumkin To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Fri Sep 09 10:54:41 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 1R1wrA-0003OZ-L7 for gcvg-git-2@lo.gmane.org; Fri, 09 Sep 2011 10:54:41 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933031Ab1IIIyi convert rfc822-to-quoted-printable (ORCPT ); Fri, 9 Sep 2011 04:54:38 -0400 Received: from smtp6.mail.ru ([94.100.176.48]:55537 "EHLO smtp6.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932827Ab1IIIyg (ORCPT ); Fri, 9 Sep 2011 04:54:36 -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=GyKsvu50VSafX/nJ1/Ko7QjOSg3sgPN9CTepe+Fl8GA=; b=KEKyUH+TDL+gLq2SHHExiH2cGifOhs5HWjmQXm1Bg4fNc0LEdigwCx45oMqXkHAJNcXs3GSI7Y1vvQLJ7NL1CyLF7APBu0ITeGk0hMn3snZyEIINts+ak9Z+zsJsr0fj; Received: from [91.77.44.195] (port=13592 helo=zappedws) by smtp6.mail.ru with asmtp id 1R1wr3-00077i-00; Fri, 09 Sep 2011 12:54:34 +0400 Received: from Alex by zappedws with local (Exim 4.76) (envelope-from ) id 1R1wqV-0001f5-Iq; Fri, 09 Sep 2011 12:53:59 +0400 X-Mailer: git-send-email 1.7.6.1.g8f21c In-Reply-To: <1315558437-6295-1-git-send-email-zapped@mail.ru> X-Spam: Not detected X-Mras: Ok Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: The following two ought to give the same output to a terminal: $ 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". A log messages written in an encoding i18n.commitEncoding that 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 | 44 +++++---- t/t4205-log-pretty-formats.sh | 22 ++++- t/t6006-rev-list-format.sh | 192 +++++++++++++++++++++++-------= -------- 3 files changed, 161 insertions(+), 97 deletions(-) diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-= option.sh index bf9a752..4460cff 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,12 @@ add_file () { echo "$name" > "$name" && git add "$name" && test_tick && - git commit -m "Add $name" + git config i18n.commitEncoding cp1251 && + echo "Add $name ($added $name)" \ + | iconv -f utf-8 -t cp1251 \ + | xargs -I{} git commit -m "{}" done >/dev/null + git config --unset i18n.commitEncoding git rev-parse --verify HEAD | cut -c1-7 cd "$owd" } @@ -37,7 +43,7 @@ head1=3D$(add_file sm1 foo1 foo2) test_expect_success 'added submodule' " git add sm1 && git diff-index -p --submodule=3Dlog HEAD >actual && - cat >expected <<-EOF && + cat >expected <actual && - cat >expected <<-EOF && + cat >expected < Add foo3 + > Add foo3 ($added foo3) EOF test_cmp expected actual " =20 test_expect_success 'modified submodule(forward)' " git diff --submodule=3Dlog >actual && - cat >expected <<-EOF && + cat >expected < Add foo3 + > Add foo3 ($added foo3) EOF test_cmp expected actual " =20 test_expect_success 'modified submodule(forward) --submodule' " git diff --submodule >actual && - cat >expected <<-EOF && + cat >expected < Add foo3 + > Add foo3 ($added foo3) EOF test_cmp expected actual " @@ -98,10 +104,10 @@ head3=3D$( =20 test_expect_success 'modified submodule(backward)' " git diff-index -p --submodule=3Dlog HEAD >actual && - cat >expected <<-EOF && + cat >expected <actual && - cat >expected <<-EOF && + cat >expected < 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 " @@ -131,10 +137,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 +154,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..96e0229 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 && + printf "initial \320\272\320\276\320\274\320\274\320\270\321\202" \ + | iconv -f utf-8 -t cp1251 | xargs -I{} git commit -m "{}" && 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