3 test_description
='CRLF conversion'
8 sed -e 's/$/Q/' |
tr Q
'\015'
12 tr '\015' Q
<"$1" |
grep Q
>/dev
/null
&&
13 tr '\015' Q
<"$1" |
sed -ne 's/Q$//p'
16 test_expect_success setup
'
18 git repo-config core.autocrlf false &&
20 for w in Hello world how are you; do echo $w; done >one &&
22 for w in I am very very fine thank you; do echo $w; done >dir/two &&
25 git commit -m initial &&
27 one=`git rev-parse HEAD:one` &&
28 dir=`git rev-parse HEAD:dir` &&
29 two=`git rev-parse HEAD:dir/two` &&
31 for w in Some extra lines here; do echo $w; done >>one &&
32 git diff >patch.file &&
33 patched=`git hash-object --stdin <one` &&
34 git read-tree --reset -u HEAD &&
39 test_expect_success
'update with autocrlf=input' '
41 rm -f tmp one dir/two &&
42 git read-tree --reset -u HEAD &&
43 git repo-config core.autocrlf input &&
47 append_cr <$f >tmp && mv -f tmp $f &&
48 git update-index -- $f || {
55 differs=`git diff-index --cached HEAD` &&
56 test -z "$differs" || {
63 test_expect_success
'update with autocrlf=true' '
65 rm -f tmp one dir/two &&
66 git read-tree --reset -u HEAD &&
67 git repo-config core.autocrlf true &&
71 append_cr <$f >tmp && mv -f tmp $f &&
72 git update-index -- $f || {
79 differs=`git diff-index --cached HEAD` &&
80 test -z "$differs" || {
87 test_expect_success
'checkout with autocrlf=true' '
89 rm -f tmp one dir/two &&
90 git repo-config core.autocrlf true &&
91 git read-tree --reset -u HEAD &&
95 remove_cr "$f" >tmp && mv -f tmp $f &&
96 git update-index -- $f || {
102 test "$one" = `git hash-object --stdin <one` &&
103 test "$two" = `git hash-object --stdin <dir/two` &&
104 differs=`git diff-index --cached HEAD` &&
105 test -z "$differs" || {
111 test_expect_success
'checkout with autocrlf=input' '
113 rm -f tmp one dir/two &&
114 git repo-config core.autocrlf input &&
115 git read-tree --reset -u HEAD &&
119 if remove_cr "$f" >/dev/null
125 git update-index -- $f
128 test "$one" = `git hash-object --stdin <one` &&
129 test "$two" = `git hash-object --stdin <dir/two` &&
130 differs=`git diff-index --cached HEAD` &&
131 test -z "$differs" || {
137 test_expect_success
'apply patch (autocrlf=input)' '
139 rm -f tmp one dir/two &&
140 git repo-config core.autocrlf input &&
141 git read-tree --reset -u HEAD &&
143 git apply patch.file &&
144 test "$patched" = "`git hash-object --stdin <one`" || {
145 echo "Eh? apply without index"
150 test_expect_success
'apply patch --cached (autocrlf=input)' '
152 rm -f tmp one dir/two &&
153 git repo-config core.autocrlf input &&
154 git read-tree --reset -u HEAD &&
156 git apply --cached patch.file &&
157 test "$patched" = `git rev-parse :one` || {
158 echo "Eh? apply with --cached"
163 test_expect_success
'apply patch --index (autocrlf=input)' '
165 rm -f tmp one dir/two &&
166 git repo-config core.autocrlf input &&
167 git read-tree --reset -u HEAD &&
169 git apply --index patch.file &&
170 test "$patched" = `git rev-parse :one` &&
171 test "$patched" = `git hash-object --stdin <one` || {
172 echo "Eh? apply with --index"
177 test_expect_success
'apply patch (autocrlf=true)' '
179 rm -f tmp one dir/two &&
180 git repo-config core.autocrlf true &&
181 git read-tree --reset -u HEAD &&
183 git apply patch.file &&
184 test "$patched" = "`remove_cr one | git hash-object --stdin`" || {
185 echo "Eh? apply without index"
190 test_expect_success
'apply patch --cached (autocrlf=true)' '
192 rm -f tmp one dir/two &&
193 git repo-config core.autocrlf true &&
194 git read-tree --reset -u HEAD &&
196 git apply --cached patch.file &&
197 test "$patched" = `git rev-parse :one` || {
198 echo "Eh? apply without index"
203 test_expect_success
'apply patch --index (autocrlf=true)' '
205 rm -f tmp one dir/two &&
206 git repo-config core.autocrlf true &&
207 git read-tree --reset -u HEAD &&
209 git apply --index patch.file &&
210 test "$patched" = `git rev-parse :one` &&
211 test "$patched" = "`remove_cr one | git hash-object --stdin`" || {
212 echo "Eh? apply with --index"