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 <[email protected]>
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
'
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html