3 test_description
='CRLF conversion all combinations'
5 TEST_PASSES_SANITIZE_LEAK
=true
9 tr '\015\000' QN
<"$1" >"$1".expect
&&
10 tr '\015\000' QN
<"$2" |
tr -d 'Z' >"$2".actual
&&
11 test_cmp
"$1".expect
"$2".actual
&&
12 rm "$1".expect
"$2".actual
19 tr '\015\000abcdef0123456789' QN00000000000000000
<"$2" |
20 sed -e "s/0000*/$ZERO_OID/" >"$exp" &&
21 tr '\015\000abcdef0123456789' QN00000000000000000
<"$3" |
22 sed -e "s/0000*/$ZERO_OID/" >"$act" &&
23 test_cmp
"$exp" "$act" &&
27 create_gitattributes
() {
32 auto
) echo '*.txt text=auto' ;;
33 ident
) echo '*.txt ident' ;;
34 text
) echo '*.txt text' ;;
35 -text) echo '*.txt -text' ;;
36 crlf
) echo '*.txt eol=crlf' ;;
37 lf
) echo '*.txt eol=lf' ;;
40 echo >&2 invalid attribute
: "$1"
49 # Create 2 sets of files:
50 # The NNO files are "Not NOrmalized in the repo. We use CRLF_mix_LF and store
51 # it under different names for the different test cases, see ${pfx}
52 # Depending on .gitattributes they are normalized at the next commit (or not)
53 # The MIX files have different contents in the repo.
54 # Depending on its contents, the "new safer autocrlf" may kick in.
55 create_NNO_MIX_files
() {
56 for crlf
in false true input
58 for attr
in "" auto text
-text
60 for aeol
in "" lf crlf
62 pfx
=NNO_attr_
${attr}_aeol_${aeol}_${crlf} &&
63 cp CRLF_mix_LF
${pfx}_LF.txt
&&
64 cp CRLF_mix_LF
${pfx}_CRLF.txt
&&
65 cp CRLF_mix_LF
${pfx}_CRLF_mix_LF.txt
&&
66 cp CRLF_mix_LF
${pfx}_LF_mix_CR.txt
&&
67 cp CRLF_mix_LF
${pfx}_CRLF_nul.txt
&&
68 pfx
=MIX_attr_
${attr}_aeol_${aeol}_${crlf} &&
69 cp LF
${pfx}_LF.txt
&&
70 cp CRLF
${pfx}_CRLF.txt
&&
71 cp CRLF_mix_LF
${pfx}_CRLF_mix_LF.txt
&&
72 cp LF_mix_CR
${pfx}_LF_mix_CR.txt
&&
73 cp CRLF_nul
${pfx}_CRLF_nul.txt
81 LF_CRLF
) echo "LF will be replaced by CRLF" >"$2".expect
;;
82 CRLF_LF
) echo "CRLF will be replaced by LF" >"$2".expect
;;
84 *) echo >&2 "Illegal 1": "$1" ; return false
;;
86 sed -e "s/^.* \([^ ]* will be replaced by [^ ]*\) .*$/\1/" "$2" |
uniq >"$2".actual
87 test_cmp
"$2".expect
"$2".actual
90 commit_check_warn
() {
98 pfx
=crlf_
${crlf}_attr_
${attr}
99 create_gitattributes
"$attr" &&
100 for f
in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul
102 fname
=${pfx}_
$f.txt
&&
104 git
-c core.autocrlf
=$crlf add
$fname 2>"${pfx}_$f.err"
106 git commit
-m "core.autocrlf $crlf" &&
107 check_warning
"$lfname" ${pfx}_LF.err
&&
108 check_warning
"$crlfname" ${pfx}_CRLF.err
&&
109 check_warning
"$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
&&
110 check_warning
"$lfmixcr" ${pfx}_LF_mix_CR.err
&&
111 check_warning
"$crlfnul" ${pfx}_CRLF_nul.err
114 commit_chk_wrnNNO
() {
123 pfx
=NNO_attr_
${attr}_aeol_${aeol}_${crlf}
124 #Commit files on top of existing file
125 create_gitattributes
"$attr" $aeol &&
126 for f
in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
128 fname
=${pfx}_
$f.txt
&&
130 printf Z
>>"$fname" &&
131 git
-c core.autocrlf
=$crlf add
$fname 2>"${pfx}_$f.err"
134 test_expect_success
"commit NNO files crlf=$crlf attr=$attr LF" '
135 check_warning "$lfwarn" ${pfx}_LF.err
137 test_expect_success
"commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF" '
138 check_warning "$crlfwarn" ${pfx}_CRLF.err
141 test_expect_success
"commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF_mix_LF" '
142 check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
145 test_expect_success
"commit NNO files attr=$attr aeol=$aeol crlf=$crlf LF_mix_cr" '
146 check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
149 test_expect_success
"commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF_nul" '
150 check_warning "$crlfnul" ${pfx}_CRLF_nul.err
154 # Commit a file with mixed line endings on top of different files
155 # in the index. Check for warnings
156 commit_MIX_chkwrn
() {
165 pfx
=MIX_attr_
${attr}_aeol_${aeol}_${crlf}
166 #Commit file with CLRF_mix_LF on top of existing file
167 create_gitattributes
"$attr" $aeol &&
168 for f
in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
170 fname
=${pfx}_
$f.txt
&&
171 cp CRLF_mix_LF
$fname &&
172 printf Z
>>"$fname" &&
173 git
-c core.autocrlf
=$crlf add
$fname 2>"${pfx}_$f.err"
176 test_expect_success
"commit file with mixed EOL onto LF crlf=$crlf attr=$attr" '
177 check_warning "$lfwarn" ${pfx}_LF.err
179 test_expect_success
"commit file with mixed EOL onto CLRF attr=$attr aeol=$aeol crlf=$crlf" '
180 check_warning "$crlfwarn" ${pfx}_CRLF.err
183 test_expect_success
"commit file with mixed EOL onto CRLF_mix_LF attr=$attr aeol=$aeol crlf=$crlf" '
184 check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
187 test_expect_success
"commit file with mixed EOL onto LF_mix_cr attr=$attr aeol=$aeol crlf=$crlf " '
188 check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
191 test_expect_success
"commit file with mixed EOL onto CRLF_nul attr=$attr aeol=$aeol crlf=$crlf" '
192 check_warning "$crlfnul" ${pfx}_CRLF_nul.err
208 LF_mix_CR|CRLF_nul|LF_nul|CRLF_mix_CR
)
212 echo error_invalid
$1
219 # construct the attr/ returned by git ls-files --eol
220 # Take none (=empty), one or two args
221 # convert.c: eol=XX overrides text=auto
224 -text,*) echo "-text" ;;
225 text
,) echo "text" ;;
226 text
,lf
) echo "text eol=lf" ;;
227 text
,crlf
) echo "text eol=crlf" ;;
228 auto
,) echo "text=auto" ;;
229 auto
,lf
) echo "text=auto eol=lf" ;;
230 auto
,crlf
) echo "text=auto eol=crlf" ;;
231 lf
,) echo "text eol=lf" ;;
232 crlf
,) echo "text eol=crlf" ;;
234 *) echo invalid_attr
"$1,$2" ;;
238 check_files_in_repo
() {
246 pfx
=crlf_
${crlf}_attr_
${attr}_
&&
247 compare_files
$lfname ${pfx}LF.txt
&&
248 compare_files
$crlfname ${pfx}CRLF.txt
&&
249 compare_files
$lfmixcrlf ${pfx}CRLF_mix_LF.txt
&&
250 compare_files
$lfmixcr ${pfx}LF_mix_CR.txt
&&
251 compare_files
$crlfnul ${pfx}CRLF_nul.txt
254 check_in_repo_NNO
() {
263 pfx
=NNO_attr_
${attr}_aeol_${aeol}_${crlf}
264 test_expect_success
"compare_files $lfname ${pfx}_LF.txt" '
265 compare_files $lfname ${pfx}_LF.txt
267 test_expect_success
"compare_files $crlfname ${pfx}_CRLF.txt" '
268 compare_files $crlfname ${pfx}_CRLF.txt
270 test_expect_success
"compare_files $lfmixcrlf ${pfx}_CRLF_mix_LF.txt" '
271 compare_files $lfmixcrlf ${pfx}_CRLF_mix_LF.txt
273 test_expect_success
"compare_files $lfmixcr ${pfx}_LF_mix_CR.txt" '
274 compare_files $lfmixcr ${pfx}_LF_mix_CR.txt
276 test_expect_success
"compare_files $crlfnul ${pfx}_CRLF_nul.txt" '
277 compare_files $crlfnul ${pfx}_CRLF_nul.txt
292 create_gitattributes
"$attr" $ident $aeol &&
293 git config core.autocrlf
$crlf &&
294 pfx
=eol_
${ceol}_crlf_${crlf}_attr_${attr}_
&&
295 for f
in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul
297 rm crlf_false_attr__
$f.txt
&&
298 if test -z "$ceol"; then
299 git checkout
-- crlf_false_attr__
$f.txt
301 git
-c core.eol
=$ceol checkout
-- crlf_false_attr__
$f.txt
305 test_expect_success
"ls-files --eol attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol" '
306 test_when_finished "rm expect actual" &&
307 sort <<-EOF >expect &&
308 i/crlf w/$(stats_ascii $crlfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF.txt
309 i/mixed w/$(stats_ascii $lfmixcrlf) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_mix_LF.txt
310 i/lf w/$(stats_ascii $lfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF.txt
311 i/-text w/$(stats_ascii $lfmixcr) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_mix_CR.txt
312 i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt
313 i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt
315 git ls-files --eol crlf_false_attr__* >tmp &&
316 sed -e "s/ / /g" -e "s/ */ /g" tmp |
318 test_cmp expect actual
320 test_expect_success
"checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF" "
321 compare_ws_file $pfx $lfname crlf_false_attr__LF.txt
323 test_expect_success
"checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF" "
324 compare_ws_file $pfx $crlfname crlf_false_attr__CRLF.txt
326 test_expect_success
"checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF" "
327 compare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt
329 test_expect_success
"checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR" "
330 compare_ws_file $pfx $lfmixcr crlf_false_attr__LF_mix_CR.txt
332 test_expect_success
"checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul" "
333 compare_ws_file $pfx $crlfnul crlf_false_attr__LF_nul.txt
337 # Test control characters
339 test_expect_success
'ls-files --eol -o Text/Binary' '
340 test_when_finished "rm expect actual TeBi_*" &&
341 STRT=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA &&
342 STR=$STRT$STRT$STRT$STRT &&
343 printf "${STR}BBB\001" >TeBi_127_S &&
344 printf "${STR}BBBB\001">TeBi_128_S &&
345 printf "${STR}BBB\032" >TeBi_127_E &&
346 printf "\032${STR}BBB" >TeBi_E_127 &&
347 printf "${STR}BBBB\000">TeBi_128_N &&
348 printf "${STR}BBB\012">TeBi_128_L &&
349 printf "${STR}BBB\015">TeBi_127_C &&
350 printf "${STR}BB\015\012" >TeBi_126_CL &&
351 printf "${STR}BB\015\012\015" >TeBi_126_CLC &&
352 sort <<-\EOF >expect &&
353 i/ w/-text TeBi_127_S
356 i/ w/-text TeBi_E_127
357 i/ w/-text TeBi_128_N
359 i/ w/-text TeBi_127_C
360 i/ w/crlf TeBi_126_CL
361 i/ w/-text TeBi_126_CLC
363 git ls-files --eol -o >tmp &&
364 sed -n -e "/TeBi_/{s!attr/[ ]*!!g
368 }" tmp | sort >actual &&
369 test_cmp expect actual
372 test_expect_success
'setup main' '
373 echo >.gitattributes &&
374 git checkout -b main &&
375 git add .gitattributes &&
376 git commit -m "add .gitattributes" . &&
377 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\nLINETHREE" >LF &&
378 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\r\nLINETHREE" >CRLF &&
379 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\r\nLINETWO\nLINETHREE" >CRLF_mix_LF &&
380 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\rLINETHREE" >LF_mix_CR &&
381 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\rLINETHREE" >CRLF_mix_CR &&
382 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONEQ\r\nLINETWO\r\nLINETHREE" | q_to_nul >CRLF_nul &&
383 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONEQ\nLINETWO\nLINETHREE" | q_to_nul >LF_nul &&
384 create_NNO_MIX_files &&
385 git -c core.autocrlf=false add NNO_*.txt MIX_*.txt &&
386 git commit -m "mixed line endings" &&
390 # Disable extra chain-linting for the next set of tests. There are many
391 # auto-generated ones that are not worth checking over and over.
392 GIT_TEST_CHAIN_LINT_HARDER_DEFAULT
=0
394 warn_LF_CRLF
="LF will be replaced by CRLF"
395 warn_CRLF_LF
="CRLF will be replaced by LF"
397 # WILC stands for "Warn if (this OS) converts LF into CRLF".
398 # WICL: Warn if CRLF becomes LF
399 # WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF
400 if test_have_prereq NATIVE_CRLF
411 # attr LF CRLF CRLFmixLF LFmixCR CRLFNUL
412 test_expect_success
'commit files empty attr' '
413 commit_check_warn false "" "" "" "" "" "" &&
414 commit_check_warn true "" "LF_CRLF" "" "LF_CRLF" "" "" &&
415 commit_check_warn input "" "" "CRLF_LF" "CRLF_LF" "" ""
418 test_expect_success
'commit files attr=auto' '
419 commit_check_warn false "auto" "$WILC" "$WICL" "$WAMIX" "" "" &&
420 commit_check_warn true "auto" "LF_CRLF" "" "LF_CRLF" "" "" &&
421 commit_check_warn input "auto" "" "CRLF_LF" "CRLF_LF" "" ""
424 test_expect_success
'commit files attr=text' '
425 commit_check_warn false "text" "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL" &&
426 commit_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
427 commit_check_warn input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
430 test_expect_success
'commit files attr=-text' '
431 commit_check_warn false "-text" "" "" "" "" "" &&
432 commit_check_warn true "-text" "" "" "" "" "" &&
433 commit_check_warn input "-text" "" "" "" "" ""
436 test_expect_success
'commit files attr=lf' '
437 commit_check_warn false "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
438 commit_check_warn true "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
439 commit_check_warn input "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
442 test_expect_success
'commit files attr=crlf' '
443 commit_check_warn false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
444 commit_check_warn true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
445 commit_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
448 # Commit "CRLFmixLF" on top of these files already in the repo:
449 # mixed mixed mixed mixed mixed
450 # onto onto onto onto onto
451 # attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
452 commit_MIX_chkwrn
"" "" false
"" "" "" "" ""
453 commit_MIX_chkwrn
"" "" true
"LF_CRLF" "" "" "LF_CRLF" "LF_CRLF"
454 commit_MIX_chkwrn
"" "" input
"CRLF_LF" "" "" "CRLF_LF" "CRLF_LF"
456 commit_MIX_chkwrn
"auto" "" false
"$WAMIX" "" "" "$WAMIX" "$WAMIX"
457 commit_MIX_chkwrn
"auto" "" true
"LF_CRLF" "" "" "LF_CRLF" "LF_CRLF"
458 commit_MIX_chkwrn
"auto" "" input
"CRLF_LF" "" "" "CRLF_LF" "CRLF_LF"
460 # attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
461 commit_chk_wrnNNO
"" "" false
"" "" "" "" ""
462 commit_chk_wrnNNO
"" "" true LF_CRLF
"" "" "" ""
463 commit_chk_wrnNNO
"" "" input
"" "" "" "" ""
465 commit_chk_wrnNNO
"auto" "" false
"$WILC" "" "" "" ""
466 commit_chk_wrnNNO
"auto" "" true LF_CRLF
"" "" "" ""
467 commit_chk_wrnNNO
"auto" "" input
"" "" "" "" ""
468 for crlf
in true false input
470 commit_chk_wrnNNO
-text "" $crlf "" "" "" "" ""
471 commit_chk_wrnNNO
-text lf
$crlf "" "" "" "" ""
472 commit_chk_wrnNNO
-text crlf
$crlf "" "" "" "" ""
473 commit_chk_wrnNNO
"" lf
$crlf "" CRLF_LF CRLF_LF
"" CRLF_LF
474 commit_chk_wrnNNO
"" crlf
$crlf LF_CRLF
"" LF_CRLF LF_CRLF
""
475 commit_chk_wrnNNO auto lf
$crlf "" "" "" "" ""
476 commit_chk_wrnNNO auto crlf
$crlf LF_CRLF
"" "" "" ""
477 commit_chk_wrnNNO text lf
$crlf "" CRLF_LF CRLF_LF
"" CRLF_LF
478 commit_chk_wrnNNO text crlf
$crlf LF_CRLF
"" LF_CRLF LF_CRLF
""
481 commit_chk_wrnNNO
"text" "" false
"$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL"
482 commit_chk_wrnNNO
"text" "" true LF_CRLF
"" LF_CRLF LF_CRLF
""
483 commit_chk_wrnNNO
"text" "" input
"" CRLF_LF CRLF_LF
"" CRLF_LF
485 test_expect_success
'commit NNO and cleanup' '
486 git commit -m "commit files on top of NNO" &&
488 git -c core.autocrlf=false reset --hard
491 test_expect_success
'commit empty gitattribues' '
492 check_files_in_repo false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
493 check_files_in_repo true "" LF LF LF LF_mix_CR CRLF_nul &&
494 check_files_in_repo input "" LF LF LF LF_mix_CR CRLF_nul
497 test_expect_success
'commit text=auto' '
498 check_files_in_repo false "auto" LF LF LF LF_mix_CR CRLF_nul &&
499 check_files_in_repo true "auto" LF LF LF LF_mix_CR CRLF_nul &&
500 check_files_in_repo input "auto" LF LF LF LF_mix_CR CRLF_nul
503 test_expect_success
'commit text' '
504 check_files_in_repo false "text" LF LF LF LF_mix_CR LF_nul &&
505 check_files_in_repo true "text" LF LF LF LF_mix_CR LF_nul &&
506 check_files_in_repo input "text" LF LF LF LF_mix_CR LF_nul
509 test_expect_success
'commit -text' '
510 check_files_in_repo false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
511 check_files_in_repo true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
512 check_files_in_repo input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
515 for crlf
in true false input
517 # attr aeol LF CRLF CRLF_mix_LF LF_mix_CR CRLFNUL
518 check_in_repo_NNO
"" "" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
519 check_in_repo_NNO
-text "" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
520 check_in_repo_NNO
-text lf
$crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
521 check_in_repo_NNO
-text crlf
$crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
522 check_in_repo_NNO auto
"" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
523 check_in_repo_NNO auto lf
$crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
524 check_in_repo_NNO auto crlf
$crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
525 check_in_repo_NNO text
"" $crlf LF LF LF LF_mix_CR LF_nul
526 check_in_repo_NNO text lf
$crlf LF LF LF LF_mix_CR LF_nul
527 check_in_repo_NNO text crlf
$crlf LF LF LF LF_mix_CR LF_nul
529 ################################################################################
530 # Check how files in the repo are changed when they are checked out
531 # How to read the table below:
532 # - checkout_files will check multiple files with a combination of settings
533 # and attributes (core.autocrlf=input is forbidden with core.eol=crlf)
535 # - parameter $1 : text in .gitattributs "" (empty) | auto | text | -text
536 # - parameter $2 : ident "" | i (i == ident)
537 # - parameter $3 : eol in .gitattributs "" (empty) | lf | crlf
538 # - parameter $4 : core.autocrlf false | true | input
539 # - parameter $5 : core.eol "" | lf | crlf | "native"
540 # - parameter $6 : reference for a file with only LF in the repo
541 # - parameter $7 : reference for a file with only CRLF in the repo
542 # - parameter $8 : reference for a file with mixed LF and CRLF in the repo
543 # - parameter $9 : reference for a file with LF and CR in the repo
544 # - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)
546 if test_have_prereq NATIVE_CRLF
549 MIX_LF_CR
=CRLF_mix_CR
553 MIX_CRLF_LF
=CRLF_mix_LF
558 export CRLF_MIX_LF_CR MIX NL
560 # Same handling with and without ident
563 for ceol
in lf crlf native
565 for crlf
in true false input
567 # -text overrides core.autocrlf and core.eol
568 # text and eol=crlf or eol=lf override core.autocrlf and core.eol
569 checkout_files
-text "$id" "" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
570 checkout_files
-text "$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
571 checkout_files
-text "$id" "crlf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
573 checkout_files text
"$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
574 checkout_files text
"$id" "crlf" "$crlf" "$ceol" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
575 # currently the same as text, eol=XXX
576 checkout_files auto
"$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
577 checkout_files auto
"$id" "crlf" "$crlf" "$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
580 # core.autocrlf false, different core.eol
581 checkout_files
"" "$id" "" false
"$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
583 checkout_files
"" "$id" "" true
"$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
584 # text: core.autocrlf = true overrides core.eol
585 checkout_files auto
"$id" "" true
"$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
586 checkout_files text
"$id" "" true
"$ceol" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
587 # text: core.autocrlf = input overrides core.eol
588 checkout_files text
"$id" "" input
"$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
589 checkout_files auto
"$id" "" input
"$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
590 # text=auto + eol=XXX
592 # text: core.autocrlf=false uses core.eol
593 checkout_files text
"$id" "" false crlf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
594 checkout_files text
"$id" "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
595 # text: core.autocrlf=false and core.eol unset(or native) uses native eol
596 checkout_files text
"$id" "" false
"" $NL CRLF
$MIX_CRLF_LF $MIX_LF_CR $LFNUL
597 checkout_files text
"$id" "" false native
$NL CRLF
$MIX_CRLF_LF $MIX_LF_CR $LFNUL
598 # auto: core.autocrlf=false and core.eol unset(or native) uses native eol
599 checkout_files auto
"$id" "" false
"" $NL CRLF CRLF_mix_LF LF_mix_CR LF_nul
600 checkout_files auto
"$id" "" false native
$NL CRLF CRLF_mix_LF LF_mix_CR LF_nul
601 # core.autocrlf false, .gitattributes sets eol
602 checkout_files
"" "$id" "lf" false
"" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
603 checkout_files
"" "$id" "crlf" false
"" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
604 # core.autocrlf true, .gitattributes sets eol
605 checkout_files
"" "$id" "lf" true
"" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
606 checkout_files
"" "$id" "crlf" true
"" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
609 # The rest of the tests are unique; do the usual linting.
610 unset GIT_TEST_CHAIN_LINT_HARDER_DEFAULT
612 # Should be the last test case: remove some files from the worktree
613 test_expect_success
'ls-files --eol -d -z' '
614 rm crlf_false_attr__CRLF.txt crlf_false_attr__CRLF_mix_LF.txt crlf_false_attr__LF.txt .gitattributes &&
615 cat >expect <<-\EOF &&
616 i/crlf w/ crlf_false_attr__CRLF.txt
617 i/lf w/ .gitattributes
618 i/lf w/ crlf_false_attr__LF.txt
619 i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
621 git ls-files --eol -d >tmp &&
622 sed -e "s!attr/[^ ]*!!g" -e "s/ / /g" -e "s/ */ /g" tmp |
624 test_cmp expect actual