2014-06-29 10:34:54 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='CRLF conversion all combinations'
|
|
|
|
|
leak tests: mark passing SANITIZE=leak tests as leak-free
Mark those remaining tests that pass when run under SANITIZE=leak with
TEST_PASSES_SANITIZE_LEAK=true, these were either omitted in
f346fcb62a0 (Merge branch 'ab/mark-leak-free-tests-even-more',
2021-12-15) and 5a4f8381b68 (Merge branch 'ab/mark-leak-free-tests',
2021-10-25), or have had their memory leaks fixed since then.
With this change there's now a a one-to-one mapping between those
tests that we have opted-in via "TEST_PASSES_SANITIZE_LEAK=true", and
those that pass with the new "check" mode:
GIT_TEST_PASSING_SANITIZE_LEAK=check \
GIT_TEST_SANITIZE_LEAK_LOG=true \
make test SANITIZE=leak
Note that the "GIT_TEST_SANITIZE_LEAK_LOG=true" is needed due to the
edge cases noted in a preceding commit, i.e. in some cases we'd pass
the test itself, but still have outstanding leaks due to ignored exit
codes.
The "GIT_TEST_SANITIZE_LEAK_LOG=true" corrects for that, we're only
marking those tests as passing that really don't have any leaks,
whether that was reflected in their exit code or not.
Note that the change here to "t9100-git-svn-basic.sh" is marking that
test as passing under SANITIZE=leak, we're removing a
"TEST_FAILS_SANITIZE_LEAK=true" line, not
"TEST_PASSES_SANITIZE_LEAK=true". See 7a98d9ab00d (revisions API: have
release_revisions() release "cmdline", 2022-04-13) for the
introduction of that t/lib-git-svn.sh-specific variable.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-07-28 02:13:41 +03:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2014-06-29 10:34:54 +04:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
2014-08-17 00:16:58 +04:00
|
|
|
compare_files () {
|
|
|
|
tr '\015\000' QN <"$1" >"$1".expect &&
|
2016-04-25 19:56:27 +03:00
|
|
|
tr '\015\000' QN <"$2" | tr -d 'Z' >"$2".actual &&
|
2014-06-29 10:34:54 +04:00
|
|
|
test_cmp "$1".expect "$2".actual &&
|
|
|
|
rm "$1".expect "$2".actual
|
|
|
|
}
|
|
|
|
|
2014-08-17 00:16:58 +04:00
|
|
|
compare_ws_file () {
|
2014-06-29 10:34:54 +04:00
|
|
|
pfx=$1
|
|
|
|
exp=$2.expect
|
|
|
|
act=$pfx.actual.$3
|
2019-06-29 01:59:24 +03:00
|
|
|
tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" |
|
|
|
|
sed -e "s/0000*/$ZERO_OID/" >"$exp" &&
|
|
|
|
tr '\015\000abcdef0123456789' QN00000000000000000 <"$3" |
|
|
|
|
sed -e "s/0000*/$ZERO_OID/" >"$act" &&
|
2016-02-05 19:13:20 +03:00
|
|
|
test_cmp "$exp" "$act" &&
|
|
|
|
rm "$exp" "$act"
|
2014-06-29 10:34:54 +04:00
|
|
|
}
|
|
|
|
|
2014-08-17 00:16:58 +04:00
|
|
|
create_gitattributes () {
|
2016-02-05 19:13:20 +03:00
|
|
|
{
|
|
|
|
while test "$#" != 0
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
auto) echo '*.txt text=auto' ;;
|
|
|
|
ident) echo '*.txt ident' ;;
|
|
|
|
text) echo '*.txt text' ;;
|
|
|
|
-text) echo '*.txt -text' ;;
|
|
|
|
crlf) echo '*.txt eol=crlf' ;;
|
|
|
|
lf) echo '*.txt eol=lf' ;;
|
|
|
|
"") ;;
|
|
|
|
*)
|
|
|
|
echo >&2 invalid attribute: "$1"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac &&
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
} >.gitattributes
|
2014-06-29 10:34:54 +04:00
|
|
|
}
|
|
|
|
|
2017-11-26 15:20:52 +03:00
|
|
|
# Create 2 sets of files:
|
|
|
|
# The NNO files are "Not NOrmalized in the repo. We use CRLF_mix_LF and store
|
|
|
|
# it under different names for the different test cases, see ${pfx}
|
|
|
|
# Depending on .gitattributes they are normalized at the next commit (or not)
|
|
|
|
# The MIX files have different contents in the repo.
|
|
|
|
# Depending on its contents, the "new safer autocrlf" may kick in.
|
|
|
|
create_NNO_MIX_files () {
|
2015-10-10 07:23:53 +03:00
|
|
|
for crlf in false true input
|
|
|
|
do
|
2016-04-25 19:56:31 +03:00
|
|
|
for attr in "" auto text -text
|
2015-10-10 07:23:53 +03:00
|
|
|
do
|
2016-04-25 19:56:31 +03:00
|
|
|
for aeol in "" lf crlf
|
|
|
|
do
|
2017-11-26 15:20:52 +03:00
|
|
|
pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf} &&
|
2016-04-25 19:56:31 +03:00
|
|
|
cp CRLF_mix_LF ${pfx}_LF.txt &&
|
|
|
|
cp CRLF_mix_LF ${pfx}_CRLF.txt &&
|
|
|
|
cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt &&
|
|
|
|
cp CRLF_mix_LF ${pfx}_LF_mix_CR.txt &&
|
2017-11-26 15:20:52 +03:00
|
|
|
cp CRLF_mix_LF ${pfx}_CRLF_nul.txt &&
|
|
|
|
pfx=MIX_attr_${attr}_aeol_${aeol}_${crlf} &&
|
|
|
|
cp LF ${pfx}_LF.txt &&
|
|
|
|
cp CRLF ${pfx}_CRLF.txt &&
|
|
|
|
cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt &&
|
|
|
|
cp LF_mix_CR ${pfx}_LF_mix_CR.txt &&
|
|
|
|
cp CRLF_nul ${pfx}_CRLF_nul.txt
|
2016-04-25 19:56:31 +03:00
|
|
|
done
|
2015-10-10 07:23:53 +03:00
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-11-30 23:15:52 +03:00
|
|
|
check_warning () {
|
|
|
|
case "$1" in
|
2022-04-08 07:41:54 +03:00
|
|
|
LF_CRLF) echo "LF will be replaced by CRLF" >"$2".expect ;;
|
|
|
|
CRLF_LF) echo "CRLF will be replaced by LF" >"$2".expect ;;
|
|
|
|
'') >"$2".expect ;;
|
2015-04-17 18:44:05 +03:00
|
|
|
*) echo >&2 "Illegal 1": "$1" ; return false ;;
|
2014-11-30 23:15:52 +03:00
|
|
|
esac
|
2022-04-08 07:41:54 +03:00
|
|
|
sed -e "s/^.* \([^ ]* will be replaced by [^ ]*\) .*$/\1/" "$2" | uniq >"$2".actual
|
2021-02-11 04:53:53 +03:00
|
|
|
test_cmp "$2".expect "$2".actual
|
2014-11-30 23:15:52 +03:00
|
|
|
}
|
|
|
|
|
2015-04-17 18:43:43 +03:00
|
|
|
commit_check_warn () {
|
2014-06-29 10:34:54 +04:00
|
|
|
crlf=$1
|
2014-08-17 00:16:58 +04:00
|
|
|
attr=$2
|
2014-11-30 23:15:52 +03:00
|
|
|
lfname=$3
|
|
|
|
crlfname=$4
|
2015-10-10 07:23:53 +03:00
|
|
|
lfmixcrlf=$5
|
|
|
|
lfmixcr=$6
|
|
|
|
crlfnul=$7
|
2014-11-30 23:15:52 +03:00
|
|
|
pfx=crlf_${crlf}_attr_${attr}
|
2015-04-25 09:47:13 +03:00
|
|
|
create_gitattributes "$attr" &&
|
2016-01-16 09:50:02 +03:00
|
|
|
for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul
|
2014-06-29 10:34:54 +04:00
|
|
|
do
|
2014-11-30 23:15:52 +03:00
|
|
|
fname=${pfx}_$f.txt &&
|
|
|
|
cp $f $fname &&
|
|
|
|
git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
|
2014-06-29 10:34:54 +04:00
|
|
|
done &&
|
2014-11-30 23:15:52 +03:00
|
|
|
git commit -m "core.autocrlf $crlf" &&
|
|
|
|
check_warning "$lfname" ${pfx}_LF.err &&
|
|
|
|
check_warning "$crlfname" ${pfx}_CRLF.err &&
|
|
|
|
check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err &&
|
|
|
|
check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err &&
|
|
|
|
check_warning "$crlfnul" ${pfx}_CRLF_nul.err
|
2014-06-29 10:34:54 +04:00
|
|
|
}
|
|
|
|
|
2015-10-10 07:23:53 +03:00
|
|
|
commit_chk_wrnNNO () {
|
2016-04-25 19:56:31 +03:00
|
|
|
attr=$1 ; shift
|
|
|
|
aeol=$1 ; shift
|
|
|
|
crlf=$1 ; shift
|
|
|
|
lfwarn=$1 ; shift
|
|
|
|
crlfwarn=$1 ; shift
|
|
|
|
lfmixcrlf=$1 ; shift
|
|
|
|
lfmixcr=$1 ; shift
|
|
|
|
crlfnul=$1 ; shift
|
|
|
|
pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf}
|
2015-10-10 07:23:53 +03:00
|
|
|
#Commit files on top of existing file
|
2016-04-25 19:56:31 +03:00
|
|
|
create_gitattributes "$attr" $aeol &&
|
2015-10-10 07:23:53 +03:00
|
|
|
for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
|
|
|
do
|
|
|
|
fname=${pfx}_$f.txt &&
|
|
|
|
cp $f $fname &&
|
2016-04-25 19:56:27 +03:00
|
|
|
printf Z >>"$fname" &&
|
2016-08-14 00:29:27 +03:00
|
|
|
git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
|
2015-10-10 07:23:53 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
test_expect_success "commit NNO files crlf=$crlf attr=$attr LF" '
|
|
|
|
check_warning "$lfwarn" ${pfx}_LF.err
|
|
|
|
'
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF" '
|
2015-10-10 07:23:53 +03:00
|
|
|
check_warning "$crlfwarn" ${pfx}_CRLF.err
|
|
|
|
'
|
|
|
|
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF_mix_LF" '
|
2015-10-10 07:23:53 +03:00
|
|
|
check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
|
|
|
|
'
|
|
|
|
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "commit NNO files attr=$attr aeol=$aeol crlf=$crlf LF_mix_cr" '
|
2015-10-10 07:23:53 +03:00
|
|
|
check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
|
|
|
|
'
|
|
|
|
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "commit NNO files attr=$attr aeol=$aeol crlf=$crlf CRLF_nul" '
|
2015-10-10 07:23:53 +03:00
|
|
|
check_warning "$crlfnul" ${pfx}_CRLF_nul.err
|
|
|
|
'
|
|
|
|
}
|
|
|
|
|
2017-11-26 15:20:52 +03:00
|
|
|
# Commit a file with mixed line endings on top of different files
|
|
|
|
# in the index. Check for warnings
|
|
|
|
commit_MIX_chkwrn () {
|
|
|
|
attr=$1 ; shift
|
|
|
|
aeol=$1 ; shift
|
|
|
|
crlf=$1 ; shift
|
|
|
|
lfwarn=$1 ; shift
|
|
|
|
crlfwarn=$1 ; shift
|
|
|
|
lfmixcrlf=$1 ; shift
|
|
|
|
lfmixcr=$1 ; shift
|
|
|
|
crlfnul=$1 ; shift
|
|
|
|
pfx=MIX_attr_${attr}_aeol_${aeol}_${crlf}
|
|
|
|
#Commit file with CLRF_mix_LF on top of existing file
|
|
|
|
create_gitattributes "$attr" $aeol &&
|
|
|
|
for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
|
|
|
do
|
|
|
|
fname=${pfx}_$f.txt &&
|
|
|
|
cp CRLF_mix_LF $fname &&
|
|
|
|
printf Z >>"$fname" &&
|
|
|
|
git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
|
|
|
|
done
|
|
|
|
|
2017-12-08 20:46:36 +03:00
|
|
|
test_expect_success "commit file with mixed EOL onto LF crlf=$crlf attr=$attr" '
|
2017-11-26 15:20:52 +03:00
|
|
|
check_warning "$lfwarn" ${pfx}_LF.err
|
|
|
|
'
|
2017-12-08 20:46:36 +03:00
|
|
|
test_expect_success "commit file with mixed EOL onto CLRF attr=$attr aeol=$aeol crlf=$crlf" '
|
2017-11-26 15:20:52 +03:00
|
|
|
check_warning "$crlfwarn" ${pfx}_CRLF.err
|
|
|
|
'
|
|
|
|
|
2017-12-08 20:46:36 +03:00
|
|
|
test_expect_success "commit file with mixed EOL onto CRLF_mix_LF attr=$attr aeol=$aeol crlf=$crlf" '
|
2017-11-26 15:20:52 +03:00
|
|
|
check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
|
|
|
|
'
|
|
|
|
|
2017-12-08 20:46:36 +03:00
|
|
|
test_expect_success "commit file with mixed EOL onto LF_mix_cr attr=$attr aeol=$aeol crlf=$crlf " '
|
2017-11-26 15:20:52 +03:00
|
|
|
check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
|
|
|
|
'
|
|
|
|
|
2017-12-08 20:46:36 +03:00
|
|
|
test_expect_success "commit file with mixed EOL onto CRLF_nul attr=$attr aeol=$aeol crlf=$crlf" '
|
2017-11-26 15:20:52 +03:00
|
|
|
check_warning "$crlfnul" ${pfx}_CRLF_nul.err
|
|
|
|
'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-16 09:50:02 +03:00
|
|
|
stats_ascii () {
|
|
|
|
case "$1" in
|
|
|
|
LF)
|
|
|
|
echo lf
|
|
|
|
;;
|
|
|
|
CRLF)
|
|
|
|
echo crlf
|
|
|
|
;;
|
|
|
|
CRLF_mix_LF)
|
|
|
|
echo mixed
|
|
|
|
;;
|
|
|
|
LF_mix_CR|CRLF_nul|LF_nul|CRLF_mix_CR)
|
|
|
|
echo "-text"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo error_invalid $1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-23 20:07:19 +03:00
|
|
|
|
2019-11-05 20:07:24 +03:00
|
|
|
# construct the attr/ returned by git ls-files --eol
|
2016-02-23 20:07:19 +03:00
|
|
|
# Take none (=empty), one or two args
|
2016-04-25 19:56:31 +03:00
|
|
|
# convert.c: eol=XX overrides text=auto
|
2016-02-23 20:07:19 +03:00
|
|
|
attr_ascii () {
|
|
|
|
case $1,$2 in
|
|
|
|
-text,*) echo "-text" ;;
|
|
|
|
text,) echo "text" ;;
|
|
|
|
text,lf) echo "text eol=lf" ;;
|
|
|
|
text,crlf) echo "text eol=crlf" ;;
|
|
|
|
auto,) echo "text=auto" ;;
|
2016-06-28 11:01:13 +03:00
|
|
|
auto,lf) echo "text=auto eol=lf" ;;
|
|
|
|
auto,crlf) echo "text=auto eol=crlf" ;;
|
2016-02-23 20:07:19 +03:00
|
|
|
lf,) echo "text eol=lf" ;;
|
|
|
|
crlf,) echo "text eol=crlf" ;;
|
|
|
|
,) echo "" ;;
|
|
|
|
*) echo invalid_attr "$1,$2" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2014-08-17 00:16:58 +04:00
|
|
|
check_files_in_repo () {
|
2014-06-29 10:34:54 +04:00
|
|
|
crlf=$1
|
2014-08-17 00:16:58 +04:00
|
|
|
attr=$2
|
2014-06-29 10:34:54 +04:00
|
|
|
lfname=$3
|
|
|
|
crlfname=$4
|
|
|
|
lfmixcrlf=$5
|
|
|
|
lfmixcr=$6
|
|
|
|
crlfnul=$7
|
2014-08-17 00:16:58 +04:00
|
|
|
pfx=crlf_${crlf}_attr_${attr}_ &&
|
2014-06-29 10:34:54 +04:00
|
|
|
compare_files $lfname ${pfx}LF.txt &&
|
|
|
|
compare_files $crlfname ${pfx}CRLF.txt &&
|
|
|
|
compare_files $lfmixcrlf ${pfx}CRLF_mix_LF.txt &&
|
|
|
|
compare_files $lfmixcr ${pfx}LF_mix_CR.txt &&
|
|
|
|
compare_files $crlfnul ${pfx}CRLF_nul.txt
|
|
|
|
}
|
|
|
|
|
2015-10-10 07:23:53 +03:00
|
|
|
check_in_repo_NNO () {
|
2016-04-25 19:56:31 +03:00
|
|
|
attr=$1 ; shift
|
|
|
|
aeol=$1 ; shift
|
|
|
|
crlf=$1 ; shift
|
|
|
|
lfname=$1 ; shift
|
|
|
|
crlfname=$1 ; shift
|
|
|
|
lfmixcrlf=$1 ; shift
|
|
|
|
lfmixcr=$1 ; shift
|
|
|
|
crlfnul=$1 ; shift
|
|
|
|
pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf}
|
|
|
|
test_expect_success "compare_files $lfname ${pfx}_LF.txt" '
|
|
|
|
compare_files $lfname ${pfx}_LF.txt
|
2015-10-10 07:23:53 +03:00
|
|
|
'
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "compare_files $crlfname ${pfx}_CRLF.txt" '
|
|
|
|
compare_files $crlfname ${pfx}_CRLF.txt
|
2015-10-10 07:23:53 +03:00
|
|
|
'
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "compare_files $lfmixcrlf ${pfx}_CRLF_mix_LF.txt" '
|
|
|
|
compare_files $lfmixcrlf ${pfx}_CRLF_mix_LF.txt
|
2015-10-10 07:23:53 +03:00
|
|
|
'
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "compare_files $lfmixcr ${pfx}_LF_mix_CR.txt" '
|
|
|
|
compare_files $lfmixcr ${pfx}_LF_mix_CR.txt
|
2015-10-10 07:23:53 +03:00
|
|
|
'
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "compare_files $crlfnul ${pfx}_CRLF_nul.txt" '
|
|
|
|
compare_files $crlfnul ${pfx}_CRLF_nul.txt
|
2015-10-10 07:23:53 +03:00
|
|
|
'
|
|
|
|
}
|
2014-06-29 10:34:54 +04:00
|
|
|
|
2015-04-17 18:43:43 +03:00
|
|
|
checkout_files () {
|
2016-02-05 19:13:20 +03:00
|
|
|
attr=$1 ; shift
|
|
|
|
ident=$1; shift
|
|
|
|
aeol=$1 ; shift
|
|
|
|
crlf=$1 ; shift
|
|
|
|
ceol=$1 ; shift
|
|
|
|
lfname=$1 ; shift
|
|
|
|
crlfname=$1 ; shift
|
|
|
|
lfmixcrlf=$1 ; shift
|
|
|
|
lfmixcr=$1 ; shift
|
|
|
|
crlfnul=$1 ; shift
|
2016-04-25 19:56:31 +03:00
|
|
|
create_gitattributes "$attr" $ident $aeol &&
|
2014-06-29 10:34:54 +04:00
|
|
|
git config core.autocrlf $crlf &&
|
2016-02-05 19:13:20 +03:00
|
|
|
pfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&
|
2015-04-25 09:47:13 +03:00
|
|
|
for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul
|
2014-06-29 10:34:54 +04:00
|
|
|
do
|
2016-01-16 09:50:02 +03:00
|
|
|
rm crlf_false_attr__$f.txt &&
|
2016-02-05 19:13:20 +03:00
|
|
|
if test -z "$ceol"; then
|
2018-11-20 06:43:24 +03:00
|
|
|
git checkout -- crlf_false_attr__$f.txt
|
2014-06-29 10:34:54 +04:00
|
|
|
else
|
2018-11-20 06:43:24 +03:00
|
|
|
git -c core.eol=$ceol checkout -- crlf_false_attr__$f.txt
|
2014-06-29 10:34:54 +04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "ls-files --eol attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol" '
|
2016-01-16 09:50:02 +03:00
|
|
|
test_when_finished "rm expect actual" &&
|
|
|
|
sort <<-EOF >expect &&
|
2016-02-23 20:07:19 +03:00
|
|
|
i/crlf w/$(stats_ascii $crlfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF.txt
|
|
|
|
i/mixed w/$(stats_ascii $lfmixcrlf) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_mix_LF.txt
|
|
|
|
i/lf w/$(stats_ascii $lfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF.txt
|
|
|
|
i/-text w/$(stats_ascii $lfmixcr) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_mix_CR.txt
|
|
|
|
i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt
|
|
|
|
i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt
|
2016-01-16 09:50:02 +03:00
|
|
|
EOF
|
2022-03-12 09:21:25 +03:00
|
|
|
git ls-files --eol crlf_false_attr__* >tmp &&
|
|
|
|
sed -e "s/ / /g" -e "s/ */ /g" tmp |
|
2016-01-16 09:50:02 +03:00
|
|
|
sort >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF" "
|
2016-01-16 09:50:02 +03:00
|
|
|
compare_ws_file $pfx $lfname crlf_false_attr__LF.txt
|
2014-06-29 10:34:54 +04:00
|
|
|
"
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF" "
|
2016-01-16 09:50:02 +03:00
|
|
|
compare_ws_file $pfx $crlfname crlf_false_attr__CRLF.txt
|
2014-06-29 10:34:54 +04:00
|
|
|
"
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF" "
|
2016-01-16 09:50:02 +03:00
|
|
|
compare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt
|
2014-06-29 10:34:54 +04:00
|
|
|
"
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR" "
|
2016-01-16 09:50:02 +03:00
|
|
|
compare_ws_file $pfx $lfmixcr crlf_false_attr__LF_mix_CR.txt
|
2014-06-29 10:34:54 +04:00
|
|
|
"
|
2016-04-25 19:56:31 +03:00
|
|
|
test_expect_success "checkout attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul" "
|
2016-01-16 09:50:02 +03:00
|
|
|
compare_ws_file $pfx $crlfnul crlf_false_attr__LF_nul.txt
|
2014-06-29 10:34:54 +04:00
|
|
|
"
|
|
|
|
}
|
|
|
|
|
2016-06-15 17:59:16 +03:00
|
|
|
test_expect_success 'crlf conversions blocked when under GVFS' '
|
|
|
|
git checkout -b gvfs &&
|
|
|
|
test_commit initial &&
|
|
|
|
rm initial.t &&
|
|
|
|
test_config core.gvfs 64 &&
|
|
|
|
test_config core.autocrlf true &&
|
|
|
|
test_must_fail git read-tree --reset -u HEAD &&
|
|
|
|
|
|
|
|
git config core.autocrlf false &&
|
|
|
|
git read-tree --reset -u HEAD
|
|
|
|
'
|
|
|
|
|
2016-01-16 09:50:02 +03:00
|
|
|
# Test control characters
|
|
|
|
# NUL SOH CR EOF==^Z
|
|
|
|
test_expect_success 'ls-files --eol -o Text/Binary' '
|
|
|
|
test_when_finished "rm expect actual TeBi_*" &&
|
|
|
|
STRT=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA &&
|
|
|
|
STR=$STRT$STRT$STRT$STRT &&
|
|
|
|
printf "${STR}BBB\001" >TeBi_127_S &&
|
|
|
|
printf "${STR}BBBB\001">TeBi_128_S &&
|
|
|
|
printf "${STR}BBB\032" >TeBi_127_E &&
|
|
|
|
printf "\032${STR}BBB" >TeBi_E_127 &&
|
|
|
|
printf "${STR}BBBB\000">TeBi_128_N &&
|
|
|
|
printf "${STR}BBB\012">TeBi_128_L &&
|
|
|
|
printf "${STR}BBB\015">TeBi_127_C &&
|
|
|
|
printf "${STR}BB\015\012" >TeBi_126_CL &&
|
|
|
|
printf "${STR}BB\015\012\015" >TeBi_126_CLC &&
|
|
|
|
sort <<-\EOF >expect &&
|
|
|
|
i/ w/-text TeBi_127_S
|
|
|
|
i/ w/none TeBi_128_S
|
|
|
|
i/ w/none TeBi_127_E
|
|
|
|
i/ w/-text TeBi_E_127
|
|
|
|
i/ w/-text TeBi_128_N
|
|
|
|
i/ w/lf TeBi_128_L
|
|
|
|
i/ w/-text TeBi_127_C
|
|
|
|
i/ w/crlf TeBi_126_CL
|
|
|
|
i/ w/-text TeBi_126_CLC
|
|
|
|
EOF
|
2022-03-12 09:21:25 +03:00
|
|
|
git ls-files --eol -o >tmp &&
|
2016-01-16 09:50:02 +03:00
|
|
|
sed -n -e "/TeBi_/{s!attr/[ ]*!!g
|
|
|
|
s! ! !g
|
|
|
|
s! *! !g
|
|
|
|
p
|
2022-03-12 09:21:25 +03:00
|
|
|
}" tmp | sort >actual &&
|
2016-01-16 09:50:02 +03:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2020-11-19 02:44:21 +03:00
|
|
|
test_expect_success 'setup main' '
|
2014-06-29 10:34:54 +04:00
|
|
|
echo >.gitattributes &&
|
2020-11-19 02:44:21 +03:00
|
|
|
git checkout -b main &&
|
2014-06-29 10:34:54 +04:00
|
|
|
git add .gitattributes &&
|
2017-06-23 21:04:14 +03:00
|
|
|
git commit -m "add .gitattributes" . &&
|
2016-02-05 19:13:20 +03:00
|
|
|
printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\nLINETHREE" >LF &&
|
|
|
|
printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\r\nLINETHREE" >CRLF &&
|
|
|
|
printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\r\nLINETWO\nLINETHREE" >CRLF_mix_LF &&
|
|
|
|
printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\rLINETHREE" >LF_mix_CR &&
|
|
|
|
printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\rLINETHREE" >CRLF_mix_CR &&
|
|
|
|
printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONEQ\r\nLINETWO\r\nLINETHREE" | q_to_nul >CRLF_nul &&
|
|
|
|
printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONEQ\nLINETWO\nLINETHREE" | q_to_nul >LF_nul &&
|
2017-12-08 20:46:36 +03:00
|
|
|
create_NNO_MIX_files &&
|
2017-11-26 15:20:52 +03:00
|
|
|
git -c core.autocrlf=false add NNO_*.txt MIX_*.txt &&
|
2015-10-10 07:23:53 +03:00
|
|
|
git commit -m "mixed line endings" &&
|
|
|
|
test_tick
|
2014-06-29 10:34:54 +04:00
|
|
|
'
|
2014-08-17 00:16:58 +04:00
|
|
|
|
test-lib: retire "lint harder" optimization hack
`test_run_` in test-lib.sh "lints" the body of a test by sending it down
a `sed chainlint.sed | grep` pipeline; this happens once for each test
run by a test script. Although this pipeline may seem relatively cheap
in isolation, it can become expensive when invoked 26800+ times by `make
test`, once for each test run, despite the existence of only 16500+ test
definitions across all tests scripts.
This difference in the number of tests defined in the scripts (16500+)
and the number of tests actually run by `make test` (26800+) is
explained by the fact that some test scripts run a very large number of
small tests, all driven by a series of functions/loops which fill in the
test bodies. This means that certain test definitions are being linted
repeatedly (tens or hundreds of times) unnecessarily. To avoid such
unnecessary work, 2d86a96220 (t: avoid sed-based chain-linting in some
expensive cases, 2021-05-13) added an optimization hack which allows
individual scripts to manually suppress the unnecessary repeated linting
of the same test definition.
However, unlike chainlint.sed which checks a test body as the test is
run, chainlint.pl checks each test definition just once, no matter how
many times the test is run, thus the sort of optimization hack
introduced by 2d86a96220 is no longer needed and can be retired.
Therefore, revert 2d86a96220.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-09-01 03:29:53 +03:00
|
|
|
|
2014-06-29 10:34:54 +04:00
|
|
|
|
2014-11-30 23:15:52 +03:00
|
|
|
warn_LF_CRLF="LF will be replaced by CRLF"
|
|
|
|
warn_CRLF_LF="CRLF will be replaced by LF"
|
|
|
|
|
2015-04-17 18:44:05 +03:00
|
|
|
# WILC stands for "Warn if (this OS) converts LF into CRLF".
|
|
|
|
# WICL: Warn if CRLF becomes LF
|
|
|
|
# WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF
|
|
|
|
if test_have_prereq NATIVE_CRLF
|
|
|
|
then
|
|
|
|
WILC=LF_CRLF
|
|
|
|
WICL=
|
|
|
|
WAMIX=LF_CRLF
|
|
|
|
else
|
|
|
|
WILC=
|
|
|
|
WICL=CRLF_LF
|
|
|
|
WAMIX=CRLF_LF
|
|
|
|
fi
|
|
|
|
|
2015-10-10 07:23:53 +03:00
|
|
|
# attr LF CRLF CRLFmixLF LFmixCR CRLFNUL
|
2015-04-17 18:43:43 +03:00
|
|
|
test_expect_success 'commit files empty attr' '
|
2015-10-10 07:23:53 +03:00
|
|
|
commit_check_warn false "" "" "" "" "" "" &&
|
|
|
|
commit_check_warn true "" "LF_CRLF" "" "LF_CRLF" "" "" &&
|
|
|
|
commit_check_warn input "" "" "CRLF_LF" "CRLF_LF" "" ""
|
2014-11-30 23:15:52 +03:00
|
|
|
'
|
|
|
|
|
2015-04-17 18:43:43 +03:00
|
|
|
test_expect_success 'commit files attr=auto' '
|
2015-10-10 07:23:53 +03:00
|
|
|
commit_check_warn false "auto" "$WILC" "$WICL" "$WAMIX" "" "" &&
|
|
|
|
commit_check_warn true "auto" "LF_CRLF" "" "LF_CRLF" "" "" &&
|
|
|
|
commit_check_warn input "auto" "" "CRLF_LF" "CRLF_LF" "" ""
|
2014-11-30 23:15:52 +03:00
|
|
|
'
|
|
|
|
|
2015-04-17 18:43:43 +03:00
|
|
|
test_expect_success 'commit files attr=text' '
|
2015-10-10 07:23:53 +03:00
|
|
|
commit_check_warn false "text" "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL" &&
|
|
|
|
commit_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
|
|
|
|
commit_check_warn input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
|
2014-11-30 23:15:52 +03:00
|
|
|
'
|
|
|
|
|
2015-04-17 18:43:43 +03:00
|
|
|
test_expect_success 'commit files attr=-text' '
|
2015-10-10 07:23:53 +03:00
|
|
|
commit_check_warn false "-text" "" "" "" "" "" &&
|
|
|
|
commit_check_warn true "-text" "" "" "" "" "" &&
|
|
|
|
commit_check_warn input "-text" "" "" "" "" ""
|
2014-11-30 23:15:52 +03:00
|
|
|
'
|
|
|
|
|
2015-04-17 18:43:43 +03:00
|
|
|
test_expect_success 'commit files attr=lf' '
|
2015-10-10 07:23:53 +03:00
|
|
|
commit_check_warn false "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
|
|
|
|
commit_check_warn true "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
|
|
|
|
commit_check_warn input "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
|
2014-11-30 23:15:52 +03:00
|
|
|
'
|
2014-06-29 10:34:54 +04:00
|
|
|
|
2015-04-17 18:43:43 +03:00
|
|
|
test_expect_success 'commit files attr=crlf' '
|
2015-10-10 07:23:53 +03:00
|
|
|
commit_check_warn false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
|
|
|
|
commit_check_warn true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
|
|
|
|
commit_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
|
2014-11-30 23:15:52 +03:00
|
|
|
'
|
2014-06-29 10:34:54 +04:00
|
|
|
|
2017-11-26 15:20:52 +03:00
|
|
|
# Commit "CRLFmixLF" on top of these files already in the repo:
|
2017-12-08 20:46:36 +03:00
|
|
|
# mixed mixed mixed mixed mixed
|
|
|
|
# onto onto onto onto onto
|
2017-11-26 15:20:52 +03:00
|
|
|
# attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
|
|
|
|
commit_MIX_chkwrn "" "" false "" "" "" "" ""
|
|
|
|
commit_MIX_chkwrn "" "" true "LF_CRLF" "" "" "LF_CRLF" "LF_CRLF"
|
|
|
|
commit_MIX_chkwrn "" "" input "CRLF_LF" "" "" "CRLF_LF" "CRLF_LF"
|
|
|
|
|
2017-12-08 20:46:36 +03:00
|
|
|
commit_MIX_chkwrn "auto" "" false "$WAMIX" "" "" "$WAMIX" "$WAMIX"
|
2017-11-26 15:20:52 +03:00
|
|
|
commit_MIX_chkwrn "auto" "" true "LF_CRLF" "" "" "LF_CRLF" "LF_CRLF"
|
|
|
|
commit_MIX_chkwrn "auto" "" input "CRLF_LF" "" "" "CRLF_LF" "CRLF_LF"
|
|
|
|
|
2016-04-25 19:56:31 +03:00
|
|
|
# attr LF CRLF CRLFmixLF LF_mix_CR CRLFNUL
|
|
|
|
commit_chk_wrnNNO "" "" false "" "" "" "" ""
|
|
|
|
commit_chk_wrnNNO "" "" true LF_CRLF "" "" "" ""
|
|
|
|
commit_chk_wrnNNO "" "" input "" "" "" "" ""
|
2015-10-10 07:23:53 +03:00
|
|
|
|
2016-06-28 11:01:13 +03:00
|
|
|
commit_chk_wrnNNO "auto" "" false "$WILC" "" "" "" ""
|
|
|
|
commit_chk_wrnNNO "auto" "" true LF_CRLF "" "" "" ""
|
|
|
|
commit_chk_wrnNNO "auto" "" input "" "" "" "" ""
|
2016-04-25 19:56:31 +03:00
|
|
|
for crlf in true false input
|
|
|
|
do
|
|
|
|
commit_chk_wrnNNO -text "" $crlf "" "" "" "" ""
|
|
|
|
commit_chk_wrnNNO -text lf $crlf "" "" "" "" ""
|
|
|
|
commit_chk_wrnNNO -text crlf $crlf "" "" "" "" ""
|
|
|
|
commit_chk_wrnNNO "" lf $crlf "" CRLF_LF CRLF_LF "" CRLF_LF
|
|
|
|
commit_chk_wrnNNO "" crlf $crlf LF_CRLF "" LF_CRLF LF_CRLF ""
|
2016-06-28 11:01:13 +03:00
|
|
|
commit_chk_wrnNNO auto lf $crlf "" "" "" "" ""
|
|
|
|
commit_chk_wrnNNO auto crlf $crlf LF_CRLF "" "" "" ""
|
2016-04-25 19:56:31 +03:00
|
|
|
commit_chk_wrnNNO text lf $crlf "" CRLF_LF CRLF_LF "" CRLF_LF
|
|
|
|
commit_chk_wrnNNO text crlf $crlf LF_CRLF "" LF_CRLF LF_CRLF ""
|
|
|
|
done
|
2015-10-10 07:23:53 +03:00
|
|
|
|
2016-04-25 19:56:31 +03:00
|
|
|
commit_chk_wrnNNO "text" "" false "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL"
|
|
|
|
commit_chk_wrnNNO "text" "" true LF_CRLF "" LF_CRLF LF_CRLF ""
|
|
|
|
commit_chk_wrnNNO "text" "" input "" CRLF_LF CRLF_LF "" CRLF_LF
|
2015-10-10 07:23:53 +03:00
|
|
|
|
2016-08-14 00:29:27 +03:00
|
|
|
test_expect_success 'commit NNO and cleanup' '
|
|
|
|
git commit -m "commit files on top of NNO" &&
|
2014-06-29 10:34:54 +04:00
|
|
|
rm -f *.txt &&
|
2015-10-10 07:23:53 +03:00
|
|
|
git -c core.autocrlf=false reset --hard
|
2014-06-29 10:34:54 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commit empty gitattribues' '
|
|
|
|
check_files_in_repo false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
|
|
|
|
check_files_in_repo true "" LF LF LF LF_mix_CR CRLF_nul &&
|
|
|
|
check_files_in_repo input "" LF LF LF LF_mix_CR CRLF_nul
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commit text=auto' '
|
|
|
|
check_files_in_repo false "auto" LF LF LF LF_mix_CR CRLF_nul &&
|
|
|
|
check_files_in_repo true "auto" LF LF LF LF_mix_CR CRLF_nul &&
|
|
|
|
check_files_in_repo input "auto" LF LF LF LF_mix_CR CRLF_nul
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commit text' '
|
|
|
|
check_files_in_repo false "text" LF LF LF LF_mix_CR LF_nul &&
|
|
|
|
check_files_in_repo true "text" LF LF LF LF_mix_CR LF_nul &&
|
|
|
|
check_files_in_repo input "text" LF LF LF LF_mix_CR LF_nul
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commit -text' '
|
|
|
|
check_files_in_repo false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
|
|
|
|
check_files_in_repo true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
|
|
|
|
check_files_in_repo input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
|
|
|
'
|
|
|
|
|
2016-04-25 19:56:31 +03:00
|
|
|
for crlf in true false input
|
|
|
|
do
|
|
|
|
# attr aeol LF CRLF CRLF_mix_LF LF_mix_CR CRLFNUL
|
|
|
|
check_in_repo_NNO "" "" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
|
|
|
check_in_repo_NNO -text "" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
|
|
|
check_in_repo_NNO -text lf $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
|
|
|
check_in_repo_NNO -text crlf $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
2016-06-28 11:01:13 +03:00
|
|
|
check_in_repo_NNO auto "" $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
|
|
|
check_in_repo_NNO auto lf $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
|
|
|
check_in_repo_NNO auto crlf $crlf LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
|
2016-04-25 19:56:31 +03:00
|
|
|
check_in_repo_NNO text "" $crlf LF LF LF LF_mix_CR LF_nul
|
|
|
|
check_in_repo_NNO text lf $crlf LF LF LF LF_mix_CR LF_nul
|
|
|
|
check_in_repo_NNO text crlf $crlf LF LF LF LF_mix_CR LF_nul
|
|
|
|
done
|
2014-06-29 10:34:54 +04:00
|
|
|
################################################################################
|
|
|
|
# Check how files in the repo are changed when they are checked out
|
|
|
|
# How to read the table below:
|
2015-04-17 18:43:43 +03:00
|
|
|
# - checkout_files will check multiple files with a combination of settings
|
2014-08-17 00:16:58 +04:00
|
|
|
# and attributes (core.autocrlf=input is forbidden with core.eol=crlf)
|
2016-02-05 19:13:20 +03:00
|
|
|
#
|
|
|
|
# - parameter $1 : text in .gitattributs "" (empty) | auto | text | -text
|
|
|
|
# - parameter $2 : ident "" | i (i == ident)
|
|
|
|
# - parameter $3 : eol in .gitattributs "" (empty) | lf | crlf
|
|
|
|
# - parameter $4 : core.autocrlf false | true | input
|
|
|
|
# - parameter $5 : core.eol "" | lf | crlf | "native"
|
|
|
|
# - parameter $6 : reference for a file with only LF in the repo
|
|
|
|
# - parameter $7 : reference for a file with only CRLF in the repo
|
|
|
|
# - parameter $8 : reference for a file with mixed LF and CRLF in the repo
|
|
|
|
# - parameter $9 : reference for a file with LF and CR in the repo
|
|
|
|
# - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)
|
|
|
|
|
2015-04-25 09:47:13 +03:00
|
|
|
if test_have_prereq NATIVE_CRLF
|
2014-06-29 10:34:54 +04:00
|
|
|
then
|
2014-08-17 00:16:58 +04:00
|
|
|
MIX_CRLF_LF=CRLF
|
|
|
|
MIX_LF_CR=CRLF_mix_CR
|
|
|
|
NL=CRLF
|
2015-04-25 09:47:13 +03:00
|
|
|
LFNUL=CRLF_nul
|
2014-08-17 00:16:58 +04:00
|
|
|
else
|
|
|
|
MIX_CRLF_LF=CRLF_mix_LF
|
|
|
|
MIX_LF_CR=LF_mix_CR
|
|
|
|
NL=LF
|
2015-04-25 09:47:13 +03:00
|
|
|
LFNUL=LF_nul
|
2014-06-29 10:34:54 +04:00
|
|
|
fi
|
2014-08-17 00:16:58 +04:00
|
|
|
export CRLF_MIX_LF_CR MIX NL
|
|
|
|
|
2016-04-25 19:56:31 +03:00
|
|
|
# Same handling with and without ident
|
2016-04-25 19:56:32 +03:00
|
|
|
for id in "" ident
|
2016-02-05 19:13:20 +03:00
|
|
|
do
|
2016-04-25 19:56:31 +03:00
|
|
|
for ceol in lf crlf native
|
|
|
|
do
|
|
|
|
for crlf in true false input
|
|
|
|
do
|
|
|
|
# -text overrides core.autocrlf and core.eol
|
|
|
|
# text and eol=crlf or eol=lf override core.autocrlf and core.eol
|
|
|
|
checkout_files -text "$id" "" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
checkout_files -text "$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
checkout_files -text "$id" "crlf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
# text
|
|
|
|
checkout_files text "$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
checkout_files text "$id" "crlf" "$crlf" "$ceol" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
|
|
|
|
# currently the same as text, eol=XXX
|
|
|
|
checkout_files auto "$id" "lf" "$crlf" "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
2016-06-28 11:01:13 +03:00
|
|
|
checkout_files auto "$id" "crlf" "$crlf" "$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
2016-04-25 19:56:31 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
# core.autocrlf false, different core.eol
|
|
|
|
checkout_files "" "$id" "" false "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
# core.autocrlf true
|
|
|
|
checkout_files "" "$id" "" true "$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
# text: core.autocrlf = true overrides core.eol
|
2016-06-28 11:01:13 +03:00
|
|
|
checkout_files auto "$id" "" true "$ceol" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
2016-04-25 19:56:31 +03:00
|
|
|
checkout_files text "$id" "" true "$ceol" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
|
|
|
|
# text: core.autocrlf = input overrides core.eol
|
|
|
|
checkout_files text "$id" "" input "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
checkout_files auto "$id" "" input "$ceol" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
# text=auto + eol=XXX
|
|
|
|
done
|
|
|
|
# text: core.autocrlf=false uses core.eol
|
|
|
|
checkout_files text "$id" "" false crlf CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
|
|
|
|
checkout_files text "$id" "" false lf LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
# text: core.autocrlf=false and core.eol unset(or native) uses native eol
|
|
|
|
checkout_files text "$id" "" false "" $NL CRLF $MIX_CRLF_LF $MIX_LF_CR $LFNUL
|
|
|
|
checkout_files text "$id" "" false native $NL CRLF $MIX_CRLF_LF $MIX_LF_CR $LFNUL
|
|
|
|
# auto: core.autocrlf=false and core.eol unset(or native) uses native eol
|
2016-06-28 11:01:13 +03:00
|
|
|
checkout_files auto "$id" "" false "" $NL CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
checkout_files auto "$id" "" false native $NL CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
2022-01-11 05:15:06 +03:00
|
|
|
# core.autocrlf false, .gitattributes sets eol
|
|
|
|
checkout_files "" "$id" "lf" false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
checkout_files "" "$id" "crlf" false "" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
|
|
|
|
# core.autocrlf true, .gitattributes sets eol
|
|
|
|
checkout_files "" "$id" "lf" true "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul
|
|
|
|
checkout_files "" "$id" "crlf" true "" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
|
2016-02-05 19:13:20 +03:00
|
|
|
done
|
2014-06-29 10:34:54 +04:00
|
|
|
|
2016-01-16 09:50:02 +03:00
|
|
|
# Should be the last test case: remove some files from the worktree
|
|
|
|
test_expect_success 'ls-files --eol -d -z' '
|
|
|
|
rm crlf_false_attr__CRLF.txt crlf_false_attr__CRLF_mix_LF.txt crlf_false_attr__LF.txt .gitattributes &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
i/crlf w/ crlf_false_attr__CRLF.txt
|
|
|
|
i/lf w/ .gitattributes
|
|
|
|
i/lf w/ crlf_false_attr__LF.txt
|
|
|
|
i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
|
|
|
|
EOF
|
2022-03-12 09:21:25 +03:00
|
|
|
git ls-files --eol -d >tmp &&
|
|
|
|
sed -e "s!attr/[^ ]*!!g" -e "s/ / /g" -e "s/ */ /g" tmp |
|
2016-01-16 09:50:02 +03:00
|
|
|
sort >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2014-06-29 10:34:54 +04:00
|
|
|
test_done
|