Merge branch 'ez/doc-duplicated-words-fix'
[alt-git.git] / t / t0027-auto-crlf.sh
blobdeb3ae7813052d01b6dab92586e2c37d313ef8ff
1 #!/bin/sh
3 test_description='CRLF conversion all combinations'
5 . ./test-lib.sh
7 compare_files () {
8 tr '\015\000' QN <"$1" >"$1".expect &&
9 tr '\015\000' QN <"$2" | tr -d 'Z' >"$2".actual &&
10 test_cmp "$1".expect "$2".actual &&
11 rm "$1".expect "$2".actual
14 compare_ws_file () {
15 pfx=$1
16 exp=$2.expect
17 act=$pfx.actual.$3
18 tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" >"$exp" &&
19 tr '\015\000abcdef0123456789' QN00000000000000000 <"$3" >"$act" &&
20 test_cmp "$exp" "$act" &&
21 rm "$exp" "$act"
24 create_gitattributes () {
26 while test "$#" != 0
28 case "$1" in
29 auto) echo '*.txt text=auto' ;;
30 ident) echo '*.txt ident' ;;
31 text) echo '*.txt text' ;;
32 -text) echo '*.txt -text' ;;
33 crlf) echo '*.txt eol=crlf' ;;
34 lf) echo '*.txt eol=lf' ;;
35 "") ;;
37 echo >&2 invalid attribute: "$1"
38 exit 1
40 esac &&
41 shift
42 done
43 } >.gitattributes
46 create_NNO_files () {
47 for crlf in false true input
49 for attr in "" auto text -text
51 for aeol in "" lf crlf
53 pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf}
54 cp CRLF_mix_LF ${pfx}_LF.txt &&
55 cp CRLF_mix_LF ${pfx}_CRLF.txt &&
56 cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt &&
57 cp CRLF_mix_LF ${pfx}_LF_mix_CR.txt &&
58 cp CRLF_mix_LF ${pfx}_CRLF_nul.txt
59 done
60 done
61 done
64 check_warning () {
65 case "$1" in
66 LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;;
67 CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;;
68 '') >"$2".expect ;;
69 *) echo >&2 "Illegal 1": "$1" ; return false ;;
70 esac
71 grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" | uniq >"$2".actual
72 test_i18ncmp "$2".expect "$2".actual
75 commit_check_warn () {
76 crlf=$1
77 attr=$2
78 lfname=$3
79 crlfname=$4
80 lfmixcrlf=$5
81 lfmixcr=$6
82 crlfnul=$7
83 pfx=crlf_${crlf}_attr_${attr}
84 create_gitattributes "$attr" &&
85 for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul
87 fname=${pfx}_$f.txt &&
88 cp $f $fname &&
89 git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
90 done &&
91 git commit -m "core.autocrlf $crlf" &&
92 check_warning "$lfname" ${pfx}_LF.err &&
93 check_warning "$crlfname" ${pfx}_CRLF.err &&
94 check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err &&
95 check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err &&
96 check_warning "$crlfnul" ${pfx}_CRLF_nul.err
99 commit_chk_wrnNNO () {
100 attr=$1 ; shift
101 aeol=$1 ; shift
102 crlf=$1 ; shift
103 lfwarn=$1 ; shift
104 crlfwarn=$1 ; shift
105 lfmixcrlf=$1 ; shift
106 lfmixcr=$1 ; shift
107 crlfnul=$1 ; shift
108 pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf}
109 #Commit files on top of existing file
110 create_gitattributes "$attr" $aeol &&
111 for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
113 fname=${pfx}_$f.txt &&
114 cp $f $fname &&
115 printf Z >>"$fname" &&
116 git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
117 done
119 test_expect_success "commit NNO files crlf=$crlf attr=$attr LF" '
120 check_warning "$lfwarn" ${pfx}_LF.err
122 test_expect_success "commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF" '
123 check_warning "$crlfwarn" ${pfx}_CRLF.err
126 test_expect_success "commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF_mix_LF" '
127 check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
130 test_expect_success "commit NNO files attr=$attr aeol=$aeol crlf=$crlf LF_mix_cr" '
131 check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
134 test_expect_success "commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF_nul" '
135 check_warning "$crlfnul" ${pfx}_CRLF_nul.err
139 stats_ascii () {
140 case "$1" in
142 echo lf
144 CRLF)
145 echo crlf
147 CRLF_mix_LF)
148 echo mixed
150 LF_mix_CR|CRLF_nul|LF_nul|CRLF_mix_CR)
151 echo "-text"
154 echo error_invalid $1
156 esac
161 # contruct the attr/ returned by git ls-files --eol
162 # Take none (=empty), one or two args
163 # convert.c: eol=XX overrides text=auto
164 attr_ascii () {
165 case $1,$2 in
166 -text,*) echo "-text" ;;
167 text,) echo "text" ;;
168 text,lf) echo "text eol=lf" ;;
169 text,crlf) echo "text eol=crlf" ;;
170 auto,) echo "text=auto" ;;
171 auto,lf) echo "text=auto eol=lf" ;;
172 auto,crlf) echo "text=auto eol=crlf" ;;
173 lf,) echo "text eol=lf" ;;
174 crlf,) echo "text eol=crlf" ;;
175 ,) echo "" ;;
176 *) echo invalid_attr "$1,$2" ;;
177 esac
180 check_files_in_repo () {
181 crlf=$1
182 attr=$2
183 lfname=$3
184 crlfname=$4
185 lfmixcrlf=$5
186 lfmixcr=$6
187 crlfnul=$7
188 pfx=crlf_${crlf}_attr_${attr}_ &&
189 compare_files $lfname ${pfx}LF.txt &&
190 compare_files $crlfname ${pfx}CRLF.txt &&
191 compare_files $lfmixcrlf ${pfx}CRLF_mix_LF.txt &&
192 compare_files $lfmixcr ${pfx}LF_mix_CR.txt &&
193 compare_files $crlfnul ${pfx}CRLF_nul.txt
196 check_in_repo_NNO () {
197 attr=$1 ; shift
198 aeol=$1 ; shift
199 crlf=$1 ; shift
200 lfname=$1 ; shift
201 crlfname=$1 ; shift
202 lfmixcrlf=$1 ; shift
203 lfmixcr=$1 ; shift
204 crlfnul=$1 ; shift
205 pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf}
206 test_expect_success "compare_files $lfname ${pfx}_LF.txt" '
207 compare_files $lfname ${pfx}_LF.txt
209 test_expect_success "compare_files $crlfname ${pfx}_CRLF.txt" '
210 compare_files $crlfname ${pfx}_CRLF.txt
212 test_expect_success "compare_files $lfmixcrlf ${pfx}_CRLF_mix_LF.txt" '
213 compare_files $lfmixcrlf ${pfx}_CRLF_mix_LF.txt
215 test_expect_success "compare_files $lfmixcr ${pfx}_LF_mix_CR.txt" '
216 compare_files $lfmixcr ${pfx}_LF_mix_CR.txt
218 test_expect_success "compare_files $crlfnul ${pfx}_CRLF_nul.txt" '
219 compare_files $crlfnul ${pfx}_CRLF_nul.txt
223 checkout_files () {
224 attr=$1 ; shift
225 ident=$1; shift
226 aeol=$1 ; shift
227 crlf=$1 ; shift
228 ceol=$1 ; shift
229 lfname=$1 ; shift
230 crlfname=$1 ; shift
231 lfmixcrlf=$1 ; shift
232 lfmixcr=$1 ; shift
233 crlfnul=$1 ; shift
234 create_gitattributes "$attr" $ident $aeol &&
235 git config core.autocrlf $crlf &&
236 pfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&
237 for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul
239 rm crlf_false_attr__$f.txt &&
240 if test -z "$ceol"; then
241 git checkout crlf_false_attr__$f.txt
242 else
243 git -c core.eol=$ceol checkout crlf_false_attr__$f.txt
245 done
247 test_expect_success "ls-files --eol attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol" '
248 test_when_finished "rm expect actual" &&
249 sort <<-EOF >expect &&
250 i/crlf w/$(stats_ascii $crlfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF.txt
251 i/mixed w/$(stats_ascii $lfmixcrlf) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_mix_LF.txt
252 i/lf w/$(stats_ascii $lfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF.txt
253 i/-text w/$(stats_ascii $lfmixcr) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_mix_CR.txt
254 i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt
255 i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt
257 git ls-files --eol crlf_false_attr__* |
258 sed -e "s/ / /g" -e "s/ */ /g" |
259 sort >actual &&
260 test_cmp expect actual
262 test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF" "
263 compare_ws_file $pfx $lfname crlf_false_attr__LF.txt
265 test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF" "
266 compare_ws_file $pfx $crlfname crlf_false_attr__CRLF.txt
268 test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF" "
269 compare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt
271 test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR" "
272 compare_ws_file $pfx $lfmixcr crlf_false_attr__LF_mix_CR.txt
274 test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul" "
275 compare_ws_file $pfx $crlfnul crlf_false_attr__LF_nul.txt
279 # Test control characters
280 # NUL SOH CR EOF==^Z
281 test_expect_success 'ls-files --eol -o Text/Binary' '
282 test_when_finished "rm expect actual TeBi_*" &&
283 STRT=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA &&
284 STR=$STRT$STRT$STRT$STRT &&
285 printf "${STR}BBB\001" >TeBi_127_S &&
286 printf "${STR}BBBB\001">TeBi_128_S &&
287 printf "${STR}BBB\032" >TeBi_127_E &&
288 printf "\032${STR}BBB" >TeBi_E_127 &&
289 printf "${STR}BBBB\000">TeBi_128_N &&
290 printf "${STR}BBB\012">TeBi_128_L &&
291 printf "${STR}BBB\015">TeBi_127_C &&
292 printf "${STR}BB\015\012" >TeBi_126_CL &&
293 printf "${STR}BB\015\012\015" >TeBi_126_CLC &&
294 sort <<-\EOF >expect &&
295 i/ w/-text TeBi_127_S
296 i/ w/none TeBi_128_S
297 i/ w/none TeBi_127_E
298 i/ w/-text TeBi_E_127
299 i/ w/-text TeBi_128_N
300 i/ w/lf TeBi_128_L
301 i/ w/-text TeBi_127_C
302 i/ w/crlf TeBi_126_CL
303 i/ w/-text TeBi_126_CLC
305 git ls-files --eol -o |
306 sed -n -e "/TeBi_/{s!attr/[ ]*!!g
307 s! ! !g
308 s! *! !g
310 }" | sort >actual &&
311 test_cmp expect actual
314 test_expect_success 'setup master' '
315 echo >.gitattributes &&
316 git checkout -b master &&
317 git add .gitattributes &&
318 git commit -m "add .gitattributes" "" &&
319 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\nLINETHREE" >LF &&
320 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\r\nLINETHREE" >CRLF &&
321 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\r\nLINETWO\nLINETHREE" >CRLF_mix_LF &&
322 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\rLINETHREE" >LF_mix_CR &&
323 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\rLINETHREE" >CRLF_mix_CR &&
324 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONEQ\r\nLINETWO\r\nLINETHREE" | q_to_nul >CRLF_nul &&
325 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONEQ\nLINETWO\nLINETHREE" | q_to_nul >LF_nul &&
326 create_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&
327 git -c core.autocrlf=false add NNO_*.txt &&
328 git commit -m "mixed line endings" &&
329 test_tick
334 warn_LF_CRLF="LF will be replaced by CRLF"
335 warn_CRLF_LF="CRLF will be replaced by LF"
337 # WILC stands for "Warn if (this OS) converts LF into CRLF".
338 # WICL: Warn if CRLF becomes LF
339 # WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF
340 if test_have_prereq NATIVE_CRLF
341 then
342 WILC=LF_CRLF
343 WICL=
344 WAMIX=LF_CRLF
345 else
346 WILC=
347 WICL=CRLF_LF
348 WAMIX=CRLF_LF
351 # attr LF CRLF CRLFmixLF LFmixCR CRLFNUL
352 test_expect_success 'commit files empty attr' '
353 commit_check_warn false "" "" "" "" "" "" &&
354 commit_check_warn true "" "LF_CRLF" "" "LF_CRLF" "" "" &&
355 commit_check_warn input "" "" "CRLF_LF" "CRLF_LF" "" ""
358 test_expect_success 'commit files attr=auto' '
359 commit_check_warn false "auto" "$WILC" "$WICL" "$WAMIX" "" "" &&
360 commit_check_warn true "auto" "LF_CRLF" "" "LF_CRLF" "" "" &&
361 commit_check_warn input "auto" "" "CRLF_LF" "CRLF_LF" "" ""
364 test_expect_success 'commit files attr=text' '
365 commit_check_warn false "text" "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL" &&
366 commit_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
367 commit_check_warn input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
370 test_expect_success 'commit files attr=-text' '
371 commit_check_warn false "-text" "" "" "" "" "" &&
372 commit_check_warn true "-text" "" "" "" "" "" &&
373 commit_check_warn input "-text" "" "" "" "" ""
376 test_expect_success 'commit files attr=lf' '
377 commit_check_warn false "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
378 commit_check_warn true "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
379 commit_check_warn input "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
382 test_expect_success 'commit files attr=crlf' '
383 commit_check_warn false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
384 commit_check_warn true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
385 commit_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
388 # attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
389 commit_chk_wrnNNO "" "" false "" "" "" "" ""
390 commit_chk_wrnNNO "" "" true LF_CRLF "" "" "" ""
391 commit_chk_wrnNNO "" "" input "" "" "" "" ""
393 commit_chk_wrnNNO "auto" "" false "$WILC" "" "" "" ""
394 commit_chk_wrnNNO "auto" "" true LF_CRLF "" "" "" ""
395 commit_chk_wrnNNO "auto" "" input "" "" "" "" ""
396 for crlf in true false input
398 commit_chk_wrnNNO -text "" $crlf "" "" "" "" ""
399 commit_chk_wrnNNO -text lf $crlf "" "" "" "" ""
400 commit_chk_wrnNNO -text crlf $crlf "" "" "" "" ""
401 commit_chk_wrnNNO "" lf $crlf "" CRLF_LF CRLF_LF "" CRLF_LF
402 commit_chk_wrnNNO "" crlf $crlf LF_CRLF "" LF_CRLF LF_CRLF ""
403 commit_chk_wrnNNO auto lf $crlf "" "" "" "" ""
404 commit_chk_wrnNNO auto crlf $crlf LF_CRLF "" "" "" ""
405 commit_chk_wrnNNO text lf $crlf "" CRLF_LF CRLF_LF "" CRLF_LF
406 commit_chk_wrnNNO text crlf $crlf LF_CRLF "" LF_CRLF LF_CRLF ""
407 done
409 commit_chk_wrnNNO "text" "" false "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL"
410 commit_chk_wrnNNO "text" "" true LF_CRLF "" LF_CRLF LF_CRLF ""
411 commit_chk_wrnNNO "text" "" input "" CRLF_LF CRLF_LF "" CRLF_LF
413 test_expect_success 'commit NNO and cleanup' '
414 git commit -m "commit files on top of NNO" &&
415 rm -f *.txt &&
416 git -c core.autocrlf=false reset --hard
419 test_expect_success 'commit empty gitattribues' '
420 check_files_in_repo false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
421 check_files_in_repo true "" LF LF LF LF_mix_CR CRLF_nul &&
422 check_files_in_repo input "" LF LF LF LF_mix_CR CRLF_nul
425 test_expect_success 'commit text=auto' '
426 check_files_in_repo false "auto" LF LF LF LF_mix_CR CRLF_nul &&
427 check_files_in_repo true "auto" LF LF LF LF_mix_CR CRLF_nul &&
428 check_files_in_repo input "auto" LF LF LF LF_mix_CR CRLF_nul
431 test_expect_success 'commit text' '
432 check_files_in_repo false "text" LF LF LF LF_mix_CR LF_nul &&
433 check_files_in_repo true "text" LF LF LF LF_mix_CR LF_nul &&
434 check_files_in_repo input "text" LF LF LF LF_mix_CR LF_nul
437 test_expect_success 'commit -text' '
438 check_files_in_repo false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
439 check_files_in_repo true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
440 check_files_in_repo input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
443 for crlf in true false input
445 # attr aeol LF CRLF CRLF_mix_LF LF_mix_CR CRLFNUL
446 check_in_repo_NNO "" "" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
447 check_in_repo_NNO -text "" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
448 check_in_repo_NNO -text lf $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
449 check_in_repo_NNO -text crlf $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
450 check_in_repo_NNO auto "" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
451 check_in_repo_NNO auto lf $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
452 check_in_repo_NNO auto crlf $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
453 check_in_repo_NNO text "" $crlf LF LF LF LF_mix_CR LF_nul
454 check_in_repo_NNO text lf $crlf LF LF LF LF_mix_CR LF_nul
455 check_in_repo_NNO text crlf $crlf LF LF LF LF_mix_CR LF_nul
456 done
457 ################################################################################
458 # Check how files in the repo are changed when they are checked out
459 # How to read the table below:
460 # - checkout_files will check multiple files with a combination of settings
461 # and attributes (core.autocrlf=input is forbidden with core.eol=crlf)
463 # - parameter $1 : text in .gitattributs "" (empty) | auto | text | -text
464 # - parameter $2 : ident "" | i (i == ident)
465 # - parameter $3 : eol in .gitattributs "" (empty) | lf | crlf
466 # - parameter $4 : core.autocrlf false | true | input
467 # - parameter $5 : core.eol "" | lf | crlf | "native"
468 # - parameter $6 : reference for a file with only LF in the repo
469 # - parameter $7 : reference for a file with only CRLF in the repo
470 # - parameter $8 : reference for a file with mixed LF and CRLF in the repo
471 # - parameter $9 : reference for a file with LF and CR in the repo
472 # - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)
474 if test_have_prereq NATIVE_CRLF
475 then
476 MIX_CRLF_LF=CRLF
477 MIX_LF_CR=CRLF_mix_CR
478 NL=CRLF
479 LFNUL=CRLF_nul
480 else
481 MIX_CRLF_LF=CRLF_mix_LF
482 MIX_LF_CR=LF_mix_CR
483 NL=LF
484 LFNUL=LF_nul
486 export CRLF_MIX_LF_CR MIX NL
488 # Same handling with and without ident
489 for id in "" ident
491 for ceol in lf crlf native
493 for crlf in true false input
495 # -text overrides core.autocrlf and core.eol
496 # text and eol=crlf or eol=lf override core.autocrlf and core.eol
497 checkout_files -text "$id" "" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
498 checkout_files -text "$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
499 checkout_files -text "$id" "crlf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
500 # text
501 checkout_files text "$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
502 checkout_files text "$id" "crlf" "$crlf" "$ceol" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
503 # currently the same as text, eol=XXX
504 checkout_files auto "$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
505 checkout_files auto "$id" "crlf" "$crlf" "$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
506 done
508 # core.autocrlf false, different core.eol
509 checkout_files "" "$id" "" false "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
510 # core.autocrlf true
511 checkout_files "" "$id" "" true "$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
512 # text: core.autocrlf = true overrides core.eol
513 checkout_files auto "$id" "" true "$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
514 checkout_files text "$id" "" true "$ceol" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
515 # text: core.autocrlf = input overrides core.eol
516 checkout_files text "$id" "" input "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
517 checkout_files auto "$id" "" input "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
518 # text=auto + eol=XXX
519 done
520 # text: core.autocrlf=false uses core.eol
521 checkout_files text "$id" "" false crlf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
522 checkout_files text "$id" "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
523 # text: core.autocrlf=false and core.eol unset(or native) uses native eol
524 checkout_files text "$id" "" false "" $NL CRLF $MIX_CRLF_LF $MIX_LF_CR $LFNUL
525 checkout_files text "$id" "" false native $NL CRLF $MIX_CRLF_LF $MIX_LF_CR $LFNUL
526 # auto: core.autocrlf=false and core.eol unset(or native) uses native eol
527 checkout_files auto "$id" "" false "" $NL CRLF CRLF_mix_LF LF_mix_CR LF_nul
528 checkout_files auto "$id" "" false native $NL CRLF CRLF_mix_LF LF_mix_CR LF_nul
529 done
531 # Should be the last test case: remove some files from the worktree
532 test_expect_success 'ls-files --eol -d -z' '
533 rm crlf_false_attr__CRLF.txt crlf_false_attr__CRLF_mix_LF.txt crlf_false_attr__LF.txt .gitattributes &&
534 cat >expect <<-\EOF &&
535 i/crlf w/ crlf_false_attr__CRLF.txt
536 i/lf w/ .gitattributes
537 i/lf w/ crlf_false_attr__LF.txt
538 i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
540 git ls-files --eol -d |
541 sed -e "s!attr/[^ ]*!!g" -e "s/ / /g" -e "s/ */ /g" |
542 sort >actual &&
543 test_cmp expect actual
546 test_done