@matheusbsbs / matheus-bagliano / commits / e85fe4d85b
Fork 0

more tr portability test script fixes

Dealing with NULs is not always safe with tr. On Solaris, incoming NULs are silently deleted by both the System V and UCB versions of tr. When converting to NULs, the System V version works fine, but the UCB version silently ignores the request to convert the character. This patch changes all instances of tr using NULs to use "perl -pe 'y///'" instead. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 12, 2008 at 17:31 UTC e85fe4d85bc7654af20ccf8054ab6922665405e5
10 files changed +17 -17
t/diff-lib.sh
+2 -2
@@ -21,8 +21,8 @@ compare_diff_raw_z () {
21 # Also we do not check SHA1 hash generation in this test, which
22 # is a job for t0000-basic.sh
23
24 - tr '\000' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
25 - tr '\000' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
24 + perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
25 + perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
26 git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
27 }
28
t/t0020-crlf.sh
+1 -1
@@ -5,7 +5,7 @@ test_description='CRLF conversion'
5 . ./test-lib.sh
6
7 q_to_nul () {
8 - tr Q '\000'
8 + perl -pe 'y/Q/\000/'
9 }
10
11 q_to_cr () {
t/t1300-repo-config.sh
+2 -2
@@ -657,12 +657,12 @@ Qsection.sub=section.val4
657 Qsection.sub=section.val5Q
658 EOF
659
660 -git config --null --list | tr '\000' 'Q' > result
660 +git config --null --list | perl -pe 'y/\000/Q/' > result
661 echo >>result
662
663 test_expect_success '--null --list' 'cmp result expect'
664
665 -git config --null --get-regexp 'val[0-9]' | tr '\000' 'Q' > result
665 +git config --null --get-regexp 'val[0-9]' | perl -pe 'y/\000/Q/' > result
666 echo >>result
667
668 test_expect_success '--null --get-regexp' 'cmp result expect'
t/t3300-funny-names.sh
+3 -3
@@ -54,7 +54,7 @@ echo 'just space
54 no-funny
55 tabs ," (dq) and spaces' >expected
56 test_expect_success 'git ls-files -z with-funny' \
57 - 'git ls-files -z | tr \\000 \\012 >current &&
57 + 'git ls-files -z | perl -pe y/\\000/\\012/ >current &&
58 git diff expected current'
59
60 t1=`git write-tree`
@@ -83,11 +83,11 @@ test_expect_success 'git diff-tree with-funny' \
83 echo 'A
84 tabs ," (dq) and spaces' >expected
85 test_expect_success 'git diff-index -z with-funny' \
86 - 'git diff-index -z --name-status $t0 | tr \\000 \\012 >current &&
86 + 'git diff-index -z --name-status $t0 | perl -pe y/\\000/\\012/ >current &&
87 git diff expected current'
88
89 test_expect_success 'git diff-tree -z with-funny' \
90 - 'git diff-tree -z --name-status $t0 $t1 | tr \\000 \\012 >current &&
90 + 'git diff-tree -z --name-status $t0 $t1 | perl -pe y/\\000/\\012/ >current &&
91 git diff expected current'
92
93 cat > expected <<\EOF
t/t4020-diff-external.sh
+1 -1
@@ -99,7 +99,7 @@ test_expect_success 'no diff with -diff' '
99 git diff | grep Binary
100 '
101
102 -echo NULZbetweenZwords | tr Z '\000' > file
102 +echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
103
104 test_expect_success 'force diff with "diff"' '
105 echo >.gitattributes "file diff" &&
t/t4103-apply-binary.sh
+2 -2
@@ -24,10 +24,10 @@ git update-index --add --remove file1 file2 file4
24 git-commit -m 'Initial Version' 2>/dev/null
25
26 git-checkout -b binary
27 -tr 'x' '\000' <file1 >file3
27 +perl -pe 'y/x/\000/' <file1 >file3
28 cat file3 >file4
29 git add file2
30 -tr '\000' 'v' <file3 >file1
30 +perl -pe 'y/\000/v/' <file3 >file1
31 rm -f file2
32 git update-index --add --remove file1 file2 file3 file4
33 git-commit -m 'Second Version'
t/t4116-apply-reverse.sh
+2 -2
@@ -12,14 +12,14 @@ test_description='git apply in reverse
12 test_expect_success setup '
13
14 for i in a b c d e f g h i j k l m n; do echo $i; done >file1 &&
15 - tr "ijk" '\''\000\001\002'\'' <file1 >file2 &&
15 + perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
16
17 git add file1 file2 &&
18 git commit -m initial &&
19 git tag initial &&
20
21 for i in a b c g h i J K L m o n p q; do echo $i; done >file1 &&
22 - tr "mon" '\''\000\001\002'\'' <file1 >file2 &&
22 + perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
23
24 git commit -a -m second &&
25 git tag second &&
t/t4200-rerere.sh
+1 -1
@@ -129,7 +129,7 @@ test_expect_success 'rerere kicked in' "! grep ======= a1"
129 test_expect_success 'rerere prefers first change' 'git diff a1 expect'
130
131 rm $rr/postimage
132 -echo "$sha1 a1" | tr '\012' '\000' > .git/rr-cache/MERGE_RR
132 +echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/rr-cache/MERGE_RR
133
134 test_expect_success 'rerere clear' 'git rerere clear'
135
t/t5300-pack-object.sh
+1 -1
@@ -15,7 +15,7 @@ test_expect_success \
15 'rm -f .git/index*
16 for i in a b c
17 do
18 - dd if=/dev/zero bs=4k count=1 | tr "\\000" $i >$i &&
18 + dd if=/dev/zero bs=4k count=1 | perl -pe "y/\\000/$i/" >$i &&
19 git update-index --add $i || return 1
20 done &&
21 cat c >d && echo foo >>d && git update-index --add d &&
test-sha1.sh
+2 -2
@@ -10,7 +10,7 @@ do
10 {
11 test -z "$pfx" || echo "$pfx"
12 dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
13 - tr '\000' 'g'
13 + perl -pe 'y/\000/g/'
14 } | ./test-sha1 $cnt
15 `
16 if test "$expect" = "$actual"
@@ -55,7 +55,7 @@ do
55 {
56 test -z "$pfx" || echo "$pfx"
57 dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
58 - tr '\000' 'g'
58 + perl -pe 'y/\000/g/'
59 } | sha1sum |
60 sed -e 's/ .*//'
61 `