3 test_description
='CRLF conversion'
8 tr '\015' Q
<"$1" |
grep Q
>/dev
/null
11 # core.eol crlf and core.autocrlf input are not permitted.
12 # this lets us check for the core.eol native being crlf.
13 set_native_eol_prereq
() {
14 rm -rf eol
&& mkdir eol
&&
17 git config core.autocrlf input
&&
18 git config core.eol native
&&
19 git var core.eol
2> /dev
/null
21 test_set_prereq NATIVE_EOL_IS_CRLF
25 test_expect_success setup
'
27 git config core.autocrlf false &&
29 echo "one text" > .gitattributes &&
31 for w in Hello world how are you; do echo $w; done >one &&
32 for w in I am very very fine thank you; do echo $w; done >two &&
35 git commit -m initial &&
37 one=`git rev-parse HEAD:one` &&
38 two=`git rev-parse HEAD:two` &&
43 test_expect_success
'eol=lf puts LFs in normalized file' '
45 rm -f .gitattributes tmp one two &&
46 git config core.eol lf &&
47 git read-tree --reset -u HEAD &&
51 onediff=`git diff one` &&
52 twodiff=`git diff two` &&
53 test -z "$onediff" -a -z "$twodiff"
56 test_expect_success
'eol=crlf puts CRLFs in normalized file' '
58 rm -f .gitattributes tmp one two &&
59 git config core.eol crlf &&
60 git read-tree --reset -u HEAD &&
64 onediff=`git diff one` &&
65 twodiff=`git diff two` &&
66 test -z "$onediff" -a -z "$twodiff"
69 test_expect_success
'autocrlf=true overrides eol=lf' '
71 rm -f .gitattributes tmp one two &&
72 git config core.eol lf &&
73 git config core.autocrlf true &&
74 git read-tree --reset -u HEAD &&
78 onediff=`git diff one` &&
79 twodiff=`git diff two` &&
80 test -z "$onediff" -a -z "$twodiff"
83 test_expect_success
'autocrlf=true overrides unset eol' '
85 rm -f .gitattributes tmp one two &&
86 git config --unset-all core.eol &&
87 git config core.autocrlf true &&
88 git read-tree --reset -u HEAD &&
92 onediff=`git diff one` &&
93 twodiff=`git diff two` &&
94 test -z "$onediff" -a -z "$twodiff"
97 test_expect_success NATIVE_EOL_IS_CRLF
'eol native is crlf' '
99 rm -rf native_eol && mkdir native_eol &&
101 printf "*.txt text\n" > .gitattributes
102 printf "one\r\ntwo\r\nthree\r\n" > filedos.txt
103 printf "one\ntwo\nthree\n" > fileunix.txt
105 git config core.autocrlf false &&
106 git config core.eol native &&
107 git add filedos.txt fileunix.txt &&
108 git commit -m "first" &&
110 git reset --hard HEAD &&
111 has_cr filedos.txt && has_cr fileunix.txt