9fe539b13d2d6df2e416438fcfe3f9116ccc996c
1#!/bin/sh
2
3test_description='CRLF conversion all combinations'
4
5. ./test-lib.sh
6
7if ! test_have_prereq EXPENSIVE
8then
9 skip_all="EXPENSIVE not set"
10 test_done
11fi
12
13compare_files () {
14 tr '\015\000' QN <"$1" >"$1".expect &&
15 tr '\015\000' QN <"$2" | tr -d 'Z' >"$2".actual &&
16 test_cmp "$1".expect "$2".actual &&
17 rm "$1".expect "$2".actual
18}
19
20compare_ws_file () {
21 pfx=$1
22 exp=$2.expect
23 act=$pfx.actual.$3
24 tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" >"$exp" &&
25 tr '\015\000abcdef0123456789' QN00000000000000000 <"$3" >"$act" &&
26 test_cmp "$exp" "$act" &&
27 rm "$exp" "$act"
28}
29
30create_gitattributes () {
31 {
32 while test "$#" != 0
33 do
34 case "$1" in
35 auto) echo '*.txt text=auto' ;;
36 ident) echo '*.txt ident' ;;
37 text) echo '*.txt text' ;;
38 -text) echo '*.txt -text' ;;
39 crlf) echo '*.txt eol=crlf' ;;
40 lf) echo '*.txt eol=lf' ;;
41 "") ;;
42 *)
43 echo >&2 invalid attribute: "$1"
44 exit 1
45 ;;
46 esac &&
47 shift
48 done
49 } >.gitattributes
50}
51
52create_NNO_files () {
53 for crlf in false true input
54 do
55 for attr in "" auto text -text lf crlf
56 do
57 pfx=NNO_${crlf}_attr_${attr} &&
58 cp CRLF_mix_LF ${pfx}_LF.txt &&
59 cp CRLF_mix_LF ${pfx}_CRLF.txt &&
60 cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt &&
61 cp CRLF_mix_LF ${pfx}_LF_mix_CR.txt &&
62 cp CRLF_mix_LF ${pfx}_CRLF_nul.txt
63 done
64 done
65}
66
67check_warning () {
68 case "$1" in
69 LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;;
70 CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;;
71 '') >"$2".expect ;;
72 *) echo >&2 "Illegal 1": "$1" ; return false ;;
73 esac
74 grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" | uniq >"$2".actual
75 test_cmp "$2".expect "$2".actual
76}
77
78commit_check_warn () {
79 crlf=$1
80 attr=$2
81 lfname=$3
82 crlfname=$4
83 lfmixcrlf=$5
84 lfmixcr=$6
85 crlfnul=$7
86 pfx=crlf_${crlf}_attr_${attr}
87 create_gitattributes "$attr" &&
88 for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul
89 do
90 fname=${pfx}_$f.txt &&
91 cp $f $fname &&
92 git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
93 done &&
94 git commit -m "core.autocrlf $crlf" &&
95 check_warning "$lfname" ${pfx}_LF.err &&
96 check_warning "$crlfname" ${pfx}_CRLF.err &&
97 check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err &&
98 check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err &&
99 check_warning "$crlfnul" ${pfx}_CRLF_nul.err
100}
101
102commit_chk_wrnNNO () {
103 crlf=$1
104 attr=$2
105 lfwarn=$3
106 crlfwarn=$4
107 lfmixcrlf=$5
108 lfmixcr=$6
109 crlfnul=$7
110 pfx=NNO_${crlf}_attr_${attr}
111 #Commit files on top of existing file
112 create_gitattributes "$attr" &&
113 for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
114 do
115 fname=${pfx}_$f.txt &&
116 cp $f $fname &&
117 printf Z >>"$fname" &&
118 git -c core.autocrlf=$crlf add $fname 2>/dev/null &&
119 git -c core.autocrlf=$crlf commit -m "commit_$fname" $fname >"${pfx}_$f.err" 2>&1
120 done
121
122 test_expect_success "commit NNO files crlf=$crlf attr=$attr LF" '
123 check_warning "$lfwarn" ${pfx}_LF.err
124 '
125 test_expect_success "commit NNO files crlf=$crlf attr=$attr CRLF" '
126 check_warning "$crlfwarn" ${pfx}_CRLF.err
127 '
128
129 test_expect_success "commit NNO files crlf=$crlf attr=$attr CRLF_mix_LF" '
130 check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
131 '
132
133 test_expect_success "commit NNO files crlf=$crlf attr=$attr LF_mix_cr" '
134 check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
135 '
136
137 test_expect_success "commit NNO files crlf=$crlf attr=$attr CRLF_nul" '
138 check_warning "$crlfnul" ${pfx}_CRLF_nul.err
139 '
140}
141
142stats_ascii () {
143 case "$1" in
144 LF)
145 echo lf
146 ;;
147 CRLF)
148 echo crlf
149 ;;
150 CRLF_mix_LF)
151 echo mixed
152 ;;
153 LF_mix_CR|CRLF_nul|LF_nul|CRLF_mix_CR)
154 echo "-text"
155 ;;
156 *)
157 echo error_invalid $1
158 ;;
159 esac
160
161}
162
163
164# contruct the attr/ returned by git ls-files --eol
165# Take none (=empty), one or two args
166attr_ascii () {
167 case $1,$2 in
168 -text,*) echo "-text" ;;
169 text,) echo "text" ;;
170 text,lf) echo "text eol=lf" ;;
171 text,crlf) echo "text eol=crlf" ;;
172 auto,) echo "text=auto" ;;
173 auto,lf) echo "text=auto eol=lf" ;;
174 auto,crlf) echo "text=auto eol=crlf" ;;
175 lf,) echo "text eol=lf" ;;
176 crlf,) echo "text eol=crlf" ;;
177 ,) echo "" ;;
178 *) echo invalid_attr "$1,$2" ;;
179 esac
180}
181
182check_files_in_repo () {
183 crlf=$1
184 attr=$2
185 lfname=$3
186 crlfname=$4
187 lfmixcrlf=$5
188 lfmixcr=$6
189 crlfnul=$7
190 pfx=crlf_${crlf}_attr_${attr}_ &&
191 compare_files $lfname ${pfx}LF.txt &&
192 compare_files $crlfname ${pfx}CRLF.txt &&
193 compare_files $lfmixcrlf ${pfx}CRLF_mix_LF.txt &&
194 compare_files $lfmixcr ${pfx}LF_mix_CR.txt &&
195 compare_files $crlfnul ${pfx}CRLF_nul.txt
196}
197
198check_in_repo_NNO () {
199 crlf=$1
200 attr=$2
201 lfname=$3
202 crlfname=$4
203 lfmixcrlf=$5
204 lfmixcr=$6
205 crlfnul=$7
206 pfx=NNO_${crlf}_attr_${attr}_
207 test_expect_success "compare_files $lfname ${pfx}LF.txt" '
208 compare_files $lfname ${pfx}LF.txt
209 '
210 test_expect_success "compare_files $crlfname ${pfx}CRLF.txt" '
211 compare_files $crlfname ${pfx}CRLF.txt
212 '
213 test_expect_success "compare_files $lfmixcrlf ${pfx}CRLF_mix_LF.txt" '
214 compare_files $lfmixcrlf ${pfx}CRLF_mix_LF.txt
215 '
216 test_expect_success "compare_files $lfmixcr ${pfx}LF_mix_CR.txt" '
217 compare_files $lfmixcr ${pfx}LF_mix_CR.txt
218 '
219 test_expect_success "compare_files $crlfnul ${pfx}CRLF_nul.txt" '
220 compare_files $crlfnul ${pfx}CRLF_nul.txt
221 '
222}
223
224checkout_files () {
225 attr=$1 ; shift
226 ident=$1; shift
227 aeol=$1 ; shift
228 crlf=$1 ; shift
229 ceol=$1 ; shift
230 lfname=$1 ; shift
231 crlfname=$1 ; shift
232 lfmixcrlf=$1 ; shift
233 lfmixcr=$1 ; shift
234 crlfnul=$1 ; shift
235 create_gitattributes "$attr" "$ident" &&
236 git config core.autocrlf $crlf &&
237 pfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&
238 for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul
239 do
240 rm crlf_false_attr__$f.txt &&
241 if test -z "$ceol"; then
242 git checkout crlf_false_attr__$f.txt
243 else
244 git -c core.eol=$ceol checkout crlf_false_attr__$f.txt
245 fi
246 done
247
248 test_expect_success "ls-files --eol attr=$attr $ident $aeol core.autocrlf=$crlf core.eol=$ceol" '
249 test_when_finished "rm expect actual" &&
250 sort <<-EOF >expect &&
251 i/crlf w/$(stats_ascii $crlfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF.txt
252 i/mixed w/$(stats_ascii $lfmixcrlf) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_mix_LF.txt
253 i/lf w/$(stats_ascii $lfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF.txt
254 i/-text w/$(stats_ascii $lfmixcr) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_mix_CR.txt
255 i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt
256 i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt
257 EOF
258 git ls-files --eol crlf_false_attr__* |
259 sed -e "s/ / /g" -e "s/ */ /g" |
260 sort >actual &&
261 test_cmp expect actual
262 '
263 test_expect_success "checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF" "
264 compare_ws_file $pfx $lfname crlf_false_attr__LF.txt
265 "
266 test_expect_success "checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF" "
267 compare_ws_file $pfx $crlfname crlf_false_attr__CRLF.txt
268 "
269 test_expect_success "checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF" "
270 compare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt
271 "
272 test_expect_success "checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR" "
273 compare_ws_file $pfx $lfmixcr crlf_false_attr__LF_mix_CR.txt
274 "
275 test_expect_success "checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul" "
276 compare_ws_file $pfx $crlfnul crlf_false_attr__LF_nul.txt
277 "
278}
279
280# Test control characters
281# NUL SOH CR EOF==^Z
282test_expect_success 'ls-files --eol -o Text/Binary' '
283 test_when_finished "rm expect actual TeBi_*" &&
284 STRT=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA &&
285 STR=$STRT$STRT$STRT$STRT &&
286 printf "${STR}BBB\001" >TeBi_127_S &&
287 printf "${STR}BBBB\001">TeBi_128_S &&
288 printf "${STR}BBB\032" >TeBi_127_E &&
289 printf "\032${STR}BBB" >TeBi_E_127 &&
290 printf "${STR}BBBB\000">TeBi_128_N &&
291 printf "${STR}BBB\012">TeBi_128_L &&
292 printf "${STR}BBB\015">TeBi_127_C &&
293 printf "${STR}BB\015\012" >TeBi_126_CL &&
294 printf "${STR}BB\015\012\015" >TeBi_126_CLC &&
295 sort <<-\EOF >expect &&
296 i/ w/-text TeBi_127_S
297 i/ w/none TeBi_128_S
298 i/ w/none TeBi_127_E
299 i/ w/-text TeBi_E_127
300 i/ w/-text TeBi_128_N
301 i/ w/lf TeBi_128_L
302 i/ w/-text TeBi_127_C
303 i/ w/crlf TeBi_126_CL
304 i/ w/-text TeBi_126_CLC
305 EOF
306 git ls-files --eol -o |
307 sed -n -e "/TeBi_/{s!attr/[ ]*!!g
308 s! ! !g
309 s! *! !g
310 p
311 }" | sort >actual &&
312 test_cmp expect actual
313'
314
315test_expect_success 'setup master' '
316 echo >.gitattributes &&
317 git checkout -b master &&
318 git add .gitattributes &&
319 git commit -m "add .gitattributes" "" &&
320 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\nLINETHREE" >LF &&
321 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\r\nLINETHREE" >CRLF &&
322 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\r\nLINETWO\nLINETHREE" >CRLF_mix_LF &&
323 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\rLINETHREE" >LF_mix_CR &&
324 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\rLINETHREE" >CRLF_mix_CR &&
325 printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONEQ\r\nLINETWO\r\nLINETHREE" | q_to_nul >CRLF_nul &&
326 printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONEQ\nLINETWO\nLINETHREE" | q_to_nul >LF_nul &&
327 create_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&
328 git -c core.autocrlf=false add NNO_*.txt &&
329 git commit -m "mixed line endings" &&
330 test_tick
331'
332
333
334
335warn_LF_CRLF="LF will be replaced by CRLF"
336warn_CRLF_LF="CRLF will be replaced by LF"
337
338# WILC stands for "Warn if (this OS) converts LF into CRLF".
339# WICL: Warn if CRLF becomes LF
340# WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF
341if test_have_prereq NATIVE_CRLF
342then
343 WILC=LF_CRLF
344 WICL=
345 WAMIX=LF_CRLF
346else
347 WILC=
348 WICL=CRLF_LF
349 WAMIX=CRLF_LF
350fi
351
352# attr LF CRLF CRLFmixLF LFmixCR CRLFNUL
353test_expect_success 'commit files empty attr' '
354 commit_check_warn false "" "" "" "" "" "" &&
355 commit_check_warn true "" "LF_CRLF" "" "LF_CRLF" "" "" &&
356 commit_check_warn input "" "" "CRLF_LF" "CRLF_LF" "" ""
357'
358
359test_expect_success 'commit files attr=auto' '
360 commit_check_warn false "auto" "$WILC" "$WICL" "$WAMIX" "" "" &&
361 commit_check_warn true "auto" "LF_CRLF" "" "LF_CRLF" "" "" &&
362 commit_check_warn input "auto" "" "CRLF_LF" "CRLF_LF" "" ""
363'
364
365test_expect_success 'commit files attr=text' '
366 commit_check_warn false "text" "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL" &&
367 commit_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
368 commit_check_warn input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
369'
370
371test_expect_success 'commit files attr=-text' '
372 commit_check_warn false "-text" "" "" "" "" "" &&
373 commit_check_warn true "-text" "" "" "" "" "" &&
374 commit_check_warn input "-text" "" "" "" "" ""
375'
376
377test_expect_success 'commit files attr=lf' '
378 commit_check_warn false "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
379 commit_check_warn true "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
380 commit_check_warn input "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
381'
382
383test_expect_success 'commit files attr=crlf' '
384 commit_check_warn false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
385 commit_check_warn true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
386 commit_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
387'
388
389# attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
390commit_chk_wrnNNO false "" "" "" "" "" ""
391commit_chk_wrnNNO true "" "LF_CRLF" "" "" "" ""
392commit_chk_wrnNNO input "" "" "" "" "" ""
393
394
395commit_chk_wrnNNO false "auto" "$WILC" "$WICL" "$WAMIX" "" ""
396commit_chk_wrnNNO true "auto" "LF_CRLF" "" "LF_CRLF" "" ""
397commit_chk_wrnNNO input "auto" "" "CRLF_LF" "CRLF_LF" "" ""
398
399commit_chk_wrnNNO false "text" "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL"
400commit_chk_wrnNNO true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
401commit_chk_wrnNNO input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
402
403commit_chk_wrnNNO false "-text" "" "" "" "" ""
404commit_chk_wrnNNO true "-text" "" "" "" "" ""
405commit_chk_wrnNNO input "-text" "" "" "" "" ""
406
407commit_chk_wrnNNO false "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
408commit_chk_wrnNNO true "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
409commit_chk_wrnNNO input "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
410
411commit_chk_wrnNNO false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
412commit_chk_wrnNNO true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
413commit_chk_wrnNNO input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
414
415test_expect_success 'create files cleanup' '
416 rm -f *.txt &&
417 git -c core.autocrlf=false reset --hard
418'
419
420test_expect_success 'commit empty gitattribues' '
421 check_files_in_repo false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
422 check_files_in_repo true "" LF LF LF LF_mix_CR CRLF_nul &&
423 check_files_in_repo input "" LF LF LF LF_mix_CR CRLF_nul
424'
425
426test_expect_success 'commit text=auto' '
427 check_files_in_repo false "auto" LF LF LF LF_mix_CR CRLF_nul &&
428 check_files_in_repo true "auto" LF LF LF LF_mix_CR CRLF_nul &&
429 check_files_in_repo input "auto" LF LF LF LF_mix_CR CRLF_nul
430'
431
432test_expect_success 'commit text' '
433 check_files_in_repo false "text" LF LF LF LF_mix_CR LF_nul &&
434 check_files_in_repo true "text" LF LF LF LF_mix_CR LF_nul &&
435 check_files_in_repo input "text" LF LF LF LF_mix_CR LF_nul
436'
437
438test_expect_success 'commit -text' '
439 check_files_in_repo false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
440 check_files_in_repo true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
441 check_files_in_repo input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
442'
443
444# attr LF CRLF CRLF_mix_LF LF_mix_CR CRLFNUL
445check_in_repo_NNO false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
446check_in_repo_NNO true "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
447check_in_repo_NNO input "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
448
449check_in_repo_NNO false "auto" LF LF LF LF_mix_CR CRLF_nul
450check_in_repo_NNO true "auto" LF LF LF LF_mix_CR CRLF_nul
451check_in_repo_NNO input "auto" LF LF LF LF_mix_CR CRLF_nul
452
453check_in_repo_NNO false "text" LF LF LF LF_mix_CR LF_nul
454check_in_repo_NNO true "text" LF LF LF LF_mix_CR LF_nul
455check_in_repo_NNO input "text" LF LF LF LF_mix_CR LF_nul
456
457check_in_repo_NNO false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
458check_in_repo_NNO true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
459check_in_repo_NNO input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
460
461
462################################################################################
463# Check how files in the repo are changed when they are checked out
464# How to read the table below:
465# - checkout_files will check multiple files with a combination of settings
466# and attributes (core.autocrlf=input is forbidden with core.eol=crlf)
467#
468# - parameter $1 : text in .gitattributs "" (empty) | auto | text | -text
469# - parameter $2 : ident "" | i (i == ident)
470# - parameter $3 : eol in .gitattributs "" (empty) | lf | crlf
471# - parameter $4 : core.autocrlf false | true | input
472# - parameter $5 : core.eol "" | lf | crlf | "native"
473# - parameter $6 : reference for a file with only LF in the repo
474# - parameter $7 : reference for a file with only CRLF in the repo
475# - parameter $8 : reference for a file with mixed LF and CRLF in the repo
476# - parameter $9 : reference for a file with LF and CR in the repo
477# - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)
478
479if test_have_prereq NATIVE_CRLF
480then
481MIX_CRLF_LF=CRLF
482MIX_LF_CR=CRLF_mix_CR
483NL=CRLF
484LFNUL=CRLF_nul
485else
486MIX_CRLF_LF=CRLF_mix_LF
487MIX_LF_CR=LF_mix_CR
488NL=LF
489LFNUL=LF_nul
490fi
491export CRLF_MIX_LF_CR MIX NL
492
493checkout_files "" "" "" false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
494checkout_files "" "" "" false crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
495checkout_files "" "" "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
496checkout_files "" "" "" false native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
497checkout_files "" "" "" input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
498checkout_files "" "" "" input lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
499checkout_files "" "" "" true "" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
500checkout_files "" "" "" true crlf CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
501checkout_files "" "" "" true lf CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
502checkout_files "" "" "" true native CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
503checkout_files "" ident "" false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
504checkout_files "" ident "" false crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
505checkout_files "" ident "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
506checkout_files "" ident "" false native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
507checkout_files "" ident "" input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
508checkout_files "" ident "" input lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
509checkout_files "" ident "" true "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
510checkout_files "" ident "" true crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
511checkout_files "" ident "" true lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
512checkout_files "" ident "" true native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
513checkout_files "auto" "" "" false "" $NL CRLF $MIX_CRLF_LF LF_mix_CR LF_nul
514checkout_files "auto" "" "" false crlf CRLF CRLF CRLF LF_mix_CR LF_nul
515checkout_files "auto" "" "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
516checkout_files "auto" "" "" false native $NL CRLF $MIX_CRLF_LF LF_mix_CR LF_nul
517checkout_files "auto" "" "" input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
518checkout_files "auto" "" "" input lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
519checkout_files "auto" "" "" true "" CRLF CRLF CRLF LF_mix_CR LF_nul
520checkout_files "auto" "" "" true crlf CRLF CRLF CRLF LF_mix_CR LF_nul
521checkout_files "auto" "" "" true lf CRLF CRLF CRLF LF_mix_CR LF_nul
522checkout_files "auto" "" "" true native CRLF CRLF CRLF LF_mix_CR LF_nul
523checkout_files "auto" ident "" false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
524checkout_files "auto" ident "" false crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
525checkout_files "auto" ident "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
526checkout_files "auto" ident "" false native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
527checkout_files "auto" ident "" input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
528checkout_files "auto" ident "" input lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
529checkout_files "auto" ident "" true "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
530checkout_files "auto" ident "" true crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
531checkout_files "auto" ident "" true lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
532checkout_files "auto" ident "" true native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
533
534for id in "" ident;
535do
536 checkout_files "crlf" "$id" "" false "" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
537 checkout_files "crlf" "$id" "" false crlf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
538 checkout_files "crlf" "$id" "" false lf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
539 checkout_files "crlf" "$id" "" false native CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
540 checkout_files "crlf" "$id" "" input "" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
541 checkout_files "crlf" "$id" "" input lf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
542 checkout_files "crlf" "$id" "" true "" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
543 checkout_files "crlf" "$id" "" true crlf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
544 checkout_files "crlf" "$id" "" true lf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
545 checkout_files "crlf" "$id" "" true native CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
546 checkout_files "lf" "$id" "" false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
547 checkout_files "lf" "$id" "" false crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
548 checkout_files "lf" "$id" "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
549 checkout_files "lf" "$id" "" false native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
550 checkout_files "lf" "$id" "" input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
551 checkout_files "lf" "$id" "" input lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
552 checkout_files "lf" "$id" "" true "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
553 checkout_files "lf" "$id" "" true crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
554 checkout_files "lf" "$id" "" true lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
555 checkout_files "lf" "$id" "" true native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
556 checkout_files "text" "$id" "" false "" $NL CRLF $MIX_CRLF_LF $MIX_LF_CR $LFNUL
557 checkout_files "text" "$id" "" false crlf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
558 checkout_files "text" "$id" "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
559 checkout_files "text" "$id" "" false native $NL CRLF $MIX_CRLF_LF $MIX_LF_CR $LFNUL
560 checkout_files "text" "$id" "" input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
561 checkout_files "text" "$id" "" input lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
562 checkout_files "text" "$id" "" true "" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
563 checkout_files "text" "$id" "" true crlf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
564 checkout_files "text" "$id" "" true lf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
565 checkout_files "text" "$id" "" true native CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
566 checkout_files "-text" "$id" "" false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
567 checkout_files "-text" "$id" "" false crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
568 checkout_files "-text" "$id" "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
569 checkout_files "-text" "$id" "" false native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
570 checkout_files "-text" "$id" "" input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
571 checkout_files "-text" "$id" "" input lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
572 checkout_files "-text" "$id" "" true "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
573 checkout_files "-text" "$id" "" true crlf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
574 checkout_files "-text" "$id" "" true lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
575 checkout_files "-text" "$id" "" true native LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
576done
577
578# Should be the last test case: remove some files from the worktree
579test_expect_success 'ls-files --eol -d -z' '
580 rm crlf_false_attr__CRLF.txt crlf_false_attr__CRLF_mix_LF.txt crlf_false_attr__LF.txt .gitattributes &&
581 cat >expect <<-\EOF &&
582 i/crlf w/ crlf_false_attr__CRLF.txt
583 i/lf w/ .gitattributes
584 i/lf w/ crlf_false_attr__LF.txt
585 i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
586 EOF
587 git ls-files --eol -d |
588 sed -e "s!attr/[^ ]*!!g" -e "s/ / /g" -e "s/ */ /g" |
589 sort >actual &&
590 test_cmp expect actual
591'
592
593test_done