append_cr(), remove_cr(), q_to_nul() and q_to_cr() are defined in multiple
tests. Consolidate them into test-lib.sh so we can stop redefining them.
The use of remove_cr() in t0020 to test for a CR is replaced with a new
function has_cr() to accurately reflect what is intended (the output of
remove_cr() was being thrown away).
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-q_to_nul () {
- perl -pe 'y/Q/\000/'
-}
-
-q_to_cr () {
- tr Q '\015'
-}
-
-append_cr () {
- sed -e 's/$/Q/' | tr Q '\015'
-}
-
-remove_cr () {
- tr '\015' Q <"$1" | grep Q >/dev/null &&
- tr '\015' Q <"$1" | sed -ne 's/Q$//p'
+has_cr() {
+ tr '\015' Q <"$1" | grep Q >/dev/null
}
test_expect_success setup '
}
test_expect_success setup '
- remove_cr "$f" >tmp && mv -f tmp $f &&
+ remove_cr <"$f" >tmp && mv -f tmp $f &&
git update-index -- $f || {
echo "Eh? $f"
false
git update-index -- $f || {
echo "Eh? $f"
false
- if remove_cr "$f" >/dev/null
git read-tree --reset -u HEAD &&
git apply patch.file &&
git read-tree --reset -u HEAD &&
git apply patch.file &&
- test "$patched" = "`remove_cr one | git hash-object --stdin`" || {
+ test "$patched" = "`remove_cr <one | git hash-object --stdin`" || {
echo "Eh? apply without index"
false
}
echo "Eh? apply without index"
false
}
git apply --index patch.file &&
test "$patched" = `git rev-parse :one` &&
git apply --index patch.file &&
test "$patched" = `git rev-parse :one` &&
- test "$patched" = "`remove_cr one | git hash-object --stdin`" || {
+ test "$patched" = "`remove_cr <one | git hash-object --stdin`" || {
echo "Eh? apply with --index"
false
}
echo "Eh? apply with --index"
false
}
git config core.autocrlf true &&
git read-tree --reset -u HEAD &&
git config core.autocrlf true &&
git read-tree --reset -u HEAD &&
- if remove_cr dir/two >/dev/null
- if remove_cr one >/dev/null
- if remove_cr three >/dev/null
echo "two crlf=input" >.gitattributes &&
git read-tree --reset -u HEAD &&
echo "two crlf=input" >.gitattributes &&
git read-tree --reset -u HEAD &&
- if remove_cr dir/two >/dev/null
echo "t* crlf" >.gitattributes &&
git read-tree --reset -u HEAD &&
echo "t* crlf" >.gitattributes &&
git read-tree --reset -u HEAD &&
- if remove_cr dir/two >/dev/null
- if remove_cr three >/dev/null
rm -rf tmp one dir .gitattributes patch.file three &&
git read-tree --reset -u HEAD &&
rm -rf tmp one dir .gitattributes patch.file three &&
git read-tree --reset -u HEAD &&
- if remove_cr one >/dev/null
then
echo "Eh? one should not have CRLF"
false
else
: happy
fi &&
then
echo "Eh? one should not have CRLF"
false
else
: happy
fi &&
- remove_cr three >/dev/null || {
echo "Eh? three should still have CRLF"
false
}
echo "Eh? three should still have CRLF"
false
}
git read-tree --reset HEAD &&
git checkout-index -f -q -u -a &&
git read-tree --reset HEAD &&
git checkout-index -f -q -u -a &&
- if remove_cr one >/dev/null
then
echo "Eh? one should not have CRLF"
false
else
: happy
fi &&
then
echo "Eh? one should not have CRLF"
false
else
: happy
fi &&
- remove_cr three >/dev/null || {
echo "Eh? three should still have CRLF"
false
}
echo "Eh? three should still have CRLF"
false
}
git checkout-index -u .gitattributes &&
git checkout-index -u one dir/two three &&
git checkout-index -u .gitattributes &&
git checkout-index -u one dir/two three &&
- if remove_cr one >/dev/null
then
echo "Eh? one should not have CRLF"
false
else
: happy
fi &&
then
echo "Eh? one should not have CRLF"
false
else
: happy
fi &&
- remove_cr three >/dev/null || {
echo "Eh? three should still have CRLF"
false
}
echo "Eh? three should still have CRLF"
false
}
git checkout-index -u one dir/two three &&
git checkout-index -u .gitattributes &&
git checkout-index -u one dir/two three &&
git checkout-index -u .gitattributes &&
- if remove_cr one >/dev/null
then
echo "Eh? one should not have CRLF"
false
else
: happy
fi &&
then
echo "Eh? one should not have CRLF"
false
else
: happy
fi &&
- remove_cr three >/dev/null || {
echo "Eh? three should still have CRLF"
false
}
echo "Eh? three should still have CRLF"
false
}
git checkout master~1 &&
git checkout master &&
git checkout master~1 &&
git checkout master &&
- remove_cr .file2 >/dev/null
-q_to_cr () {
- tr Q '\015'
-}
-
test_expect_success 'Rebase a commit that sprinkles CRs in' '
(
echo "One"
test_expect_success 'Rebase a commit that sprinkles CRs in' '
(
echo "One"
tree1=`git write-tree` &&
test "$tree1" = "$tree0"'
tree1=`git write-tree` &&
test "$tree1" = "$tree0"'
-q_to_nul() {
- perl -pe 'y/Q/\000/'
-}
-
nul_to_q() {
perl -pe 'y/\000/Q/'
}
nul_to_q() {
perl -pe 'y/\000/Q/'
}
-append_cr () {
- sed -e 's/$/Q/' | tr Q '\015'
-}
-
-remove_cr () {
- tr '\015' Q | sed -e 's/Q$//'
-}
-
test_description='merge conflict in crlf repo
b---M
test_description='merge conflict in crlf repo
b---M
-q_to_nul () {
- perl -pe 'y/Q/\000/'
-}
-
-q_to_cr () {
- tr Q '\015'
-}
-
marked_as () {
foundEntry="$(grep "^/$2/" "$1/CVS/Entries")"
if [ x"$foundEntry" = x"" ] ; then
marked_as () {
foundEntry="$(grep "^/$2/" "$1/CVS/Entries")"
if [ x"$foundEntry" = x"" ] ; then
+q_to_nul () {
+ perl -pe 'y/Q/\000/'
+}
+
+q_to_cr () {
+ tr Q '\015'
+}
+
+append_cr () {
+ sed -e 's/$/Q/' | tr Q '\015'
+}
+
+remove_cr () {
+ tr '\015' Q | sed -e 's/Q$//'
+}
+
test_tick () {
if test -z "${test_tick+set}"
then
test_tick () {
if test -z "${test_tick+set}"
then