@@ -43,19 +43,31 @@ create_gitattributes () {
43
43
} > .gitattributes
44
44
}
45
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 () {
47
53
for crlf in false true input
48
54
do
49
55
for attr in " " auto text -text
50
56
do
51
57
for aeol in " " lf crlf
52
58
do
53
- pfx=NNO_attr_${attr} _aeol_${aeol} _${crlf}
59
+ pfx=NNO_attr_${attr} _aeol_${aeol} _${crlf} &&
54
60
cp CRLF_mix_LF ${pfx} _LF.txt &&
55
61
cp CRLF_mix_LF ${pfx} _CRLF.txt &&
56
62
cp CRLF_mix_LF ${pfx} _CRLF_mix_LF.txt &&
57
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
59
71
done
60
72
done
61
73
done
@@ -136,6 +148,49 @@ commit_chk_wrnNNO () {
136
148
'
137
149
}
138
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 onto LF crlf=$crlf attr=$attr " '
174
+ check_warning "$lfwarn" ${pfx}_LF.err
175
+ '
176
+ test_expect_success " commit file with mixed EOL onto CLRF attr=$attr aeol=$aeol crlf=$crlf " '
177
+ check_warning "$crlfwarn" ${pfx}_CRLF.err
178
+ '
179
+
180
+ test_expect_success " commit file with mixed EOL onto CRLF_mix_LF attr=$attr aeol=$aeol crlf=$crlf " '
181
+ check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
182
+ '
183
+
184
+ test_expect_success " commit file with mixed EOL onto LF_mix_cr attr=$attr aeol=$aeol crlf=$crlf " '
185
+ check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
186
+ '
187
+
188
+ test_expect_success " commit file with mixed EOL onto CRLF_nul attr=$attr aeol=$aeol crlf=$crlf " '
189
+ check_warning "$crlfnul" ${pfx}_CRLF_nul.err
190
+ '
191
+ }
192
+
193
+
139
194
stats_ascii () {
140
195
case " $1 " in
141
196
LF)
@@ -323,8 +378,8 @@ test_expect_success 'setup master' '
323
378
printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\rLINETHREE" >CRLF_mix_CR &&
324
379
printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONEQ\r\nLINETWO\r\nLINETHREE" | q_to_nul >CRLF_nul &&
325
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 &&
382
+ git -c core.autocrlf=false add NNO_*.txt MIX_*.txt &&
328
383
git commit -m "mixed line endings" &&
329
384
test_tick
330
385
'
@@ -385,6 +440,18 @@ test_expect_success 'commit files attr=crlf' '
385
440
commit_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
386
441
'
387
442
443
+ # Commit "CRLFmixLF" on top of these files already in the repo:
444
+ # mixed mixed mixed mixed mixed
445
+ # onto onto onto onto onto
446
+ # attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
447
+ commit_MIX_chkwrn " " " " false " " " " " " " " " "
448
+ commit_MIX_chkwrn " " " " true " LF_CRLF" " " " " " LF_CRLF" " LF_CRLF"
449
+ commit_MIX_chkwrn " " " " input " CRLF_LF" " " " " " CRLF_LF" " CRLF_LF"
450
+
451
+ commit_MIX_chkwrn " auto" " " false " $WAMIX " " " " " " $WAMIX " " $WAMIX "
452
+ commit_MIX_chkwrn " auto" " " true " LF_CRLF" " " " " " LF_CRLF" " LF_CRLF"
453
+ commit_MIX_chkwrn " auto" " " input " CRLF_LF" " " " " " CRLF_LF" " CRLF_LF"
454
+
388
455
# attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
389
456
commit_chk_wrnNNO " " " " false " " " " " " " " " "
390
457
commit_chk_wrnNNO " " " " true LF_CRLF " " " " " " " "
0 commit comments