{"thread":{"id":"38078","subject":"[PATCH v2] t0027: check the eol conversion warnings","startedAt":"2014-11-30T20:15:52Z","lastAt":"2014-12-05T23:15:21Z","messageCount":2,"participants":["Torsten Bögershausen","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"252750","messageId":"547B7AF8.80700@web.de","threadId":"38078","inReplyTo":null,"subject":"[PATCH v2] t0027: check the eol conversion warnings","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-11-30T20:15:52Z","receivedAt":"2014-11-30T20:15:52Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"Depending on the file content, eol parameters and .gitattributes\n\"git add\" may give a warning when the eol of a file will change\nwhen the file is checked out again.\n\nThere are 2 different warnings, either \"CRLF will be replaced...\" or\n\"LF will be replaced...\".\n\nLet t0027 check for these warnings:\ncall create_file_in_repo() with additional parameters,\nwhich will be used to call check_warning().\n\nWhen a file has eol=lf or eol=crlf in .gitattributes, it is handled\nas text and should be normalized.\nAdd missing test cases in t0027.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\nChanges since V1:\n- Simplified the diff\n- Fixed a bug (LF_mix_CR.err was mixed with CRLF_mix_LF)\n- Changed the commit message\n t/t0027-auto-crlf.sh | 82 ++++++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 66 insertions(+), 16 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 2a4a6c1..452320d 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -55,16 +55,41 @@ create_gitattributes () {\n \tesac\n }\n \n+check_warning () {\n+\tcase \"$1\" in\n+\tLF_CRLF) grep \"LF will be replaced by CRLF\" $2;;\n+\tCRLF_LF) grep \"CRLF will be replaced by LF\" $2;;\n+\t'')\n+\t\t>expect\n+\t\tgrep \"will be replaced by\" $2 >actual\n+\t\ttest_cmp expect actual\n+\t\t;;\n+\t*) false ;;\n+\tesac\n+}\n+\n create_file_in_repo () {\n \tcrlf=$1\n \tattr=$2\n+\tlfname=$3\n+\tcrlfname=$4\n+\tlfmixcrlf=$5\n+\tlfmixcr=$6\n+\tcrlfnul=$7\n \tcreate_gitattributes \"$attr\" &&\n+\tpfx=crlf_${crlf}_attr_${attr}\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF CRLF_nul\n \tdo\n-\t\tpfx=crlf_${crlf}_attr_${attr}_$f.txt &&\n-\t\tcp $f $pfx && git -c core.autocrlf=$crlf add $pfx\n+\t\tfname=${pfx}_$f.txt &&\n+\t\tcp $f $fname &&\n+\t\tgit -c core.autocrlf=$crlf add $fname 2>\"${pfx}_$f.err\"\n \tdone &&\n-\tgit commit -m \"core.autocrlf $crlf\"\n+\tgit commit -m \"core.autocrlf $crlf\" &&\n+\tcheck_warning \"$lfname\" ${pfx}_LF.err &&\n+\tcheck_warning \"$crlfname\" ${pfx}_CRLF.err &&\n+\tcheck_warning \"$lfmixcrlf\" ${pfx}_CRLF_mix_LF.err &&\n+\tcheck_warning \"$lfmixcr\" ${pfx}_LF_mix_CR.err &&\n+\tcheck_warning \"$crlfnul\" ${pfx}_CRLF_nul.err\n }\n \n check_files_in_repo () {\n@@ -140,22 +165,47 @@ test_expect_success 'setup master' '\n '\n \n \n-test_expect_success 'create files' '\n-\tcreate_file_in_repo false \"\" &&\n-\tcreate_file_in_repo true  \"\" &&\n-\tcreate_file_in_repo input \"\" &&\n \n-\tcreate_file_in_repo false \"auto\" &&\n-\tcreate_file_in_repo true  \"auto\" &&\n-\tcreate_file_in_repo input \"auto\" &&\n+warn_LF_CRLF=\"LF will be replaced by CRLF\"\n+warn_CRLF_LF=\"CRLF will be replaced by LF\"\n+\n+test_expect_success 'add files empty attr' '\n+\tcreate_file_in_repo false \"\"     \"\"        \"\"        \"\"        \"\"        \"\" &&\n+\tcreate_file_in_repo true  \"\"     \"LF_CRLF\" \"\"        \"LF_CRLF\" \"\"        \"\" &&\n+\tcreate_file_in_repo input \"\"     \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"\"\n+'\n+\n+test_expect_success 'add files attr=auto' '\n+\tcreate_file_in_repo false \"auto\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"\" &&\n+\tcreate_file_in_repo true  \"auto\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"\"        \"\" &&\n+\tcreate_file_in_repo input \"auto\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"\"\n+'\n+\n+test_expect_success 'add files attr=text' '\n+\tcreate_file_in_repo false \"text\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"CRLF_LF\" &&\n+\tcreate_file_in_repo true  \"text\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"        &&\n+\tcreate_file_in_repo input \"text\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"CRLF_LF\"\n+'\n+\n+test_expect_success 'add files attr=-text' '\n+\tcreate_file_in_repo false \"-text\" \"\"       \"\"        \"\"        \"\"        \"\" &&\n+\tcreate_file_in_repo true  \"-text\" \"\"       \"\"        \"\"        \"\"        \"\" &&\n+\tcreate_file_in_repo input \"-text\" \"\"       \"\"        \"\"        \"\"        \"\"\n+'\n+\n+test_expect_success 'add files attr=lf' '\n+\tcreate_file_in_repo false \"lf\"    \"\"       \"CRLF_LF\" \"CRLF_LF\"  \"\"       \"CRLF_LF\" &&\n+\tcreate_file_in_repo true  \"lf\"    \"\"       \"CRLF_LF\" \"CRLF_LF\"  \"\"       \"CRLF_LF\" &&\n+\tcreate_file_in_repo input \"lf\"    \"\"       \"CRLF_LF\" \"CRLF_LF\"  \"\"       \"CRLF_LF\"\n+'\n \n-\tcreate_file_in_repo false \"text\" &&\n-\tcreate_file_in_repo true  \"text\" &&\n-\tcreate_file_in_repo input \"text\" &&\n+test_expect_success 'add files attr=crlf' '\n+\tcreate_file_in_repo false \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\" &&\n+\tcreate_file_in_repo true  \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\" &&\n+\tcreate_file_in_repo input \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"\n+'\n \n-\tcreate_file_in_repo false \"-text\" &&\n-\tcreate_file_in_repo true  \"-text\" &&\n-\tcreate_file_in_repo input \"-text\" &&\n+test_expect_success 'create files cleanup' '\n \trm -f *.txt &&\n \tgit reset --hard\n '\n-- \n1.9.1.dirty\n"},{"id":"253207","messageId":"xmqqfvctofhy.fsf@gitster.dls.corp.google.com","threadId":"38078","inReplyTo":"547B7AF8.80700@web.de","subject":"Re: [PATCH v2] t0027: check the eol conversion warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-12-05T23:15:21Z","receivedAt":"2014-12-05T23:15:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> Depending on the file content, eol parameters and .gitattributes\n> \"git add\" may give a warning when the eol of a file will change\n> when the file is checked out again.\n>\n> There are 2 different warnings, either \"CRLF will be replaced...\" or\n> \"LF will be replaced...\".\n>\n> Let t0027 check for these warnings:\n> call create_file_in_repo() with additional parameters,\n> which will be used to call check_warning().\n>\n> When a file has eol=lf or eol=crlf in .gitattributes, it is handled\n> as text and should be normalized.\n> Add missing test cases in t0027.\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n\nThanks; nobody seems to have shown interest in this and it fell\nthrough the cracks it seems.  I didn't make a connection to the\nprevious discussion when I saw this v2, and backburnered it.\n\nThe patch is clear that the change to check the expected \"X will be\nreplaced by Y\" is added to existing combinations, and also for the\nlf & crlf cases the existing tests were not checking earlier.\n\nWill queue.\n\n> Changes since V1:\n> - Simplified the diff\n> - Fixed a bug (LF_mix_CR.err was mixed with CRLF_mix_LF)\n> - Changed the commit message\n>  t/t0027-auto-crlf.sh | 82 ++++++++++++++++++++++++++++++++++++++++++----------\n>  1 file changed, 66 insertions(+), 16 deletions(-)\n>\n> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\n> index 2a4a6c1..452320d 100755\n> --- a/t/t0027-auto-crlf.sh\n> +++ b/t/t0027-auto-crlf.sh\n> @@ -55,16 +55,41 @@ create_gitattributes () {\n>  \tesac\n>  }\n>  \n> +check_warning () {\n> +\tcase \"$1\" in\n> +\tLF_CRLF) grep \"LF will be replaced by CRLF\" $2;;\n> +\tCRLF_LF) grep \"CRLF will be replaced by LF\" $2;;\n> +\t'')\n> +\t\t>expect\n> +\t\tgrep \"will be replaced by\" $2 >actual\n> +\t\ttest_cmp expect actual\n> +\t\t;;\n> +\t*) false ;;\n> +\tesac\n> +}\n> +\n>  create_file_in_repo () {\n>  \tcrlf=$1\n>  \tattr=$2\n> +\tlfname=$3\n> +\tcrlfname=$4\n> +\tlfmixcrlf=$5\n> +\tlfmixcr=$6\n> +\tcrlfnul=$7\n>  \tcreate_gitattributes \"$attr\" &&\n> +\tpfx=crlf_${crlf}_attr_${attr}\n>  \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF CRLF_nul\n>  \tdo\n> -\t\tpfx=crlf_${crlf}_attr_${attr}_$f.txt &&\n> -\t\tcp $f $pfx && git -c core.autocrlf=$crlf add $pfx\n> +\t\tfname=${pfx}_$f.txt &&\n> +\t\tcp $f $fname &&\n> +\t\tgit -c core.autocrlf=$crlf add $fname 2>\"${pfx}_$f.err\"\n>  \tdone &&\n> -\tgit commit -m \"core.autocrlf $crlf\"\n> +\tgit commit -m \"core.autocrlf $crlf\" &&\n> +\tcheck_warning \"$lfname\" ${pfx}_LF.err &&\n> +\tcheck_warning \"$crlfname\" ${pfx}_CRLF.err &&\n> +\tcheck_warning \"$lfmixcrlf\" ${pfx}_CRLF_mix_LF.err &&\n> +\tcheck_warning \"$lfmixcr\" ${pfx}_LF_mix_CR.err &&\n> +\tcheck_warning \"$crlfnul\" ${pfx}_CRLF_nul.err\n>  }\n>  \n>  check_files_in_repo () {\n> @@ -140,22 +165,47 @@ test_expect_success 'setup master' '\n>  '\n>  \n>  \n> -test_expect_success 'create files' '\n> -\tcreate_file_in_repo false \"\" &&\n> -\tcreate_file_in_repo true  \"\" &&\n> -\tcreate_file_in_repo input \"\" &&\n>  \n> -\tcreate_file_in_repo false \"auto\" &&\n> -\tcreate_file_in_repo true  \"auto\" &&\n> -\tcreate_file_in_repo input \"auto\" &&\n> +warn_LF_CRLF=\"LF will be replaced by CRLF\"\n> +warn_CRLF_LF=\"CRLF will be replaced by LF\"\n> +\n> +test_expect_success 'add files empty attr' '\n> +\tcreate_file_in_repo false \"\"     \"\"        \"\"        \"\"        \"\"        \"\" &&\n> +\tcreate_file_in_repo true  \"\"     \"LF_CRLF\" \"\"        \"LF_CRLF\" \"\"        \"\" &&\n> +\tcreate_file_in_repo input \"\"     \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"\"\n> +'\n> +\n> +test_expect_success 'add files attr=auto' '\n> +\tcreate_file_in_repo false \"auto\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"\" &&\n> +\tcreate_file_in_repo true  \"auto\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"\"        \"\" &&\n> +\tcreate_file_in_repo input \"auto\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"\"\n> +'\n> +\n> +test_expect_success 'add files attr=text' '\n> +\tcreate_file_in_repo false \"text\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"CRLF_LF\" &&\n> +\tcreate_file_in_repo true  \"text\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"        &&\n> +\tcreate_file_in_repo input \"text\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"CRLF_LF\"\n> +'\n> +\n> +test_expect_success 'add files attr=-text' '\n> +\tcreate_file_in_repo false \"-text\" \"\"       \"\"        \"\"        \"\"        \"\" &&\n> +\tcreate_file_in_repo true  \"-text\" \"\"       \"\"        \"\"        \"\"        \"\" &&\n> +\tcreate_file_in_repo input \"-text\" \"\"       \"\"        \"\"        \"\"        \"\"\n> +'\n> +\n> +test_expect_success 'add files attr=lf' '\n> +\tcreate_file_in_repo false \"lf\"    \"\"       \"CRLF_LF\" \"CRLF_LF\"  \"\"       \"CRLF_LF\" &&\n> +\tcreate_file_in_repo true  \"lf\"    \"\"       \"CRLF_LF\" \"CRLF_LF\"  \"\"       \"CRLF_LF\" &&\n> +\tcreate_file_in_repo input \"lf\"    \"\"       \"CRLF_LF\" \"CRLF_LF\"  \"\"       \"CRLF_LF\"\n> +'\n>  \n> -\tcreate_file_in_repo false \"text\" &&\n> -\tcreate_file_in_repo true  \"text\" &&\n> -\tcreate_file_in_repo input \"text\" &&\n> +test_expect_success 'add files attr=crlf' '\n> +\tcreate_file_in_repo false \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\" &&\n> +\tcreate_file_in_repo true  \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\" &&\n> +\tcreate_file_in_repo input \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"\n> +'\n>  \n> -\tcreate_file_in_repo false \"-text\" &&\n> -\tcreate_file_in_repo true  \"-text\" &&\n> -\tcreate_file_in_repo input \"-text\" &&\n> +test_expect_success 'create files cleanup' '\n>  \trm -f *.txt &&\n>  \tgit reset --hard\n>  '\n"}]}