Merge branch 'some-CR-fixes'

This branch contains some hacks so that Git produces less CR, and then
some tests.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Stepan Kasal
2014-05-15 09:44:08 +02:00
8 changed files with 76 additions and 28 deletions

View File

@@ -1477,6 +1477,9 @@ ifdef NO_REGEX
COMPAT_CFLAGS += -Icompat/regex
COMPAT_OBJS += compat/regex/regex.o
endif
ifdef NATIVE_CRLF
BASIC_CFLAGS += -DNATIVE_CRLF
endif
ifdef USE_NED_ALLOCATOR
COMPAT_CFLAGS += -Icompat/nedmalloc

View File

@@ -182,7 +182,9 @@ It does not apply to blobs recorded in its index.")"
}
clean_abort () {
test $# = 0 || echo >&2 "$@"
test $# = 0 || cat >&2 <<EOF
$@
EOF
rm -fr "$dotest"
exit 1
}

View File

@@ -71,7 +71,9 @@ do
case "$LF$common$LF" in
*"$LF$SHA1$LF"*)
echo "Already up-to-date with $pretty_name"
cat << EOF
Already up-to-date with $pretty_name
EOF
continue
;;
esac
@@ -83,7 +85,9 @@ do
# tree as the intermediate result of the merge.
# We still need to count this as part of the parent set.
echo "Fast-forwarding to: $pretty_name"
cat << EOF
Fast-forwarding to: $pretty_name
EOF
git read-tree -u -m $head $SHA1 || exit
MRC=$SHA1 MRT=$(git write-tree)
continue
@@ -91,7 +95,9 @@ do
NON_FF_MERGE=1
echo "Trying simple merge with $pretty_name"
cat << EOF
Trying simple merge with $pretty_name
EOF
git read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2
next=$(git write-tree 2>/dev/null)
if test $? -ne 0

View File

@@ -59,7 +59,9 @@ GIT_QUIET=
say () {
if test -z "$GIT_QUIET"
then
printf '%s\n' "$*"
cat <<EOF
$*
EOF
fi
}

View File

@@ -428,9 +428,11 @@ cmd_add()
if test -z "$force" && ! git add --dry-run --ignore-missing "$sm_path" > /dev/null 2>&1
then
eval_gettextln "The following path is ignored by one of your .gitignore files:
\$sm_path
Use -f if you really want to add it." >&2
cat >&2 <<EOF
The following path is ignored by one of your .gitignore files:
$(eval_gettextln $sm_path)
Use -f if you really want to add it.
EOF
exit 1
fi

View File

@@ -80,4 +80,22 @@ test_expect_success 'autocrlf=true overrides unset eol' '
test -z "$onediff" -a -z "$twodiff"
'
test_expect_success NATIVE_CRLF 'eol native is crlf' '
rm -rf native_eol && mkdir native_eol &&
( cd native_eol &&
printf "*.txt text\n" > .gitattributes
printf "one\r\ntwo\r\nthree\r\n" > filedos.txt
printf "one\ntwo\nthree\n" > fileunix.txt
git init &&
git config core.autocrlf false &&
git config core.eol native &&
git add filedos.txt fileunix.txt &&
git commit -m "first" &&
rm file*.txt &&
git reset --hard HEAD &&
has_cr filedos.txt && has_cr fileunix.txt
)
'
test_done

View File

@@ -72,6 +72,10 @@ test_expect_success 'Merge after setting text=auto' '
same line
EOF
if test_have_prereq NATIVE_CRLF; then
append_cr <expected >expected.temp &&
mv expected.temp expected
fi &&
git config merge.renormalize true &&
git rm -fr . &&
rm -f .gitattributes &&
@@ -86,6 +90,10 @@ test_expect_success 'Merge addition of text=auto' '
same line
EOF
if test_have_prereq NATIVE_CRLF; then
append_cr <expected >expected.temp &&
mv expected.temp expected
fi &&
git config merge.renormalize true &&
git rm -fr . &&
rm -f .gitattributes &&
@@ -95,16 +103,19 @@ test_expect_success 'Merge addition of text=auto' '
'
test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
q_to_cr <<-\EOF >expected &&
<<<<<<<
first line
same line
=======
first lineQ
same lineQ
>>>>>>>
EOF
echo "<<<<<<<" >expected &&
if test_have_prereq NATIVE_CRLF; then
echo first line | append_cr >>expected &&
echo same line | append_cr >>expected &&
echo ======= | append_cr >>expected
else
echo first line >>expected &&
echo same line >>expected &&
echo ======= >>expected
fi &&
echo first line | append_cr >>expected &&
echo same line | append_cr >>expected &&
echo ">>>>>>>" >>expected &&
git config merge.renormalize false &&
rm -f .gitattributes &&
git reset --hard a &&
@@ -114,16 +125,19 @@ test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
'
test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
q_to_cr <<-\EOF >expected &&
<<<<<<<
first lineQ
same lineQ
=======
first line
same line
>>>>>>>
EOF
echo "<<<<<<<" >expected &&
echo first line | append_cr >>expected &&
echo same line | append_cr >>expected &&
if test_have_prereq NATIVE_CRLF; then
echo ======= | append_cr >>expected &&
echo first line | append_cr >>expected &&
echo same line | append_cr >>expected
else
echo ======= >>expected &&
echo first line >>expected &&
echo same line >>expected
fi &&
echo ">>>>>>>" >>expected &&
git config merge.renormalize false &&
rm -f .gitattributes &&
git reset --hard b &&

View File

@@ -750,6 +750,7 @@ case $(uname -s) in
# exec does not inherit the PID
test_set_prereq MINGW
test_set_prereq NOT_CYGWIN
test_set_prereq NATIVE_CRLF
test_set_prereq SED_STRIPS_CR
test_set_prereq GREP_STRIPS_CR
GIT_TEST_CMP=mingw_test_cmp