From: Johannes Sixt <j.sixt@viscovery.net>
To: Alexey Shumkin <Alex.Crezoff@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
Date: Tue, 02 Jul 2013 08:46:19 +0200 [thread overview]
Message-ID: <51D2773B.9020006@viscovery.net> (raw)
In-Reply-To: <f0307d1e6d5bebb0a90ff1c0ffe70f8ef32f78df.1372719264.git.Alex.Crezoff@gmail.com>
Am 7/2/2013 1:19, schrieb Alexey Shumkin:
> +commit_msg() {
> + # String "initial. initial" partly in German
> + # (translated with Google Translate),
> + # encoded in UTF-8, used as a commit log message below.
> + msg=$(printf "initial. anf\303\244nglich")
> + if test -n "$1"
> + then
> + msg=$(echo $msg | iconv -f utf-8 -t $1)
> + fi
> + if test -n "$2" -a -n "$3"
> + then
> + # cut string, replace cut part with two dots
> + # $2 - chars count from the beginning of the string
> + # $3 - "trailing" chars
> + # LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
> + # as it does with C locale
> + msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
> + fi
> + echo $msg
> +}
Ignoring failure reports is not very helpful. Anyway, here is how I would
adjust this patch. (There are trivial conflicts when 5/5 is applied on
top.) Notice the comment I added in test case 'left alignment formatting
with ltrunc'.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
To be squashed into v8 4/5:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index a23da67..ef3a226 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,25 +7,13 @@
test_description='Test pretty formats'
. ./test-lib.sh
-commit_msg() {
- # String "initial. initial" partly in German
- # (translated with Google Translate),
- # encoded in UTF-8, used as a commit log message below.
- msg=$(printf "initial. anf\303\244nglich")
- if test -n "$1"
- then
- msg=$(echo $msg | iconv -f utf-8 -t $1)
- fi
- if test -n "$2" -a -n "$3"
- then
- # cut string, replace cut part with two dots
- # $2 - chars count from the beginning of the string
- # $3 - "trailing" chars
- # LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
- # as it does with C locale
- msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
- fi
- echo $msg
+# String "initial. initial" partly in German encoded in UTF-8
+initial_msg=$(printf "initial. anf\303\244nglich")
+
+# extract part of the initial commit message
+# $1 - a RE with \( \) brackets that specify which part to keep
+extract_msg() {
+ echo "$initial_msg" | sed -e "s/$1/\1/"
}
test_expect_success 'set up basic repos' '
@@ -33,12 +21,11 @@ test_expect_success 'set up basic repos' '
>bar &&
git add foo &&
test_tick &&
- git config i18n.commitEncoding iso8859-1 &&
- git commit -m "$(commit_msg iso8859-1)" &&
+ test_config i18n.commitEncoding iso8859-1 &&
+ git commit -m "$(echo "$initial_msg" | iconv -f utf-8 -t iso8859-1)" &&
git add bar &&
test_tick &&
- git commit -m "add bar" &&
- git config --unset i18n.commitEncoding
+ git commit -m "add bar"
'
test_expect_success 'alias builtin format' '
@@ -63,10 +50,9 @@ test_expect_success 'alias user-defined format' '
'
test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
- git config i18n.logOutputEncoding iso8859-1 &&
+ test_config i18n.logOutputEncoding iso8859-1 &&
git log --oneline >expected-s &&
git log --pretty="tformat:%h %s" >actual-s &&
- git config --unset i18n.logOutputEncoding &&
test_cmp expected-s actual-s
'
@@ -110,13 +96,13 @@ test_expect_success 'alias loop' '
'
test_expect_failure 'NUL separation' '
- printf "add bar\0$(commit_msg)" >expected &&
+ printf "add bar\0$initial_msg" >expected &&
git log -z --pretty="format:%s" >actual &&
test_cmp expected actual
'
test_expect_failure 'NUL termination' '
- printf "add bar\0$(commit_msg)\0" >expected &&
+ printf "add bar\0$initial_msg\0" >expected &&
git log -z --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
@@ -124,7 +110,7 @@ test_expect_failure 'NUL termination' '
test_expect_failure 'NUL separation with --stat' '
stat0_part=$(git diff --stat HEAD^ HEAD) &&
stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
- printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
+ printf "add bar\n$stat0_part\n\0$initial_msg\n$stat1_part\n" >expected &&
git log -z --stat --pretty="format:%s" >actual &&
test_i18ncmp expected actual
'
@@ -132,7 +118,7 @@ test_expect_failure 'NUL separation with --stat' '
test_expect_failure 'NUL termination with --stat' '
stat0_part=$(git diff --stat HEAD^ HEAD) &&
stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
- printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
+ printf "add bar\n$stat0_part\n\0$initial_msg\n$stat1_part\n0" >expected &&
git log -z --stat --pretty="tformat:%s" >actual &&
test_i18ncmp expected actual
'
@@ -154,7 +140,7 @@ test_expect_failure 'left alignment formatting' '
message two Z
message one Z
add bar Z
-$(commit_msg) Z
+$initial_msg Z
EOF
test_cmp expected actual
'
@@ -167,7 +153,7 @@ test_expect_failure 'left alignment formatting at the nth column' '
$head1 message two Z
$head2 message one Z
$head3 add bar Z
-$head4 $(commit_msg) Z
+$head4 $initial_msg Z
EOF
test_cmp expected actual
'
@@ -180,7 +166,7 @@ test_expect_failure 'left alignment formatting with no padding' '
message two
message one
add bar
-$(commit_msg)
+$initial_msg
EOF
test_cmp expected actual
'
@@ -193,7 +179,7 @@ test_expect_failure 'left alignment formatting with trunc' '
message ..
message ..
add bar Z
-$(commit_msg "" "8" ".\+$")
+$(extract_msg "^\(........\).*")..
EOF
test_cmp expected actual
'
@@ -206,8 +192,10 @@ test_expect_failure 'left alignment formatting with ltrunc' '
..sage two
..sage one
add bar Z
-$(commit_msg "" "0" ".\{11\}")
+..$(extract_msg ".*\(.........\)$")
EOF
+ # the RE above covers 9 bytes because there is one UTF-8 character
+ # where two bytes occupy only one character position
test_cmp expected actual
'
@@ -219,7 +207,7 @@ test_expect_failure 'left alignment formatting with mtrunc' '
mess.. two
mess.. one
add bar Z
-$(commit_msg "" "4" ".\{11\}")
+$(extract_msg "^\(....\).*")..$(extract_msg ".*\(....\)$")
EOF
test_cmp expected actual
'
@@ -232,7 +220,7 @@ test_expect_failure 'right alignment formatting' '
Z message two
Z message one
Z add bar
-Z $(commit_msg)
+Z $initial_msg
EOF
test_cmp expected actual
'
@@ -245,7 +233,7 @@ test_expect_failure 'right alignment formatting at the nth column' '
$head1 message two
$head2 message one
$head3 add bar
-$head4 $(commit_msg)
+$head4 $initial_msg
EOF
test_cmp expected actual
'
@@ -258,7 +246,7 @@ test_expect_failure 'right alignment formatting with no padding' '
message two
message one
add bar
-$(commit_msg)
+$initial_msg
EOF
test_cmp expected actual
'
@@ -271,7 +259,7 @@ test_expect_failure 'center alignment formatting' '
Z message two Z
Z message one Z
Z add bar Z
-Z $(commit_msg) Z
+Z $initial_msg Z
EOF
test_cmp expected actual
'
@@ -284,7 +272,7 @@ test_expect_failure 'center alignment formatting at the nth column' '
$head1 message two Z
$head2 message one Z
$head3 add bar Z
-$head4 $(commit_msg) Z
+$head4 $initial_msg Z
EOF
test_cmp expected actual
'
@@ -297,7 +285,7 @@ test_expect_failure 'center alignment formatting with no padding' '
message two
message one
add bar
-$(commit_msg)
+$initial_msg
EOF
test_cmp expected actual
'
@@ -311,7 +299,7 @@ test_expect_failure 'left/right alignment formatting with stealing' '
short long long long
message .. A U Thor
add bar A U Thor
-$(commit_msg "" "8" ".\+$") A U Thor
+$(extract_msg "^\(........\).*").. A U Thor
EOF
test_cmp expected actual
'
next prev parent reply other threads:[~2013-07-02 6:46 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-22 7:06 git log --oneline and git log --pretty=format... give differrent outputs Shumkin Alexey
2011-07-22 7:53 ` Alexey Shumkin
2011-07-25 10:31 ` [PATCH] pretty: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2011-07-25 10:31 ` Alexey Shumkin
2011-07-25 19:45 ` Junio C Hamano
2011-07-26 13:18 ` Alexey Shumkin
2011-09-09 8:43 ` [PATCH v2] " Alexey Shumkin
2011-09-09 8:43 ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-09 8:43 ` [PATCH 2/2] pretty: " Alexey Shumkin
2011-09-09 8:53 ` [PATCH v2] " Alexey Shumkin
2011-09-09 8:53 ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-09 22:54 ` Junio C Hamano
2011-09-20 8:20 ` [PATCH v3 0/2] pretty: " Alexey Shumkin
2011-09-20 8:21 ` [PATCH v3 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-20 19:12 ` Junio C Hamano
2011-09-20 20:46 ` Alexey Shumkin
2013-01-24 9:10 ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
2013-06-20 9:26 ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
2013-06-20 20:10 ` Junio C Hamano
2013-06-25 8:55 ` [PATCH v6 " Alexey Shumkin
2013-06-25 19:28 ` Junio C Hamano
2013-06-26 7:37 ` Alexey Shumkin
2013-06-26 14:24 ` Junio C Hamano
2013-06-26 10:19 ` [PATCH v7 " Alexey Shumkin
2013-06-26 16:19 ` Junio C Hamano
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
2013-07-02 19:41 ` Junio C Hamano
2013-07-03 20:03 ` Alexey Shumkin
2013-07-03 20:06 ` Junio C Hamano
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 " Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
2013-07-05 18:38 ` Junio C Hamano
2013-07-05 18:45 ` Junio C Hamano
2013-07-05 12:01 ` [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed` Alexey Shumkin
2013-07-04 12:45 ` [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
2013-07-05 6:47 ` Junio C Hamano
2013-07-05 8:00 ` Alexey Shumkin
2013-07-05 8:11 ` Junio C Hamano
2013-07-05 8:42 ` Alexey Shumkin
2013-07-05 8:56 ` Junio C Hamano
2013-07-04 12:45 ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
2013-07-05 7:07 ` Junio C Hamano
2013-07-04 12:45 ` [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable Alexey Shumkin
2013-07-05 6:45 ` Junio C Hamano
2013-07-05 8:13 ` Alexey Shumkin
2013-07-05 8:44 ` Junio C Hamano
2013-07-05 8:51 ` Alexey Shumkin
2013-07-05 8:58 ` Junio C Hamano
2013-07-04 12:45 ` [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set Alexey Shumkin
2013-07-05 6:52 ` Junio C Hamano
2013-07-05 7:04 ` Junio C Hamano
2013-07-05 7:46 ` Alexey Shumkin
2013-07-05 8:09 ` Junio C Hamano
2013-07-04 12:45 ` [PATCH v9 5/5] t4205: avoid using `sed` Alexey Shumkin
2013-07-01 23:19 ` [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-07-01 23:19 ` [PATCH v8 2/5] t7102 (reset): " Alexey Shumkin
2013-07-01 23:19 ` [PATCH v8 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-07-01 23:19 ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-07-02 6:46 ` Johannes Sixt [this message]
2013-07-01 23:19 ` [PATCH v8 5/5] pretty: " Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 2/5] t7102 (reset): " Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-07-01 7:00 ` Johannes Sixt
2013-07-01 22:50 ` Alexey Shumkin
2013-07-02 7:22 ` Johannes Sixt
2013-07-03 20:20 ` Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 5/5] pretty: " Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 2/5] t7102 (reset): " Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 5/5] pretty: " Alexey Shumkin
2013-06-20 9:26 ` [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-20 20:38 ` Junio C Hamano
2013-06-20 9:26 ` [PATCH v5 2/5] t7102 (reset): " Alexey Shumkin
2013-06-20 9:26 ` [PATCH v5 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-20 20:38 ` Junio C Hamano
2013-06-20 9:26 ` [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2013-06-20 20:23 ` Junio C Hamano
2013-06-20 9:26 ` [PATCH v5 5/5] pretty: " Alexey Shumkin
2013-06-20 20:37 ` Junio C Hamano
2013-01-24 9:10 ` [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-01-24 20:29 ` Junio C Hamano
2013-01-25 9:20 ` Alexey Shumkin
2013-01-25 11:06 ` Alexey Shumkin
2013-01-25 15:16 ` Junio C Hamano
2013-01-25 15:27 ` Alexey Shumkin
2013-01-24 9:10 ` [PATCH v4 2/4] t7102 (reset): refactoring: " Alexey Shumkin
2013-01-24 20:30 ` Junio C Hamano
2013-01-25 9:08 ` Alexey Shumkin
2013-01-24 9:10 ` [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2013-01-24 20:44 ` Junio C Hamano
2013-01-25 9:07 ` Alexey Shumkin
2013-01-24 21:02 ` Junio C Hamano
2013-01-25 9:01 ` Alexey Shumkin
2013-01-24 9:10 ` [PATCH v4 4/4] pretty: " Alexey Shumkin
2011-09-20 8:21 ` [PATCH v3 2/2] " Alexey Shumkin
2011-09-09 8:53 ` [PATCH " Alexey Shumkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51D2773B.9020006@viscovery.net \
--to=j.sixt@viscovery.net \
--cc=Alex.Crezoff@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).