* Re: [PATCH v2 1/2] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set
2014-05-16 18:49 ` Junio C Hamano
@ 2014-05-17 8:52 ` Alexey Shumkin
2014-05-19 15:28 ` [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work Alexey Shumkin
` (5 subsequent siblings)
6 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-17 8:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Nguyễn Thái Ngọc Duy
On Fri, May 16, 2014 at 11:49:40AM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
>
> > Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
> > length with an appropriate padding. This works for non-ASCII texts when
> > i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
> > message encoding) but does not work when i18n.logOutputEncoding is NOT
> > UTF-8.
> >
> > There were no breakages as far as were no tests for the case
> > when both a commit message and logOutputEncoding are not UTF-8.
> >
> > Add failing tests for that which will be fixed in the next patch.
> >
> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> > Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> > ---
> > t/t4205-log-pretty-formats.sh | 169 ++++++++++++++++++++++++++++++++++++++++++
> > t/t6006-rev-list-format.sh | 75 ++++++++++++++++++-
> > 2 files changed, 242 insertions(+), 2 deletions(-)
> >
> > diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> > index 2a6278b..6791e0d 100755
> > --- a/t/t4205-log-pretty-formats.sh
> > +++ b/t/t4205-log-pretty-formats.sh
> > @@ -153,6 +153,19 @@ EOF
> > test_cmp expected actual
> > '
> >
> > +test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
> > + git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%<(40)%s" >actual &&
> > + # complete the incomplete line at the end
> > + echo >>actual &&
>
> Would it change the meaning of the test if you used tformat: instead
> of format: (or --format="%<(40)%s")? If it doesn't, it would make
> it unnecessary to append an extra LF and explain why you do so.
Well, actually, I just copied previous tests and added
i18n.logOutputEncoding.
But as I can see in the code - no, tformat will not change the meaning.
so, may be there is a reason to change that (initial) tests from format
to tformat first? And then add mine new.
>
> > + qz_to_tab_space <<EOF | iconv -f utf-8 -t iso8859-1 >expected &&
>
> It is minor but many existing uses of iconv in our tests spell these
> as UTF-8 and ISO8859-1 in uppercase. I vaguely recall there was a
> portability concern to favor the ones that are used in existing
> tests, but probably it no longer matters (I see you added the
> lowercase one with de6029a2 mid last year), so I am fine if these
> stay lowercase.
I've grep'ed for lowercase iso8859-1 in test, and found almost all of
them is code added by me.
Grep for uppercase gives more results. I can refactor that first for
uniformity.
>
> > + git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%<(1)%s" >actual &&
> > + # complete the incomplete line at the end
> > + echo >>actual &&
>
> Likewise for all the other "--pretty=format:" followed by an echo.
the same copy-paste-modify.
>
> Thanks.
--
Alexey Shumkin
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work
2014-05-16 18:49 ` Junio C Hamano
2014-05-17 8:52 ` Alexey Shumkin
@ 2014-05-19 15:28 ` Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 " Alexey Shumkin
` (5 more replies)
2014-05-19 15:28 ` [PATCH v3 1/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs Alexey Shumkin
` (4 subsequent siblings)
6 siblings, 6 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-19 15:28 UTC (permalink / raw)
To: Junio C Hamano
Cc: Alexey Shumkin, git, brian m. carlson,
Nguyễn Thái Ngọc Duy
This patch series differs from the previous (v2) version in the following:
t4205 refactored: hardcoded SHA-1 digests replaced with variabled
Tested encoding `iso8859-1` replaced with variable (and uppercased to be in line
in other tests)
Usage of `format` + `echo` replaced with `tformat`
brian m. carlson <sandals@crustytoothpaste.net> CCed as he committed 5e1361c
(log: properly handle decorations with chained tags, 2013-12-17)
Alexey Shumkin (5):
t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
t4041, t4205, t6006, t7102: Don't hardcode tested encoding value
t4205 (log-pretty-format): Use `tformat` rather than `format`
t4205, t6006: Add failing tests for the case when
i18n.logOutputEncoding is set
pretty.c: format string with truncate respects logOutputEncoding
pretty.c | 7 +-
t/t4041-diff-submodule-option.sh | 7 +-
t/t4205-log-pretty-formats.sh | 217 ++++++++++++++++++++++++++++++---------
t/t6006-rev-list-format.sh | 110 ++++++++++++++++----
t/t7102-reset.sh | 13 ++-
5 files changed, 282 insertions(+), 72 deletions(-)
--
1.9.2-15
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 0/5] Reroll patches. Pretty print truncate does not work
2014-05-19 15:28 ` [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work Alexey Shumkin
@ 2014-05-21 13:20 ` Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 1/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs Alexey Shumkin
` (4 subsequent siblings)
5 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-21 13:20 UTC (permalink / raw)
To: Junio C Hamano
Cc: brian m. carlson, Nguyễn Thái Ngọc Duy,
Ramsay Jones, Alexey Shumkin, git
This version (v4) differs from the previuos (v3):
1. Fixed typo ISO8895-1 (vs ISO8859-1)
2. Fixed t4205 test: tested format strings are double-quoted
Alexey Shumkin (5):
t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
t4041, t4205, t6006, t7102: Don't hardcode tested encoding value
t4205 (log-pretty-format): Use `tformat` rather than `format`
t4205, t6006: Add failing tests for the case when
i18n.logOutputEncoding is set
pretty.c: format string with truncate respects logOutputEncoding
pretty.c | 7 +-
t/t4041-diff-submodule-option.sh | 7 +-
t/t4205-log-pretty-formats.sh | 217 ++++++++++++++++++++++++++++++---------
t/t6006-rev-list-format.sh | 110 ++++++++++++++++----
t/t7102-reset.sh | 13 ++-
5 files changed, 282 insertions(+), 72 deletions(-)
--
1.9.2-15
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 1/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
2014-05-19 15:28 ` [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 " Alexey Shumkin
@ 2014-05-21 13:20 ` Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value Alexey Shumkin
` (3 subsequent siblings)
5 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-21 13:20 UTC (permalink / raw)
To: Junio C Hamano
Cc: brian m. carlson, Nguyễn Thái Ngọc Duy,
Ramsay Jones, Alexey Shumkin, git
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
That was introduced in a742f2a (t4205 (log-pretty-formats): don't
hardcode SHA-1 in expected outputs, 2013-06-26) but unfortunately was
not followed in 5e1361c (log: properly handle decorations with chained
tags, 2013-12-17)
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4205-log-pretty-formats.sh | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2a6278b..f9f33ae 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -296,6 +296,10 @@ EOF
test_cmp expected actual
'
+# save HEAD's SHA-1 digest (with no abbreviations) to use it below
+# as far as the next test amends HEAD
+old_head1=$(git rev-parse --verify HEAD~0)
+
test_expect_success 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long <long@me.com>" &&
git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
@@ -310,6 +314,10 @@ EOF
test_cmp expected actual
'
+# get new digests (with no abbreviations)
+head1=$(git rev-parse --verify HEAD~0) &&
+head2=$(git rev-parse --verify HEAD~1) &&
+
test_expect_success 'log decoration properly follows tag chain' '
git tag -a tag1 -m tag1 &&
git tag -a tag2 -m tag2 tag1 &&
@@ -317,9 +325,9 @@ test_expect_success 'log decoration properly follows tag chain' '
git commit --amend -m shorter &&
git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
cat <<EOF >expected &&
-6a908c10688b2503073c39c9ba26322c73902bb5 (tag: refs/tags/tag2)
-9f716384d92283fb915a4eee5073f030638e05f9 (tag: refs/tags/message-one)
-b87e4cccdb77336ea79d89224737be7ea8e95367 (tag: refs/tags/message-two)
+$head1 (tag: refs/tags/tag2)
+$head2 (tag: refs/tags/message-one)
+$old_head1 (tag: refs/tags/message-two)
EOF
sort actual >actual1 &&
test_cmp expected actual1
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value
2014-05-19 15:28 ` [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 " Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 1/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2014-05-21 13:20 ` Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 3/5] t4205 (log-pretty-format): Use `tformat` rather than `format` Alexey Shumkin
` (2 subsequent siblings)
5 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-21 13:20 UTC (permalink / raw)
To: Junio C Hamano
Cc: brian m. carlson, Nguyễn Thái Ngọc Duy,
Ramsay Jones, Alexey Shumkin, git
The tested encoding is always available in a variable. Use it instead of
hardcoding. Also, to be in line with other tests use ISO8859-1
(uppercase) rather then iso8859-1.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4041-diff-submodule-option.sh | 7 +++++--
t/t4205-log-pretty-formats.sh | 11 +++++++----
t/t6006-rev-list-format.sh | 35 +++++++++++++++++++----------------
t/t7102-reset.sh | 13 ++++++++-----
4 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 1751c83..463d63b 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -11,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
. ./test-lib.sh
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
@@ -23,8 +26,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
- msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso8859-1) &&
- git -c 'i18n.commitEncoding=iso8859-1' commit -m "$msg_added_iso88591"
+ msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding) &&
+ git -c "i18n.commitEncoding=$test_encoding" commit -m "$msg_added_iso88591"
done >/dev/null &&
git rev-parse --short --verify HEAD
)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index f9f33ae..f5ea3f8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,6 +7,9 @@
test_description='Test pretty formats'
. ./test-lib.sh
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
sample_utf8_part=$(printf "f\303\244ng")
commit_msg () {
@@ -27,8 +30,8 @@ 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)" &&
+ git config i18n.commitEncoding $test_encoding &&
+ git commit -m "$(commit_msg $test_encoding)" &&
git add bar &&
test_tick &&
git commit -m "add bar" &&
@@ -56,8 +59,8 @@ test_expect_success 'alias user-defined format' '
test_cmp expected actual
'
-test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
- git config i18n.logOutputEncoding iso8859-1 &&
+test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
+ git config i18n.logOutputEncoding $test_encoding &&
git log --oneline >expected-s &&
git log --pretty="tformat:%h %s" >actual-s &&
git config --unset i18n.logOutputEncoding &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 9874403..9e4ba62 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -9,19 +9,22 @@ test_description='git rev-list --pretty=format test'
. "$TEST_DIRECTORY"/lib-terminal.sh
test_tick
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
# String "added" in German
# (translated with Google Translate),
# encoded in UTF-8, used as a commit log message below.
added=$(printf "added (hinzugef\303\274gt) foo")
-added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
# same but "changed"
changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
test_expect_success 'setup' '
: >foo &&
git add foo &&
- git config i18n.commitEncoding iso8859-1 &&
+ git config i18n.commitEncoding $test_encoding &&
git commit -m "$added_iso88591" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -124,9 +127,9 @@ EOF
test_format encoding %e <<EOF
commit $head2
-iso8859-1
+$test_encoding
commit $head1
-iso8859-1
+$test_encoding
EOF
test_format subject %s <<EOF
@@ -206,16 +209,16 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
)
'
-iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
+iconv -f utf-8 -t $test_encoding > commit-msg <<EOF
Test printing of complex bodies
This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in $test_encoding. We should therefore
+include an ISO8859 character: ¡bueno!
EOF
test_expect_success 'setup complex body' '
- git config i18n.commitencoding iso8859-1 &&
+ git config i18n.commitencoding $test_encoding &&
echo change2 >foo && git commit -a -F commit-msg &&
head3=$(git rev-parse --verify HEAD) &&
head3_short=$(git rev-parse --short $head3)
@@ -223,11 +226,11 @@ test_expect_success 'setup complex body' '
test_format complex-encoding %e <<EOF
commit $head3
-iso8859-1
+$test_encoding
commit $head2
-iso8859-1
+$test_encoding
commit $head1
-iso8859-1
+$test_encoding
EOF
test_format complex-subject %s <<EOF
@@ -243,16 +246,16 @@ test_expect_success 'prepare expected messages (for test %b)' '
cat <<-EOF >expected.utf-8 &&
commit $head3
This commit message is much longer than the others,
- and it will be encoded in iso8859-1. We should therefore
- include an iso8859 character: ¡bueno!
+ and it will be encoded in $test_encoding. We should therefore
+ include an ISO8859 character: ¡bueno!
commit $head2
commit $head1
EOF
- iconv -f utf-8 -t iso8859-1 expected.utf-8 >expected.iso8859-1
+ iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
'
-test_format complex-body %b <expected.iso8859-1
+test_format complex-body %b <expected.ISO8859-1
# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
# so unset i18n.commitEncoding to test encoding conversion
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index ee117e2..8a56756 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -22,6 +22,9 @@ commit_msg () {
fi
}
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
test_expect_success 'creating initial files and commits' '
test_tick &&
echo "1st file" >first &&
@@ -41,7 +44,7 @@ test_expect_success 'creating initial files and commits' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
+ git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
@@ -64,10 +67,10 @@ test_expect_success 'reset --hard message' '
test_cmp .expected .actual
'
-test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
+test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
hex=$(git log -1 --format="%h") &&
- git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
- echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
+ git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected &&
test_cmp .expected .actual
'
@@ -331,7 +334,7 @@ test_expect_success 'redoing the last two commits should succeed' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
+ git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
check_changes $head5
'
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 3/5] t4205 (log-pretty-format): Use `tformat` rather than `format`
2014-05-19 15:28 ` [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work Alexey Shumkin
` (2 preceding siblings ...)
2014-05-21 13:20 ` [PATCH v4 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value Alexey Shumkin
@ 2014-05-21 13:20 ` Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set Alexey Shumkin
2014-05-21 13:20 ` [PATCH v4 5/5] pretty.c: format string with truncate respects logOutputEncoding Alexey Shumkin
5 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-21 13:20 UTC (permalink / raw)
To: Junio C Hamano
Cc: brian m. carlson, Nguyễn Thái Ngọc Duy,
Ramsay Jones, Alexey Shumkin, git
Use `tformat` to avoid using of `echo` to complete end of line.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4205-log-pretty-formats.sh | 52 +++++++++++--------------------------------
1 file changed, 13 insertions(+), 39 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index f5ea3f8..c03a65e 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -144,9 +144,7 @@ test_expect_success 'setup more commits' '
'
test_expect_success 'left alignment formatting' '
- git log --pretty="format:%<(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
message two Z
message one Z
@@ -157,9 +155,7 @@ EOF
'
test_expect_success 'left alignment formatting at the nth column' '
- git log --pretty="format:%h %<|(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
$head1 message two Z
$head2 message one Z
@@ -170,9 +166,7 @@ EOF
'
test_expect_success 'left alignment formatting with no padding' '
- git log --pretty="format:%<(1)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(1)%s" >actual &&
cat <<EOF >expected &&
message two
message one
@@ -183,9 +177,7 @@ EOF
'
test_expect_success 'left alignment formatting with trunc' '
- git log --pretty="format:%<(10,trunc)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
message ..
message ..
@@ -196,9 +188,7 @@ EOF
'
test_expect_success 'left alignment formatting with ltrunc' '
- git log --pretty="format:%<(10,ltrunc)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
..sage two
..sage one
@@ -209,9 +199,7 @@ EOF
'
test_expect_success 'left alignment formatting with mtrunc' '
- git log --pretty="format:%<(10,mtrunc)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
mess.. two
mess.. one
@@ -222,9 +210,7 @@ EOF
'
test_expect_success 'right alignment formatting' '
- git log --pretty="format:%>(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%>(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
Z message two
Z message one
@@ -235,9 +221,7 @@ EOF
'
test_expect_success 'right alignment formatting at the nth column' '
- git log --pretty="format:%h %>|(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
$head1 message two
$head2 message one
@@ -248,9 +232,7 @@ EOF
'
test_expect_success 'right alignment formatting with no padding' '
- git log --pretty="format:%>(1)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%>(1)%s" >actual &&
cat <<EOF >expected &&
message two
message one
@@ -261,9 +243,7 @@ EOF
'
test_expect_success 'center alignment formatting' '
- git log --pretty="format:%><(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%><(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
Z message two Z
Z message one Z
@@ -274,9 +254,7 @@ EOF
'
test_expect_success 'center alignment formatting at the nth column' '
- git log --pretty="format:%h %><|(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%h %><|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
$head1 message two Z
$head2 message one Z
@@ -287,9 +265,7 @@ EOF
'
test_expect_success 'center alignment formatting with no padding' '
- git log --pretty="format:%><(1)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%><(1)%s" >actual &&
cat <<EOF >expected &&
message two
message one
@@ -305,9 +281,7 @@ old_head1=$(git rev-parse --verify HEAD~0)
test_expect_success 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long <long@me.com>" &&
- git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
cat <<EOF >expected &&
short long long long
message .. A U Thor
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set
2014-05-19 15:28 ` [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work Alexey Shumkin
` (3 preceding siblings ...)
2014-05-21 13:20 ` [PATCH v4 3/5] t4205 (log-pretty-format): Use `tformat` rather than `format` Alexey Shumkin
@ 2014-05-21 13:20 ` Alexey Shumkin
2014-05-21 15:38 ` Ramsay Jones
2014-05-21 13:20 ` [PATCH v4 5/5] pretty.c: format string with truncate respects logOutputEncoding Alexey Shumkin
5 siblings, 1 reply; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-21 13:20 UTC (permalink / raw)
To: Junio C Hamano
Cc: brian m. carlson, Nguyễn Thái Ngọc Duy,
Ramsay Jones, Alexey Shumkin, git
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.
There were no breakages as far as were no tests for the case
when both a commit message and logOutputEncoding are not UTF-8.
Add failing tests for that which will be fixed in the next patch.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Reviewed-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
t/t4205-log-pretty-formats.sh | 140 ++++++++++++++++++++++++++++++++++++++++++
t/t6006-rev-list-format.sh | 75 +++++++++++++++++++++-
2 files changed, 213 insertions(+), 2 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index c03a65e..74babce 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -154,6 +154,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message two Z
+message one Z
+add bar Z
+$(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting at the nth column' '
git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -165,6 +176,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 $(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting with no padding' '
git log --pretty="tformat:%<(1)%s" >actual &&
cat <<EOF >expected &&
@@ -176,6 +198,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message two
+message one
+add bar
+$(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting with trunc' '
git log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -187,6 +220,17 @@ EOF
test_cmp expected actual
'
+test_expect_failure 'left alignment formatting with trunc. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message ..
+message ..
+add bar Z
+initial...
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting with ltrunc' '
git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -198,6 +242,17 @@ EOF
test_cmp expected actual
'
+test_expect_failure 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+..sage two
+..sage one
+add bar Z
+..${sample_utf8_part}lich
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting with mtrunc' '
git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -209,6 +264,17 @@ EOF
test_cmp expected actual
'
+test_expect_failure 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+mess.. two
+mess.. one
+add bar Z
+init..lich
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting' '
git log --pretty="tformat:%>(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -220,6 +286,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'right alignment formatting. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+Z message two
+Z message one
+Z add bar
+Z $(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting at the nth column' '
git log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -231,6 +308,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+$head1 message two
+$head2 message one
+$head3 add bar
+$head4 $(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting with no padding' '
git log --pretty="tformat:%>(1)%s" >actual &&
cat <<EOF >expected &&
@@ -242,6 +330,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual &&
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message two
+message one
+add bar
+$(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'center alignment formatting' '
git log --pretty="tformat:%><(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -253,6 +352,16 @@ EOF
test_cmp expected actual
'
+test_expect_success 'center alignment formatting. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+Z message two Z
+Z message one Z
+Z add bar Z
+Z $(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
test_expect_success 'center alignment formatting at the nth column' '
git log --pretty="tformat:%h %><|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -264,6 +373,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 $(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'center alignment formatting with no padding' '
git log --pretty="tformat:%><(1)%s" >actual &&
cat <<EOF >expected &&
@@ -278,6 +398,16 @@ EOF
# save HEAD's SHA-1 digest (with no abbreviations) to use it below
# as far as the next test amends HEAD
old_head1=$(git rev-parse --verify HEAD~0)
+test_expect_success 'center alignment formatting with no padding. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(1)%s" >actual &&
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message two
+message one
+add bar
+$(commit_msg)
+EOF
+ test_cmp expected actual
+'
test_expect_success 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long <long@me.com>" &&
@@ -290,6 +420,16 @@ initial... A U Thor
EOF
test_cmp expected actual
'
+test_expect_failure 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+short long long long
+message .. A U Thor
+add bar A U Thor
+initial... A U Thor
+EOF
+ test_cmp expected actual
+'
# get new digests (with no abbreviations)
head1=$(git rev-parse --verify HEAD~0) &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 9e4ba62..42bdefe 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -15,12 +15,22 @@ test_encoding="ISO8859-1"
# String "added" in German
# (translated with Google Translate),
# encoded in UTF-8, used as a commit log message below.
-added=$(printf "added (hinzugef\303\274gt) foo")
+added_utf8_part=$(printf "\303\274")
+added_utf8_part_iso88591=$(echo "$added_utf8_part" | iconv -f utf-8 -t $test_encoding)
+added=$(printf "added (hinzugef${added_utf8_part}gt) foo")
added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
# same but "changed"
-changed=$(printf "changed (ge\303\244ndert) foo")
+changed_utf8_part=$(printf "\303\244")
+changed_utf8_part_iso88591=$(echo "$changed_utf8_part" | iconv -f utf-8 -t $test_encoding)
+changed=$(printf "changed (ge${changed_utf8_part}ndert) foo")
changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
+# Count of char to truncate
+# Number is chosen so, that non-ACSII characters
+# (see $added_utf8_part and $changed_utf8_part)
+# fall into truncated parts of appropriate words both from left and right
+truncate_count=20
+
test_expect_success 'setup' '
: >foo &&
git add foo &&
@@ -139,6 +149,13 @@ commit $head1
$added
EOF
+test_format subject-truncated "%<($truncate_count,trunc)%s" <<EOF
+commit $head2
+changed (ge${changed_utf8_part}ndert)..
+commit $head1
+added (hinzugef${added_utf8_part}gt..
+EOF
+
test_format body %b <<EOF
commit $head2
commit $head1
@@ -242,6 +259,33 @@ commit $head1
$added_iso88591
EOF
+test_format complex-subject-trunc "%<($truncate_count,trunc)%s" failure <<EOF
+commit $head3
+Test printing of c..
+commit $head2
+changed (ge${changed_utf8_part_iso88591}ndert)..
+commit $head1
+added (hinzugef${added_utf8_part_iso88591}gt..
+EOF
+
+test_format complex-subject-mtrunc "%<($truncate_count,mtrunc)%s" failure <<EOF
+commit $head3
+Test prin..ex bodies
+commit $head2
+changed (..dert) foo
+commit $head1
+added (hi..f${added_utf8_part_iso88591}gt) foo
+EOF
+
+test_format complex-subject-ltrunc "%<($truncate_count,ltrunc)%s" failure <<EOF
+commit $head3
+.. of complex bodies
+commit $head2
+..ged (ge${changed_utf8_part_iso88591}ndert) foo
+commit $head1
+.. (hinzugef${added_utf8_part_iso88591}gt) foo
+EOF
+
test_expect_success 'prepare expected messages (for test %b)' '
cat <<-EOF >expected.utf-8 &&
commit $head3
@@ -270,6 +314,33 @@ commit $head1
$added
EOF
+test_format complex-subject-commitencoding-unset-trunc "%<($truncate_count,trunc)%s" <<EOF
+commit $head3
+Test printing of c..
+commit $head2
+changed (ge${changed_utf8_part}ndert)..
+commit $head1
+added (hinzugef${added_utf8_part}gt..
+EOF
+
+test_format complex-subject-commitencoding-unset-mtrunc "%<($truncate_count,mtrunc)%s" <<EOF
+commit $head3
+Test prin..ex bodies
+commit $head2
+changed (..dert) foo
+commit $head1
+added (hi..f${added_utf8_part}gt) foo
+EOF
+
+test_format complex-subject-commitencoding-unset-ltrunc "%<($truncate_count,ltrunc)%s" <<EOF
+commit $head3
+.. of complex bodies
+commit $head2
+..ged (ge${changed_utf8_part}ndert) foo
+commit $head1
+.. (hinzugef${added_utf8_part}gt) foo
+EOF
+
test_format complex-body-commitencoding-unset %b <expected.utf-8
test_expect_success '%x00 shows NUL' '
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v4 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set
2014-05-21 13:20 ` [PATCH v4 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set Alexey Shumkin
@ 2014-05-21 15:38 ` Ramsay Jones
2014-05-21 18:11 ` Junio C Hamano
0 siblings, 1 reply; 25+ messages in thread
From: Ramsay Jones @ 2014-05-21 15:38 UTC (permalink / raw)
To: Alexey Shumkin, Junio C Hamano
Cc: brian m. carlson, Nguyễn Thái Ngọc Duy, git
On 21/05/14 14:20, Alexey Shumkin wrote:
> Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
> length with an appropriate padding. This works for non-ASCII texts when
> i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
> message encoding) but does not work when i18n.logOutputEncoding is NOT
> UTF-8.
>
> There were no breakages as far as were no tests for the case
> when both a commit message and logOutputEncoding are not UTF-8.
>
> Add failing tests for that which will be fixed in the next patch.
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> Reviewed-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Hmm, I didn't really review these patches. I simply noted a problem
on my system and provided you with an extended bug-report and
assisted you in fixing it up. So, if it even warrants a mention in
the commit message, then 'Helped-by:' would be nearer the mark.
Thanks!
ATB,
Ramsay Jones
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set
2014-05-21 15:38 ` Ramsay Jones
@ 2014-05-21 18:11 ` Junio C Hamano
0 siblings, 0 replies; 25+ messages in thread
From: Junio C Hamano @ 2014-05-21 18:11 UTC (permalink / raw)
To: Ramsay Jones
Cc: Alexey Shumkin, brian m. carlson,
Nguyễn Thái Ngọc Duy, git
Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
> On 21/05/14 14:20, Alexey Shumkin wrote:
>> Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
>> length with an appropriate padding. This works for non-ASCII texts when
>> i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
>> message encoding) but does not work when i18n.logOutputEncoding is NOT
>> UTF-8.
>>
>> There were no breakages as far as were no tests for the case
>> when both a commit message and logOutputEncoding are not UTF-8.
>>
>> Add failing tests for that which will be fixed in the next patch.
>>
>> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
>> Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> Reviewed-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
>
> Hmm, I didn't really review these patches. I simply noted a problem
> on my system and provided you with an extended bug-report and
> assisted you in fixing it up. So, if it even warrants a mention in
> the commit message, then 'Helped-by:' would be nearer the mark.
I had the same impression. The same for Duy's.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 5/5] pretty.c: format string with truncate respects logOutputEncoding
2014-05-19 15:28 ` [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work Alexey Shumkin
` (4 preceding siblings ...)
2014-05-21 13:20 ` [PATCH v4 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set Alexey Shumkin
@ 2014-05-21 13:20 ` Alexey Shumkin
5 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-21 13:20 UTC (permalink / raw)
To: Junio C Hamano
Cc: brian m. carlson, Nguyễn Thái Ngọc Duy,
Ramsay Jones, Alexey Shumkin, git
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.
In 7e77df3 (pretty: two phase conversion for non utf-8 commits, 2013-04-19)
'format_commit_item' function assumes commit message to be in UTF-8.
And that was so until ecaee80 (pretty: --format output should honor
logOutputEncoding, 2013-06-26) where conversion to logOutputEncoding was
added before calling 'format_commit_message'.
Correct this by converting a commit message to UTF-8 first (as it
assumed in 7e77df3 (pretty: two phase conversion for non utf-8 commits,
2013-04-19)). Only after that convert a commit message to an actual
logOutputEncoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
pretty.c | 7 ++++++-
t/t4205-log-pretty-formats.sh | 8 ++++----
t/t6006-rev-list-format.sh | 6 +++---
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/pretty.c b/pretty.c
index 6e266dd..25e8825 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1507,13 +1507,18 @@ void format_commit_message(const struct commit *commit,
context.commit = commit;
context.pretty_ctx = pretty_ctx;
context.wrap_start = sb->len;
+ /*
+ * convert a commit message to UTF-8 first
+ * as far as 'format_commit_item' assumes it in UTF-8
+ */
context.message = logmsg_reencode(commit,
&context.commit_encoding,
- output_enc);
+ utf8);
strbuf_expand(sb, format, format_commit_item, &context);
rewrap_message_tail(sb, &context, 0, 0, 0);
+ /* then convert a commit message to an actual output encoding */
if (output_enc) {
if (same_encoding(utf8, output_enc))
output_enc = NULL;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 74babce..c84ec9a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -220,7 +220,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with trunc. i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with trunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
message ..
@@ -242,7 +242,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
..sage two
@@ -264,7 +264,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
mess.. two
@@ -420,7 +420,7 @@ initial... A U Thor
EOF
test_cmp expected actual
'
-test_expect_failure 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
+test_expect_success 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
short long long long
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 42bdefe..19434ad 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -259,7 +259,7 @@ commit $head1
$added_iso88591
EOF
-test_format complex-subject-trunc "%<($truncate_count,trunc)%s" failure <<EOF
+test_format complex-subject-trunc "%<($truncate_count,trunc)%s" <<EOF
commit $head3
Test printing of c..
commit $head2
@@ -268,7 +268,7 @@ commit $head1
added (hinzugef${added_utf8_part_iso88591}gt..
EOF
-test_format complex-subject-mtrunc "%<($truncate_count,mtrunc)%s" failure <<EOF
+test_format complex-subject-mtrunc "%<($truncate_count,mtrunc)%s" <<EOF
commit $head3
Test prin..ex bodies
commit $head2
@@ -277,7 +277,7 @@ commit $head1
added (hi..f${added_utf8_part_iso88591}gt) foo
EOF
-test_format complex-subject-ltrunc "%<($truncate_count,ltrunc)%s" failure <<EOF
+test_format complex-subject-ltrunc "%<($truncate_count,ltrunc)%s" <<EOF
commit $head3
.. of complex bodies
commit $head2
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v3 1/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
2014-05-16 18:49 ` Junio C Hamano
2014-05-17 8:52 ` Alexey Shumkin
2014-05-19 15:28 ` [PATCH v3 0/5] Reroll patches. Pretty print truncate does not work Alexey Shumkin
@ 2014-05-19 15:28 ` Alexey Shumkin
2014-05-19 15:28 ` [PATCH v3 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value Alexey Shumkin
` (3 subsequent siblings)
6 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-19 15:28 UTC (permalink / raw)
To: Junio C Hamano
Cc: Alexey Shumkin, git, brian m. carlson,
Nguyễn Thái Ngọc Duy
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
That was introduced in a742f2a (t4205 (log-pretty-formats): don't
hardcode SHA-1 in expected outputs, 2013-06-26) but unfortunately was
not followed in 5e1361c (log: properly handle decorations with chained
tags, 2013-12-17)
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4205-log-pretty-formats.sh | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2a6278b..f9f33ae 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -296,6 +296,10 @@ EOF
test_cmp expected actual
'
+# save HEAD's SHA-1 digest (with no abbreviations) to use it below
+# as far as the next test amends HEAD
+old_head1=$(git rev-parse --verify HEAD~0)
+
test_expect_success 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long <long@me.com>" &&
git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
@@ -310,6 +314,10 @@ EOF
test_cmp expected actual
'
+# get new digests (with no abbreviations)
+head1=$(git rev-parse --verify HEAD~0) &&
+head2=$(git rev-parse --verify HEAD~1) &&
+
test_expect_success 'log decoration properly follows tag chain' '
git tag -a tag1 -m tag1 &&
git tag -a tag2 -m tag2 tag1 &&
@@ -317,9 +325,9 @@ test_expect_success 'log decoration properly follows tag chain' '
git commit --amend -m shorter &&
git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
cat <<EOF >expected &&
-6a908c10688b2503073c39c9ba26322c73902bb5 (tag: refs/tags/tag2)
-9f716384d92283fb915a4eee5073f030638e05f9 (tag: refs/tags/message-one)
-b87e4cccdb77336ea79d89224737be7ea8e95367 (tag: refs/tags/message-two)
+$head1 (tag: refs/tags/tag2)
+$head2 (tag: refs/tags/message-one)
+$old_head1 (tag: refs/tags/message-two)
EOF
sort actual >actual1 &&
test_cmp expected actual1
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v3 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value
2014-05-16 18:49 ` Junio C Hamano
` (2 preceding siblings ...)
2014-05-19 15:28 ` [PATCH v3 1/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2014-05-19 15:28 ` Alexey Shumkin
2014-05-20 1:49 ` brian m. carlson
2014-05-19 15:28 ` [PATCH v3 3/5] t4205 (log-pretty-format): Use `tformat` rather than `format` Alexey Shumkin
` (2 subsequent siblings)
6 siblings, 1 reply; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-19 15:28 UTC (permalink / raw)
To: Junio C Hamano
Cc: Alexey Shumkin, git, brian m. carlson,
Nguyễn Thái Ngọc Duy
The tested encoding is always available in a variable. Use it instead of
hardcoding. Also, to be in line with other tests use ISO8859-1
(uppercase) rather then iso8895-1.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4041-diff-submodule-option.sh | 7 +++++--
t/t4205-log-pretty-formats.sh | 11 +++++++----
t/t6006-rev-list-format.sh | 35 +++++++++++++++++++----------------
t/t7102-reset.sh | 13 ++++++++-----
4 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 1751c83..463d63b 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -11,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
. ./test-lib.sh
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
@@ -23,8 +26,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
- msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso8859-1) &&
- git -c 'i18n.commitEncoding=iso8859-1' commit -m "$msg_added_iso88591"
+ msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding) &&
+ git -c "i18n.commitEncoding=$test_encoding" commit -m "$msg_added_iso88591"
done >/dev/null &&
git rev-parse --short --verify HEAD
)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index f9f33ae..f5ea3f8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,6 +7,9 @@
test_description='Test pretty formats'
. ./test-lib.sh
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
sample_utf8_part=$(printf "f\303\244ng")
commit_msg () {
@@ -27,8 +30,8 @@ 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)" &&
+ git config i18n.commitEncoding $test_encoding &&
+ git commit -m "$(commit_msg $test_encoding)" &&
git add bar &&
test_tick &&
git commit -m "add bar" &&
@@ -56,8 +59,8 @@ test_expect_success 'alias user-defined format' '
test_cmp expected actual
'
-test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
- git config i18n.logOutputEncoding iso8859-1 &&
+test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
+ git config i18n.logOutputEncoding $test_encoding &&
git log --oneline >expected-s &&
git log --pretty="tformat:%h %s" >actual-s &&
git config --unset i18n.logOutputEncoding &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 9874403..9e4ba62 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -9,19 +9,22 @@ test_description='git rev-list --pretty=format test'
. "$TEST_DIRECTORY"/lib-terminal.sh
test_tick
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
# String "added" in German
# (translated with Google Translate),
# encoded in UTF-8, used as a commit log message below.
added=$(printf "added (hinzugef\303\274gt) foo")
-added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
# same but "changed"
changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
test_expect_success 'setup' '
: >foo &&
git add foo &&
- git config i18n.commitEncoding iso8859-1 &&
+ git config i18n.commitEncoding $test_encoding &&
git commit -m "$added_iso88591" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -124,9 +127,9 @@ EOF
test_format encoding %e <<EOF
commit $head2
-iso8859-1
+$test_encoding
commit $head1
-iso8859-1
+$test_encoding
EOF
test_format subject %s <<EOF
@@ -206,16 +209,16 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
)
'
-iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
+iconv -f utf-8 -t $test_encoding > commit-msg <<EOF
Test printing of complex bodies
This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in $test_encoding. We should therefore
+include an ISO8859 character: ¡bueno!
EOF
test_expect_success 'setup complex body' '
- git config i18n.commitencoding iso8859-1 &&
+ git config i18n.commitencoding $test_encoding &&
echo change2 >foo && git commit -a -F commit-msg &&
head3=$(git rev-parse --verify HEAD) &&
head3_short=$(git rev-parse --short $head3)
@@ -223,11 +226,11 @@ test_expect_success 'setup complex body' '
test_format complex-encoding %e <<EOF
commit $head3
-iso8859-1
+$test_encoding
commit $head2
-iso8859-1
+$test_encoding
commit $head1
-iso8859-1
+$test_encoding
EOF
test_format complex-subject %s <<EOF
@@ -243,16 +246,16 @@ test_expect_success 'prepare expected messages (for test %b)' '
cat <<-EOF >expected.utf-8 &&
commit $head3
This commit message is much longer than the others,
- and it will be encoded in iso8859-1. We should therefore
- include an iso8859 character: ¡bueno!
+ and it will be encoded in $test_encoding. We should therefore
+ include an ISO8859 character: ¡bueno!
commit $head2
commit $head1
EOF
- iconv -f utf-8 -t iso8859-1 expected.utf-8 >expected.iso8859-1
+ iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
'
-test_format complex-body %b <expected.iso8859-1
+test_format complex-body %b <expected.ISO8859-1
# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
# so unset i18n.commitEncoding to test encoding conversion
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index ee117e2..8a56756 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -22,6 +22,9 @@ commit_msg () {
fi
}
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
test_expect_success 'creating initial files and commits' '
test_tick &&
echo "1st file" >first &&
@@ -41,7 +44,7 @@ test_expect_success 'creating initial files and commits' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
+ git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
@@ -64,10 +67,10 @@ test_expect_success 'reset --hard message' '
test_cmp .expected .actual
'
-test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
+test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
hex=$(git log -1 --format="%h") &&
- git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
- echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
+ git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected &&
test_cmp .expected .actual
'
@@ -331,7 +334,7 @@ test_expect_success 'redoing the last two commits should succeed' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
+ git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
check_changes $head5
'
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v3 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value
2014-05-19 15:28 ` [PATCH v3 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value Alexey Shumkin
@ 2014-05-20 1:49 ` brian m. carlson
2014-05-20 6:41 ` Alexey Shumkin
0 siblings, 1 reply; 25+ messages in thread
From: brian m. carlson @ 2014-05-20 1:49 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: Junio C Hamano, git, Nguyễn Thái Ngọc Duy
[-- Attachment #1: Type: text/plain, Size: 516 bytes --]
On Mon, May 19, 2014 at 07:28:17PM +0400, Alexey Shumkin wrote:
> The tested encoding is always available in a variable. Use it instead of
> hardcoding. Also, to be in line with other tests use ISO8859-1
> (uppercase) rather then iso8895-1.
You wrote "iso8895" when I think you meant "iso8859".
--
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v3 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value
2014-05-20 1:49 ` brian m. carlson
@ 2014-05-20 6:41 ` Alexey Shumkin
0 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-20 6:41 UTC (permalink / raw)
To: Junio C Hamano, git, Nguyễn Thái Ngọc Duy
On Tue, May 20, 2014 at 01:49:31AM +0000, brian m. carlson wrote:
> On Mon, May 19, 2014 at 07:28:17PM +0400, Alexey Shumkin wrote:
> > The tested encoding is always available in a variable. Use it instead of
> > hardcoding. Also, to be in line with other tests use ISO8859-1
> > (uppercase) rather then iso8895-1.
>
> You wrote "iso8895" when I think you meant "iso8859".
Oops!
Yes, you're right, I've meant iso8859.
>
> --
> brian m. carlson / brian with sandals: Houston, Texas, US
> +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
> OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
--
Alexey Shumkin
E-mail: Alex.Crezoff@gmail.com
ICQ: 118001447
Jabber (GoogleTalk): Alex.Crezoff@gmail.com
Skype: crezoff
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v3 3/5] t4205 (log-pretty-format): Use `tformat` rather than `format`
2014-05-16 18:49 ` Junio C Hamano
` (3 preceding siblings ...)
2014-05-19 15:28 ` [PATCH v3 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value Alexey Shumkin
@ 2014-05-19 15:28 ` Alexey Shumkin
2014-05-19 15:28 ` [PATCH v3 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set Alexey Shumkin
2014-05-19 15:28 ` [PATCH v3 5/5] pretty.c: format string with truncate respects logOutputEncoding Alexey Shumkin
6 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-19 15:28 UTC (permalink / raw)
To: Junio C Hamano
Cc: Alexey Shumkin, git, brian m. carlson,
Nguyễn Thái Ngọc Duy
Use `tformat` to avoid using of `echo` to complete end of line.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4205-log-pretty-formats.sh | 52 +++++++++++--------------------------------
1 file changed, 13 insertions(+), 39 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index f5ea3f8..c03a65e 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -144,9 +144,7 @@ test_expect_success 'setup more commits' '
'
test_expect_success 'left alignment formatting' '
- git log --pretty="format:%<(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
message two Z
message one Z
@@ -157,9 +155,7 @@ EOF
'
test_expect_success 'left alignment formatting at the nth column' '
- git log --pretty="format:%h %<|(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
$head1 message two Z
$head2 message one Z
@@ -170,9 +166,7 @@ EOF
'
test_expect_success 'left alignment formatting with no padding' '
- git log --pretty="format:%<(1)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(1)%s" >actual &&
cat <<EOF >expected &&
message two
message one
@@ -183,9 +177,7 @@ EOF
'
test_expect_success 'left alignment formatting with trunc' '
- git log --pretty="format:%<(10,trunc)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
message ..
message ..
@@ -196,9 +188,7 @@ EOF
'
test_expect_success 'left alignment formatting with ltrunc' '
- git log --pretty="format:%<(10,ltrunc)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
..sage two
..sage one
@@ -209,9 +199,7 @@ EOF
'
test_expect_success 'left alignment formatting with mtrunc' '
- git log --pretty="format:%<(10,mtrunc)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
mess.. two
mess.. one
@@ -222,9 +210,7 @@ EOF
'
test_expect_success 'right alignment formatting' '
- git log --pretty="format:%>(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%>(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
Z message two
Z message one
@@ -235,9 +221,7 @@ EOF
'
test_expect_success 'right alignment formatting at the nth column' '
- git log --pretty="format:%h %>|(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
$head1 message two
$head2 message one
@@ -248,9 +232,7 @@ EOF
'
test_expect_success 'right alignment formatting with no padding' '
- git log --pretty="format:%>(1)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%>(1)%s" >actual &&
cat <<EOF >expected &&
message two
message one
@@ -261,9 +243,7 @@ EOF
'
test_expect_success 'center alignment formatting' '
- git log --pretty="format:%><(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%><(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
Z message two Z
Z message one Z
@@ -274,9 +254,7 @@ EOF
'
test_expect_success 'center alignment formatting at the nth column' '
- git log --pretty="format:%h %><|(40)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%h %><|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
$head1 message two Z
$head2 message one Z
@@ -287,9 +265,7 @@ EOF
'
test_expect_success 'center alignment formatting with no padding' '
- git log --pretty="format:%><(1)%s" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%><(1)%s" >actual &&
cat <<EOF >expected &&
message two
message one
@@ -305,9 +281,7 @@ old_head1=$(git rev-parse --verify HEAD~0)
test_expect_success 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long <long@me.com>" &&
- git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
- # complete the incomplete line at the end
- echo >>actual &&
+ git log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
cat <<EOF >expected &&
short long long long
message .. A U Thor
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v3 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set
2014-05-16 18:49 ` Junio C Hamano
` (4 preceding siblings ...)
2014-05-19 15:28 ` [PATCH v3 3/5] t4205 (log-pretty-format): Use `tformat` rather than `format` Alexey Shumkin
@ 2014-05-19 15:28 ` Alexey Shumkin
2014-05-19 15:28 ` [PATCH v3 5/5] pretty.c: format string with truncate respects logOutputEncoding Alexey Shumkin
6 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-19 15:28 UTC (permalink / raw)
To: Junio C Hamano
Cc: Alexey Shumkin, git, brian m. carlson,
Nguyễn Thái Ngọc Duy
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.
There were no breakages as far as were no tests for the case
when both a commit message and logOutputEncoding are not UTF-8.
Add failing tests for that which will be fixed in the next patch.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
t/t4205-log-pretty-formats.sh | 140 ++++++++++++++++++++++++++++++++++++++++++
t/t6006-rev-list-format.sh | 75 +++++++++++++++++++++-
2 files changed, 213 insertions(+), 2 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index c03a65e..74babce 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -154,6 +154,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message two Z
+message one Z
+add bar Z
+$(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting at the nth column' '
git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -165,6 +176,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 $(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting with no padding' '
git log --pretty="tformat:%<(1)%s" >actual &&
cat <<EOF >expected &&
@@ -176,6 +198,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message two
+message one
+add bar
+$(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting with trunc' '
git log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -187,6 +220,17 @@ EOF
test_cmp expected actual
'
+test_expect_failure 'left alignment formatting with trunc. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message ..
+message ..
+add bar Z
+initial...
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting with ltrunc' '
git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -198,6 +242,17 @@ EOF
test_cmp expected actual
'
+test_expect_failure 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+..sage two
+..sage one
+add bar Z
+..${sample_utf8_part}lich
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting with mtrunc' '
git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -209,6 +264,17 @@ EOF
test_cmp expected actual
'
+test_expect_failure 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+mess.. two
+mess.. one
+add bar Z
+init..lich
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting' '
git log --pretty="tformat:%>(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -220,6 +286,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'right alignment formatting. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+Z message two
+Z message one
+Z add bar
+Z $(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting at the nth column' '
git log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -231,6 +308,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+$head1 message two
+$head2 message one
+$head3 add bar
+$head4 $(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting with no padding' '
git log --pretty="tformat:%>(1)%s" >actual &&
cat <<EOF >expected &&
@@ -242,6 +330,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual &&
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message two
+message one
+add bar
+$(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'center alignment formatting' '
git log --pretty="tformat:%><(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -253,6 +352,16 @@ EOF
test_cmp expected actual
'
+test_expect_success 'center alignment formatting. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+Z message two Z
+Z message one Z
+Z add bar Z
+Z $(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
test_expect_success 'center alignment formatting at the nth column' '
git log --pretty="tformat:%h %><|(40)%s" >actual &&
qz_to_tab_space <<EOF >expected &&
@@ -264,6 +373,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual &&
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 $(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'center alignment formatting with no padding' '
git log --pretty="tformat:%><(1)%s" >actual &&
cat <<EOF >expected &&
@@ -278,6 +398,16 @@ EOF
# save HEAD's SHA-1 digest (with no abbreviations) to use it below
# as far as the next test amends HEAD
old_head1=$(git rev-parse --verify HEAD~0)
+test_expect_success 'center alignment formatting with no padding. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(1)%s" >actual &&
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+message two
+message one
+add bar
+$(commit_msg)
+EOF
+ test_cmp expected actual
+'
test_expect_success 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long <long@me.com>" &&
@@ -290,6 +420,16 @@ initial... A U Thor
EOF
test_cmp expected actual
'
+test_expect_failure 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
+short long long long
+message .. A U Thor
+add bar A U Thor
+initial... A U Thor
+EOF
+ test_cmp expected actual
+'
# get new digests (with no abbreviations)
head1=$(git rev-parse --verify HEAD~0) &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 9e4ba62..a932f34 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -15,12 +15,22 @@ test_encoding="ISO8859-1"
# String "added" in German
# (translated with Google Translate),
# encoded in UTF-8, used as a commit log message below.
-added=$(printf "added (hinzugef\303\274gt) foo")
+added_utf8_part=$(printf "\303\274")
+added_utf8_part_iso88591=$(echo "$added_utf8_part" | iconv -f utf-8 -t $test_encoding)
+added=$(printf "added (hinzugef${added_utf8_part}gt) foo")
added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
# same but "changed"
-changed=$(printf "changed (ge\303\244ndert) foo")
+changed_utf8_part=$(printf "\303\244")
+changed_utf8_part_iso88591=$(echo "$changed_utf8_part" | iconv -f utf-8 -t $test_encoding)
+changed=$(printf "changed (ge${changed_utf8_part}ndert) foo")
changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
+# Count of char to truncate
+# Number is chosen so, that non-ACSII characters
+# (see $added_utf8_part and $changed_utf8_part)
+# fall into truncated parts of appropriate words both from left and right
+truncate_count=20
+
test_expect_success 'setup' '
: >foo &&
git add foo &&
@@ -139,6 +149,13 @@ commit $head1
$added
EOF
+test_format subject-truncated %<($truncate_count,trunc)%s <<EOF
+commit $head2
+changed (ge${changed_utf8_part}ndert)..
+commit $head1
+added (hinzugef${added_utf8_part}gt..
+EOF
+
test_format body %b <<EOF
commit $head2
commit $head1
@@ -242,6 +259,33 @@ commit $head1
$added_iso88591
EOF
+test_format complex-subject-trunc %<($truncate_count,trunc)%s failure <<EOF
+commit $head3
+Test printing of c..
+commit $head2
+changed (ge${changed_utf8_part_iso88591}ndert)..
+commit $head1
+added (hinzugef${added_utf8_part_iso88591}gt..
+EOF
+
+test_format complex-subject-mtrunc %<($truncate_count,mtrunc)%s failure <<EOF
+commit $head3
+Test prin..ex bodies
+commit $head2
+changed (..dert) foo
+commit $head1
+added (hi..f${added_utf8_part_iso88591}gt) foo
+EOF
+
+test_format complex-subject-ltrunc %<($truncate_count,ltrunc)%s failure <<EOF
+commit $head3
+.. of complex bodies
+commit $head2
+..ged (ge${changed_utf8_part_iso88591}ndert) foo
+commit $head1
+.. (hinzugef${added_utf8_part_iso88591}gt) foo
+EOF
+
test_expect_success 'prepare expected messages (for test %b)' '
cat <<-EOF >expected.utf-8 &&
commit $head3
@@ -270,6 +314,33 @@ commit $head1
$added
EOF
+test_format complex-subject-commitencoding-unset-trunc %<($truncate_count,trunc)%s <<EOF
+commit $head3
+Test printing of c..
+commit $head2
+changed (ge${changed_utf8_part}ndert)..
+commit $head1
+added (hinzugef${added_utf8_part}gt..
+EOF
+
+test_format complex-subject-commitencoding-unset-mtrunc %<($truncate_count,mtrunc)%s <<EOF
+commit $head3
+Test prin..ex bodies
+commit $head2
+changed (..dert) foo
+commit $head1
+added (hi..f${added_utf8_part}gt) foo
+EOF
+
+test_format complex-subject-commitencoding-unset-ltrunc %<($truncate_count,ltrunc)%s <<EOF
+commit $head3
+.. of complex bodies
+commit $head2
+..ged (ge${changed_utf8_part}ndert) foo
+commit $head1
+.. (hinzugef${added_utf8_part}gt) foo
+EOF
+
test_format complex-body-commitencoding-unset %b <expected.utf-8
test_expect_success '%x00 shows NUL' '
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v3 5/5] pretty.c: format string with truncate respects logOutputEncoding
2014-05-16 18:49 ` Junio C Hamano
` (5 preceding siblings ...)
2014-05-19 15:28 ` [PATCH v3 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set Alexey Shumkin
@ 2014-05-19 15:28 ` Alexey Shumkin
6 siblings, 0 replies; 25+ messages in thread
From: Alexey Shumkin @ 2014-05-19 15:28 UTC (permalink / raw)
To: Junio C Hamano
Cc: Alexey Shumkin, git, brian m. carlson,
Nguyễn Thái Ngọc Duy
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.
In 7e77df3 (pretty: two phase conversion for non utf-8 commits, 2013-04-19)
'format_commit_item' function assumes commit message to be in UTF-8.
And that was so until ecaee80 (pretty: --format output should honor
logOutputEncoding, 2013-06-26) where conversion to logOutputEncoding was
added before calling 'format_commit_message'.
Correct this by converting a commit message to UTF-8 first (as it
assumed in 7e77df3 (pretty: two phase conversion for non utf-8 commits,
2013-04-19)). Only after that convert a commit message to an actual
logOutputEncoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
pretty.c | 7 ++++++-
t/t4205-log-pretty-formats.sh | 8 ++++----
t/t6006-rev-list-format.sh | 6 +++---
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/pretty.c b/pretty.c
index 6e266dd..25e8825 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1507,13 +1507,18 @@ void format_commit_message(const struct commit *commit,
context.commit = commit;
context.pretty_ctx = pretty_ctx;
context.wrap_start = sb->len;
+ /*
+ * convert a commit message to UTF-8 first
+ * as far as 'format_commit_item' assumes it in UTF-8
+ */
context.message = logmsg_reencode(commit,
&context.commit_encoding,
- output_enc);
+ utf8);
strbuf_expand(sb, format, format_commit_item, &context);
rewrap_message_tail(sb, &context, 0, 0, 0);
+ /* then convert a commit message to an actual output encoding */
if (output_enc) {
if (same_encoding(utf8, output_enc))
output_enc = NULL;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 74babce..c84ec9a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -220,7 +220,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with trunc. i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with trunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
message ..
@@ -242,7 +242,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
..sage two
@@ -264,7 +264,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
mess.. two
@@ -420,7 +420,7 @@ initial... A U Thor
EOF
test_cmp expected actual
'
-test_expect_failure 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
+test_expect_success 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
short long long long
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index a932f34..c6e9a73 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -259,7 +259,7 @@ commit $head1
$added_iso88591
EOF
-test_format complex-subject-trunc %<($truncate_count,trunc)%s failure <<EOF
+test_format complex-subject-trunc %<($truncate_count,trunc)%s <<EOF
commit $head3
Test printing of c..
commit $head2
@@ -268,7 +268,7 @@ commit $head1
added (hinzugef${added_utf8_part_iso88591}gt..
EOF
-test_format complex-subject-mtrunc %<($truncate_count,mtrunc)%s failure <<EOF
+test_format complex-subject-mtrunc %<($truncate_count,mtrunc)%s <<EOF
commit $head3
Test prin..ex bodies
commit $head2
@@ -277,7 +277,7 @@ commit $head1
added (hi..f${added_utf8_part_iso88591}gt) foo
EOF
-test_format complex-subject-ltrunc %<($truncate_count,ltrunc)%s failure <<EOF
+test_format complex-subject-ltrunc %<($truncate_count,ltrunc)%s <<EOF
commit $head3
.. of complex bodies
commit $head2
--
1.9.2-15
^ permalink raw reply related [flat|nested] 25+ messages in thread