* [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
2013-06-25 8:55 ` [PATCH v6 " Alexey Shumkin
@ 2013-06-25 8:55 ` Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 2/5] t7102 (reset): " Alexey Shumkin
` (5 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25 8:55 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 7061 bytes --]
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t6006-rev-list-format.sh | 140 +++++++++++++++++++++++++--------------------
1 file changed, 77 insertions(+), 63 deletions(-)
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 0393c9f..cc1008d 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,8 +7,19 @@ test_description='git rev-list --pretty=format test'
test_tick
test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
- echo changed >foo && git commit -a -m "changed foo"
+ : >foo &&
+ git add foo &&
+ git commit -m "added foo" &&
+ head1=$(git rev-parse --verify HEAD) &&
+ head1_short=$(git rev-parse --verify --short $head1) &&
+ tree1=$(git rev-parse --verify HEAD:) &&
+ tree1_short=$(git rev-parse --verify --short $tree1) &&
+ echo changed >foo &&
+ git commit -a -m "changed foo" &&
+ head2=$(git rev-parse --verify HEAD) &&
+ head2_short=$(git rev-parse --verify --short $head2) &&
+ tree2=$(git rev-parse --verify HEAD:) &&
+ tree2_short=$(git rev-parse --verify --short $tree2)
'
# usage: test_format name format_string <expected_output
@@ -32,49 +43,49 @@ has_no_color () {
test_cmp expect "$1"
}
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
%h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
%h
EOF
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_short
+commit $head1
+$head1
+$head1_short
EOF
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-4d5fcadc293a348e88f777dc0920f11e7d71441c
-4d5fcad
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_short
+commit $head1
+$tree1
+$tree1_short
EOF
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head1_short
+commit $head1
EOF
# we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
A U Thor
author@example.com
Thu Apr 7 15:13:13 2005 -0700
Thu, 7 Apr 2005 15:13:13 -0700
1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
A U Thor
author@example.com
Thu Apr 7 15:13:13 2005 -0700
@@ -82,14 +93,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
1112911993
EOF
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
C O Mitter
committer@example.com
Thu Apr 7 15:13:13 2005 -0700
Thu, 7 Apr 2005 15:13:13 -0700
1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
C O Mitter
committer@example.com
Thu Apr 7 15:13:13 2005 -0700
@@ -97,43 +108,43 @@ Thu, 7 Apr 2005 15:13:13 -0700
1112911993
EOF
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
EOF
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
EOF
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format raw-body %B <<EOF
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
EOF
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
^[[1;31;43mfoo^[[m
EOF
@@ -186,39 +197,42 @@ 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!
EOF
+
test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
- echo change2 >foo && git commit -a -F commit-msg
+ git config i18n.commitencoding iso8859-1 &&
+ echo change2 >foo && git commit -a -F commit-msg &&
+ head3=$(git rev-parse --verify HEAD) &&
+ head3_short=$(git rev-parse --short $head3)
'
-test_format complex-encoding %e <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-encoding %e <<EOF
+commit $head3
iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
EOF
-test_format complex-subject %s <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-subject %s <<EOF
+commit $head3
Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format complex-body %b <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-body %b <<EOF
+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!
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
EOF
test_expect_success '%x00 shows NUL' '
- echo >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+ echo >expect commit $head3 &&
echo >>expect fooQbar &&
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
nul_to_q <actual.nul >actual &&
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v6 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
2013-06-25 8:55 ` [PATCH v6 " 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 ` Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
` (4 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25 8:55 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t7102-reset.sh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index df82ec9..05dfb27 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -192,7 +192,8 @@ test_expect_success \
'changing files and redo the last commit should succeed' '
echo "3rd line 2nd file" >>secondfile &&
git commit -a -C ORIG_HEAD &&
- check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+ head4=$(git rev-parse --verify HEAD) &&
+ check_changes $head4 &&
test "$(git rev-parse ORIG_HEAD)" = \
$head5
'
@@ -211,7 +212,7 @@ test_expect_success \
git reset --hard HEAD~2 &&
check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
test "$(git rev-parse ORIG_HEAD)" = \
- 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+ $head4
'
>.diff_expect
@@ -326,10 +327,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
git checkout branch2 &&
echo "3rd line in branch2" >>secondfile &&
git commit -a -m "change in branch2" &&
+ head3=$(git rev-parse --verify HEAD) &&
test_must_fail git pull . branch1 &&
git reset --hard &&
- check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+ check_changes $head3
'
>.diff_expect
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v6 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
2013-06-25 8:55 ` [PATCH v6 " 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 ` Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
` (3 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25 8:55 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 26fbfde..73ba5e8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' '
test_expect_success 'setup more commits' '
test_commit "message one" one one message-one &&
- test_commit "message two" two two message-two
+ test_commit "message two" two two message-two &&
+ head1=$(git rev-parse --verify --short HEAD~0) &&
+ head2=$(git rev-parse --verify --short HEAD~1) &&
+ head3=$(git rev-parse --verify --short HEAD~2) &&
+ head4=$(git rev-parse --verify --short HEAD~3)
'
test_expect_success 'left alignment formatting' '
@@ -117,18 +121,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'left alignment formatting at the nth column' '
- git log --pretty="format:%h %<|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two Z
-7cd6c63 message one Z
-1711bf9 add bar Z
-af20c06 initial Z
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 initial Z
EOF
test_cmp expected actual
-'
+"
test_expect_success 'left alignment formatting with no padding' '
git log --pretty="format:%<(1)%s" >actual &&
@@ -195,18 +199,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'right alignment formatting at the nth column' '
- git log --pretty="format:%h %>|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two
-7cd6c63 message one
-1711bf9 add bar
-af20c06 initial
+$head1 message two
+$head2 message one
+$head3 add bar
+$head4 initial
EOF
test_cmp expected actual
-'
+"
test_expect_success 'right alignment formatting with no padding' '
git log --pretty="format:%>(1)%s" >actual &&
@@ -234,18 +238,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'center alignment formatting at the nth column' '
- git log --pretty="format:%h %><|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two Z
-7cd6c63 message one Z
-1711bf9 add bar Z
-af20c06 initial Z
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 initial Z
EOF
test_cmp expected actual
-'
+"
test_expect_success 'center alignment formatting with no padding' '
git log --pretty="format:%><(1)%s" >actual &&
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
2013-06-25 8:55 ` [PATCH v6 " Alexey Shumkin
` (2 preceding siblings ...)
2013-06-25 8:55 ` [PATCH v6 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
@ 2013-06-25 8:55 ` Alexey Shumkin
2013-06-25 8:55 ` [PATCH v6 5/5] pretty: " Alexey Shumkin
` (2 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25 8:55 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 22539 bytes --]
One can set an alias
$ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
--abbrev-commit --date=local"
to see the log as a pretty tree (like *gitk* but in a terminal).
However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
To simplify an example we can say the following two commands are expected
to give the same output to a terminal:
$ git log --oneline --no-color
$ git log --pretty=format:'%h %s'
However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".
The same corruption is true for
$ git diff --submodule=log
and
$ git rev-list --pretty=format:%s HEAD
and
$ git reset --hard
This patch adds failing tests for the next patch that fixes them.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4041-diff-submodule-option.sh | 35 +++++----
t/t4205-log-pretty-formats.sh | 149 ++++++++++++++++++++++++---------------
t/t6006-rev-list-format.sh | 83 +++++++++++++++-------
t/t7102-reset.sh | 29 +++++++-
4 files changed, 199 insertions(+), 97 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..67afb86 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#
test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
. ./test-lib.sh
+# String "added" in Russian, encoded in UTF-8, used in
+# sample commit log messages in add_file() function below.
+added=$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")
add_file () {
(
cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
- git commit -m "Add $name" || exit
+ msg_added_cp1251=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t cp1251) &&
+ git -c 'i18n.commitEncoding=cp1251' commit -m "$msg_added_cp1251"
done >/dev/null &&
git rev-parse --short --verify HEAD
)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
commit_file sm1 &&
head2=$(add_file sm1 foo3)
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
git diff --submodule=log >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
git diff --submodule >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
@@ -138,25 +143,25 @@ head3=$(
git rev-parse --short --verify HEAD
)
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2..$head3 (rewind):
- < Add foo3
- < Add foo2
+ < Add foo3 ($added foo3)
+ < Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2...$head4:
- > Add foo5
- > Add foo4
- < Add foo3
- < Add foo2
+ > Add foo5 ($added foo5)
+ > Add foo4 ($added foo4)
+ < Add foo3 ($added foo3)
+ < Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 73ba5e8..a45bb55 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,43 @@
#!/bin/sh
#
# Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#
test_description='Test pretty formats'
. ./test-lib.sh
+commit_msg() {
+ # String "initial commit" partly in Russian, encoded in UTF-8,
+ # used as a commit log message below.
+ msg=$(printf "initial \320\272\320\276\320\274\320\274\320\270\321\202")
+ 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
+}
+
test_expect_success 'set up basic repos' '
>foo &&
>bar &&
git add foo &&
test_tick &&
- git commit -m initial &&
+ git config i18n.commitEncoding cp1251 &&
+ git commit -m "$(commit_msg cp1251)" &&
git add bar &&
test_tick &&
- git commit -m "add bar"
+ git commit -m "add bar" &&
+ git config --unset i18n.commitEncoding
'
test_expect_success 'alias builtin format' '
@@ -38,6 +61,20 @@ test_expect_success 'alias user-defined format' '
test_cmp expected actual
'
+test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
+ git config i18n.logOutputEncoding cp1251 &&
+ git log --oneline >expected-s &&
+ git log --pretty="tformat:%h %s" >actual-s &&
+ git config --unset i18n.logOutputEncoding &&
+ test_cmp expected-s actual-s
+'
+
+test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+ git log --oneline >expected-s &&
+ git log --pretty="tformat:%h %s" >actual-s &&
+ test_cmp expected-s actual-s
+'
+
test_expect_success 'alias user-defined tformat' '
git log --pretty="tformat:%h" >expected &&
git config pretty.test-alias "tformat:%h" &&
@@ -71,22 +108,22 @@ test_expect_success 'alias loop' '
test_must_fail git log --pretty=test-foo
'
-test_expect_success 'NUL separation' '
- printf "add bar\0initial" >expected &&
+test_expect_failure 'NUL separation' '
+ printf "add bar\0$(commit_msg)" >expected &&
git log -z --pretty="format:%s" >actual &&
test_cmp expected actual
'
-test_expect_success 'NUL termination' '
- printf "add bar\0initial\0" >expected &&
+test_expect_failure 'NUL termination' '
+ printf "add bar\0$(commit_msg)\0" >expected &&
git log -z --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
-test_expect_success 'NUL separation with --stat' '
+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\0initial\n$stat1_part\n" >expected &&
+ printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
git log -z --stat --pretty="format:%s" >actual &&
test_i18ncmp expected actual
'
@@ -94,7 +131,7 @@ test_expect_success '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\0initial\n$stat1_part\n\0" >expected &&
+ printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
git log -z --stat --pretty="tformat:%s" >actual &&
test_i18ncmp expected actual
'
@@ -108,20 +145,20 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_success 'left alignment formatting' '
- git log --pretty="format:%<(40)%s" >actual &&
+test_expect_failure 'left alignment formatting' "
+ git log --pretty='format:%<(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
message two Z
message one Z
add bar Z
-initial Z
+$(commit_msg) Z
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'left alignment formatting at the nth column' "
+test_expect_failure 'left alignment formatting at the nth column' "
git log --pretty='format:%h %<|(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -129,77 +166,77 @@ test_expect_success 'left alignment formatting at the nth column' "
$head1 message two Z
$head2 message one Z
$head3 add bar Z
-$head4 initial Z
+$head4 $(commit_msg) Z
EOF
test_cmp expected actual
"
-test_expect_success 'left alignment formatting with no padding' '
- git log --pretty="format:%<(1)%s" >actual &&
+test_expect_failure 'left alignment formatting with no padding' "
+ git log --pretty='format:%<(1)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
cat <<\EOF >expected &&
message two
message one
add bar
-initial
+$(commit_msg)
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'left alignment formatting with trunc' '
- git log --pretty="format:%<(10,trunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with trunc' "
+ git log --pretty='format:%<(10,trunc)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
message ..
message ..
add bar Z
-initial Z
+$(commit_msg "" "8" ".\+$")
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'left alignment formatting with ltrunc' '
- git log --pretty="format:%<(10,ltrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with ltrunc' "
+ git log --pretty='format:%<(10,ltrunc)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
..sage two
..sage one
add bar Z
-initial Z
+$(commit_msg "" "0" ".\{6\}")
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'left alignment formatting with mtrunc' '
- git log --pretty="format:%<(10,mtrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with mtrunc' "
+ git log --pretty='format:%<(10,mtrunc)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
mess.. two
mess.. one
add bar Z
-initial Z
+$(commit_msg "" "4" ".\{6\}")
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'right alignment formatting' '
- git log --pretty="format:%>(40)%s" >actual &&
+test_expect_failure 'right alignment formatting' "
+ git log --pretty='format:%>(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
Z message two
Z message one
Z add bar
-Z initial
+Z $(commit_msg)
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'right alignment formatting at the nth column' "
+test_expect_failure 'right alignment formatting at the nth column' "
git log --pretty='format:%h %>|(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -207,38 +244,38 @@ test_expect_success 'right alignment formatting at the nth column' "
$head1 message two
$head2 message one
$head3 add bar
-$head4 initial
+$head4 $(commit_msg)
EOF
test_cmp expected actual
"
-test_expect_success 'right alignment formatting with no padding' '
- git log --pretty="format:%>(1)%s" >actual &&
+test_expect_failure 'right alignment formatting with no padding' "
+ git log --pretty='format:%>(1)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
cat <<\EOF >expected &&
message two
message one
add bar
-initial
+$(commit_msg)
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'center alignment formatting' '
- git log --pretty="format:%><(40)%s" >actual &&
+test_expect_failure 'center alignment formatting' "
+ git log --pretty='format:%><(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
Z message two Z
Z message one Z
Z add bar Z
-Z initial Z
+Z $(commit_msg) Z
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'center alignment formatting at the nth column' "
+test_expect_failure 'center alignment formatting at the nth column' "
git log --pretty='format:%h %><|(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -246,36 +283,36 @@ test_expect_success 'center alignment formatting at the nth column' "
$head1 message two Z
$head2 message one Z
$head3 add bar Z
-$head4 initial Z
+$head4 $(commit_msg) Z
EOF
test_cmp expected actual
"
-test_expect_success 'center alignment formatting with no padding' '
- git log --pretty="format:%><(1)%s" >actual &&
+test_expect_failure 'center alignment formatting with no padding' "
+ git log --pretty='format:%><(1)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
cat <<\EOF >expected &&
message two
message one
add bar
-initial
+$(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>" &&
- git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
+test_expect_failure '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 &&
cat <<\EOF >expected &&
short long long long
message .. A U Thor
add bar A U Thor
-initial A U Thor
+$(commit_msg "" "8" ".\+$") A U Thor
EOF
test_cmp expected actual
-'
+"
test_done
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index cc1008d..ce62214 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,34 +1,60 @@
#!/bin/sh
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
test_description='git rev-list --pretty=format test'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh
test_tick
+# String "added" in Russian, encoded in UTF-8,
+# used as a commit log message below.
+added=$(printf "added (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+added_cp1251=$(echo "$added" | iconv -f utf-8 -t cp1251)
+# same but "changed"
+changed=$(printf "changed (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+changed_cp1251=$(echo "$changed" | iconv -f utf-8 -t cp1251)
+
test_expect_success 'setup' '
: >foo &&
git add foo &&
- git commit -m "added foo" &&
+ git config i18n.commitEncoding cp1251 &&
+ git commit -m "$added_cp1251" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
tree1=$(git rev-parse --verify HEAD:) &&
tree1_short=$(git rev-parse --verify --short $tree1) &&
- echo changed >foo &&
- git commit -a -m "changed foo" &&
+ echo "$changed" > foo &&
+ git commit -a -m "$changed_cp1251" &&
head2=$(git rev-parse --verify HEAD) &&
head2_short=$(git rev-parse --verify --short $head2) &&
tree2=$(git rev-parse --verify HEAD:) &&
tree2_short=$(git rev-parse --verify --short $tree2)
+ git config --unset i18n.commitEncoding
'
-# usage: test_format name format_string <expected_output
+# usage: test_format [failure] name format_string <expected_output
test_format () {
+ must_fail=0
+ # if parameters count is more than 2 then test must fail
+ if test $# -gt 2
+ then
+ must_fail=1
+ # remove first parameter which is flag for test failure
+ shift
+ fi
cat >expect.$1
- test_expect_success "format $1" "
- git rev-list --pretty=format:'$2' master >output.$1 &&
- test_cmp expect.$1 output.$1
- "
+ name="format $1"
+ command="git rev-list --pretty=format:'$2' master >output.$1 &&
+ test_cmp expect.$1 output.$1"
+ if test $must_fail -eq 1
+ then
+ test_expect_failure "$name" "$command"
+ else
+ test_expect_success "$name" "$command"
+ fi
}
# Feed to --format to provide predictable colored sequences.
@@ -110,14 +136,16 @@ EOF
test_format encoding %e <<EOF
commit $head2
+cp1251
commit $head1
+cp1251
EOF
-test_format subject %s <<EOF
+test_format failure subject %s <<EOF
commit $head2
-changed foo
+$changed
commit $head1
-added foo
+$added
EOF
test_format body %b <<EOF
@@ -125,12 +153,12 @@ commit $head2
commit $head1
EOF
-test_format raw-body %B <<EOF
+test_format failure raw-body %B <<EOF
commit $head2
-changed foo
+$changed
commit $head1
-added foo
+$added
EOF
@@ -190,42 +218,49 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
)
'
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t iso8859-1 > 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!
+include an iso8859 character: ¡bueno!
EOF
test_expect_success 'setup complex body' '
git config i18n.commitencoding iso8859-1 &&
echo change2 >foo && git commit -a -F commit-msg &&
head3=$(git rev-parse --verify HEAD) &&
- head3_short=$(git rev-parse --short $head3)
+ head3_short=$(git rev-parse --short $head3) &&
+ # unset commit encoding config
+ # otherwise %e does not print encoding value
+ # and following test fails
+ git config --unset i18n.commitEncoding
+
'
test_format complex-encoding %e <<EOF
commit $head3
iso8859-1
commit $head2
+cp1251
commit $head1
+cp1251
EOF
-test_format complex-subject %s <<EOF
+test_format failure complex-subject %s <<EOF
commit $head3
Test printing of complex bodies
commit $head2
-changed foo
+$changed
commit $head1
-added foo
+$added
EOF
-test_format complex-body %b <<EOF
+test_format failure complex-body %b <<EOF
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!
+include an iso8859 character: ¡bueno!
commit $head2
commit $head1
@@ -279,12 +314,12 @@ test_expect_success 'add LF before non-empty (2)' '
test_expect_success 'add SP before non-empty (1)' '
git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
- test $(wc -w <actual) = 2
+ test $(wc -w <actual) = 3
'
test_expect_success 'add SP before non-empty (2)' '
git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
- test $(wc -w <actual) = 4
+ test $(wc -w <actual) = 6
'
test_expect_success '--abbrev' '
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 05dfb27..19a4cf4 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,17 @@ Documented tests for git reset'
. ./test-lib.sh
+commit_msg() {
+ # String "2nd file modified" in Russian, encoded in UTF-8,
+ # used as a commit log message below.
+ msg=$(printf "modify 2nd file (\320\270\320\267\320\274\320\265\320\275\321\221\320\275 \321\204\320\260\320\271\320\273)")
+ if test -n "$1"
+ then
+ msg=$(echo $msg | iconv -f utf-8 -t $1)
+ fi
+ echo $msg
+}
+
test_expect_success 'creating initial files and commits' '
test_tick &&
echo "1st file" >first &&
@@ -28,7 +39,7 @@ test_expect_success 'creating initial files and commits' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git commit -a -m "modify 2nd file" &&
+ git -c "i18n.commitEncoding=cp1251" commit -a -m "$(commit_msg cp1251)" &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +55,20 @@ check_changes () {
done | test_cmp .cat_expect -
}
+test_expect_failure 'reset --hard message' '
+ hex=$(git log -1 --format="%h") &&
+ git reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg) > .expected &&
+ test_cmp .expected .actual
+'
+
+test_expect_success 'reset --hard message (cp1251 logoutencoding)' '
+ hex=$(git log -1 --format="%h") &&
+ git -c "i18n.logOutputEncoding=cp1251" reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg cp1251) > .expected &&
+ test_cmp .expected .actual
+'
+
>.diff_expect
>.cached_expect
cat >.cat_expect <<EOF
@@ -304,7 +329,7 @@ test_expect_success 'redoing the last two commits should succeed' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git commit -a -m "modify 2nd file" &&
+ git -c "i18n.commitEncoding=cp1251" commit -a -m "$(commit_msg cp1251)" &&
check_changes $head5
'
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v6 5/5] pretty: --format output should honor logOutputEncoding
2013-06-25 8:55 ` [PATCH v6 " Alexey Shumkin
` (3 preceding siblings ...)
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 ` Alexey Shumkin
2013-06-25 19:28 ` [PATCH v6 0/5] Reroll patches against v1.8.3.1 Junio C Hamano
2013-06-26 10:19 ` [PATCH v7 " Alexey Shumkin
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25 8:55 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
One can set an alias
$ git config [--global] alias.lg "log --graph --pretty=format:'%Cred%h%Creset
-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
--abbrev-commit --date=local"
to see the log as a pretty tree (like *gitk* but in a terminal).
However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
To simplify an example we can say the following two commands are expected
to give the same output to a terminal:
$ git log --oneline --no-color
$ git log --pretty=format:'%h %s'
However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".
The same corruption is true for
$ git diff --submodule=log
and
$ git rev-list --pretty=format:%s HEAD
and
$ git reset --hard
This patch makes pretty --format honor logOutputEncoding when it formats
log message.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
builtin/reset.c | 6 ++++--
builtin/rev-list.c | 1 +
builtin/shortlog.c | 1 +
log-tree.c | 1 +
submodule.c | 1 +
t/t4041-diff-submodule-option.sh | 10 +++++-----
t/t4205-log-pretty-formats.sh | 34 +++++++++++++++++-----------------
t/t6006-rev-list-format.sh | 8 ++++----
t/t7102-reset.sh | 2 +-
9 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..a6cacc6 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -92,11 +92,12 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
static void print_new_head_line(struct commit *commit)
{
- const char *hex, *body;
+ const char *hex, *body, *msg;
hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
printf(_("HEAD is now at %s"), hex);
- body = strstr(commit->buffer, "\n\n");
+ msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+ body = strstr(msg, "\n\n");
if (body) {
const char *eol;
size_t len;
@@ -107,6 +108,7 @@ static void print_new_head_line(struct commit *commit)
}
else
printf("\n");
+ logmsg_free(msg, commit);
}
static void update_index_from_diff(struct diff_queue_struct *q,
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 67701be..a5ec30d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
ctx.date_mode = revs->date_mode;
ctx.date_mode_explicit = revs->date_mode_explicit;
ctx.fmt = revs->commit_format;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &buf);
if (revs->graph) {
if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 1fd6f8a..1434f8f 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
ctx.subject = "";
ctx.after_subject = "";
ctx.date_mode = DATE_NORMAL;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &ufbuf);
buffer = ufbuf.buf;
} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index 1946e9c..5277d3e 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -616,6 +616,7 @@ void show_log(struct rev_info *opt)
ctx.fmt = opt->commit_format;
ctx.mailmap = opt->mailmap;
ctx.color = opt->diffopt.use_color;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &msgbuf);
if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index 1821a5b..78734e1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -226,6 +226,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
while ((commit = get_revision(rev))) {
struct pretty_print_context ctx = {0};
ctx.date_mode = rev->date_mode;
+ ctx.output_encoding = get_log_output_encoding();
strbuf_setlen(&sb, 0);
strbuf_addstr(&sb, line_prefix);
if (commit->object.flags & SYMMETRIC_LEFT) {
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 67afb86..9ba4b8e 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -94,7 +94,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
commit_file sm1 &&
head2=$(add_file sm1 foo3)
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -103,7 +103,7 @@ test_expect_failure 'modified submodule(forward)' '
test_cmp expected actual
'
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
git diff --submodule=log >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -112,7 +112,7 @@ test_expect_failure 'modified submodule(forward)' '
test_cmp expected actual
'
-test_expect_failure 'modified submodule(forward) --submodule' '
+test_expect_success 'modified submodule(forward) --submodule' '
git diff --submodule >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -143,7 +143,7 @@ head3=$(
git rev-parse --short --verify HEAD
)
-test_expect_failure 'modified submodule(backward)' '
+test_expect_success 'modified submodule(backward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2..$head3 (rewind):
@@ -154,7 +154,7 @@ test_expect_failure 'modified submodule(backward)' '
'
head4=$(add_file sm1 foo4 foo5)
-test_expect_failure 'modified submodule(backward and forward)' '
+test_expect_success 'modified submodule(backward and forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2...$head4:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index a45bb55..5a14124 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -69,7 +69,7 @@ test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
test_cmp expected-s actual-s
'
-test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
git log --oneline >expected-s &&
git log --pretty="tformat:%h %s" >actual-s &&
test_cmp expected-s actual-s
@@ -108,19 +108,19 @@ test_expect_success 'alias loop' '
test_must_fail git log --pretty=test-foo
'
-test_expect_failure 'NUL separation' '
+test_expect_success 'NUL separation' '
printf "add bar\0$(commit_msg)" >expected &&
git log -z --pretty="format:%s" >actual &&
test_cmp expected actual
'
-test_expect_failure 'NUL termination' '
+test_expect_success 'NUL termination' '
printf "add bar\0$(commit_msg)\0" >expected &&
git log -z --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
-test_expect_failure 'NUL separation with --stat' '
+test_expect_success '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 &&
@@ -145,7 +145,7 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_failure 'left alignment formatting' "
+test_expect_success 'left alignment formatting' "
git log --pretty='format:%<(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -158,7 +158,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting at the nth column' "
+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 &&
@@ -171,7 +171,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting with no padding' "
+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 &&
@@ -184,7 +184,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting with trunc' "
+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 &&
@@ -197,7 +197,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting with ltrunc' "
+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 &&
@@ -210,7 +210,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting with mtrunc' "
+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 &&
@@ -223,7 +223,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'right alignment formatting' "
+test_expect_success 'right alignment formatting' "
git log --pretty='format:%>(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -236,7 +236,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'right alignment formatting at the nth column' "
+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 &&
@@ -249,7 +249,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'right alignment formatting with no padding' "
+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 &&
@@ -262,7 +262,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'center alignment formatting' "
+test_expect_success 'center alignment formatting' "
git log --pretty='format:%><(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -275,7 +275,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'center alignment formatting at the nth column' "
+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 &&
@@ -288,7 +288,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'center alignment formatting with no padding' "
+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 &&
@@ -301,7 +301,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left/right alignment formatting with stealing' "
+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
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index ce62214..6356046 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -141,7 +141,7 @@ commit $head1
cp1251
EOF
-test_format failure subject %s <<EOF
+test_format subject %s <<EOF
commit $head2
$changed
commit $head1
@@ -153,7 +153,7 @@ commit $head2
commit $head1
EOF
-test_format failure raw-body %B <<EOF
+test_format raw-body %B <<EOF
commit $head2
$changed
@@ -247,7 +247,7 @@ commit $head1
cp1251
EOF
-test_format failure complex-subject %s <<EOF
+test_format complex-subject %s <<EOF
commit $head3
Test printing of complex bodies
commit $head2
@@ -256,7 +256,7 @@ commit $head1
$added
EOF
-test_format failure complex-body %b <<EOF
+test_format complex-body %b <<EOF
commit $head3
This commit message is much longer than the others,
and it will be encoded in iso8859-1. We should therefore
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 19a4cf4..ea96e43 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -55,7 +55,7 @@ check_changes () {
done | test_cmp .cat_expect -
}
-test_expect_failure 'reset --hard message' '
+test_expect_success 'reset --hard message' '
hex=$(git log -1 --format="%h") &&
git reset --hard > .actual &&
echo HEAD is now at $hex $(commit_msg) > .expected &&
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v6 0/5] Reroll patches against v1.8.3.1
2013-06-25 8:55 ` [PATCH v6 " Alexey Shumkin
` (4 preceding siblings ...)
2013-06-25 8:55 ` [PATCH v6 5/5] pretty: " Alexey Shumkin
@ 2013-06-25 19:28 ` Junio C Hamano
2013-06-26 7:37 ` Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 " Alexey Shumkin
6 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-06-25 19:28 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git
Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
> 4. [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
> iso8859-5 encoding reverted back to cp1251 encoding (as it was in v4 series)
Thanks for a reroll, but why this change?
The reason I asked you to avoid 8859-5 is because our test do not
use that encoding and I do not want to add new dependency to people
when they run test. cp1251 shares exactly the same issue, doesn't
it? So in that sense, this change does not make anything better.
That is why I asked you if the breakage you are trying to
demonstrate about non-ASCII non-UTF8 encoding was specific to
Cyrillic/Russian. I do not recall seeing your answer, but what is
the right thing to do depend on it.
- If the answer is yes, then we would need to add dependency either
way, and 8859-5 is just as fine as cp1251.
- If the breakage is not specific to Cyrillic, it should be
reproducible using 8859-1 (latin-1), and our tests already depend
on 8859-1, so we wouldn't be adding new dependencies on people.
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v6 0/5] Reroll patches against v1.8.3.1
2013-06-25 19:28 ` [PATCH v6 0/5] Reroll patches against v1.8.3.1 Junio C Hamano
@ 2013-06-26 7:37 ` Alexey Shumkin
2013-06-26 14:24 ` Junio C Hamano
0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 7:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Tue, Jun 25, 2013 at 12:28:02PM -0700, Junio C Hamano wrote:
> Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
>
> > 4. [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
> > iso8859-5 encoding reverted back to cp1251 encoding (as it was in v4 series)
>
> Thanks for a reroll, but why this change?
>
> The reason I asked you to avoid 8859-5 is because our test do not
> use that encoding and I do not want to add new dependency to people
> when they run test. cp1251 shares exactly the same issue, doesn't
> it? So in that sense, this change does not make anything better.
>
> That is why I asked you if the breakage you are trying to
> demonstrate about non-ASCII non-UTF8 encoding was specific to
> Cyrillic/Russian. I do not recall seeing your answer, but what is
> the right thing to do depend on it.
>
> - If the answer is yes, then we would need to add dependency either
> way, and 8859-5 is just as fine as cp1251.
>
> - If the breakage is not specific to Cyrillic, it should be
> reproducible using 8859-1 (latin-1), and our tests already depend
> on 8859-1, so we wouldn't be adding new dependencies on people.
>
I suppose you've missed my answer somehow. It was:
---8<---
> Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
>
> > @@ -19,7 +23,8 @@ add_file () {
> > echo "$name" >"$name" &&
> > git add "$name" &&
> > test_tick &&
> > - git commit -m "Add $name" || exit
> > + msg_added_iso88595=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso88595) &&
> > + git -c 'i18n.commitEncoding=iso88595' commit -m "$msg_added_iso88595"
>
> Hmph. Do we know 8859-5 is available or do these need to be
> protected with prereq?
Opps, this encoding is absent even in my Cygwin box :)
Actually, previuosly, there was a Windows-1251 encoding,
you said we'd prefer to limit different encodings used in tests,
And I've made an attempt to avoid this but I'm way off the mark.
>
> Can these tests be done with 8859-1 i.e. something we already depend
> on, by changing that $added message to latin-1, or is there something
> very Russian specific breakage we want to test here?
Well, actually, most popular Russian 8-bit codepages are Windows-1251 (aka cp1251) and KOI8-R.
Cygwin (as a "Linux box on Windows") uses cp1251.
Iconv cannot even convert Russian messages from cp1251(or UTF-8) to latin1.
It fails.
$ echo "коммит" | LANG= iconv -t latin1 -f UTF-8
iconv: illegal input sequence at position 0
("коммит" is a "commit" in Russian)
>
> If the former, please redo this entire patch (not just t4041) with
> 8859-1.
>
> If there is some Russian specific breakage you cannot demonstrate
> with 8859-1, then please explain it in the log message.
Well, it's not a "Russian specific". It's "codepage conversion" specific,
but I cannot use latin1 codepage because I do not know any language that
uses iso8859-1/latin1 codepage (as German, Spanish, for example) to
write a commit message in it.
If someone can do the same with latin1, I'd be happy.
>
> > diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> > index d32e65e..36e4cc0 100755
> > --- a/t/t6006-rev-list-format.sh
> > +++ b/t/t6006-rev-list-format.sh
> > ...
> > -# usage: test_format name format_string <expected_output
> > +# usage: test_format [failure] name format_string <expected_output
> > test_format () {
> > + local must_fail=0
>
> This breaks tests for non-bash users. "local" is not even in POSIX.
---8<---
But today I've taken a look to Cygwin's locales more closely and found
out that I've used incorrect encoding name (`iso88595` instead of "canonic"
`iso-8859-5` that Cygwin has and "understands")
Nevertheless, as I've already said that is not a Russian locale specific
issue.
The problem in tests for me now is a language (that uses iso-8859-1
encoding) I do not speak or even write ;)
--
Alexey Shumkin
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v6 0/5] Reroll patches against v1.8.3.1
2013-06-26 7:37 ` Alexey Shumkin
@ 2013-06-26 14:24 ` Junio C Hamano
0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-26 14:24 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git
Alexey Shumkin <alex.crezoff@gmail.com> writes:
> On Tue, Jun 25, 2013 at 12:28:02PM -0700, Junio C Hamano wrote:
> ...
> If someone can do the same with latin1, I'd be happy.
> ...
> But today I've taken a look to Cygwin's locales more closely and found
> out that I've used incorrect encoding name (`iso88595` instead of "canonic"
> `iso-8859-5` that Cygwin has and "understands")
>
> Nevertheless, as I've already said that is not a Russian locale specific
> issue.
> The problem in tests for me now is a language (that uses iso-8859-1
> encoding) I do not speak or even write ;)
Many of the people on thee list don't, either, and that is perfectly
OK.
For the purpose of the test, "áëîõù" should be sufficient. In a
sense, using such an artificial string would make it even clearer
than a real message that what we are testing, no?
^ permalink raw reply [flat|nested] 104+ messages in thread
* [PATCH v7 0/5] Reroll patches against v1.8.3.1
2013-06-25 8:55 ` [PATCH v6 " Alexey Shumkin
` (5 preceding siblings ...)
2013-06-25 19:28 ` [PATCH v6 0/5] Reroll patches against v1.8.3.1 Junio C Hamano
@ 2013-06-26 10:19 ` 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
` (6 more replies)
6 siblings, 7 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
v7 of this patch series includes the following changes against v6:
1. [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
untouched
2. [PATCH v7 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
untouched
3. [PATCH v7 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
untouched
4. [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
cp1251 encoding changed to iso-8859-1 encoding already used in tests
Test commit messages contain words ("changed" and "added") in German
(which is covered by iso-8859-1 encoding)
They are translated from English (verified in Russian) with Google Translate
5. [PATCH v7 5/5] pretty: --format output should honor logOutputEncoding
builtin/reset.c:
"const char ..., *msg;" declaration replaced with "char *msg;"
to avoid compiler warning on the line "logmsg_free(msg, commit);"
P.S.
It's all started here [http://thread.gmane.org/gmane.comp.version-control.git/177634]
Alexey Shumkin (5):
t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
t7102 (reset): don't hardcode SHA-1 in expected outputs
t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
pretty: Add failing tests: --format output should honor
logOutputEncoding
pretty: --format output should honor logOutputEncoding
builtin/reset.c | 5 +-
builtin/rev-list.c | 1 +
builtin/shortlog.c | 1 +
log-tree.c | 1 +
submodule.c | 1 +
t/t4041-diff-submodule-option.sh | 25 +++--
t/t4205-log-pretty-formats.sh | 179 ++++++++++++++++++++-------------
t/t6006-rev-list-format.sh | 207 ++++++++++++++++++++++++---------------
t/t7102-reset.sh | 37 ++++++-
9 files changed, 293 insertions(+), 164 deletions(-)
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply [flat|nested] 104+ messages in thread* [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
2013-06-26 10:19 ` [PATCH v7 " Alexey Shumkin
@ 2013-06-26 10:19 ` Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 2/5] t7102 (reset): " Alexey Shumkin
` (5 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 7061 bytes --]
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t6006-rev-list-format.sh | 140 +++++++++++++++++++++++++--------------------
1 file changed, 77 insertions(+), 63 deletions(-)
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 0393c9f..cc1008d 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,8 +7,19 @@ test_description='git rev-list --pretty=format test'
test_tick
test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
- echo changed >foo && git commit -a -m "changed foo"
+ : >foo &&
+ git add foo &&
+ git commit -m "added foo" &&
+ head1=$(git rev-parse --verify HEAD) &&
+ head1_short=$(git rev-parse --verify --short $head1) &&
+ tree1=$(git rev-parse --verify HEAD:) &&
+ tree1_short=$(git rev-parse --verify --short $tree1) &&
+ echo changed >foo &&
+ git commit -a -m "changed foo" &&
+ head2=$(git rev-parse --verify HEAD) &&
+ head2_short=$(git rev-parse --verify --short $head2) &&
+ tree2=$(git rev-parse --verify HEAD:) &&
+ tree2_short=$(git rev-parse --verify --short $tree2)
'
# usage: test_format name format_string <expected_output
@@ -32,49 +43,49 @@ has_no_color () {
test_cmp expect "$1"
}
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
%h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
%h
EOF
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_short
+commit $head1
+$head1
+$head1_short
EOF
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-4d5fcadc293a348e88f777dc0920f11e7d71441c
-4d5fcad
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_short
+commit $head1
+$tree1
+$tree1_short
EOF
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head1_short
+commit $head1
EOF
# we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
A U Thor
author@example.com
Thu Apr 7 15:13:13 2005 -0700
Thu, 7 Apr 2005 15:13:13 -0700
1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
A U Thor
author@example.com
Thu Apr 7 15:13:13 2005 -0700
@@ -82,14 +93,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
1112911993
EOF
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
C O Mitter
committer@example.com
Thu Apr 7 15:13:13 2005 -0700
Thu, 7 Apr 2005 15:13:13 -0700
1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
C O Mitter
committer@example.com
Thu Apr 7 15:13:13 2005 -0700
@@ -97,43 +108,43 @@ Thu, 7 Apr 2005 15:13:13 -0700
1112911993
EOF
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
EOF
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
EOF
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format raw-body %B <<EOF
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
EOF
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
^[[1;31;43mfoo^[[m
EOF
@@ -186,39 +197,42 @@ 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!
EOF
+
test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
- echo change2 >foo && git commit -a -F commit-msg
+ git config i18n.commitencoding iso8859-1 &&
+ echo change2 >foo && git commit -a -F commit-msg &&
+ head3=$(git rev-parse --verify HEAD) &&
+ head3_short=$(git rev-parse --short $head3)
'
-test_format complex-encoding %e <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-encoding %e <<EOF
+commit $head3
iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
EOF
-test_format complex-subject %s <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-subject %s <<EOF
+commit $head3
Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format complex-body %b <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-body %b <<EOF
+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!
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
EOF
test_expect_success '%x00 shows NUL' '
- echo >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+ echo >expect commit $head3 &&
echo >>expect fooQbar &&
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
nul_to_q <actual.nul >actual &&
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v7 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
2013-06-26 10:19 ` [PATCH v7 " 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 ` Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
` (4 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t7102-reset.sh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index df82ec9..05dfb27 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -192,7 +192,8 @@ test_expect_success \
'changing files and redo the last commit should succeed' '
echo "3rd line 2nd file" >>secondfile &&
git commit -a -C ORIG_HEAD &&
- check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+ head4=$(git rev-parse --verify HEAD) &&
+ check_changes $head4 &&
test "$(git rev-parse ORIG_HEAD)" = \
$head5
'
@@ -211,7 +212,7 @@ test_expect_success \
git reset --hard HEAD~2 &&
check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
test "$(git rev-parse ORIG_HEAD)" = \
- 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+ $head4
'
>.diff_expect
@@ -326,10 +327,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
git checkout branch2 &&
echo "3rd line in branch2" >>secondfile &&
git commit -a -m "change in branch2" &&
+ head3=$(git rev-parse --verify HEAD) &&
test_must_fail git pull . branch1 &&
git reset --hard &&
- check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+ check_changes $head3
'
>.diff_expect
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v7 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
2013-06-26 10:19 ` [PATCH v7 " 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 ` Alexey Shumkin
2013-06-26 10:19 ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
` (3 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 26fbfde..73ba5e8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' '
test_expect_success 'setup more commits' '
test_commit "message one" one one message-one &&
- test_commit "message two" two two message-two
+ test_commit "message two" two two message-two &&
+ head1=$(git rev-parse --verify --short HEAD~0) &&
+ head2=$(git rev-parse --verify --short HEAD~1) &&
+ head3=$(git rev-parse --verify --short HEAD~2) &&
+ head4=$(git rev-parse --verify --short HEAD~3)
'
test_expect_success 'left alignment formatting' '
@@ -117,18 +121,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'left alignment formatting at the nth column' '
- git log --pretty="format:%h %<|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two Z
-7cd6c63 message one Z
-1711bf9 add bar Z
-af20c06 initial Z
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 initial Z
EOF
test_cmp expected actual
-'
+"
test_expect_success 'left alignment formatting with no padding' '
git log --pretty="format:%<(1)%s" >actual &&
@@ -195,18 +199,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'right alignment formatting at the nth column' '
- git log --pretty="format:%h %>|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two
-7cd6c63 message one
-1711bf9 add bar
-af20c06 initial
+$head1 message two
+$head2 message one
+$head3 add bar
+$head4 initial
EOF
test_cmp expected actual
-'
+"
test_expect_success 'right alignment formatting with no padding' '
git log --pretty="format:%>(1)%s" >actual &&
@@ -234,18 +238,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'center alignment formatting at the nth column' '
- git log --pretty="format:%h %><|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two Z
-7cd6c63 message one Z
-1711bf9 add bar Z
-af20c06 initial Z
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 initial Z
EOF
test_cmp expected actual
-'
+"
test_expect_success 'center alignment formatting with no padding' '
git log --pretty="format:%><(1)%s" >actual &&
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
2013-06-26 10:19 ` [PATCH v7 " Alexey Shumkin
` (2 preceding siblings ...)
2013-06-26 10:19 ` [PATCH v7 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
@ 2013-06-26 10:19 ` Alexey Shumkin
2013-07-01 7:00 ` Johannes Sixt
2013-06-26 10:19 ` [PATCH v7 5/5] pretty: " Alexey Shumkin
` (2 subsequent siblings)
6 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 22510 bytes --]
One can set an alias
$ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
--abbrev-commit --date=local"
to see the log as a pretty tree (like *gitk* but in a terminal).
However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
To simplify an example we can say the following two commands are expected
to give the same output to a terminal:
$ git log --oneline --no-color
$ git log --pretty=format:'%h %s'
However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".
The same corruption is true for
$ git diff --submodule=log
and
$ git rev-list --pretty=format:%s HEAD
and
$ git reset --hard
This patch adds failing tests for the next patch that fixes them.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4041-diff-submodule-option.sh | 35 +++++----
t/t4205-log-pretty-formats.sh | 149 ++++++++++++++++++++++++---------------
t/t6006-rev-list-format.sh | 83 +++++++++++++++-------
t/t7102-reset.sh | 29 +++++++-
4 files changed, 199 insertions(+), 97 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..2a7877d 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#
test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
. ./test-lib.sh
+# 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")
add_file () {
(
cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
- git commit -m "Add $name" || exit
+ msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso-8859-1) &&
+ git -c 'i18n.commitEncoding=iso-8859-1' commit -m "$msg_added_iso88591"
done >/dev/null &&
git rev-parse --short --verify HEAD
)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
commit_file sm1 &&
head2=$(add_file sm1 foo3)
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
git diff --submodule=log >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
git diff --submodule >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
@@ -138,25 +143,25 @@ head3=$(
git rev-parse --short --verify HEAD
)
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2..$head3 (rewind):
- < Add foo3
- < Add foo2
+ < Add foo3 ($added foo3)
+ < Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2...$head4:
- > Add foo5
- > Add foo4
- < Add foo3
- < Add foo2
+ > Add foo5 ($added foo5)
+ > Add foo4 ($added foo4)
+ < Add foo3 ($added foo3)
+ < Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 73ba5e8..6b62da2 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,43 @@
#!/bin/sh
#
# Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#
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
+}
+
test_expect_success 'set up basic repos' '
>foo &&
>bar &&
git add foo &&
test_tick &&
- git commit -m initial &&
+ git config i18n.commitEncoding iso-8859-1 &&
+ git commit -m "$(commit_msg iso-8859-1)" &&
git add bar &&
test_tick &&
- git commit -m "add bar"
+ git commit -m "add bar" &&
+ git config --unset i18n.commitEncoding
'
test_expect_success 'alias builtin format' '
@@ -38,6 +61,20 @@ test_expect_success 'alias user-defined format' '
test_cmp expected actual
'
+test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' '
+ git config i18n.logOutputEncoding iso-8859-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
+'
+
+test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+ git log --oneline >expected-s &&
+ git log --pretty="tformat:%h %s" >actual-s &&
+ test_cmp expected-s actual-s
+'
+
test_expect_success 'alias user-defined tformat' '
git log --pretty="tformat:%h" >expected &&
git config pretty.test-alias "tformat:%h" &&
@@ -71,22 +108,22 @@ test_expect_success 'alias loop' '
test_must_fail git log --pretty=test-foo
'
-test_expect_success 'NUL separation' '
- printf "add bar\0initial" >expected &&
+test_expect_failure 'NUL separation' '
+ printf "add bar\0$(commit_msg)" >expected &&
git log -z --pretty="format:%s" >actual &&
test_cmp expected actual
'
-test_expect_success 'NUL termination' '
- printf "add bar\0initial\0" >expected &&
+test_expect_failure 'NUL termination' '
+ printf "add bar\0$(commit_msg)\0" >expected &&
git log -z --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
-test_expect_success 'NUL separation with --stat' '
+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\0initial\n$stat1_part\n" >expected &&
+ printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
git log -z --stat --pretty="format:%s" >actual &&
test_i18ncmp expected actual
'
@@ -94,7 +131,7 @@ test_expect_success '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\0initial\n$stat1_part\n\0" >expected &&
+ printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
git log -z --stat --pretty="tformat:%s" >actual &&
test_i18ncmp expected actual
'
@@ -108,20 +145,20 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_success 'left alignment formatting' '
- git log --pretty="format:%<(40)%s" >actual &&
+test_expect_failure 'left alignment formatting' "
+ git log --pretty='format:%<(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
message two Z
message one Z
add bar Z
-initial Z
+$(commit_msg) Z
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'left alignment formatting at the nth column' "
+test_expect_failure 'left alignment formatting at the nth column' "
git log --pretty='format:%h %<|(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -129,77 +166,77 @@ test_expect_success 'left alignment formatting at the nth column' "
$head1 message two Z
$head2 message one Z
$head3 add bar Z
-$head4 initial Z
+$head4 $(commit_msg) Z
EOF
test_cmp expected actual
"
-test_expect_success 'left alignment formatting with no padding' '
- git log --pretty="format:%<(1)%s" >actual &&
+test_expect_failure 'left alignment formatting with no padding' "
+ git log --pretty='format:%<(1)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
cat <<\EOF >expected &&
message two
message one
add bar
-initial
+$(commit_msg)
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'left alignment formatting with trunc' '
- git log --pretty="format:%<(10,trunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with trunc' "
+ git log --pretty='format:%<(10,trunc)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
message ..
message ..
add bar Z
-initial Z
+$(commit_msg "" "8" ".\+$")
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'left alignment formatting with ltrunc' '
- git log --pretty="format:%<(10,ltrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with ltrunc' "
+ git log --pretty='format:%<(10,ltrunc)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
..sage two
..sage one
add bar Z
-initial Z
+$(commit_msg "" "0" ".\{11\}")
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'left alignment formatting with mtrunc' '
- git log --pretty="format:%<(10,mtrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with mtrunc' "
+ git log --pretty='format:%<(10,mtrunc)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
mess.. two
mess.. one
add bar Z
-initial Z
+$(commit_msg "" "4" ".\{11\}")
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'right alignment formatting' '
- git log --pretty="format:%>(40)%s" >actual &&
+test_expect_failure 'right alignment formatting' "
+ git log --pretty='format:%>(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
Z message two
Z message one
Z add bar
-Z initial
+Z $(commit_msg)
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'right alignment formatting at the nth column' "
+test_expect_failure 'right alignment formatting at the nth column' "
git log --pretty='format:%h %>|(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -207,38 +244,38 @@ test_expect_success 'right alignment formatting at the nth column' "
$head1 message two
$head2 message one
$head3 add bar
-$head4 initial
+$head4 $(commit_msg)
EOF
test_cmp expected actual
"
-test_expect_success 'right alignment formatting with no padding' '
- git log --pretty="format:%>(1)%s" >actual &&
+test_expect_failure 'right alignment formatting with no padding' "
+ git log --pretty='format:%>(1)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
cat <<\EOF >expected &&
message two
message one
add bar
-initial
+$(commit_msg)
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'center alignment formatting' '
- git log --pretty="format:%><(40)%s" >actual &&
+test_expect_failure 'center alignment formatting' "
+ git log --pretty='format:%><(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
qz_to_tab_space <<\EOF >expected &&
Z message two Z
Z message one Z
Z add bar Z
-Z initial Z
+Z $(commit_msg) Z
EOF
test_cmp expected actual
-'
+"
-test_expect_success 'center alignment formatting at the nth column' "
+test_expect_failure 'center alignment formatting at the nth column' "
git log --pretty='format:%h %><|(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -246,36 +283,36 @@ test_expect_success 'center alignment formatting at the nth column' "
$head1 message two Z
$head2 message one Z
$head3 add bar Z
-$head4 initial Z
+$head4 $(commit_msg) Z
EOF
test_cmp expected actual
"
-test_expect_success 'center alignment formatting with no padding' '
- git log --pretty="format:%><(1)%s" >actual &&
+test_expect_failure 'center alignment formatting with no padding' "
+ git log --pretty='format:%><(1)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
cat <<\EOF >expected &&
message two
message one
add bar
-initial
+$(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>" &&
- git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
+test_expect_failure '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 &&
cat <<\EOF >expected &&
short long long long
message .. A U Thor
add bar A U Thor
-initial A U Thor
+$(commit_msg "" "8" ".\+$") A U Thor
EOF
test_cmp expected actual
-'
+"
test_done
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index cc1008d..c66a07f 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,34 +1,60 @@
#!/bin/sh
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
test_description='git rev-list --pretty=format test'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh
test_tick
+# 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 iso-8859-1)
+# same but "changed"
+changed=$(printf "changed (ge\303\244ndert) foo")
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso-8859-1)
+
test_expect_success 'setup' '
: >foo &&
git add foo &&
- git commit -m "added foo" &&
+ git config i18n.commitEncoding iso-8859-1 &&
+ git commit -m "$added_iso88591" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
tree1=$(git rev-parse --verify HEAD:) &&
tree1_short=$(git rev-parse --verify --short $tree1) &&
- echo changed >foo &&
- git commit -a -m "changed foo" &&
+ echo "$changed" > foo &&
+ git commit -a -m "$changed_iso88591" &&
head2=$(git rev-parse --verify HEAD) &&
head2_short=$(git rev-parse --verify --short $head2) &&
tree2=$(git rev-parse --verify HEAD:) &&
tree2_short=$(git rev-parse --verify --short $tree2)
+ git config --unset i18n.commitEncoding
'
-# usage: test_format name format_string <expected_output
+# usage: test_format [failure] name format_string <expected_output
test_format () {
+ must_fail=0
+ # if parameters count is more than 2 then test must fail
+ if test $# -gt 2
+ then
+ must_fail=1
+ # remove first parameter which is flag for test failure
+ shift
+ fi
cat >expect.$1
- test_expect_success "format $1" "
- git rev-list --pretty=format:'$2' master >output.$1 &&
- test_cmp expect.$1 output.$1
- "
+ name="format $1"
+ command="git rev-list --pretty=format:'$2' master >output.$1 &&
+ test_cmp expect.$1 output.$1"
+ if test $must_fail -eq 1
+ then
+ test_expect_failure "$name" "$command"
+ else
+ test_expect_success "$name" "$command"
+ fi
}
# Feed to --format to provide predictable colored sequences.
@@ -110,14 +136,16 @@ EOF
test_format encoding %e <<EOF
commit $head2
+iso-8859-1
commit $head1
+iso-8859-1
EOF
-test_format subject %s <<EOF
+test_format failure subject %s <<EOF
commit $head2
-changed foo
+$changed
commit $head1
-added foo
+$added
EOF
test_format body %b <<EOF
@@ -125,12 +153,12 @@ commit $head2
commit $head1
EOF
-test_format raw-body %B <<EOF
+test_format failure raw-body %B <<EOF
commit $head2
-changed foo
+$changed
commit $head1
-added foo
+$added
EOF
@@ -190,42 +218,49 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
)
'
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t iso8859-1 > 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!
+include an iso8859 character: ¡bueno!
EOF
test_expect_success 'setup complex body' '
git config i18n.commitencoding iso8859-1 &&
echo change2 >foo && git commit -a -F commit-msg &&
head3=$(git rev-parse --verify HEAD) &&
- head3_short=$(git rev-parse --short $head3)
+ head3_short=$(git rev-parse --short $head3) &&
+ # unset commit encoding config
+ # otherwise %e does not print encoding value
+ # and following test fails
+ git config --unset i18n.commitEncoding
+
'
test_format complex-encoding %e <<EOF
commit $head3
iso8859-1
commit $head2
+iso-8859-1
commit $head1
+iso-8859-1
EOF
-test_format complex-subject %s <<EOF
+test_format failure complex-subject %s <<EOF
commit $head3
Test printing of complex bodies
commit $head2
-changed foo
+$changed
commit $head1
-added foo
+$added
EOF
-test_format complex-body %b <<EOF
+test_format failure complex-body %b <<EOF
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!
+include an iso8859 character: ¡bueno!
commit $head2
commit $head1
@@ -279,12 +314,12 @@ test_expect_success 'add LF before non-empty (2)' '
test_expect_success 'add SP before non-empty (1)' '
git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
- test $(wc -w <actual) = 2
+ test $(wc -w <actual) = 3
'
test_expect_success 'add SP before non-empty (2)' '
git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
- test $(wc -w <actual) = 4
+ test $(wc -w <actual) = 6
'
test_expect_success '--abbrev' '
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 05dfb27..72e364e 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,17 @@ Documented tests for git reset'
. ./test-lib.sh
+commit_msg() {
+ # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+ # encoded in UTF-8, used as a commit log message below.
+ msg=$(printf "modify 2nd file (ge\303\244ndert)")
+ if test -n "$1"
+ then
+ msg=$(echo $msg | iconv -f utf-8 -t $1)
+ fi
+ echo $msg
+}
+
test_expect_success 'creating initial files and commits' '
test_tick &&
echo "1st file" >first &&
@@ -28,7 +39,7 @@ test_expect_success 'creating initial files and commits' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git commit -a -m "modify 2nd file" &&
+ git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +55,20 @@ check_changes () {
done | test_cmp .cat_expect -
}
+test_expect_failure 'reset --hard message' '
+ hex=$(git log -1 --format="%h") &&
+ git reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg) > .expected &&
+ test_cmp .expected .actual
+'
+
+test_expect_success 'reset --hard message (iso-8859-1 logoutencoding)' '
+ hex=$(git log -1 --format="%h") &&
+ git -c "i18n.logOutputEncoding=iso-8859-1" reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg iso-8859-1) > .expected &&
+ test_cmp .expected .actual
+'
+
>.diff_expect
>.cached_expect
cat >.cat_expect <<EOF
@@ -304,7 +329,7 @@ test_expect_success 'redoing the last two commits should succeed' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git commit -a -m "modify 2nd file" &&
+ git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
check_changes $head5
'
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
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
0 siblings, 1 reply; 104+ messages in thread
From: Johannes Sixt @ 2013-07-01 7:00 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, Junio C Hamano
Am 6/26/2013 12:19, schrieb Alexey Shumkin:
> One can set an alias
> $ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
> -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
> --abbrev-commit --date=local"
>
> to see the log as a pretty tree (like *gitk* but in a terminal).
>
> However, log messages written in an encoding i18n.commitEncoding which differs
> from terminal encoding are shown corrupted even when i18n.logOutputEncoding
> and terminal encoding are the same (e.g. log messages committed on a Cygwin box
> with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
>
> To simplify an example we can say the following two commands are expected
> to give the same output to a terminal:
>
> $ git log --oneline --no-color
> $ git log --pretty=format:'%h %s'
>
> However, the former pays attention to i18n.logOutputEncoding
> configuration, while the latter does not when it formats "%s".
>
> The same corruption is true for
> $ git diff --submodule=log
> and
> $ git rev-list --pretty=format:%s HEAD
> and
> $ git reset --hard
>
> This patch adds failing tests for the next patch that fixes them.
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 73ba5e8..6b62da2 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.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../")
This does not work as expected on Windows because sed ignores the .UTF-8
part of the locale specifier. (We don't even have en_US; we have de, but
with de.UTF-8 this doesn't work, either.)
I don't have an idea, yet, how to work it around.
> + fi
> + echo $msg
> +}
> -test_expect_success 'left alignment formatting with mtrunc' '
> - git log --pretty="format:%<(10,mtrunc)%s" >actual &&
> +test_expect_failure 'left alignment formatting with mtrunc' "
> + git log --pretty='format:%<(10,mtrunc)%s' >actual &&
> # complete the incomplete line at the end
> echo >>actual &&
> qz_to_tab_space <<\EOF >expected &&
> mess.. two
> mess.. one
> add bar Z
> -initial Z
> +$(commit_msg "" "4" ".\{11\}")
> EOF
> test_cmp expected actual
> -'
> +"
This is the failing test case.
BTW, if you re-roll, there would be fewer changes needed if you kept the
test code single-quoted, but changed <<\EOF to <<EOF where needed.
> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index cc1008d..c66a07f 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
...
> test_expect_success 'setup' '
> : >foo &&
> git add foo &&
> - git commit -m "added foo" &&
> + git config i18n.commitEncoding iso-8859-1 &&
Perhaps
test_config i18n.commitEncoding iso-8859-1 &&
Also, it is "iso-8869-1" here, but we see "iso8859-1" already used later.
It's probably wise to use that same encoding name everywhere because we
can be very sure that the latter is already understood on all supported
platforms.
> + git commit -m "$added_iso88591" &&
> head1=$(git rev-parse --verify HEAD) &&
> head1_short=$(git rev-parse --verify --short $head1) &&
> tree1=$(git rev-parse --verify HEAD:) &&
> tree1_short=$(git rev-parse --verify --short $tree1) &&
> - echo changed >foo &&
> - git commit -a -m "changed foo" &&
> + echo "$changed" > foo &&
> + git commit -a -m "$changed_iso88591" &&
> head2=$(git rev-parse --verify HEAD) &&
> head2_short=$(git rev-parse --verify --short $head2) &&
> tree2=$(git rev-parse --verify HEAD:) &&
> tree2_short=$(git rev-parse --verify --short $tree2)
> + git config --unset i18n.commitEncoding
> '
>
> -# usage: test_format name format_string <expected_output
> +# usage: test_format [failure] name format_string <expected_output
> test_format () {
> + must_fail=0
> + # if parameters count is more than 2 then test must fail
> + if test $# -gt 2
> + then
> + must_fail=1
> + # remove first parameter which is flag for test failure
> + shift
> + fi
> cat >expect.$1
> - test_expect_success "format $1" "
> - git rev-list --pretty=format:'$2' master >output.$1 &&
> - test_cmp expect.$1 output.$1
> - "
> + name="format $1"
> + command="git rev-list --pretty=format:'$2' master >output.$1 &&
> + test_cmp expect.$1 output.$1"
> + if test $must_fail -eq 1
> + then
> + test_expect_failure "$name" "$command"
> + else
> + test_expect_success "$name" "$command"
> + fi
> }
This function would be much shorter with the optional "failure" token as
$3 (untested):
test_format () {
cat >expect.$1
test_expect_${3:-success} "format $1" "
git rev-list --pretty=format:'$2' master >output.$1 &&
test_cmp expect.$1 output.$1
"
}
> test_expect_success 'setup complex body' '
> git config i18n.commitencoding iso8859-1 &&
> echo change2 >foo && git commit -a -F commit-msg &&
> head3=$(git rev-parse --verify HEAD) &&
> - head3_short=$(git rev-parse --short $head3)
> + head3_short=$(git rev-parse --short $head3) &&
> + # unset commit encoding config
> + # otherwise %e does not print encoding value
> + # and following test fails
I don't understand this comment. The test vector below already shows that
an encoding is printed. Why would this suddenly be different with the
updated tests?
Assuming that this change doesn't sweep a deeper problem under the rug,
it's better to use test_config a few lines earlier.
> + git config --unset i18n.commitEncoding
> +
> '
>
> test_format complex-encoding %e <<EOF
> commit $head3
> iso8859-1
This is the encoding that I mean.
> commit $head2
> +iso-8859-1
> commit $head1
> +iso-8859-1
> EOF
> diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> index 05dfb27..72e364e 100755
> --- a/t/t7102-reset.sh
> +++ b/t/t7102-reset.sh
> @@ -9,6 +9,17 @@ Documented tests for git reset'
>
> . ./test-lib.sh
>
> +commit_msg() {
> + # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
> + # encoded in UTF-8, used as a commit log message below.
> + msg=$(printf "modify 2nd file (ge\303\244ndert)")
> + if test -n "$1"
> + then
> + msg=$(echo $msg | iconv -f utf-8 -t $1)
> + fi
> + echo $msg
> +}
If you wanted to, you could write this as
commit_msg () {
# String "modify 2nd file (changed)" partly in German
#(translated with Google Translate),
# encoded in UTF-8, used as a commit log message below.
printf "modify 2nd file (ge\303\244ndert)" |
if test -n "$1"
then
iconv -f utf-8 -t $1
else
cat
fi
}
but I'm not sure whether it's a lot better.
-- Hannes
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
2013-07-01 7:00 ` Johannes Sixt
@ 2013-07-01 22:50 ` Alexey Shumkin
2013-07-02 7:22 ` Johannes Sixt
0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 22:50 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Junio C Hamano
On Mon, Jul 01, 2013 at 09:00:55AM +0200, Johannes Sixt wrote:
> Am 6/26/2013 12:19, schrieb Alexey Shumkin:
> > One can set an alias
> > $ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
> > -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
> > --abbrev-commit --date=local"
> >
> > to see the log as a pretty tree (like *gitk* but in a terminal).
> >
> > However, log messages written in an encoding i18n.commitEncoding which differs
> > from terminal encoding are shown corrupted even when i18n.logOutputEncoding
> > and terminal encoding are the same (e.g. log messages committed on a Cygwin box
> > with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
> >
> > To simplify an example we can say the following two commands are expected
> > to give the same output to a terminal:
> >
> > $ git log --oneline --no-color
> > $ git log --pretty=format:'%h %s'
> >
> > However, the former pays attention to i18n.logOutputEncoding
> > configuration, while the latter does not when it formats "%s".
> >
> > The same corruption is true for
> > $ git diff --submodule=log
> > and
> > $ git rev-list --pretty=format:%s HEAD
> > and
> > $ git reset --hard
> >
> > This patch adds failing tests for the next patch that fixes them.
> >
> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
>
> > diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> > index 73ba5e8..6b62da2 100755
> > --- a/t/t4205-log-pretty-formats.sh
> > +++ b/t/t4205-log-pretty-formats.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../")
>
> This does not work as expected on Windows because sed ignores the .UTF-8
> part of the locale specifier. (We don't even have en_US; we have de, but
> with de.UTF-8 this doesn't work, either.)
>
> I don't have an idea, yet, how to work it around.
>
Hmm. I have Cygwin v1.7 (on Windows 7 and Windows 2003 Server R2)
with many locales installed (and with en_US.UTF-8 locale, too)
Today I could not find a way to run tests with "no en_US.UTF-8 locale installed" simulation
to test your failure
> > + fi
> > + echo $msg
> > +}
>
> > -test_expect_success 'left alignment formatting with mtrunc' '
> > - git log --pretty="format:%<(10,mtrunc)%s" >actual &&
> > +test_expect_failure 'left alignment formatting with mtrunc' "
> > + git log --pretty='format:%<(10,mtrunc)%s' >actual &&
> > # complete the incomplete line at the end
> > echo >>actual &&
> > qz_to_tab_space <<\EOF >expected &&
> > mess.. two
> > mess.. one
> > add bar Z
> > -initial Z
> > +$(commit_msg "" "4" ".\{11\}")
> > EOF
> > test_cmp expected actual
> > -'
> > +"
>
> This is the failing test case.
Hmm, for me all these tests pass on both Linux and Cygwin (mentioned
above) boxes
>
> BTW, if you re-roll, there would be fewer changes needed if you kept the
> test code single-quoted, but changed <<\EOF to <<EOF where needed.
Yep, thanks for your correction
>
> > diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> > index cc1008d..c66a07f 100755
> > --- a/t/t6006-rev-list-format.sh
> > +++ b/t/t6006-rev-list-format.sh
> ...
> > test_expect_success 'setup' '
> > : >foo &&
> > git add foo &&
> > - git commit -m "added foo" &&
> > + git config i18n.commitEncoding iso-8859-1 &&
>
> Perhaps
> test_config i18n.commitEncoding iso-8859-1 &&
>
> Also, it is "iso-8869-1" here, but we see "iso8859-1" already used later.
> It's probably wise to use that same encoding name everywhere because we
> can be very sure that the latter is already understood on all supported
> platforms.
You're right (I've looked at explanation in
3994e8a98dc7bbf67e61d23c8125f44383499a1f; I've thought ISO-8859-1 is a
common name).
>
> > + git commit -m "$added_iso88591" &&
> > head1=$(git rev-parse --verify HEAD) &&
> > head1_short=$(git rev-parse --verify --short $head1) &&
> > tree1=$(git rev-parse --verify HEAD:) &&
> > tree1_short=$(git rev-parse --verify --short $tree1) &&
> > - echo changed >foo &&
> > - git commit -a -m "changed foo" &&
> > + echo "$changed" > foo &&
> > + git commit -a -m "$changed_iso88591" &&
> > head2=$(git rev-parse --verify HEAD) &&
> > head2_short=$(git rev-parse --verify --short $head2) &&
> > tree2=$(git rev-parse --verify HEAD:) &&
> > tree2_short=$(git rev-parse --verify --short $tree2)
> > + git config --unset i18n.commitEncoding
> > '
> >
> > -# usage: test_format name format_string <expected_output
> > +# usage: test_format [failure] name format_string <expected_output
> > test_format () {
> > + must_fail=0
> > + # if parameters count is more than 2 then test must fail
> > + if test $# -gt 2
> > + then
> > + must_fail=1
> > + # remove first parameter which is flag for test failure
> > + shift
> > + fi
> > cat >expect.$1
> > - test_expect_success "format $1" "
> > - git rev-list --pretty=format:'$2' master >output.$1 &&
> > - test_cmp expect.$1 output.$1
> > - "
> > + name="format $1"
> > + command="git rev-list --pretty=format:'$2' master >output.$1 &&
> > + test_cmp expect.$1 output.$1"
> > + if test $must_fail -eq 1
> > + then
> > + test_expect_failure "$name" "$command"
> > + else
> > + test_expect_success "$name" "$command"
> > + fi
> > }
>
> This function would be much shorter with the optional "failure" token as
> $3 (untested):
>
> test_format () {
> cat >expect.$1
> test_expect_${3:-success} "format $1" "
> git rev-list --pretty=format:'$2' master >output.$1 &&
> test_cmp expect.$1 output.$1
> "
Thank you for your suggesstion
> }
>
> > test_expect_success 'setup complex body' '
> > git config i18n.commitencoding iso8859-1 &&
> > echo change2 >foo && git commit -a -F commit-msg &&
> > head3=$(git rev-parse --verify HEAD) &&
> > - head3_short=$(git rev-parse --short $head3)
> > + head3_short=$(git rev-parse --short $head3) &&
> > + # unset commit encoding config
> > + # otherwise %e does not print encoding value
> > + # and following test fails
>
> I don't understand this comment. The test vector below already shows that
> an encoding is printed. Why would this suddenly be different with the
> updated tests?
I've changed tests. I've reverted back these ones, and added
new ones with no i18n.commitEncoding set
>
> Assuming that this change doesn't sweep a deeper problem under the rug,
> it's better to use test_config a few lines earlier.
>
> > + git config --unset i18n.commitEncoding
> > +
> > '
> >
> > test_format complex-encoding %e <<EOF
> > commit $head3
> > iso8859-1
>
> This is the encoding that I mean.
These encodings "have appeared" because we've changed 'setup':
we make commits with i18n.commitEncoding set
>
> > commit $head2
> > +iso-8859-1
> > commit $head1
> > +iso-8859-1
> > EOF
>
> > diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> > index 05dfb27..72e364e 100755
> > --- a/t/t7102-reset.sh
> > +++ b/t/t7102-reset.sh
> > @@ -9,6 +9,17 @@ Documented tests for git reset'
> >
> > . ./test-lib.sh
> >
> > +commit_msg() {
> > + # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
> > + # encoded in UTF-8, used as a commit log message below.
> > + msg=$(printf "modify 2nd file (ge\303\244ndert)")
> > + if test -n "$1"
> > + then
> > + msg=$(echo $msg | iconv -f utf-8 -t $1)
> > + fi
> > + echo $msg
> > +}
>
> If you wanted to, you could write this as
>
> commit_msg () {
> # String "modify 2nd file (changed)" partly in German
> #(translated with Google Translate),
> # encoded in UTF-8, used as a commit log message below.
> printf "modify 2nd file (ge\303\244ndert)" |
> if test -n "$1"
> then
> iconv -f utf-8 -t $1
> else
> cat
> fi
> }
>
> but I'm not sure whether it's a lot better.
It looks more readable. Thank you
>
> -- Hannes
--
Alexey Shumkin
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
2013-07-01 22:50 ` Alexey Shumkin
@ 2013-07-02 7:22 ` Johannes Sixt
2013-07-03 20:20 ` Alexey Shumkin
0 siblings, 1 reply; 104+ messages in thread
From: Johannes Sixt @ 2013-07-02 7:22 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, Junio C Hamano
Am 7/2/2013 0:50, schrieb Alexey Shumkin:
> On Mon, Jul 01, 2013 at 09:00:55AM +0200, Johannes Sixt wrote:
>> Am 6/26/2013 12:19, schrieb Alexey Shumkin:
>>> test_expect_success 'setup complex body' '
>>> git config i18n.commitencoding iso8859-1 &&
>>> echo change2 >foo && git commit -a -F commit-msg &&
>>> head3=$(git rev-parse --verify HEAD) &&
>>> - head3_short=$(git rev-parse --short $head3)
>>> + head3_short=$(git rev-parse --short $head3) &&
>>> + # unset commit encoding config
>>> + # otherwise %e does not print encoding value
>>> + # and following test fails
>>
>> I don't understand this comment. The test vector below already shows that
>> an encoding is printed. Why would this suddenly be different with the
>> updated tests?
> I've changed tests. I've reverted back these ones, and added
> new ones with no i18n.commitEncoding set
>>
>> Assuming that this change doesn't sweep a deeper problem under the rug,
>> it's better to use test_config a few lines earlier.
>>
>>> + git config --unset i18n.commitEncoding
>>> +
>>> '
>>>
>>> test_format complex-encoding %e <<EOF
>>> commit $head3
>>> iso8859-1
>>
>> This is the encoding that I mean.
> These encodings "have appeared" because we've changed 'setup':
> we make commits with i18n.commitEncoding set
I understand why there are additional encoding entries in the expected
output, but we see one encoding entry already listed without this patch.
Why do you say "does not print encoding value" in the comment above?
>>
>>> commit $head2
>>> +iso-8859-1
>>> commit $head1
>>> +iso-8859-1
>>> EOF
-- Hannes
^ permalink raw reply [flat|nested] 104+ messages in thread
* Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
2013-07-02 7:22 ` Johannes Sixt
@ 2013-07-03 20:20 ` Alexey Shumkin
0 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-03 20:20 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Junio C Hamano
On Tue, Jul 02, 2013 at 09:22:09AM +0200, Johannes Sixt wrote:
> Am 7/2/2013 0:50, schrieb Alexey Shumkin:
> > On Mon, Jul 01, 2013 at 09:00:55AM +0200, Johannes Sixt wrote:
> >> Am 6/26/2013 12:19, schrieb Alexey Shumkin:
> >>> test_expect_success 'setup complex body' '
> >>> git config i18n.commitencoding iso8859-1 &&
> >>> echo change2 >foo && git commit -a -F commit-msg &&
> >>> head3=$(git rev-parse --verify HEAD) &&
> >>> - head3_short=$(git rev-parse --short $head3)
> >>> + head3_short=$(git rev-parse --short $head3) &&
> >>> + # unset commit encoding config
> >>> + # otherwise %e does not print encoding value
> >>> + # and following test fails
> >>
> >> I don't understand this comment. The test vector below already shows that
> >> an encoding is printed. Why would this suddenly be different with the
> >> updated tests?
> > I've changed tests. I've reverted back these ones, and added
> > new ones with no i18n.commitEncoding set
> >>
> >> Assuming that this change doesn't sweep a deeper problem under the rug,
> >> it's better to use test_config a few lines earlier.
> >>
> >>> + git config --unset i18n.commitEncoding
> >>> +
> >>> '
> >>>
> >>> test_format complex-encoding %e <<EOF
> >>> commit $head3
> >>> iso8859-1
> >>
> >> This is the encoding that I mean.
> > These encodings "have appeared" because we've changed 'setup':
> > we make commits with i18n.commitEncoding set
>
> I understand why there are additional encoding entries in the expected
> output, but we see one encoding entry already listed without this patch.
> Why do you say "does not print encoding value" in the comment above?
I don't even remember today. I guess (that comment initially was written
loooooong time time ago), that was a "legacy" comment.
Nevermind,
nowadays it's removed ;)
>
> >>
> >>> commit $head2
> >>> +iso-8859-1
> >>> commit $head1
> >>> +iso-8859-1
> >>> EOF
>
> -- Hannes
^ permalink raw reply [flat|nested] 104+ messages in thread
* [PATCH v7 5/5] pretty: --format output should honor logOutputEncoding
2013-06-26 10:19 ` [PATCH v7 " Alexey Shumkin
` (3 preceding siblings ...)
2013-06-26 10:19 ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
@ 2013-06-26 10:19 ` Alexey Shumkin
2013-06-26 16:19 ` [PATCH v7 0/5] Reroll patches against v1.8.3.1 Junio C Hamano
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
To: git; +Cc: Alexey Shumkin, Junio C Hamano
One can set an alias
$ git config [--global] alias.lg "log --graph --pretty=format:'%Cred%h%Creset
-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
--abbrev-commit --date=local"
to see the log as a pretty tree (like *gitk* but in a terminal).
However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
To simplify an example we can say the following two commands are expected
to give the same output to a terminal:
$ git log --oneline --no-color
$ git log --pretty=format:'%h %s'
However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".
The same corruption is true for
$ git diff --submodule=log
and
$ git rev-list --pretty=format:%s HEAD
and
$ git reset --hard
This patch makes pretty --format honor logOutputEncoding when it formats
log message.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
builtin/reset.c | 5 ++++-
builtin/rev-list.c | 1 +
builtin/shortlog.c | 1 +
log-tree.c | 1 +
submodule.c | 1 +
t/t4041-diff-submodule-option.sh | 10 +++++-----
t/t4205-log-pretty-formats.sh | 34 +++++++++++++++++-----------------
t/t6006-rev-list-format.sh | 8 ++++----
t/t7102-reset.sh | 2 +-
9 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..afa6e02 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -93,10 +93,12 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
static void print_new_head_line(struct commit *commit)
{
const char *hex, *body;
+ char *msg;
hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
printf(_("HEAD is now at %s"), hex);
- body = strstr(commit->buffer, "\n\n");
+ msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+ body = strstr(msg, "\n\n");
if (body) {
const char *eol;
size_t len;
@@ -107,6 +109,7 @@ static void print_new_head_line(struct commit *commit)
}
else
printf("\n");
+ logmsg_free(msg, commit);
}
static void update_index_from_diff(struct diff_queue_struct *q,
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 67701be..a5ec30d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
ctx.date_mode = revs->date_mode;
ctx.date_mode_explicit = revs->date_mode_explicit;
ctx.fmt = revs->commit_format;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &buf);
if (revs->graph) {
if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 1fd6f8a..1434f8f 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
ctx.subject = "";
ctx.after_subject = "";
ctx.date_mode = DATE_NORMAL;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &ufbuf);
buffer = ufbuf.buf;
} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index 1946e9c..5277d3e 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -616,6 +616,7 @@ void show_log(struct rev_info *opt)
ctx.fmt = opt->commit_format;
ctx.mailmap = opt->mailmap;
ctx.color = opt->diffopt.use_color;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &msgbuf);
if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index 1821a5b..78734e1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -226,6 +226,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
while ((commit = get_revision(rev))) {
struct pretty_print_context ctx = {0};
ctx.date_mode = rev->date_mode;
+ ctx.output_encoding = get_log_output_encoding();
strbuf_setlen(&sb, 0);
strbuf_addstr(&sb, line_prefix);
if (commit->object.flags & SYMMETRIC_LEFT) {
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 2a7877d..0a4f496 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -94,7 +94,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
commit_file sm1 &&
head2=$(add_file sm1 foo3)
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -103,7 +103,7 @@ test_expect_failure 'modified submodule(forward)' '
test_cmp expected actual
'
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
git diff --submodule=log >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -112,7 +112,7 @@ test_expect_failure 'modified submodule(forward)' '
test_cmp expected actual
'
-test_expect_failure 'modified submodule(forward) --submodule' '
+test_expect_success 'modified submodule(forward) --submodule' '
git diff --submodule >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -143,7 +143,7 @@ head3=$(
git rev-parse --short --verify HEAD
)
-test_expect_failure 'modified submodule(backward)' '
+test_expect_success 'modified submodule(backward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2..$head3 (rewind):
@@ -154,7 +154,7 @@ test_expect_failure 'modified submodule(backward)' '
'
head4=$(add_file sm1 foo4 foo5)
-test_expect_failure 'modified submodule(backward and forward)' '
+test_expect_success 'modified submodule(backward and forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2...$head4:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 6b62da2..2fc9674 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -69,7 +69,7 @@ test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' '
test_cmp expected-s actual-s
'
-test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
git log --oneline >expected-s &&
git log --pretty="tformat:%h %s" >actual-s &&
test_cmp expected-s actual-s
@@ -108,19 +108,19 @@ test_expect_success 'alias loop' '
test_must_fail git log --pretty=test-foo
'
-test_expect_failure 'NUL separation' '
+test_expect_success 'NUL separation' '
printf "add bar\0$(commit_msg)" >expected &&
git log -z --pretty="format:%s" >actual &&
test_cmp expected actual
'
-test_expect_failure 'NUL termination' '
+test_expect_success 'NUL termination' '
printf "add bar\0$(commit_msg)\0" >expected &&
git log -z --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
-test_expect_failure 'NUL separation with --stat' '
+test_expect_success '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 &&
@@ -145,7 +145,7 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_failure 'left alignment formatting' "
+test_expect_success 'left alignment formatting' "
git log --pretty='format:%<(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -158,7 +158,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting at the nth column' "
+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 &&
@@ -171,7 +171,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting with no padding' "
+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 &&
@@ -184,7 +184,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting with trunc' "
+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 &&
@@ -197,7 +197,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting with ltrunc' "
+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 &&
@@ -210,7 +210,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left alignment formatting with mtrunc' "
+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 &&
@@ -223,7 +223,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'right alignment formatting' "
+test_expect_success 'right alignment formatting' "
git log --pretty='format:%>(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -236,7 +236,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'right alignment formatting at the nth column' "
+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 &&
@@ -249,7 +249,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'right alignment formatting with no padding' "
+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 &&
@@ -262,7 +262,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'center alignment formatting' "
+test_expect_success 'center alignment formatting' "
git log --pretty='format:%><(40)%s' >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -275,7 +275,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'center alignment formatting at the nth column' "
+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 &&
@@ -288,7 +288,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'center alignment formatting with no padding' "
+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 &&
@@ -301,7 +301,7 @@ EOF
test_cmp expected actual
"
-test_expect_failure 'left/right alignment formatting with stealing' "
+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
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index c66a07f..380c85b 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -141,7 +141,7 @@ commit $head1
iso-8859-1
EOF
-test_format failure subject %s <<EOF
+test_format subject %s <<EOF
commit $head2
$changed
commit $head1
@@ -153,7 +153,7 @@ commit $head2
commit $head1
EOF
-test_format failure raw-body %B <<EOF
+test_format raw-body %B <<EOF
commit $head2
$changed
@@ -247,7 +247,7 @@ commit $head1
iso-8859-1
EOF
-test_format failure complex-subject %s <<EOF
+test_format complex-subject %s <<EOF
commit $head3
Test printing of complex bodies
commit $head2
@@ -256,7 +256,7 @@ commit $head1
$added
EOF
-test_format failure complex-body %b <<EOF
+test_format complex-body %b <<EOF
commit $head3
This commit message is much longer than the others,
and it will be encoded in iso8859-1. We should therefore
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 72e364e..27b1e93 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -55,7 +55,7 @@ check_changes () {
done | test_cmp .cat_expect -
}
-test_expect_failure 'reset --hard message' '
+test_expect_success 'reset --hard message' '
hex=$(git log -1 --format="%h") &&
git reset --hard > .actual &&
echo HEAD is now at $hex $(commit_msg) > .expected &&
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v7 0/5] Reroll patches against v1.8.3.1
2013-06-26 10:19 ` [PATCH v7 " Alexey Shumkin
` (4 preceding siblings ...)
2013-06-26 10:19 ` [PATCH v7 5/5] pretty: " 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
6 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-26 16:19 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git
Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
> v7 of this patch series includes the following changes against v6:
> 1. [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
> untouched
> 2. [PATCH v7 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
> untouched
> 3. [PATCH v7 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
> untouched
> 4. [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
> cp1251 encoding changed to iso-8859-1 encoding already used in tests
> Test commit messages contain words ("changed" and "added") in German
> (which is covered by iso-8859-1 encoding)
> They are translated from English (verified in Russian) with Google Translate
> 5. [PATCH v7 5/5] pretty: --format output should honor logOutputEncoding
> builtin/reset.c:
> "const char ..., *msg;" declaration replaced with "char *msg;"
> to avoid compiler warning on the line "logmsg_free(msg, commit);"
>
> P.S.
> It's all started here [http://thread.gmane.org/gmane.comp.version-control.git/177634]
Thanks for a quick reroll and reference to previous threads in the
cover letter.
^ permalink raw reply [flat|nested] 104+ messages in thread* [PATCH v8 0/5] Reroll patches against Git v1.8.3.2
2013-06-26 10:19 ` [PATCH v7 " Alexey Shumkin
` (5 preceding siblings ...)
2013-06-26 16:19 ` [PATCH v7 0/5] Reroll patches against v1.8.3.1 Junio C Hamano
@ 2013-07-01 23:18 ` 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
` (6 more replies)
6 siblings, 7 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git
v8 of this patch series includes the following changes against v7:
1. [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
untouched
2. [PATCH v8 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
untouched
3. [PATCH v8 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
untouched
4. [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
Includes suggestions of Johannes Sixt:
iso-8859-1 encoding replaced with its more "ancient" synonym "iso8859-1" already used in tests
t/t6006-rev-list-format.sh:
`test_format` function become simplier and more readable
`complex body` & `complex subject` tests are reverted back (to its "initial" state)
2 tests added to test encoding conversions with i18n.commitEncoding unset
t/t7102-reset.sh:
`commit_msg` function become more readable
5. [PATCH v8 5/5] pretty: --format output should honor logOutputEncoding
untouched
P.S.
It's all started here [http://thread.gmane.org/gmane.comp.version-control.git/177634]
Alexey Shumkin (5):
t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
t7102 (reset): don't hardcode SHA-1 in expected outputs
t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
pretty: Add failing tests: --format output should honor
logOutputEncoding
pretty: --format output should honor logOutputEncoding
builtin/reset.c | 5 +-
builtin/rev-list.c | 1 +
builtin/shortlog.c | 1 +
log-tree.c | 1 +
submodule.c | 1 +
t/t4041-diff-submodule-option.sh | 25 +++--
t/t4205-log-pretty-formats.sh | 126 ++++++++++++++++--------
t/t6006-rev-list-format.sh | 204 +++++++++++++++++++++++++--------------
t/t7102-reset.sh | 39 +++++++-
9 files changed, 270 insertions(+), 133 deletions(-)
--
1.8.3.1.16.gce2c52e
^ permalink raw reply [flat|nested] 104+ messages in thread* [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
@ 2013-07-01 23:19 ` Alexey Shumkin
2013-07-01 23:19 ` [PATCH v8 2/5] t7102 (reset): " Alexey Shumkin
` (5 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 7061 bytes --]
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t6006-rev-list-format.sh | 140 +++++++++++++++++++++++++--------------------
1 file changed, 77 insertions(+), 63 deletions(-)
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 0393c9f..cc1008d 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,8 +7,19 @@ test_description='git rev-list --pretty=format test'
test_tick
test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
- echo changed >foo && git commit -a -m "changed foo"
+ : >foo &&
+ git add foo &&
+ git commit -m "added foo" &&
+ head1=$(git rev-parse --verify HEAD) &&
+ head1_short=$(git rev-parse --verify --short $head1) &&
+ tree1=$(git rev-parse --verify HEAD:) &&
+ tree1_short=$(git rev-parse --verify --short $tree1) &&
+ echo changed >foo &&
+ git commit -a -m "changed foo" &&
+ head2=$(git rev-parse --verify HEAD) &&
+ head2_short=$(git rev-parse --verify --short $head2) &&
+ tree2=$(git rev-parse --verify HEAD:) &&
+ tree2_short=$(git rev-parse --verify --short $tree2)
'
# usage: test_format name format_string <expected_output
@@ -32,49 +43,49 @@ has_no_color () {
test_cmp expect "$1"
}
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
%h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
%h
EOF
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_short
+commit $head1
+$head1
+$head1_short
EOF
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-4d5fcadc293a348e88f777dc0920f11e7d71441c
-4d5fcad
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_short
+commit $head1
+$tree1
+$tree1_short
EOF
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head1_short
+commit $head1
EOF
# we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
A U Thor
author@example.com
Thu Apr 7 15:13:13 2005 -0700
Thu, 7 Apr 2005 15:13:13 -0700
1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
A U Thor
author@example.com
Thu Apr 7 15:13:13 2005 -0700
@@ -82,14 +93,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
1112911993
EOF
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
C O Mitter
committer@example.com
Thu Apr 7 15:13:13 2005 -0700
Thu, 7 Apr 2005 15:13:13 -0700
1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
C O Mitter
committer@example.com
Thu Apr 7 15:13:13 2005 -0700
@@ -97,43 +108,43 @@ Thu, 7 Apr 2005 15:13:13 -0700
1112911993
EOF
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
EOF
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
EOF
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format raw-body %B <<EOF
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
EOF
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
^[[1;31;43mfoo^[[m
EOF
@@ -186,39 +197,42 @@ 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!
EOF
+
test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
- echo change2 >foo && git commit -a -F commit-msg
+ git config i18n.commitencoding iso8859-1 &&
+ echo change2 >foo && git commit -a -F commit-msg &&
+ head3=$(git rev-parse --verify HEAD) &&
+ head3_short=$(git rev-parse --short $head3)
'
-test_format complex-encoding %e <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-encoding %e <<EOF
+commit $head3
iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
EOF
-test_format complex-subject %s <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-subject %s <<EOF
+commit $head3
Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
added foo
EOF
-test_format complex-body %b <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-body %b <<EOF
+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!
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
EOF
test_expect_success '%x00 shows NUL' '
- echo >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+ echo >expect commit $head3 &&
echo >>expect fooQbar &&
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
nul_to_q <actual.nul >actual &&
--
1.8.3.1.16.gce2c52e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v8 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 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 ` Alexey Shumkin
2013-07-01 23:19 ` [PATCH v8 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
` (4 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t7102-reset.sh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index df82ec9..05dfb27 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -192,7 +192,8 @@ test_expect_success \
'changing files and redo the last commit should succeed' '
echo "3rd line 2nd file" >>secondfile &&
git commit -a -C ORIG_HEAD &&
- check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+ head4=$(git rev-parse --verify HEAD) &&
+ check_changes $head4 &&
test "$(git rev-parse ORIG_HEAD)" = \
$head5
'
@@ -211,7 +212,7 @@ test_expect_success \
git reset --hard HEAD~2 &&
check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
test "$(git rev-parse ORIG_HEAD)" = \
- 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+ $head4
'
>.diff_expect
@@ -326,10 +327,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
git checkout branch2 &&
echo "3rd line in branch2" >>secondfile &&
git commit -a -m "change in branch2" &&
+ head3=$(git rev-parse --verify HEAD) &&
test_must_fail git pull . branch1 &&
git reset --hard &&
- check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+ check_changes $head3
'
>.diff_expect
--
1.8.3.1.16.gce2c52e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v8 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 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 ` Alexey Shumkin
2013-07-01 23:19 ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
` (3 subsequent siblings)
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 26fbfde..73ba5e8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' '
test_expect_success 'setup more commits' '
test_commit "message one" one one message-one &&
- test_commit "message two" two two message-two
+ test_commit "message two" two two message-two &&
+ head1=$(git rev-parse --verify --short HEAD~0) &&
+ head2=$(git rev-parse --verify --short HEAD~1) &&
+ head3=$(git rev-parse --verify --short HEAD~2) &&
+ head4=$(git rev-parse --verify --short HEAD~3)
'
test_expect_success 'left alignment formatting' '
@@ -117,18 +121,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'left alignment formatting at the nth column' '
- git log --pretty="format:%h %<|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two Z
-7cd6c63 message one Z
-1711bf9 add bar Z
-af20c06 initial Z
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 initial Z
EOF
test_cmp expected actual
-'
+"
test_expect_success 'left alignment formatting with no padding' '
git log --pretty="format:%<(1)%s" >actual &&
@@ -195,18 +199,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'right alignment formatting at the nth column' '
- git log --pretty="format:%h %>|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two
-7cd6c63 message one
-1711bf9 add bar
-af20c06 initial
+$head1 message two
+$head2 message one
+$head3 add bar
+$head4 initial
EOF
test_cmp expected actual
-'
+"
test_expect_success 'right alignment formatting with no padding' '
git log --pretty="format:%>(1)%s" >actual &&
@@ -234,18 +238,18 @@ EOF
test_cmp expected actual
'
-test_expect_success 'center alignment formatting at the nth column' '
- git log --pretty="format:%h %><|(40)%s" >actual &&
+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 &&
qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two Z
-7cd6c63 message one Z
-1711bf9 add bar Z
-af20c06 initial Z
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 initial Z
EOF
test_cmp expected actual
-'
+"
test_expect_success 'center alignment formatting with no padding' '
git log --pretty="format:%><(1)%s" >actual &&
--
1.8.3.1.16.gce2c52e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
` (2 preceding siblings ...)
2013-07-01 23:19 ` [PATCH v8 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
@ 2013-07-01 23:19 ` Alexey Shumkin
2013-07-02 6:46 ` Johannes Sixt
2013-07-01 23:19 ` [PATCH v8 5/5] pretty: " Alexey Shumkin
` (2 subsequent siblings)
6 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 21895 bytes --]
One can set an alias
$ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
--abbrev-commit --date=local"
to see the log as a pretty tree (like *gitk* but in a terminal).
However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
To simplify an example we can say the following two commands are expected
to give the same output to a terminal:
$ git log --oneline --no-color
$ git log --pretty=format:'%h %s'
However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".
The same corruption is true for
$ git diff --submodule=log
and
$ git rev-list --pretty=format:%s HEAD
and
$ git reset --hard
This patch adds failing tests for the next patch that fixes them.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
t/t4041-diff-submodule-option.sh | 35 ++++++----
t/t4205-log-pretty-formats.sh | 146 ++++++++++++++++++++++++---------------
t/t6006-rev-list-format.sh | 74 +++++++++++++++-----
t/t7102-reset.sh | 31 ++++++++-
4 files changed, 198 insertions(+), 88 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..d300d0c 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2013 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#
test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
. ./test-lib.sh
+# 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")
add_file () {
(
cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
- git commit -m "Add $name" || exit
+ 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"
done >/dev/null &&
git rev-parse --short --verify HEAD
)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
commit_file sm1 &&
head2=$(add_file sm1 foo3)
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
git diff --submodule=log >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
git diff --submodule >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
- > Add foo3
+ > Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
@@ -138,25 +143,25 @@ head3=$(
git rev-parse --short --verify HEAD
)
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2..$head3 (rewind):
- < Add foo3
- < Add foo2
+ < Add foo3 ($added foo3)
+ < Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2...$head4:
- > Add foo5
- > Add foo4
- < Add foo3
- < Add foo2
+ > Add foo5 ($added foo5)
+ > Add foo4 ($added foo4)
+ < Add foo3 ($added foo3)
+ < Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 73ba5e8..a23da67 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,44 @@
#!/bin/sh
#
# Copyright (c) 2010, Will Palmer
+# Copyright (c) 2013, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#
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
+}
+
test_expect_success 'set up basic repos' '
>foo &&
>bar &&
git add foo &&
test_tick &&
- git commit -m initial &&
+ git config i18n.commitEncoding iso8859-1 &&
+ git commit -m "$(commit_msg iso8859-1)" &&
git add bar &&
test_tick &&
- git commit -m "add bar"
+ git commit -m "add bar" &&
+ git config --unset i18n.commitEncoding
'
test_expect_success 'alias builtin format' '
@@ -38,6 +62,20 @@ 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 &&
+ git log --oneline >expected-s &&
+ git log --pretty="tformat:%h %s" >actual-s &&
+ git config --unset i18n.logOutputEncoding &&
+ test_cmp expected-s actual-s
+'
+
+test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+ git log --oneline >expected-s &&
+ git log --pretty="tformat:%h %s" >actual-s &&
+ test_cmp expected-s actual-s
+'
+
test_expect_success 'alias user-defined tformat' '
git log --pretty="tformat:%h" >expected &&
git config pretty.test-alias "tformat:%h" &&
@@ -71,22 +109,22 @@ test_expect_success 'alias loop' '
test_must_fail git log --pretty=test-foo
'
-test_expect_success 'NUL separation' '
- printf "add bar\0initial" >expected &&
+test_expect_failure 'NUL separation' '
+ printf "add bar\0$(commit_msg)" >expected &&
git log -z --pretty="format:%s" >actual &&
test_cmp expected actual
'
-test_expect_success 'NUL termination' '
- printf "add bar\0initial\0" >expected &&
+test_expect_failure 'NUL termination' '
+ printf "add bar\0$(commit_msg)\0" >expected &&
git log -z --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
-test_expect_success 'NUL separation with --stat' '
+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\0initial\n$stat1_part\n" >expected &&
+ printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
git log -z --stat --pretty="format:%s" >actual &&
test_i18ncmp expected actual
'
@@ -94,7 +132,7 @@ test_expect_success '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\0initial\n$stat1_part\n\0" >expected &&
+ printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
git log -z --stat --pretty="tformat:%s" >actual &&
test_i18ncmp expected actual
'
@@ -108,172 +146,172 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_success 'left alignment formatting' '
+test_expect_failure 'left alignment formatting' '
git log --pretty="format:%<(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
message two Z
message one Z
add bar Z
-initial Z
+$(commit_msg) Z
EOF
test_cmp expected actual
'
-test_expect_success 'left alignment formatting at the nth column' "
- git log --pretty='format:%h %<|(40)%s' >actual &&
+test_expect_failure 'left alignment formatting at the nth column' '
+ git log --pretty="format:%h %<|(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
$head1 message two Z
$head2 message one Z
$head3 add bar Z
-$head4 initial Z
+$head4 $(commit_msg) Z
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'left alignment formatting with no padding' '
+test_expect_failure 'left alignment formatting with no padding' '
git log --pretty="format:%<(1)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- cat <<\EOF >expected &&
+ cat <<EOF >expected &&
message two
message one
add bar
-initial
+$(commit_msg)
EOF
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with trunc' '
+test_expect_failure 'left alignment formatting with trunc' '
git log --pretty="format:%<(10,trunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
message ..
message ..
add bar Z
-initial Z
+$(commit_msg "" "8" ".\+$")
EOF
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with ltrunc' '
+test_expect_failure 'left alignment formatting with ltrunc' '
git log --pretty="format:%<(10,ltrunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
..sage two
..sage one
add bar Z
-initial Z
+$(commit_msg "" "0" ".\{11\}")
EOF
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with mtrunc' '
+test_expect_failure 'left alignment formatting with mtrunc' '
git log --pretty="format:%<(10,mtrunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
mess.. two
mess.. one
add bar Z
-initial Z
+$(commit_msg "" "4" ".\{11\}")
EOF
test_cmp expected actual
'
-test_expect_success 'right alignment formatting' '
+test_expect_failure 'right alignment formatting' '
git log --pretty="format:%>(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
Z message two
Z message one
Z add bar
-Z initial
+Z $(commit_msg)
EOF
test_cmp expected actual
'
-test_expect_success 'right alignment formatting at the nth column' "
- git log --pretty='format:%h %>|(40)%s' >actual &&
+test_expect_failure 'right alignment formatting at the nth column' '
+ git log --pretty="format:%h %>|(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
$head1 message two
$head2 message one
$head3 add bar
-$head4 initial
+$head4 $(commit_msg)
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'right alignment formatting with no padding' '
+test_expect_failure 'right alignment formatting with no padding' '
git log --pretty="format:%>(1)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- cat <<\EOF >expected &&
+ cat <<EOF >expected &&
message two
message one
add bar
-initial
+$(commit_msg)
EOF
test_cmp expected actual
'
-test_expect_success 'center alignment formatting' '
+test_expect_failure 'center alignment formatting' '
git log --pretty="format:%><(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
Z message two Z
Z message one Z
Z add bar Z
-Z initial Z
+Z $(commit_msg) Z
EOF
test_cmp expected actual
'
-test_expect_success 'center alignment formatting at the nth column' "
- git log --pretty='format:%h %><|(40)%s' >actual &&
+test_expect_failure 'center alignment formatting at the nth column' '
+ git log --pretty="format:%h %><|(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
$head1 message two Z
$head2 message one Z
$head3 add bar Z
-$head4 initial Z
+$head4 $(commit_msg) Z
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'center alignment formatting with no padding' '
+test_expect_failure 'center alignment formatting with no padding' '
git log --pretty="format:%><(1)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- cat <<\EOF >expected &&
+ cat <<EOF >expected &&
message two
message one
add bar
-initial
+$(commit_msg)
EOF
test_cmp expected actual
'
-test_expect_success 'left/right alignment formatting with stealing' '
+test_expect_failure '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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >expected &&
short long long long
message .. A U Thor
add bar A U Thor
-initial A U Thor
+$(commit_msg "" "8" ".\+$") A U Thor
EOF
test_cmp expected actual
'
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index cc1008d..e4b50ed 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,31 +1,44 @@
#!/bin/sh
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2013 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
test_description='git rev-list --pretty=format test'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh
test_tick
+# 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)
+# same but "changed"
+changed=$(printf "changed (ge\303\244ndert) foo")
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
+
test_expect_success 'setup' '
: >foo &&
git add foo &&
- git commit -m "added foo" &&
+ git config i18n.commitEncoding iso8859-1 &&
+ git commit -m "$added_iso88591" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
tree1=$(git rev-parse --verify HEAD:) &&
tree1_short=$(git rev-parse --verify --short $tree1) &&
- echo changed >foo &&
- git commit -a -m "changed foo" &&
+ echo "$changed" > foo &&
+ git commit -a -m "$changed_iso88591" &&
head2=$(git rev-parse --verify HEAD) &&
head2_short=$(git rev-parse --verify --short $head2) &&
tree2=$(git rev-parse --verify HEAD:) &&
tree2_short=$(git rev-parse --verify --short $tree2)
+ git config --unset i18n.commitEncoding
'
-# usage: test_format name format_string <expected_output
+# usage: test_format name format_string [failure] <expected_output
test_format () {
cat >expect.$1
- test_expect_success "format $1" "
+ test_expect_${3:-success} "format $1" "
git rev-list --pretty=format:'$2' master >output.$1 &&
test_cmp expect.$1 output.$1
"
@@ -110,14 +123,16 @@ EOF
test_format encoding %e <<EOF
commit $head2
+iso8859-1
commit $head1
+iso8859-1
EOF
-test_format subject %s <<EOF
+test_format subject %s failure <<EOF
commit $head2
-changed foo
+$changed
commit $head1
-added foo
+$added
EOF
test_format body %b <<EOF
@@ -125,12 +140,12 @@ commit $head2
commit $head1
EOF
-test_format raw-body %B <<EOF
+test_format raw-body %B failure <<EOF
commit $head2
-changed foo
+$changed
commit $head1
-added foo
+$added
EOF
@@ -190,12 +205,12 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
)
'
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t iso8859-1 > 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!
+include an iso8859 character: ¡bueno!
EOF
test_expect_success 'setup complex body' '
@@ -209,16 +224,18 @@ test_format complex-encoding %e <<EOF
commit $head3
iso8859-1
commit $head2
+iso8859-1
commit $head1
+iso8859-1
EOF
test_format complex-subject %s <<EOF
commit $head3
Test printing of complex bodies
commit $head2
-changed foo
+$changed_iso88591
commit $head1
-added foo
+$added_iso88591
EOF
test_format complex-body %b <<EOF
@@ -231,6 +248,29 @@ commit $head2
commit $head1
EOF
+# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
+# so unset i18n.commitEncoding to test encoding conversion
+git config --unset i18n.commitEncoding
+
+test_format complex-subject-commitencoding-unset %s failure <<EOF
+commit $head3
+Test printing of complex bodies
+commit $head2
+$changed
+commit $head1
+$added
+EOF
+
+test_format complex-body-commitencoding-unset %b failure <<EOF
+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!
+
+commit $head2
+commit $head1
+EOF
+
test_expect_success '%x00 shows NUL' '
echo >expect commit $head3 &&
echo >>expect fooQbar &&
@@ -279,12 +319,12 @@ test_expect_success 'add LF before non-empty (2)' '
test_expect_success 'add SP before non-empty (1)' '
git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
- test $(wc -w <actual) = 2
+ test $(wc -w <actual) = 3
'
test_expect_success 'add SP before non-empty (2)' '
git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
- test $(wc -w <actual) = 4
+ test $(wc -w <actual) = 6
'
test_expect_success '--abbrev' '
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 05dfb27..6a92703 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,19 @@ Documented tests for git reset'
. ./test-lib.sh
+commit_msg() {
+ # String "modify 2nd file (changed)" partly in German
+ # (translated with Google Translate),
+ # encoded in UTF-8, used as a commit log message below.
+ printf "modify 2nd file (ge\303\244ndert)" |
+ if test -n "$1"
+ then
+ iconv -f utf-8 -t $1
+ else
+ cat
+ fi
+}
+
test_expect_success 'creating initial files and commits' '
test_tick &&
echo "1st file" >first &&
@@ -28,7 +41,7 @@ test_expect_success 'creating initial files and commits' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git commit -a -m "modify 2nd file" &&
+ git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +57,20 @@ check_changes () {
done | test_cmp .cat_expect -
}
+test_expect_failure 'reset --hard message' '
+ hex=$(git log -1 --format="%h") &&
+ git reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg) > .expected &&
+ test_cmp .expected .actual
+'
+
+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 &&
+ test_cmp .expected .actual
+'
+
>.diff_expect
>.cached_expect
cat >.cat_expect <<EOF
@@ -304,7 +331,7 @@ test_expect_success 'redoing the last two commits should succeed' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
- git commit -a -m "modify 2nd file" &&
+ git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
check_changes $head5
'
--
1.8.3.1.16.gce2c52e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
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
0 siblings, 0 replies; 104+ messages in thread
From: Johannes Sixt @ 2013-07-02 6:46 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: Junio C Hamano, git
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
'
^ permalink raw reply related [flat|nested] 104+ messages in thread
* [PATCH v8 5/5] pretty: --format output should honor logOutputEncoding
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
` (3 preceding siblings ...)
2013-07-01 23:19 ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
@ 2013-07-01 23:19 ` Alexey Shumkin
2013-07-02 19:41 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Junio C Hamano
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git
One can set an alias
$ git config [--global] alias.lg "log --graph --pretty=format:'%Cred%h%Creset
-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
--abbrev-commit --date=local"
to see the log as a pretty tree (like *gitk* but in a terminal).
However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
To simplify an example we can say the following two commands are expected
to give the same output to a terminal:
$ git log --oneline --no-color
$ git log --pretty=format:'%h %s'
However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".
The same corruption is true for
$ git diff --submodule=log
and
$ git rev-list --pretty=format:%s HEAD
and
$ git reset --hard
This patch makes pretty --format honor logOutputEncoding when it formats
log message.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
builtin/reset.c | 5 ++++-
builtin/rev-list.c | 1 +
builtin/shortlog.c | 1 +
log-tree.c | 1 +
submodule.c | 1 +
t/t4041-diff-submodule-option.sh | 10 +++++-----
t/t4205-log-pretty-formats.sh | 34 +++++++++++++++++-----------------
t/t6006-rev-list-format.sh | 8 ++++----
t/t7102-reset.sh | 2 +-
9 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..afa6e02 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -93,10 +93,12 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
static void print_new_head_line(struct commit *commit)
{
const char *hex, *body;
+ char *msg;
hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
printf(_("HEAD is now at %s"), hex);
- body = strstr(commit->buffer, "\n\n");
+ msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+ body = strstr(msg, "\n\n");
if (body) {
const char *eol;
size_t len;
@@ -107,6 +109,7 @@ static void print_new_head_line(struct commit *commit)
}
else
printf("\n");
+ logmsg_free(msg, commit);
}
static void update_index_from_diff(struct diff_queue_struct *q,
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 67701be..a5ec30d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
ctx.date_mode = revs->date_mode;
ctx.date_mode_explicit = revs->date_mode_explicit;
ctx.fmt = revs->commit_format;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &buf);
if (revs->graph) {
if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 1fd6f8a..1434f8f 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
ctx.subject = "";
ctx.after_subject = "";
ctx.date_mode = DATE_NORMAL;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &ufbuf);
buffer = ufbuf.buf;
} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index 1946e9c..5277d3e 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -616,6 +616,7 @@ void show_log(struct rev_info *opt)
ctx.fmt = opt->commit_format;
ctx.mailmap = opt->mailmap;
ctx.color = opt->diffopt.use_color;
+ ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &msgbuf);
if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index 1821a5b..78734e1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -226,6 +226,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
while ((commit = get_revision(rev))) {
struct pretty_print_context ctx = {0};
ctx.date_mode = rev->date_mode;
+ ctx.output_encoding = get_log_output_encoding();
strbuf_setlen(&sb, 0);
strbuf_addstr(&sb, line_prefix);
if (commit->object.flags & SYMMETRIC_LEFT) {
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index d300d0c..04348ea 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -94,7 +94,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
commit_file sm1 &&
head2=$(add_file sm1 foo3)
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -103,7 +103,7 @@ test_expect_failure 'modified submodule(forward)' '
test_cmp expected actual
'
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
git diff --submodule=log >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -112,7 +112,7 @@ test_expect_failure 'modified submodule(forward)' '
test_cmp expected actual
'
-test_expect_failure 'modified submodule(forward) --submodule' '
+test_expect_success 'modified submodule(forward) --submodule' '
git diff --submodule >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
@@ -143,7 +143,7 @@ head3=$(
git rev-parse --short --verify HEAD
)
-test_expect_failure 'modified submodule(backward)' '
+test_expect_success 'modified submodule(backward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2..$head3 (rewind):
@@ -154,7 +154,7 @@ test_expect_failure 'modified submodule(backward)' '
'
head4=$(add_file sm1 foo4 foo5)
-test_expect_failure 'modified submodule(backward and forward)' '
+test_expect_success 'modified submodule(backward and forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2...$head4:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index a23da67..5e13000 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -70,7 +70,7 @@ test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
test_cmp expected-s actual-s
'
-test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
git log --oneline >expected-s &&
git log --pretty="tformat:%h %s" >actual-s &&
test_cmp expected-s actual-s
@@ -109,19 +109,19 @@ test_expect_success 'alias loop' '
test_must_fail git log --pretty=test-foo
'
-test_expect_failure 'NUL separation' '
+test_expect_success 'NUL separation' '
printf "add bar\0$(commit_msg)" >expected &&
git log -z --pretty="format:%s" >actual &&
test_cmp expected actual
'
-test_expect_failure 'NUL termination' '
+test_expect_success 'NUL termination' '
printf "add bar\0$(commit_msg)\0" >expected &&
git log -z --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
-test_expect_failure 'NUL separation with --stat' '
+test_expect_success '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 &&
@@ -146,7 +146,7 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_failure 'left alignment formatting' '
+test_expect_success 'left alignment formatting' '
git log --pretty="format:%<(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -159,7 +159,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting at the nth column' '
+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 &&
@@ -172,7 +172,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with no padding' '
+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 &&
@@ -185,7 +185,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with trunc' '
+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 &&
@@ -198,7 +198,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with ltrunc' '
+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 &&
@@ -211,7 +211,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left alignment formatting with mtrunc' '
+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 &&
@@ -224,7 +224,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'right alignment formatting' '
+test_expect_success 'right alignment formatting' '
git log --pretty="format:%>(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -237,7 +237,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'right alignment formatting at the nth column' '
+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 &&
@@ -250,7 +250,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'right alignment formatting with no padding' '
+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 &&
@@ -263,7 +263,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'center alignment formatting' '
+test_expect_success 'center alignment formatting' '
git log --pretty="format:%><(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -276,7 +276,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'center alignment formatting at the nth column' '
+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 &&
@@ -289,7 +289,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'center alignment formatting with no padding' '
+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 &&
@@ -302,7 +302,7 @@ EOF
test_cmp expected actual
'
-test_expect_failure 'left/right alignment formatting with stealing' '
+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
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index e4b50ed..18d7909 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -128,7 +128,7 @@ commit $head1
iso8859-1
EOF
-test_format subject %s failure <<EOF
+test_format subject %s <<EOF
commit $head2
$changed
commit $head1
@@ -140,7 +140,7 @@ commit $head2
commit $head1
EOF
-test_format raw-body %B failure <<EOF
+test_format raw-body %B <<EOF
commit $head2
$changed
@@ -252,7 +252,7 @@ EOF
# so unset i18n.commitEncoding to test encoding conversion
git config --unset i18n.commitEncoding
-test_format complex-subject-commitencoding-unset %s failure <<EOF
+test_format complex-subject-commitencoding-unset %s <<EOF
commit $head3
Test printing of complex bodies
commit $head2
@@ -261,7 +261,7 @@ commit $head1
$added
EOF
-test_format complex-body-commitencoding-unset %b failure <<EOF
+test_format complex-body-commitencoding-unset %b <<EOF
commit $head3
This commit message is much longer than the others,
and it will be encoded in iso8859-1. We should therefore
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 6a92703..73a1bdb 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -57,7 +57,7 @@ check_changes () {
done | test_cmp .cat_expect -
}
-test_expect_failure 'reset --hard message' '
+test_expect_success 'reset --hard message' '
hex=$(git log -1 --format="%h") &&
git reset --hard > .actual &&
echo HEAD is now at $hex $(commit_msg) > .expected &&
--
1.8.3.1.16.gce2c52e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v8 0/5] Reroll patches against Git v1.8.3.2
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
` (4 preceding siblings ...)
2013-07-01 23:19 ` [PATCH v8 5/5] pretty: " Alexey Shumkin
@ 2013-07-02 19:41 ` Junio C Hamano
2013-07-03 20:03 ` Alexey Shumkin
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
6 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-02 19:41 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: Johannes Sixt, git
Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
> v8 of this patch series includes the following changes against v7:
Oops, isn't this already in 'next'? In that case, please feed
incremental updates on top of the patches that are already queued as
improvements and fixes.
Thanks.
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v8 0/5] Reroll patches against Git v1.8.3.2
2013-07-02 19:41 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Junio C Hamano
@ 2013-07-03 20:03 ` Alexey Shumkin
2013-07-03 20:06 ` Junio C Hamano
0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-03 20:03 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, git
On Tue, Jul 02, 2013 at 12:41:03PM -0700, Junio C Hamano wrote:
> Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
>
> > v8 of this patch series includes the following changes against v7:
>
> Oops, isn't this already in 'next'? In that case, please feed
> incremental updates on top of the patches that are already queued as
> improvements and fixes.
Oops ;)
I'll send patches against 'next' then.
>
> Thanks.
^ permalink raw reply [flat|nested] 104+ messages in thread
* Re: [PATCH v8 0/5] Reroll patches against Git v1.8.3.2
2013-07-03 20:03 ` Alexey Shumkin
@ 2013-07-03 20:06 ` Junio C Hamano
0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-03 20:06 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: Johannes Sixt, git
Alexey Shumkin <alex.crezoff@gmail.com> writes:
> On Tue, Jul 02, 2013 at 12:41:03PM -0700, Junio C Hamano wrote:
>> Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
>>
>> > v8 of this patch series includes the following changes against v7:
>>
>> Oops, isn't this already in 'next'? In that case, please feed
>> incremental updates on top of the patches that are already queued as
>> improvements and fixes.
> Oops ;)
> I'll send patches against 'next' then.
Thanks; please build on top of 7c375214 (t4205: replace .\+ with ..*
in sed commands, 2013-07-01).
^ permalink raw reply [flat|nested] 104+ messages in thread
* [PATCH v9 0/5] Incremental updates against 'next' branch
2013-07-01 23:18 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
` (5 preceding siblings ...)
2013-07-02 19:41 ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Junio C Hamano
@ 2013-07-04 12:45 ` 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
` (5 more replies)
6 siblings, 6 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
This patch series is an incremental updates on top of (7c375214 t4205:
replace .\+ with ..* in sed commands, 2013-07-01) as far as v7 patches
were applied to the 'next' branch but there were more improvements made
in v8.
Alexey Shumkin (5):
t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
t4205: revert back single quotes
t4205, t6006, t7102: make functions more readable
t6006: add two more tests for the case i18n.commitEncoding is not set
t4205: avoid using `sed`
t/t4041-diff-submodule-option.sh | 4 +-
t/t4205-log-pretty-formats.sh | 145 +++++++++++++++++++--------------------
t/t6006-rev-list-format.sh | 69 ++++++++++---------
t/t7102-reset.sh | 22 +++---
4 files changed, 121 insertions(+), 119 deletions(-)
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply [flat|nested] 104+ messages in thread* [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
@ 2013-07-04 12:45 ` Alexey Shumkin
2013-07-05 6:47 ` Junio C Hamano
2013-07-04 12:45 ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
` (4 subsequent siblings)
5 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
This is actually a fixup of de6029a2d7734a93a9e27b9c4471862a47dd8123,
which was applied before final patch series was sent.
Also, see 3994e8a98dc7bbf67e61d23c8125f44383499a1f for the explanation
of such a replacement.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
---
t/t4041-diff-submodule-option.sh | 4 ++--
t/t4205-log-pretty-formats.sh | 8 ++++----
t/t6006-rev-list-format.sh | 14 +++++++-------
t/t7102-reset.sh | 10 +++++-----
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 0a4f496..1751c83 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -23,8 +23,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
- msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso-8859-1) &&
- git -c 'i18n.commitEncoding=iso-8859-1' commit -m "$msg_added_iso88591"
+ 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"
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 3cfb744..c283842 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -32,8 +32,8 @@ test_expect_success 'set up basic repos' '
>bar &&
git add foo &&
test_tick &&
- git config i18n.commitEncoding iso-8859-1 &&
- git commit -m "$(commit_msg iso-8859-1)" &&
+ git config i18n.commitEncoding iso8859-1 &&
+ git commit -m "$(commit_msg iso8859-1)" &&
git add bar &&
test_tick &&
git commit -m "add bar" &&
@@ -61,8 +61,8 @@ test_expect_success 'alias user-defined format' '
test_cmp expected actual
'
-test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' '
- git config i18n.logOutputEncoding iso-8859-1 &&
+test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
+ git config i18n.logOutputEncoding iso8859-1 &&
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 380c85b..4751d22 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -12,15 +12,15 @@ test_tick
# 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 iso-8859-1)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
# same but "changed"
changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso-8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
test_expect_success 'setup' '
: >foo &&
git add foo &&
- git config i18n.commitEncoding iso-8859-1 &&
+ git config i18n.commitEncoding iso8859-1 &&
git commit -m "$added_iso88591" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -136,9 +136,9 @@ EOF
test_format encoding %e <<EOF
commit $head2
-iso-8859-1
+iso8859-1
commit $head1
-iso-8859-1
+iso8859-1
EOF
test_format subject %s <<EOF
@@ -242,9 +242,9 @@ test_format complex-encoding %e <<EOF
commit $head3
iso8859-1
commit $head2
-iso-8859-1
+iso8859-1
commit $head1
-iso-8859-1
+iso8859-1
EOF
test_format complex-subject %s <<EOF
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 9132dd9..2ef96e9 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -39,7 +39,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=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
+ git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
@@ -62,10 +62,10 @@ test_expect_success 'reset --hard message' '
test_cmp .expected .actual
'
-test_expect_success 'reset --hard message (iso-8859-1 logoutencoding)' '
+test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
hex=$(git log -1 --format="%h") &&
- git -c "i18n.logOutputEncoding=iso-8859-1" reset --hard > .actual &&
- echo HEAD is now at $hex $(commit_msg iso-8859-1) > .expected &&
+ git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
test_cmp .expected .actual
'
@@ -329,7 +329,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=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
+ git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
check_changes $head5
'
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
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
0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 6:47 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
> This is actually a fixup of de6029a2d7734a93a9e27b9c4471862a47dd8123,
> which was applied before final patch series was sent.
>
> Also, see 3994e8a98dc7bbf67e61d23c8125f44383499a1f for the explanation
> of such a replacement.
These are not very useful in a log message. People who read the
history 6 months down the road would want to see why we want to use
iso8859-1 not iso-8859-1 explained.
Both "iso8859-1" and "iso-8859-1" are understood as latin-1
by modern platforms, but the latter is not understood by
older platforms;update tests to use the former.
This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
than ISO-8859-1, 2009-12-03), which did the same.
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
I do not recall this exact patch reviewed by J6t, but perhaps I
missed a message on the list?
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
2013-07-05 6:47 ` Junio C Hamano
@ 2013-07-05 8:00 ` Alexey Shumkin
2013-07-05 8:11 ` Junio C Hamano
0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 8:00 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt
On Thu, Jul 04, 2013 at 11:47:04PM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
>
> > This is actually a fixup of de6029a2d7734a93a9e27b9c4471862a47dd8123,
> > which was applied before final patch series was sent.
> >
> > Also, see 3994e8a98dc7bbf67e61d23c8125f44383499a1f for the explanation
> > of such a replacement.
>
> These are not very useful in a log message. People who read the
> history 6 months down the road would want to see why we want to use
> iso8859-1 not iso-8859-1 explained.
>
> Both "iso8859-1" and "iso-8859-1" are understood as latin-1
> by modern platforms, but the latter is not understood by
> older platforms;update tests to use the former.
>
> This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
> than ISO-8859-1, 2009-12-03), which did the same.
Yep, it whould be better, I thought to do like this but I didn't )
>
> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> > Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
>
> I do not recall this exact patch reviewed by J6t, but perhaps I
> missed a message on the list?
I've reread 'SubmittingPatches' doc, and I can say I used "Reviewed-by"
incorrectly. Sorry for this. It must be "Suggested-by" there, I guess.
--
Alexey Shumkin
^ permalink raw reply [flat|nested] 104+ messages in thread
* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
2013-07-05 8:00 ` Alexey Shumkin
@ 2013-07-05 8:11 ` Junio C Hamano
2013-07-05 8:42 ` Alexey Shumkin
0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 8:11 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
>> Both "iso8859-1" and "iso-8859-1" are understood as latin-1
>> by modern platforms, but the latter is not understood by
>> older platforms;update tests to use the former.
>>
>> This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
>> than ISO-8859-1, 2009-12-03), which did the same.
> Yep, it whould be better, I thought to do like this but I didn't )
>>
>> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
>> > Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
>>
>> I do not recall this exact patch reviewed by J6t, but perhaps I
>> missed a message on the list?
> I've reread 'SubmittingPatches' doc, and I can say I used "Reviewed-by"
> incorrectly. Sorry for this. It must be "Suggested-by" there, I guess.
OK, then I'll queue this patch (but not 2-4/5 yet) with log message
amended.
Thanks.
^ permalink raw reply [flat|nested] 104+ messages in thread
* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
2013-07-05 8:11 ` Junio C Hamano
@ 2013-07-05 8:42 ` Alexey Shumkin
2013-07-05 8:56 ` Junio C Hamano
0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 8:42 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt
On Fri, Jul 05, 2013 at 01:11:49AM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
>
> >> Both "iso8859-1" and "iso-8859-1" are understood as latin-1
> >> by modern platforms, but the latter is not understood by
> >> older platforms;update tests to use the former.
> >>
> >> This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
> >> than ISO-8859-1, 2009-12-03), which did the same.
> > Yep, it whould be better, I thought to do like this but I didn't )
> >>
> >> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> >> > Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
> >>
> >> I do not recall this exact patch reviewed by J6t, but perhaps I
> >> missed a message on the list?
> > I've reread 'SubmittingPatches' doc, and I can say I used "Reviewed-by"
> > incorrectly. Sorry for this. It must be "Suggested-by" there, I guess.
>
> OK, then I'll queue this patch (but not 2-4/5 yet) with log message
> amended.
Excuse me, you've said "Ok" for 2/5 message, and then explained (as I
understood) then "subtle difference" between EOF and \EOF.
Should I change the message somehow?
>
> Thanks.
--
Alexey Shumkin
^ permalink raw reply [flat|nested] 104+ messages in thread
* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
2013-07-05 8:42 ` Alexey Shumkin
@ 2013-07-05 8:56 ` Junio C Hamano
0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 8:56 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
>> OK, then I'll queue this patch (but not 2-4/5 yet) with log message
>> amended.
> Excuse me, you've said "Ok" for 2/5 message, and then explained (as I
> understood) then "subtle difference" between EOF and \EOF.
> Should I change the message somehow?
I left it up to you. If I queued without waiting, it wouldn't have
been up-to-you, so...
^ permalink raw reply [flat|nested] 104+ messages in thread
* [PATCH v9 2/5] t4205: revert back single quotes
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch 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-04 12:45 ` 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
` (3 subsequent siblings)
5 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
In previuos commit de6029a2d7734a93a9e27b9c4471862a47dd8123 single
quotes were replaced with double quotes to make "$(commit_msg)"
expression in heredoc to work. The same effect can be achieved by using
"EOF" as a heredoc delimiter instead of "\EOF".
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Suggested-by: Johannes Sixt <j.sixt@viscovery.net>
---
t/t4205-log-pretty-formats.sh | 106 +++++++++++++++++++++---------------------
1 file changed, 53 insertions(+), 53 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index c283842..ef9770a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -145,174 +145,174 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_success 'left alignment formatting' "
- git log --pretty='format:%<(40)%s' >actual &&
+test_expect_success 'left alignment formatting' '
+ git log --pretty="format:%<(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%h %<|(40)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%<(1)%s' >actual &&
+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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >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='format:%<(10,trunc)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
message ..
message ..
add bar Z
$(commit_msg "" "8" "..*$")
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'left alignment formatting with ltrunc' "
- git log --pretty='format:%<(10,ltrunc)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
..sage two
..sage one
add bar Z
$(commit_msg "" "0" ".\{11\}")
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'left alignment formatting with mtrunc' "
- git log --pretty='format:%<(10,mtrunc)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
mess.. two
mess.. one
add bar Z
$(commit_msg "" "4" ".\{11\}")
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'right alignment formatting' "
- git log --pretty='format:%>(40)%s' >actual &&
+test_expect_success 'right alignment formatting' '
+ git log --pretty="format:%>(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%h %>|(40)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%>(1)%s' >actual &&
+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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >expected &&
message two
message one
add bar
$(commit_msg)
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'center alignment formatting' "
- git log --pretty='format:%><(40)%s' >actual &&
+test_expect_success 'center alignment formatting' '
+ git log --pretty="format:%><(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%h %><|(40)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%><(1)%s' >actual &&
+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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >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>' &&
- git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
+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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >expected &&
short long long long
message .. A U Thor
add bar A U Thor
$(commit_msg "" "8" "..*$") A U Thor
EOF
test_cmp expected actual
-"
+'
test_done
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v9 2/5] t4205: revert back single quotes
2013-07-04 12:45 ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
@ 2013-07-05 7:07 ` Junio C Hamano
0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 7:07 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
> In previuos commit de6029a2d7734a93a9e27b9c4471862a47dd8123 single
> quotes were replaced with double quotes to make "$(commit_msg)"
> expression in heredoc to work. The same effect can be achieved by using
> "EOF" as a heredoc delimiter instead of "\EOF".
OK.
> -test_expect_success 'left alignment formatting' "
> - git log --pretty='format:%<(40)%s' >actual &&
> +test_expect_success 'left alignment formatting' '
> + git log --pretty="format:%<(40)%s" >actual &&
> # complete the incomplete line at the end
> echo >>actual &&
> - qz_to_tab_space <<\EOF >expected &&
> + qz_to_tab_space <<EOF >expected &&
> message two Z
> message one Z
> add bar Z
> $(commit_msg) Z
> EOF
> test_cmp expected actual
> -"
> +'
A subtle difference is that a call to commit_msg is made when the
test is actually run, not when the test script is prepared to be
passed (as a parameter) to test_expect_success helper. I think the
result of applying this patch, i.e. running $(commit_msg) inside the
test, is easier to read and understand.
^ permalink raw reply [flat|nested] 104+ messages in thread
* [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch 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-04 12:45 ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
@ 2013-07-04 12:45 ` Alexey Shumkin
2013-07-05 6:45 ` 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
` (2 subsequent siblings)
5 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
Function 'test_format' is become hard to read after its change in
de6029a2d7734a93a9e27b9c4471862a47dd8123. So, make it more elegant.
Also, change 'commit_msg' function to make it more pretty.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Improved-by: Johannes Sixt <j.sixt@viscovery.net>
---
t/t4205-log-pretty-formats.sh | 5 +++--
t/t6006-rev-list-format.sh | 23 +++++------------------
t/t7102-reset.sh | 12 +++++++-----
3 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index ef9770a..bb87f02 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,8 +7,9 @@
test_description='Test pretty formats'
. ./test-lib.sh
-commit_msg () {
- # String "initial. initial" partly in German (translated with Google Translate),
+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"
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 4751d22..e069263 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -35,26 +35,13 @@ test_expect_success 'setup' '
git config --unset i18n.commitEncoding
'
-# usage: test_format [failure] name format_string <expected_output
+# usage: test_format name format_string [failure] <expected_output
test_format () {
- must_fail=0
- # if parameters count is more than 2 then test must fail
- if test $# -gt 2
- then
- must_fail=1
- # remove first parameter which is flag for test failure
- shift
- fi
cat >expect.$1
- name="format $1"
- command="git rev-list --pretty=format:'$2' master >output.$1 &&
- test_cmp expect.$1 output.$1"
- if test $must_fail -eq 1
- then
- test_expect_failure "$name" "$command"
- else
- test_expect_success "$name" "$command"
- fi
+ test_expect_${3:-success} "format $1" "
+ git rev-list --pretty=format:'$2' master >output.$1 &&
+ test_cmp expect.$1 output.$1
+ "
}
# Feed to --format to provide predictable colored sequences.
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 2ef96e9..73a1bdb 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,15 +9,17 @@ Documented tests for git reset'
. ./test-lib.sh
-commit_msg () {
- # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+commit_msg() {
+ # String "modify 2nd file (changed)" partly in German
+ # (translated with Google Translate),
# encoded in UTF-8, used as a commit log message below.
- msg=$(printf "modify 2nd file (ge\303\244ndert)")
+ printf "modify 2nd file (ge\303\244ndert)" |
if test -n "$1"
then
- msg=$(echo $msg | iconv -f utf-8 -t $1)
+ iconv -f utf-8 -t $1
+ else
+ cat
fi
- echo $msg
}
test_expect_success 'creating initial files and commits' '
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
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
0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 6:45 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
> Function 'test_format' is become hard to read after its change in
> de6029a2d7734a93a9e27b9c4471862a47dd8123. So, make it more elegant.
> Also, change 'commit_msg' function to make it more pretty.
I do not know where you pick up these "more elegant" and "more
pretty" from, but please refrain from using _only_ such vague and
subjective phrases to describe the change in the log message.
Saying "make it <<better>> by doing X" (with various subjective
adjectives to say "better") is fine, but make sure you have "doing
X" part in the explanation.
Perhaps like this.
Function 'test_format' has become harder to read after its
change in de6029a2 (pretty: Add failing tests: --format output
should honor logOutputEncoding, 2013-06-26). Simplify it by
moving its "should we expect it to fail?" parameter to the end.
I cannot read why you think the updated commit_msg is "more pretty"
in the message or in the patch.
> -commit_msg () {
> - # String "initial. initial" partly in German (translated with Google Translate),
> +commit_msg() {
Style. Have SP on both sides of () in a shell function definition.
> + # 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"
This is not "more pretty" but "better commented".
> diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> index 2ef96e9..73a1bdb 100755
> --- a/t/t7102-reset.sh
> +++ b/t/t7102-reset.sh
> @@ -9,15 +9,17 @@ Documented tests for git reset'
>
> . ./test-lib.sh
>
> -commit_msg () {
> - # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
> +commit_msg() {
> + # String "modify 2nd file (changed)" partly in German
> + # (translated with Google Translate),
> # encoded in UTF-8, used as a commit log message below.
> - msg=$(printf "modify 2nd file (ge\303\244ndert)")
> + printf "modify 2nd file (ge\303\244ndert)" |
> if test -n "$1"
> then
> - msg=$(echo $msg | iconv -f utf-8 -t $1)
> + iconv -f utf-8 -t $1
> + else
> + cat
> fi
> - echo $msg
Is it "more pretty"? The "we have to have cat only because we want
to pipe into a conditional" look somewhat ugly.
msg="modify 2nd file (ge\303\244ndert)"
if test -n "$1"
then
printf "$msg" | iconv -f utf-8 -t "$1"
else
printf "$msg"
fi
> }
>
> test_expect_success 'creating initial files and commits' '
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
2013-07-05 6:45 ` Junio C Hamano
@ 2013-07-05 8:13 ` Alexey Shumkin
2013-07-05 8:44 ` Junio C Hamano
0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 8:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt
On Thu, Jul 04, 2013 at 11:45:57PM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
>
> > Function 'test_format' is become hard to read after its change in
> > de6029a2d7734a93a9e27b9c4471862a47dd8123. So, make it more elegant.
> > Also, change 'commit_msg' function to make it more pretty.
>
> I do not know where you pick up these "more elegant" and "more
> pretty" from, but please refrain from using _only_ such vague and
> subjective phrases to describe the change in the log message.
> Saying "make it <<better>> by doing X" (with various subjective
> adjectives to say "better") is fine, but make sure you have "doing
> X" part in the explanation.
>
> Perhaps like this.
>
> Function 'test_format' has become harder to read after its
> change in de6029a2 (pretty: Add failing tests: --format output
> should honor logOutputEncoding, 2013-06-26). Simplify it by
> moving its "should we expect it to fail?" parameter to the end.
I'm not sure whether this "last parameter" is needed in that code as far as we
already removed expected to fail tests
>
> I cannot read why you think the updated commit_msg is "more pretty"
> in the message or in the patch.
>
> > -commit_msg () {
> > - # String "initial. initial" partly in German (translated with Google Translate),
> > +commit_msg() {
>
> Style. Have SP on both sides of () in a shell function definition.
Could you point me to the coding style guide, please?
>
> > + # 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"
>
> This is not "more pretty" but "better commented".
Well, this is "better formatted comment", I guess :)
>
> > diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> > index 2ef96e9..73a1bdb 100755
> > --- a/t/t7102-reset.sh
> > +++ b/t/t7102-reset.sh
> > @@ -9,15 +9,17 @@ Documented tests for git reset'
> >
> > . ./test-lib.sh
> >
> > -commit_msg () {
> > - # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
> > +commit_msg() {
> > + # String "modify 2nd file (changed)" partly in German
> > + # (translated with Google Translate),
> > # encoded in UTF-8, used as a commit log message below.
> > - msg=$(printf "modify 2nd file (ge\303\244ndert)")
> > + printf "modify 2nd file (ge\303\244ndert)" |
> > if test -n "$1"
> > then
> > - msg=$(echo $msg | iconv -f utf-8 -t $1)
> > + iconv -f utf-8 -t $1
> > + else
> > + cat
> > fi
> > - echo $msg
>
> Is it "more pretty"? The "we have to have cat only because we want
> to pipe into a conditional" look somewhat ugly.
That was a proposition of J6t :-D
(see http://article.gmane.org/gmane.comp.version-control.git/229291):
>If you wanted to, you could write this as
>
>commit_msg () {
> # String "modify 2nd file (changed)" partly in German
> #(translated with Google Translate),
> # encoded in UTF-8, used as a commit log message below.
> printf "modify 2nd file (ge\303\244ndert)" |
> if test -n "$1"
> then
> iconv -f utf-8 -t $1
> else
> cat
> fi
>}
>
>but I'm not sure whether it's a lot better.
Last sentence has apperared to be a key
>
> msg="modify 2nd file (ge\303\244ndert)"
> if test -n "$1"
> then
> printf "$msg" | iconv -f utf-8 -t "$1"
> else
> printf "$msg"
> fi
>
> > }
> >
> > test_expect_success 'creating initial files and commits' '
--
Alexey Shumkin
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
2013-07-05 8:13 ` Alexey Shumkin
@ 2013-07-05 8:44 ` Junio C Hamano
2013-07-05 8:51 ` Alexey Shumkin
0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 8:44 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
>> Perhaps like this.
>>
>> Function 'test_format' has become harder to read after its
>> change in de6029a2 (pretty: Add failing tests: --format output
>> should honor logOutputEncoding, 2013-06-26). Simplify it by
>> moving its "should we expect it to fail?" parameter to the end.
> I'm not sure whether this "last parameter" is needed in that code as far as we
> already removed expected to fail tests
Whatever.
The above is an example of justifying a more vague "simple" ("is
better" is implied) with a concrete point (i.e. By moving that to
the end, you removed the need to conditionally shift $@ in the
function to simplify the codepath), based on my _guess_ of what you
possibly meant to say, from reading your description that did not
give much clue for me to guess why you thought the result was "more
elegant". If my guess missed what your true justification was,
please replace it with the more correct one ;-)
>> I cannot read why you think the updated commit_msg is "more pretty"
>> in the message or in the patch.
>>
>> > -commit_msg () {
>> > - # String "initial. initial" partly in German (translated with Google Translate),
>> > +commit_msg() {
>>
>> Style. Have SP on both sides of () in a shell function definition.
> Could you point me to the coding style guide, please?
Documentation/CodingGuidelines::
- We prefer a space between the function name and the parentheses. The
opening "{" should also be on the same line.
E.g.: my_function () {
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
2013-07-05 8:44 ` Junio C Hamano
@ 2013-07-05 8:51 ` Alexey Shumkin
2013-07-05 8:58 ` Junio C Hamano
0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 8:51 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt
On Fri, Jul 05, 2013 at 01:44:07AM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
>
> >> Perhaps like this.
> >>
> >> Function 'test_format' has become harder to read after its
> >> change in de6029a2 (pretty: Add failing tests: --format output
> >> should honor logOutputEncoding, 2013-06-26). Simplify it by
> >> moving its "should we expect it to fail?" parameter to the end.
> > I'm not sure whether this "last parameter" is needed in that code as far as we
> > already removed expected to fail tests
>
> Whatever.
>
> The above is an example of justifying a more vague "simple" ("is
> better" is implied) with a concrete point (i.e. By moving that to
> the end, you removed the need to conditionally shift $@ in the
> function to simplify the codepath), based on my _guess_ of what you
> possibly meant to say, from reading your description that did not
> give much clue for me to guess why you thought the result was "more
> elegant". If my guess missed what your true justification was,
> please replace it with the more correct one ;-)
Ok
>
> >> I cannot read why you think the updated commit_msg is "more pretty"
> >> in the message or in the patch.
> >>
> >> > -commit_msg () {
> >> > - # String "initial. initial" partly in German (translated with Google Translate),
> >> > +commit_msg() {
> >>
> >> Style. Have SP on both sides of () in a shell function definition.
> > Could you point me to the coding style guide, please?
>
> Documentation/CodingGuidelines::
Oh! :)
thank you
>
> - We prefer a space between the function name and the parentheses. The
> opening "{" should also be on the same line.
> E.g.: my_function () {
Aha
--
Alexey Shumkin
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
2013-07-05 8:51 ` Alexey Shumkin
@ 2013-07-05 8:58 ` Junio C Hamano
0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 8:58 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
>> > Could you point me to the coding style guide, please?
>>
>> Documentation/CodingGuidelines::
> Oh! :)
> thank you
The most important part of the coding guidelines is to match the
style to existing code when writing a new one:
$ git grep '^[a-z_]* ()' -- *.sh | wc -l
132
$ git grep '^[a-z_]*()' -- *.sh | wc -l
55
We have acquired quite a few violators, but that is no reason to add
more.
^ permalink raw reply [flat|nested] 104+ messages in thread
* [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
` (2 preceding siblings ...)
2013-07-04 12:45 ` [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable Alexey Shumkin
@ 2013-07-04 12:45 ` Alexey Shumkin
2013-07-05 6:52 ` Junio C Hamano
2013-07-05 7:04 ` Junio C Hamano
2013-07-04 12:45 ` [PATCH v9 5/5] t4205: avoid using `sed` Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 0/5] Incremental updates against 'next' branch Alexey Shumkin
5 siblings, 2 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
In de6029a2d7734a93a9e27b9c4471862a47dd8123 'complex-subject' test was
changed. Revert it back, and add two more tests to test encoding
conversions with no i18n.commitEncoding set.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
---
t/t6006-rev-list-format.sh | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index e069263..843134f 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -217,12 +217,7 @@ test_expect_success 'setup complex body' '
git config i18n.commitencoding iso8859-1 &&
echo change2 >foo && git commit -a -F commit-msg &&
head3=$(git rev-parse --verify HEAD) &&
- head3_short=$(git rev-parse --short $head3) &&
- # unset commit encoding config
- # otherwise %e does not print encoding value
- # and following test fails
- git config --unset i18n.commitEncoding
-
+ head3_short=$(git rev-parse --short $head3)
'
test_format complex-encoding %e <<EOF
@@ -238,12 +233,35 @@ test_format complex-subject %s <<EOF
commit $head3
Test printing of complex bodies
commit $head2
+$changed_iso88591
+commit $head1
+$added_iso88591
+EOF
+
+test_format complex-body %b <<EOF
+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!
+
+commit $head2
+commit $head1
+EOF
+
+# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
+# so unset i18n.commitEncoding to test encoding conversion
+git config --unset i18n.commitEncoding
+
+test_format complex-subject-commitencoding-unset %s <<EOF
+commit $head3
+Test printing of complex bodies
+commit $head2
$changed
commit $head1
$added
EOF
-test_format complex-body %b <<EOF
+test_format complex-body-commitencoding-unset %b <<EOF
commit $head3
This commit message is much longer than the others,
and it will be encoded in iso8859-1. We should therefore
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
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
1 sibling, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 6:52 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
> In de6029a2d7734a93a9e27b9c4471862a47dd8123 'complex-subject' test was
> changed. Revert it back,...
... "because changing it was bad for such and such reasons"?
^ permalink raw reply [flat|nested] 104+ messages in thread
* Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
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
1 sibling, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 7:04 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
> +test_format complex-body %b <<EOF
> +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!
This is not such a good idea, as the resulting file will be in mixed
encoding (it already has a line with non-ascii that is in UTF-8),
and many editors would not like such a file.
Perhaps we should update test_format so that we can feed a quoted
input, e.g.
+include an iso8859-1 character: <A1>bueno!
or something?
> +commit $head2
> +commit $head1
> +EOF
> +
> +# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
> +# so unset i18n.commitEncoding to test encoding conversion
> +git config --unset i18n.commitEncoding
> +
> +test_format complex-subject-commitencoding-unset %s <<EOF
> +commit $head3
> +Test printing of complex bodies
> +commit $head2
> $changed
> commit $head1
> $added
> EOF
>
> -test_format complex-body %b <<EOF
> +test_format complex-body-commitencoding-unset %b <<EOF
> commit $head3
> This commit message is much longer than the others,
> and it will be encoded in iso8859-1. We should therefore
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
2013-07-05 7:04 ` Junio C Hamano
@ 2013-07-05 7:46 ` Alexey Shumkin
2013-07-05 8:09 ` Junio C Hamano
0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 7:46 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt
On Fri, Jul 05, 2013 at 12:04:34AM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
>
> > +test_format complex-body %b <<EOF
> > +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!
>
> This is not such a good idea, as the resulting file will be in mixed
> encoding (it already has a line with non-ascii that is in UTF-8),
> and many editors would not like such a file.
I agree, there was issues when I edited that file
>
> Perhaps we should update test_format so that we can feed a quoted
> input, e.g.
>
> +include an iso8859-1 character: <A1>bueno!
>
> or something?
We could use this file whole in UTF-8 but just make a conversion of
expected output as it's done a few lines above with a commit message
(stored to a file 'commit-msg' before the test 'setup complex body').
+iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
+Test printing of complex bodies
We can even use content of that file (as far as it's kept untouched
between that tests)
>
> > +commit $head2
> > +commit $head1
> > +EOF
> > +
> > +# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
> > +# so unset i18n.commitEncoding to test encoding conversion
> > +git config --unset i18n.commitEncoding
> > +
> > +test_format complex-subject-commitencoding-unset %s <<EOF
> > +commit $head3
> > +Test printing of complex bodies
> > +commit $head2
> > $changed
> > commit $head1
> > $added
> > EOF
> >
> > -test_format complex-body %b <<EOF
> > +test_format complex-body-commitencoding-unset %b <<EOF
> > commit $head3
> > This commit message is much longer than the others,
> > and it will be encoded in iso8859-1. We should therefore
--
Alexey Shumkin
^ permalink raw reply [flat|nested] 104+ messages in thread* Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
2013-07-05 7:46 ` Alexey Shumkin
@ 2013-07-05 8:09 ` Junio C Hamano
0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 8:09 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
>> Perhaps we should update test_format so that we can feed a quoted
>> input, e.g.
>>
>> +include an iso8859-1 character: <A1>bueno!
>>
>> or something?
> We could use this file whole in UTF-8 but just make a conversion of
> expected output as it's done a few lines above with a commit message
> (stored to a file 'commit-msg' before the test 'setup complex body').
> +iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
> +Test printing of complex bodies
That is way better than my <A1>bueno!.
Thanks.
^ permalink raw reply [flat|nested] 104+ messages in thread
* [PATCH v9 5/5] t4205: avoid using `sed`
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
` (3 preceding siblings ...)
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-04 12:45 ` Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 0/5] Incremental updates against 'next' branch Alexey Shumkin
5 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
For testing truncated log messages 'commit_msg' function uses `sed` to
cut a message. On various platforms `sed` behaves differently and
results of its work depend on locales installed. So, avoid using `sed`.
Use predefined expected outputs instead of calculated ones.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/t4205-log-pretty-formats.sh | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index bb87f02..8504b13 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,25 +7,19 @@
test_description='Test pretty formats'
. ./test-lib.sh
+sample_utf8_part=$(printf "f\303\244ng")
+
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")
+ msg="initial. an${sample_utf8_part}lich"
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../")
+ echo $msg | iconv -f utf-8 -t $1
+ else
+ echo $msg
fi
- echo $msg
}
test_expect_success 'set up basic repos' '
@@ -193,7 +187,7 @@ test_expect_success 'left alignment formatting with trunc' '
message ..
message ..
add bar Z
-$(commit_msg "" "8" "..*$")
+initial...
EOF
test_cmp expected actual
'
@@ -206,7 +200,7 @@ test_expect_success 'left alignment formatting with ltrunc' '
..sage two
..sage one
add bar Z
-$(commit_msg "" "0" ".\{11\}")
+..${sample_utf8_part}lich
EOF
test_cmp expected actual
'
@@ -219,7 +213,7 @@ test_expect_success 'left alignment formatting with mtrunc' '
mess.. two
mess.. one
add bar Z
-$(commit_msg "" "4" ".\{11\}")
+init..lich
EOF
test_cmp expected actual
'
@@ -311,7 +305,7 @@ test_expect_success '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
+initial... A U Thor
EOF
test_cmp expected actual
'
--
1.8.3.1.15.g5c23c1e
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v10 0/5] Incremental updates against 'next' branch
2013-07-04 12:45 ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
` (4 preceding siblings ...)
2013-07-04 12:45 ` [PATCH v9 5/5] t4205: avoid using `sed` Alexey Shumkin
@ 2013-07-05 12:01 ` 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
` (4 more replies)
5 siblings, 5 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
This patches series includes following changes against v9
1. [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
reworded. reasons of renaming explained "here and now" but not only
redirects to an older commit which did the same.
2. [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes
little change to commit message (added "(log-pretty-formats)" after
"t4205")
3. [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable
reworded. comments reformatted. function 'test_format' refactored.
4. [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set
reworded. Now whole file is in utf-8. Tested output messages are
converted from utf-8 to iso8859-1 "on the fly" and written fo files.
5. [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed`
little change to commit message (added "(log-pretty-formats)" after
"t4205")
And references to "de6029a2d7734a93a9e27b9c4471862a47dd8123" commit in
all patch messages replaced with "de6029a (pretty: Add failing
tests: --format output should honor logOutputEncoding, 2013-06-26)"
P.S. This patch series is an incremental updates on top of (7c375214 t4205:
replace .\+ with ..* in sed commands, 2013-07-01) as far as v7 patches
were applied to the 'next' branch but there were more improvements made
in v8.
Alexey Shumkin (5):
t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
t4205 (log-pretty-formats): revert back single quotes
t4205, t6006, t7102: make functions better readable
t6006 (rev-list-format): add tests for "%b" and "%s" for the case
i18n.commitEncoding is not set
t4205 (log-pretty-formats): avoid using `sed`
t/t4041-diff-submodule-option.sh | 4 +-
t/t4205-log-pretty-formats.sh | 143 +++++++++++++++++++--------------------
t/t6006-rev-list-format.sh | 83 ++++++++++++-----------
t/t7102-reset.sh | 20 +++---
4 files changed, 125 insertions(+), 125 deletions(-)
--
1.8.3.2.16.gb1f0d63
^ permalink raw reply [flat|nested] 104+ messages in thread* [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
2013-07-05 12:01 ` [PATCH v10 0/5] Incremental updates against 'next' branch Alexey Shumkin
@ 2013-07-05 12:01 ` Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes Alexey Shumkin
` (3 subsequent siblings)
4 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
Both "iso8859-1" and "iso-8859-1" are understood as latin-1
by modern platforms, but the latter is not understood by
older platforms; update tests to use the former.
This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
than ISO-8859-1, 2009-12-03), which did the same.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Suggested-by: Johannes Sixt <j.sixt@viscovery.net>
---
t/t4041-diff-submodule-option.sh | 4 ++--
t/t4205-log-pretty-formats.sh | 8 ++++----
t/t6006-rev-list-format.sh | 14 +++++++-------
t/t7102-reset.sh | 10 +++++-----
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 0a4f496..1751c83 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -23,8 +23,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
- msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso-8859-1) &&
- git -c 'i18n.commitEncoding=iso-8859-1' commit -m "$msg_added_iso88591"
+ 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"
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 3cfb744..c283842 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -32,8 +32,8 @@ test_expect_success 'set up basic repos' '
>bar &&
git add foo &&
test_tick &&
- git config i18n.commitEncoding iso-8859-1 &&
- git commit -m "$(commit_msg iso-8859-1)" &&
+ git config i18n.commitEncoding iso8859-1 &&
+ git commit -m "$(commit_msg iso8859-1)" &&
git add bar &&
test_tick &&
git commit -m "add bar" &&
@@ -61,8 +61,8 @@ test_expect_success 'alias user-defined format' '
test_cmp expected actual
'
-test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' '
- git config i18n.logOutputEncoding iso-8859-1 &&
+test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
+ git config i18n.logOutputEncoding iso8859-1 &&
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 380c85b..4751d22 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -12,15 +12,15 @@ test_tick
# 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 iso-8859-1)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
# same but "changed"
changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso-8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
test_expect_success 'setup' '
: >foo &&
git add foo &&
- git config i18n.commitEncoding iso-8859-1 &&
+ git config i18n.commitEncoding iso8859-1 &&
git commit -m "$added_iso88591" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -136,9 +136,9 @@ EOF
test_format encoding %e <<EOF
commit $head2
-iso-8859-1
+iso8859-1
commit $head1
-iso-8859-1
+iso8859-1
EOF
test_format subject %s <<EOF
@@ -242,9 +242,9 @@ test_format complex-encoding %e <<EOF
commit $head3
iso8859-1
commit $head2
-iso-8859-1
+iso8859-1
commit $head1
-iso-8859-1
+iso8859-1
EOF
test_format complex-subject %s <<EOF
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 9132dd9..2ef96e9 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -39,7 +39,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=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
+ git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
@@ -62,10 +62,10 @@ test_expect_success 'reset --hard message' '
test_cmp .expected .actual
'
-test_expect_success 'reset --hard message (iso-8859-1 logoutencoding)' '
+test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
hex=$(git log -1 --format="%h") &&
- git -c "i18n.logOutputEncoding=iso-8859-1" reset --hard > .actual &&
- echo HEAD is now at $hex $(commit_msg iso-8859-1) > .expected &&
+ git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
+ echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
test_cmp .expected .actual
'
@@ -329,7 +329,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=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
+ git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
check_changes $head5
'
--
1.8.3.2.16.gb1f0d63
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes
2013-07-05 12:01 ` [PATCH v10 0/5] Incremental updates against 'next' branch 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 ` Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
` (2 subsequent siblings)
4 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
In previuos commit de6029a (pretty: Add failing tests: --format output
should honor logOutputEncoding, 2013-06-26) single quotes were replaced
with double quotes to make "$(commit_msg)" expression in heredoc to
work. The same effect can be achieved by using "EOF" as a heredoc
delimiter instead of "\EOF".
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Suggested-by: Johannes Sixt <j.sixt@viscovery.net>
---
t/t4205-log-pretty-formats.sh | 106 +++++++++++++++++++++---------------------
1 file changed, 53 insertions(+), 53 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index c283842..ef9770a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -145,174 +145,174 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_success 'left alignment formatting' "
- git log --pretty='format:%<(40)%s' >actual &&
+test_expect_success 'left alignment formatting' '
+ git log --pretty="format:%<(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%h %<|(40)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%<(1)%s' >actual &&
+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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >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='format:%<(10,trunc)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
message ..
message ..
add bar Z
$(commit_msg "" "8" "..*$")
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'left alignment formatting with ltrunc' "
- git log --pretty='format:%<(10,ltrunc)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
..sage two
..sage one
add bar Z
$(commit_msg "" "0" ".\{11\}")
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'left alignment formatting with mtrunc' "
- git log --pretty='format:%<(10,mtrunc)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >expected &&
mess.. two
mess.. one
add bar Z
$(commit_msg "" "4" ".\{11\}")
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'right alignment formatting' "
- git log --pretty='format:%>(40)%s' >actual &&
+test_expect_success 'right alignment formatting' '
+ git log --pretty="format:%>(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%h %>|(40)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%>(1)%s' >actual &&
+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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >expected &&
message two
message one
add bar
$(commit_msg)
EOF
test_cmp expected actual
-"
+'
-test_expect_success 'center alignment formatting' "
- git log --pretty='format:%><(40)%s' >actual &&
+test_expect_success 'center alignment formatting' '
+ git log --pretty="format:%><(40)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%h %><|(40)%s' >actual &&
+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 &&
- qz_to_tab_space <<\EOF >expected &&
+ qz_to_tab_space <<EOF >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='format:%><(1)%s' >actual &&
+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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >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>' &&
- git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
+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 &&
- cat <<\EOF >expected &&
+ cat <<EOF >expected &&
short long long long
message .. A U Thor
add bar A U Thor
$(commit_msg "" "8" "..*$") A U Thor
EOF
test_cmp expected actual
-"
+'
test_done
--
1.8.3.2.16.gb1f0d63
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable
2013-07-05 12:01 ` [PATCH v10 0/5] Incremental updates against 'next' branch 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 ` Alexey Shumkin
2013-07-05 18:38 ` 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
4 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
Function 'test_format' has become harder to read after its
change in de6029a2 (pretty: Add failing tests: --format output
should honor logOutputEncoding, 2013-06-26). Simplify it by
moving its "should we expect it to fail?" parameter to the end.
Note, current code does not use this last parameter as far as there
are no tests expected to fail. We can keep that for future use.
Also, reformat comments
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Improved-by: Johannes Sixt <j.sixt@viscovery.net>
---
t/t4205-log-pretty-formats.sh | 3 ++-
t/t6006-rev-list-format.sh | 28 ++++++++--------------------
t/t7102-reset.sh | 10 ++++++----
3 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index ef9770a..2933c63 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -8,7 +8,8 @@ test_description='Test pretty formats'
. ./test-lib.sh
commit_msg () {
- # String "initial. initial" partly in German (translated with Google Translate),
+ # 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"
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 4751d22..b32405a 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -9,8 +9,9 @@ test_description='git rev-list --pretty=format test'
. "$TEST_DIRECTORY"/lib-terminal.sh
test_tick
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used as a commit log message below.
+# 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)
# same but "changed"
@@ -35,26 +36,13 @@ test_expect_success 'setup' '
git config --unset i18n.commitEncoding
'
-# usage: test_format [failure] name format_string <expected_output
+# usage: test_format name format_string [failure] <expected_output
test_format () {
- must_fail=0
- # if parameters count is more than 2 then test must fail
- if test $# -gt 2
- then
- must_fail=1
- # remove first parameter which is flag for test failure
- shift
- fi
cat >expect.$1
- name="format $1"
- command="git rev-list --pretty=format:'$2' master >output.$1 &&
- test_cmp expect.$1 output.$1"
- if test $must_fail -eq 1
- then
- test_expect_failure "$name" "$command"
- else
- test_expect_success "$name" "$command"
- fi
+ test_expect_${3:-success} "format $1" "
+ git rev-list --pretty=format:'$2' master >output.$1 &&
+ test_cmp expect.$1 output.$1
+ "
}
# Feed to --format to provide predictable colored sequences.
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 2ef96e9..535e609 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -10,14 +10,16 @@ Documented tests for git reset'
. ./test-lib.sh
commit_msg () {
- # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+ # String "modify 2nd file (changed)" partly in German
+ # (translated with Google Translate),
# encoded in UTF-8, used as a commit log message below.
- msg=$(printf "modify 2nd file (ge\303\244ndert)")
+ msg="modify 2nd file (ge\303\244ndert)"
if test -n "$1"
then
- msg=$(echo $msg | iconv -f utf-8 -t $1)
+ print "$msg" | iconv -f utf-8 -t "$1"
+ else
+ print "$msg"
fi
- echo $msg
}
test_expect_success 'creating initial files and commits' '
--
1.8.3.2.16.gb1f0d63
^ permalink raw reply related [flat|nested] 104+ messages in thread* Re: [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable
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
0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 18:38 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Alexey Shumkin <alex.crezoff@gmail.com> writes:
> - msg=$(printf "modify 2nd file (ge\303\244ndert)")
> + msg="modify 2nd file (ge\303\244ndert)"
> if test -n "$1"
> then
> - msg=$(echo $msg | iconv -f utf-8 -t $1)
> + print "$msg" | iconv -f utf-8 -t "$1"
> + else
> + print "$msg"
> fi
> - echo $msg
> }
I think I'll do s/print/&f/ before queuing this.
Thanks.
^ permalink raw reply [flat|nested] 104+ messages in thread
* Re: [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable
2013-07-05 18:38 ` Junio C Hamano
@ 2013-07-05 18:45 ` Junio C Hamano
0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 18:45 UTC (permalink / raw)
To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt
Junio C Hamano <gitster@pobox.com> writes:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
>
>> - msg=$(printf "modify 2nd file (ge\303\244ndert)")
>> + msg="modify 2nd file (ge\303\244ndert)"
>> if test -n "$1"
>> then
>> - msg=$(echo $msg | iconv -f utf-8 -t $1)
>> + print "$msg" | iconv -f utf-8 -t "$1"
>> + else
>> + print "$msg"
>> fi
>> - echo $msg
>> }
>
> I think I'll do s/print/&f/ before queuing this.
Also, I'll change the $msg constant to have \n at the end, as we are
losing it by bypassing "echo".
^ permalink raw reply [flat|nested] 104+ messages in thread
* [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set
2013-07-05 12:01 ` [PATCH v10 0/5] Incremental updates against 'next' branch Alexey Shumkin
` (2 preceding siblings ...)
2013-07-05 12:01 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
@ 2013-07-05 12:01 ` Alexey Shumkin
2013-07-05 12:01 ` [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed` Alexey Shumkin
4 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
In de6029a (pretty: Add failing tests: --format output should honor
logOutputEncoding, 2013-06-26) 'complex-subject' test was changed.
Revert it back, because that change actually removed tests for "%b" and
"%s" with i18n.commitEncoding set.
Also, add two more tests for mentioned above "%b" and "%s" to test
encoding conversions with no i18n.commitEncoding set.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Suggested-by: Johannes Sixt <j.sixt@viscovery.net>
---
t/t6006-rev-list-format.sh | 41 ++++++++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index b32405a..e51d0f0 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -218,12 +218,7 @@ test_expect_success 'setup complex body' '
git config i18n.commitencoding iso8859-1 &&
echo change2 >foo && git commit -a -F commit-msg &&
head3=$(git rev-parse --verify HEAD) &&
- head3_short=$(git rev-parse --short $head3) &&
- # unset commit encoding config
- # otherwise %e does not print encoding value
- # and following test fails
- git config --unset i18n.commitEncoding
-
+ head3_short=$(git rev-parse --short $head3)
'
test_format complex-encoding %e <<EOF
@@ -239,21 +234,41 @@ test_format complex-subject %s <<EOF
commit $head3
Test printing of complex bodies
commit $head2
-$changed
+$changed_iso88591
commit $head1
-$added
+$added_iso88591
EOF
-test_format complex-body %b <<EOF
-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!
+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!
+
+ commit $head2
+ commit $head1
+EOF
+ iconv -f utf-8 -t iso8859-1 expected.utf-8 >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
+git config --unset i18n.commitEncoding
+
+test_format complex-subject-commitencoding-unset %s <<EOF
+commit $head3
+Test printing of complex bodies
commit $head2
+$changed
commit $head1
+$added
EOF
+test_format complex-body-commitencoding-unset %b <expected.utf-8
+
test_expect_success '%x00 shows NUL' '
echo >expect commit $head3 &&
echo >>expect fooQbar &&
--
1.8.3.2.16.gb1f0d63
^ permalink raw reply related [flat|nested] 104+ messages in thread* [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed`
2013-07-05 12:01 ` [PATCH v10 0/5] Incremental updates against 'next' branch Alexey Shumkin
` (3 preceding siblings ...)
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 ` Alexey Shumkin
4 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano
For testing truncated log messages 'commit_msg' function uses `sed` to
cut a message. On various platforms `sed` behaves differently and
results of its work depend on locales installed. So, avoid using `sed`.
Use predefined expected outputs instead of calculated ones.
Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/t4205-log-pretty-formats.sh | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2933c63..73fd236 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,25 +7,19 @@
test_description='Test pretty formats'
. ./test-lib.sh
+sample_utf8_part=$(printf "f\303\244ng")
+
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")
+ msg="initial. an${sample_utf8_part}lich"
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../")
+ print $msg | iconv -f utf-8 -t "$1"
+ else
+ print $msg
fi
- echo $msg
}
test_expect_success 'set up basic repos' '
@@ -193,7 +187,7 @@ test_expect_success 'left alignment formatting with trunc' '
message ..
message ..
add bar Z
-$(commit_msg "" "8" "..*$")
+initial...
EOF
test_cmp expected actual
'
@@ -206,7 +200,7 @@ test_expect_success 'left alignment formatting with ltrunc' '
..sage two
..sage one
add bar Z
-$(commit_msg "" "0" ".\{11\}")
+..${sample_utf8_part}lich
EOF
test_cmp expected actual
'
@@ -219,7 +213,7 @@ test_expect_success 'left alignment formatting with mtrunc' '
mess.. two
mess.. one
add bar Z
-$(commit_msg "" "4" ".\{11\}")
+init..lich
EOF
test_cmp expected actual
'
@@ -311,7 +305,7 @@ test_expect_success '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
+initial... A U Thor
EOF
test_cmp expected actual
'
--
1.8.3.2.16.gb1f0d63
^ permalink raw reply related [flat|nested] 104+ messages in thread