3 test_description='CRLF conversion'
8 tr '\015' Q <"$1" | grep Q >/dev/null
11 test_expect_success setup '
13 git config core.autocrlf false &&
15 for w in Hello world how are you; do echo $w; done >one &&
16 for w in I am very very fine thank you; do echo ${w}Q; done | q_to_cr >two &&
17 for w in Oh here is a QNUL byte how alarming; do echo ${w}; done | q_to_nul >three &&
20 git commit -m initial &&
22 one=`git rev-parse HEAD:one` &&
23 two=`git rev-parse HEAD:two` &&
24 three=`git rev-parse HEAD:three` &&
29 test_expect_success 'default settings cause no changes' '
31 rm -f .gitattributes tmp one two three &&
32 git read-tree --reset -u HEAD &&
36 onediff=`git diff one` &&
37 twodiff=`git diff two` &&
38 threediff=`git diff three` &&
39 test -z "$onediff" -a -z "$twodiff" -a -z "$threediff"
42 test_expect_success 'crlf=true causes a CRLF file to be normalized' '
44 # Backwards compatibility check
45 rm -f .gitattributes tmp one two three &&
46 echo "two crlf" > .gitattributes &&
47 git read-tree --reset -u HEAD &&
49 # Note, "normalized" means that git will normalize it if added
51 twodiff=`git diff two` &&
55 test_expect_success 'text=true causes a CRLF file to be normalized' '
57 rm -f .gitattributes tmp one two three &&
58 echo "two text" > .gitattributes &&
59 git read-tree --reset -u HEAD &&
61 # Note, "normalized" means that git will normalize it if added
63 twodiff=`git diff two` &&
67 test_expect_success 'eol=crlf gives a normalized file CRLFs with autocrlf=false' '
69 rm -f .gitattributes tmp one two three &&
70 git config core.autocrlf false &&
71 echo "one eol=crlf" > .gitattributes &&
72 git read-tree --reset -u HEAD &&
75 onediff=`git diff one` &&
79 test_expect_success 'eol=crlf gives a normalized file CRLFs with autocrlf=input' '
81 rm -f .gitattributes tmp one two three &&
82 git config core.autocrlf input &&
83 echo "one eol=crlf" > .gitattributes &&
84 git read-tree --reset -u HEAD &&
87 onediff=`git diff one` &&
91 test_expect_success 'eol=lf gives a normalized file LFs with autocrlf=true' '
93 rm -f .gitattributes tmp one two three &&
94 git config core.autocrlf true &&
95 echo "one eol=lf" > .gitattributes &&
96 git read-tree --reset -u HEAD &&
99 onediff=`git diff one` &&
103 test_expect_success 'autocrlf=true does not normalize CRLF files' '
105 rm -f .gitattributes tmp one two three &&
106 git config core.autocrlf true &&
107 git read-tree --reset -u HEAD &&
111 onediff=`git diff one` &&
112 twodiff=`git diff two` &&
113 threediff=`git diff three` &&
114 test -z "$onediff" -a -z "$twodiff" -a -z "$threediff"
117 test_expect_success 'text=auto, autocrlf=true _does_ normalize CRLF files' '
119 rm -f .gitattributes tmp one two three &&
120 git config core.autocrlf true &&
121 echo "* text=auto" > .gitattributes &&
122 git read-tree --reset -u HEAD &&
126 onediff=`git diff one` &&
127 twodiff=`git diff two` &&
128 threediff=`git diff three` &&
129 test -z "$onediff" -a -n "$twodiff" -a -z "$threediff"
132 test_expect_success 'text=auto, autocrlf=true does not normalize binary files' '
134 rm -f .gitattributes tmp one two three &&
135 git config core.autocrlf true &&
136 echo "* text=auto" > .gitattributes &&
137 git read-tree --reset -u HEAD &&
140 threediff=`git diff three` &&
144 test_expect_success 'eol=crlf _does_ normalize binary files' '
146 rm -f .gitattributes tmp one two three &&
147 echo "three eol=crlf" > .gitattributes &&
148 git read-tree --reset -u HEAD &&
151 threediff=`git diff three` &&