Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 3e39b72

Browse files
committed
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>
2 parents f7a9918 + 14b4175 commit 3e39b72

File tree

8 files changed

+76
-28
lines changed

8 files changed

+76
-28
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,9 @@ ifdef NO_REGEX
14771477
COMPAT_CFLAGS += -Icompat/regex
14781478
COMPAT_OBJS += compat/regex/regex.o
14791479
endif
1480+
ifdef NATIVE_CRLF
1481+
BASIC_CFLAGS += -DNATIVE_CRLF
1482+
endif
14801483

14811484
ifdef USE_NED_ALLOCATOR
14821485
COMPAT_CFLAGS += -Icompat/nedmalloc

git-am.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ It does not apply to blobs recorded in its index.")"
184184
}
185185

186186
clean_abort () {
187-
test $# = 0 || echo >&2 "$@"
187+
test $# = 0 || cat >&2 <<EOF
188+
$@
189+
EOF
188190
rm -fr "$dotest"
189191
exit 1
190192
}

git-merge-octopus.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ do
7171

7272
case "$LF$common$LF" in
7373
*"$LF$SHA1$LF"*)
74-
echo "Already up-to-date with $pretty_name"
74+
cat << EOF
75+
Already up-to-date with $pretty_name
76+
EOF
7577
continue
7678
;;
7779
esac
@@ -83,15 +85,19 @@ do
8385
# tree as the intermediate result of the merge.
8486
# We still need to count this as part of the parent set.
8587

86-
echo "Fast-forwarding to: $pretty_name"
88+
cat << EOF
89+
Fast-forwarding to: $pretty_name
90+
EOF
8791
git read-tree -u -m $head $SHA1 || exit
8892
MRC=$SHA1 MRT=$(git write-tree)
8993
continue
9094
fi
9195

9296
NON_FF_MERGE=1
9397

94-
echo "Trying simple merge with $pretty_name"
98+
cat << EOF
99+
Trying simple merge with $pretty_name
100+
EOF
95101
git read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2
96102
next=$(git write-tree 2>/dev/null)
97103
if test $? -ne 0

git-sh-setup.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ GIT_QUIET=
5959
say () {
6060
if test -z "$GIT_QUIET"
6161
then
62-
printf '%s\n' "$*"
62+
cat <<EOF
63+
$*
64+
EOF
6365
fi
6466
}
6567

git-submodule.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,11 @@ cmd_add()
434434

435435
if test -z "$force" && ! git add --dry-run --ignore-missing "$sm_path" > /dev/null 2>&1
436436
then
437-
eval_gettextln "The following path is ignored by one of your .gitignore files:
438-
\$sm_path
439-
Use -f if you really want to add it." >&2
437+
cat >&2 <<EOF
438+
The following path is ignored by one of your .gitignore files:
439+
$(eval_gettextln $sm_path)
440+
Use -f if you really want to add it.
441+
EOF
440442
exit 1
441443
fi
442444

t/t0026-eol-config.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,22 @@ test_expect_success 'autocrlf=true overrides unset eol' '
8080
test -z "$onediff" && test -z "$twodiff"
8181
'
8282

83+
test_expect_success NATIVE_CRLF 'eol native is crlf' '
84+
85+
rm -rf native_eol && mkdir native_eol &&
86+
( cd native_eol &&
87+
printf "*.txt text\n" > .gitattributes
88+
printf "one\r\ntwo\r\nthree\r\n" > filedos.txt
89+
printf "one\ntwo\nthree\n" > fileunix.txt
90+
git init &&
91+
git config core.autocrlf false &&
92+
git config core.eol native &&
93+
git add filedos.txt fileunix.txt &&
94+
git commit -m "first" &&
95+
rm file*.txt &&
96+
git reset --hard HEAD &&
97+
has_cr filedos.txt && has_cr fileunix.txt
98+
)
99+
'
100+
83101
test_done

t/t6038-merge-text-auto.sh

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ test_expect_success 'Merge after setting text=auto' '
7272
same line
7373
EOF
7474
75+
if test_have_prereq NATIVE_CRLF; then
76+
append_cr <expected >expected.temp &&
77+
mv expected.temp expected
78+
fi &&
7579
git config merge.renormalize true &&
7680
git rm -fr . &&
7781
rm -f .gitattributes &&
@@ -86,6 +90,10 @@ test_expect_success 'Merge addition of text=auto' '
8690
same line
8791
EOF
8892
93+
if test_have_prereq NATIVE_CRLF; then
94+
append_cr <expected >expected.temp &&
95+
mv expected.temp expected
96+
fi &&
8997
git config merge.renormalize true &&
9098
git rm -fr . &&
9199
rm -f .gitattributes &&
@@ -95,16 +103,19 @@ test_expect_success 'Merge addition of text=auto' '
95103
'
96104

97105
test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
98-
q_to_cr <<-\EOF >expected &&
99-
<<<<<<<
100-
first line
101-
same line
102-
=======
103-
first lineQ
104-
same lineQ
105-
>>>>>>>
106-
EOF
107-
106+
echo "<<<<<<<" >expected &&
107+
if test_have_prereq NATIVE_CRLF; then
108+
echo first line | append_cr >>expected &&
109+
echo same line | append_cr >>expected &&
110+
echo ======= | append_cr >>expected
111+
else
112+
echo first line >>expected &&
113+
echo same line >>expected &&
114+
echo ======= >>expected
115+
fi &&
116+
echo first line | append_cr >>expected &&
117+
echo same line | append_cr >>expected &&
118+
echo ">>>>>>>" >>expected &&
108119
git config merge.renormalize false &&
109120
rm -f .gitattributes &&
110121
git reset --hard a &&
@@ -114,16 +125,19 @@ test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
114125
'
115126

116127
test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
117-
q_to_cr <<-\EOF >expected &&
118-
<<<<<<<
119-
first lineQ
120-
same lineQ
121-
=======
122-
first line
123-
same line
124-
>>>>>>>
125-
EOF
126-
128+
echo "<<<<<<<" >expected &&
129+
echo first line | append_cr >>expected &&
130+
echo same line | append_cr >>expected &&
131+
if test_have_prereq NATIVE_CRLF; then
132+
echo ======= | append_cr >>expected &&
133+
echo first line | append_cr >>expected &&
134+
echo same line | append_cr >>expected
135+
else
136+
echo ======= >>expected &&
137+
echo first line >>expected &&
138+
echo same line >>expected
139+
fi &&
140+
echo ">>>>>>>" >>expected &&
127141
git config merge.renormalize false &&
128142
rm -f .gitattributes &&
129143
git reset --hard b &&

t/test-lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ case $(uname -s) in
871871
# exec does not inherit the PID
872872
test_set_prereq MINGW
873873
test_set_prereq NOT_CYGWIN
874+
test_set_prereq NATIVE_CRLF
874875
test_set_prereq SED_STRIPS_CR
875876
test_set_prereq GREP_STRIPS_CR
876877
GIT_TEST_CMP=mingw_test_cmp

0 commit comments

Comments
 (0)