summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e8e29c7)
raw | patch | inline | side by side (parent: e8e29c7)
author | Jeff King <peff@peff.net> | |
Wed, 12 Mar 2008 21:31:06 +0000 (17:31 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 13 Mar 2008 07:57:52 +0000 (00:57 -0700) |
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>
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>
diff --git a/t/diff-lib.sh b/t/diff-lib.sh
index 7dc6d7eb1e13a1831b61c70269ce593457badf0c..28b941c493ca96b726c6cde27660e987fc31bedc 100644 (file)
--- a/t/diff-lib.sh
+++ b/t/diff-lib.sh
# Also we do not check SHA1 hash generation in this test, which
# is a job for t0000-basic.sh
- tr '\000' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
- tr '\000' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
+ perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
+ perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}
diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
index 90ea081db666d707246e37affc5676e6c3502741..2bfeac986eadeca0064b1aee808d08b2f86082c4 100755 (executable)
--- a/t/t0020-crlf.sh
+++ b/t/t0020-crlf.sh
. ./test-lib.sh
q_to_nul () {
- tr Q '\000'
+ perl -pe 'y/Q/\000/'
}
q_to_cr () {
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 4928a571144b3fb9ec38312d917e9f95e40ceb99..b36a9012ecb3a34761027de77635741e1cd80aab 100755 (executable)
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
Qsection.sub=section.val5Q
EOF
-git config --null --list | tr '\000' 'Q' > result
+git config --null --list | perl -pe 'y/\000/Q/' > result
echo >>result
test_expect_success '--null --list' 'cmp result expect'
-git config --null --get-regexp 'val[0-9]' | tr '\000' 'Q' > result
+git config --null --get-regexp 'val[0-9]' | perl -pe 'y/\000/Q/' > result
echo >>result
test_expect_success '--null --get-regexp' 'cmp result expect'
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 98c133db50a35a62ade6d06c8fc7e1bbdf1714f2..24a00a9df13b0781700f24e6a8e75505696a11dd 100755 (executable)
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
no-funny
tabs ," (dq) and spaces' >expected
test_expect_success 'git ls-files -z with-funny' \
- 'git ls-files -z | tr \\000 \\012 >current &&
+ 'git ls-files -z | perl -pe y/\\000/\\012/ >current &&
git diff expected current'
t1=`git write-tree`
echo 'A
tabs ," (dq) and spaces' >expected
test_expect_success 'git diff-index -z with-funny' \
- 'git diff-index -z --name-status $t0 | tr \\000 \\012 >current &&
+ 'git diff-index -z --name-status $t0 | perl -pe y/\\000/\\012/ >current &&
git diff expected current'
test_expect_success 'git diff-tree -z with-funny' \
- 'git diff-tree -z --name-status $t0 $t1 | tr \\000 \\012 >current &&
+ 'git diff-tree -z --name-status $t0 $t1 | perl -pe y/\\000/\\012/ >current &&
git diff expected current'
cat > expected <<\EOF
index 888293361d4ec39e389b321493dac8ed08886d7c..bf8f778a471b7fdb21b6e6df473222593439ba34 100755 (executable)
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
git diff | grep Binary
'
-echo NULZbetweenZwords | tr Z '\000' > file
+echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
test_expect_success 'force diff with "diff"' '
echo >.gitattributes "file diff" &&
index 7c25634fc2962fc7b71d7d34ea6ac8d6c8061559..1b58233da6cfa09092e6953f7d9c6bc38d7bae56 100755 (executable)
--- a/t/t4103-apply-binary.sh
+++ b/t/t4103-apply-binary.sh
git-commit -m 'Initial Version' 2>/dev/null
git-checkout -b binary
-tr 'x' '\000' <file1 >file3
+perl -pe 'y/x/\000/' <file1 >file3
cat file3 >file4
git add file2
-tr '\000' 'v' <file3 >file1
+perl -pe 'y/\000/v/' <file3 >file1
rm -f file2
git update-index --add --remove file1 file2 file3 file4
git-commit -m 'Second Version'
index b1d35ab04db88f849c024208a541c0a594f0ed3b..c3f45790076e8e5f80322ad272dc4bf1ff4b9715 100755 (executable)
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
test_expect_success setup '
for i in a b c d e f g h i j k l m n; do echo $i; done >file1 &&
- tr "ijk" '\''\000\001\002'\'' <file1 >file2 &&
+ perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
git add file1 file2 &&
git commit -m initial &&
git tag initial &&
for i in a b c g h i J K L m o n p q; do echo $i; done >file1 &&
- tr "mon" '\''\000\001\002'\'' <file1 >file2 &&
+ perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
git commit -a -m second &&
git tag second &&
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index eeff3c9c0772daa85302d44552bc9c0d2d9f0280..3cbfee704e6238eb31fa1b519567fb064ca27ad8 100755 (executable)
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
test_expect_success 'rerere prefers first change' 'git diff a1 expect'
rm $rr/postimage
-echo "$sha1 a1" | tr '\012' '\000' > .git/rr-cache/MERGE_RR
+echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/rr-cache/MERGE_RR
test_expect_success 'rerere clear' 'git rerere clear'
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index cd3c149800395553cc973317ef41e89e53771f60..c955fe44f5b962ef305e49c21bc3fb0e5b58d462 100755 (executable)
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
'rm -f .git/index*
for i in a b c
do
- dd if=/dev/zero bs=4k count=1 | tr "\\000" $i >$i &&
+ dd if=/dev/zero bs=4k count=1 | perl -pe "y/\\000/$i/" >$i &&
git update-index --add $i || return 1
done &&
cat c >d && echo foo >>d && git update-index --add d &&
diff --git a/test-sha1.sh b/test-sha1.sh
index bf526c8f5e8649590da1bfd424e11a78c5621f6f..0f0bc5d02f4dcbd67c6d405350e5aaeb39f44bfb 100755 (executable)
--- a/test-sha1.sh
+++ b/test-sha1.sh
{
test -z "$pfx" || echo "$pfx"
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
- tr '\000' 'g'
+ perl -pe 'y/\000/g/'
} | ./test-sha1 $cnt
`
if test "$expect" = "$actual"
{
test -z "$pfx" || echo "$pfx"
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
- tr '\000' 'g'
+ perl -pe 'y/\000/g/'
} | sha1sum |
sed -e 's/ .*//'
`