43
} >.gitattributes
44
}
45
46
-create_NNO_files () {
46
+# Create 2 sets of files:
47
+# The NNO files are "Not NOrmalized in the repo. We use CRLF_mix_LF and store
48
+# it under different names for the different test cases, see ${pfx}
49
+# Depending on .gitattributes they are normalized at the next commit (or not)
50
+# The MIX files have different contents in the repo.
51
+# Depending on its contents, the "new safer autocrlf" may kick in.
52
+create_NNO_MIX_files () {
53
for crlf in false true input
54
do
55
for attr in "" auto text -text
56
do
57
for aeol in "" lf crlf
58
do
53
- pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf}
59
+ pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf} &&
60
cp CRLF_mix_LF ${pfx}_LF.txt &&
61
cp CRLF_mix_LF ${pfx}_CRLF.txt &&
62
cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt &&
63
cp CRLF_mix_LF ${pfx}_LF_mix_CR.txt &&
58
- cp CRLF_mix_LF ${pfx}_CRLF_nul.txt
64
+ cp CRLF_mix_LF ${pfx}_CRLF_nul.txt &&
65
+ pfx=MIX_attr_${attr}_aeol_${aeol}_${crlf} &&
66
+ cp LF ${pfx}_LF.txt &&
67
+ cp CRLF ${pfx}_CRLF.txt &&
68
+ cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt &&
69
+ cp LF_mix_CR ${pfx}_LF_mix_CR.txt &&
70
+ cp CRLF_nul ${pfx}_CRLF_nul.txt
71
done
72
done
73
done
148
'
149
}
150
151
+# Commit a file with mixed line endings on top of different files
152
+# in the index. Check for warnings
153
+commit_MIX_chkwrn () {
154
+ attr=$1 ; shift
155
+ aeol=$1 ; shift
156
+ crlf=$1 ; shift
157
+ lfwarn=$1 ; shift
158
+ crlfwarn=$1 ; shift
159
+ lfmixcrlf=$1 ; shift
160
+ lfmixcr=$1 ; shift
161
+ crlfnul=$1 ; shift
162
+ pfx=MIX_attr_${attr}_aeol_${aeol}_${crlf}
163
+ #Commit file with CLRF_mix_LF on top of existing file
164
+ create_gitattributes "$attr" $aeol &&
165
+ for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
166
+ do
167
+ fname=${pfx}_$f.txt &&
168
+ cp CRLF_mix_LF $fname &&
169
+ printf Z >>"$fname" &&
170
+ git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
171
+ done
172
+
173
+ test_expect_success "commit file with mixed EOL crlf=$crlf attr=$attr LF" '
174
+ check_warning "$lfwarn" ${pfx}_LF.err
175
+ '
176
+ test_expect_success "commit file with mixed EOL attr=$attr aeol=$aeol crlf=$crlf CRLF" '
177
+ check_warning "$crlfwarn" ${pfx}_CRLF.err
178
+ '
179
+
180
+ test_expect_success "commit file with mixed EOL attr=$attr aeol=$aeol crlf=$crlf CRLF_mix_LF" '
181
+ check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
182
+ '
183
+
184
+ test_expect_success "commit file with mixed EOL attr=$attr aeol=$aeol crlf=$crlf LF_mix_cr" '
185
+ check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
186
+ '
187
+
188
+ test_expect_success "commit file with mixed EOL attr=$attr aeol=$aeol crlf=$crlf CRLF_nul" '
189
+ check_warning "$crlfnul" ${pfx}_CRLF_nul.err
190
+ '
191
+}
192
+
193
+
194
stats_ascii () {
195
case "$1" in
196
LF)
378
printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\rLINETHREE" >CRLF_mix_CR &&
379
printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONEQ\r\nLINETWO\r\nLINETHREE" | q_to_nul >CRLF_nul &&
380
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 &&
381
+ create_NNO_MIX_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&
382
+ git -c core.autocrlf=false add NNO_*.txt MIX_*.txt &&
383
git commit -m "mixed line endings" &&
384
test_tick
385
'
440
commit_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
441
'
442
443
+# Commit "CRLFmixLF" on top of these files already in the repo:
444
+# LF, CRLF, CRLFmixLF LF_mix_CR CRLFNULL
445
+# attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
446
+commit_MIX_chkwrn "" "" false "" "" "" "" ""
447
+commit_MIX_chkwrn "" "" true "LF_CRLF" "" "" "LF_CRLF" "LF_CRLF"
448
+commit_MIX_chkwrn "" "" input "CRLF_LF" "" "" "CRLF_LF" "CRLF_LF"
449
+
450
+commit_MIX_chkwrn "auto" "" false "CRLF_LF" "" "" "CRLF_LF" "CRLF_LF"
451
+commit_MIX_chkwrn "auto" "" true "LF_CRLF" "" "" "LF_CRLF" "LF_CRLF"
452
+commit_MIX_chkwrn "auto" "" input "CRLF_LF" "" "" "CRLF_LF" "CRLF_LF"
453
+
454
# attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
455
commit_chk_wrnNNO "" "" false "" "" "" "" ""
456
commit_chk_wrnNNO "" "" true LF_CRLF "" "" "" ""