Skip to content

Commit 37eb772

Browse files
ashumkingitster
authored andcommitted
t4205 (log-pretty-formats): avoid using sed
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0fe6df3 commit 37eb772

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

t/t4205-log-pretty-formats.sh

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@
77
test_description='Test pretty formats'
88
. ./test-lib.sh
99

10+
sample_utf8_part=$(printf "f\303\244ng")
11+
1012
commit_msg () {
1113
# String "initial. initial" partly in German
1214
# (translated with Google Translate),
1315
# encoded in UTF-8, used as a commit log message below.
14-
msg=$(printf "initial. anf\303\244nglich")
16+
msg="initial. an${sample_utf8_part}lich\n"
1517
if test -n "$1"
1618
then
17-
msg=$(echo $msg | iconv -f utf-8 -t $1)
18-
fi
19-
if test -n "$2" -a -n "$3"
20-
then
21-
# cut string, replace cut part with two dots
22-
# $2 - chars count from the beginning of the string
23-
# $3 - "trailing" chars
24-
# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
25-
# as it does with C locale
26-
msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
19+
printf "$msg" | iconv -f utf-8 -t "$1"
20+
else
21+
printf "$msg"
2722
fi
28-
echo $msg
2923
}
3024

3125
test_expect_success 'set up basic repos' '
@@ -193,7 +187,7 @@ test_expect_success 'left alignment formatting with trunc' '
193187
message ..
194188
message ..
195189
add bar Z
196-
$(commit_msg "" "8" "..*$")
190+
initial...
197191
EOF
198192
test_cmp expected actual
199193
'
@@ -206,7 +200,7 @@ test_expect_success 'left alignment formatting with ltrunc' '
206200
..sage two
207201
..sage one
208202
add bar Z
209-
$(commit_msg "" "0" ".\{11\}")
203+
..${sample_utf8_part}lich
210204
EOF
211205
test_cmp expected actual
212206
'
@@ -219,7 +213,7 @@ test_expect_success 'left alignment formatting with mtrunc' '
219213
mess.. two
220214
mess.. one
221215
add bar Z
222-
$(commit_msg "" "4" ".\{11\}")
216+
init..lich
223217
EOF
224218
test_cmp expected actual
225219
'
@@ -311,7 +305,7 @@ test_expect_success 'left/right alignment formatting with stealing' '
311305
short long long long
312306
message .. A U Thor
313307
add bar A U Thor
314-
$(commit_msg "" "8" "..*$") A U Thor
308+
initial... A U Thor
315309
EOF
316310
test_cmp expected actual
317311
'

0 commit comments

Comments
 (0)