{"thread":{"id":"38018","subject":"[PATCH RFC] t0027: check the eol conversion warnings","startedAt":"2014-11-20T21:29:10Z","lastAt":"2014-11-21T12:37:05Z","messageCount":3,"participants":["Torsten Bögershausen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"252298","messageId":"546E5D26.8030109@web.de","threadId":"38018","inReplyTo":null,"subject":"[PATCH RFC] t0027: check the eol conversion warnings","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-11-20T21:29:10Z","receivedAt":"2014-11-20T21:29:10Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"Add tests to check the warnings when adding file with eol=lf and eol=crlf.\n\nAdd a function check_warning() to check the warnings on stderr\n\"CRLF will be replaced...\" or \"LF will be replaced...\"\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n t/t0027-auto-crlf.sh | 103 +++++++++++++++++++++++++++++++++++++++------------\n 1 file changed, 80 insertions(+), 23 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 2a4a6c1..9570947 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -55,16 +55,36 @@ create_gitattributes () {\n \tesac\n }\n \n-create_file_in_repo () {\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*) test_cmp /dev/null $2;;\n+\tesac\n+}\n+\n+add_check_warn () {\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}_LF_mix_CR.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,50 +160,87 @@ 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+\tadd_check_warn false \"\"     \"\"        \"\"        \"\"        \"\"        \"\" &&\n+\tadd_check_warn true  \"\"     \"LF_CRLF\" \"\"        \"\"        \"\"        \"\" &&\n+\tadd_check_warn input \"\"     \"\"        \"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=auto' '\n+\tadd_check_warn false \"auto\" \"\"        \"CRLF_LF\" \"\"        \"\"        \"\" &&\n+\tadd_check_warn true  \"auto\" \"LF_CRLF\" \"\"        \"\"        \"\"        \"\" &&\n+\tadd_check_warn input \"auto\" \"\"        \"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=text' '\n+\tadd_check_warn false \"text\" \"\"        \"CRLF_LF\" \"\"        \"\"        \"CRLF_LF\" &&\n+\tadd_check_warn true  \"text\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"        &&\n+\tadd_check_warn input \"text\" \"\"        \"CRLF_LF\" \"\"        \"\"        \"CRLF_LF\"\n+'\n+\n+test_expect_success 'add files attr=-text' '\n+\tadd_check_warn false \"-text\" \"\"       \"\"        \"\"        \"\"        \"\" &&\n+\tadd_check_warn true  \"-text\" \"\"       \"\"        \"\"        \"\"        \"\" &&\n+\tadd_check_warn input \"-text\" \"\"       \"\"        \"\"        \"\"        \"\"\n+'\n+\n+test_expect_success 'add files attr=lf' '\n+\tadd_check_warn false \"lf\"    \"\"       \"CRLF_LF\" \"\"         \"\"       \"CRLF_LF\" &&\n+\tadd_check_warn true  \"lf\"    \"\"       \"CRLF_LF\" \"\"         \"\"       \"CRLF_LF\" &&\n+\tadd_check_warn input \"lf\"    \"\"       \"CRLF_LF\" \"\"         \"\"       \"CRLF_LF\"\n+'\n+\n+test_expect_success 'add files attr=crlf' '\n+\tadd_check_warn false \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\" &&\n+\tadd_check_warn true  \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\" &&\n+\tadd_check_warn input \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"\n+'\n+\n+test_expect_success 'create files cleanup' '\n \trm -f *.txt &&\n \tgit reset --hard\n '\n \n-test_expect_success 'commit empty gitattribues' '\n+test_expect_success 'check file in repo empty gitattribues' '\n \tcheck_files_in_repo false \"\"      LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&\n \tcheck_files_in_repo true  \"\"      LF LF   LF          LF_mix_CR CRLF_nul &&\n \tcheck_files_in_repo input \"\"      LF LF   LF          LF_mix_CR CRLF_nul\n '\n \n-test_expect_success 'commit text=auto' '\n+test_expect_success 'check file in repo text=auto' '\n \tcheck_files_in_repo false \"auto\"  LF LF   LF          LF_mix_CR CRLF_nul &&\n \tcheck_files_in_repo true  \"auto\"  LF LF   LF          LF_mix_CR CRLF_nul &&\n \tcheck_files_in_repo input \"auto\"  LF LF   LF          LF_mix_CR CRLF_nul\n '\n \n-test_expect_success 'commit text' '\n+test_expect_success 'check file in repo text' '\n \tcheck_files_in_repo false \"text\"  LF LF   LF          LF_mix_CR LF_nul &&\n \tcheck_files_in_repo true  \"text\"  LF LF   LF          LF_mix_CR LF_nul &&\n \tcheck_files_in_repo input \"text\"  LF LF   LF          LF_mix_CR LF_nul\n '\n \n-test_expect_success 'commit -text' '\n+test_expect_success 'check file in repo -text' '\n \tcheck_files_in_repo false \"-text\" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&\n \tcheck_files_in_repo true  \"-text\" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&\n \tcheck_files_in_repo input \"-text\" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul\n '\n \n+test_expect_success 'check file in repo lf' '\n+\tcheck_files_in_repo false \"lf\"    LF LF   LF          LF_mix_CR LF_nul &&\n+\tcheck_files_in_repo true  \"lf\"    LF LF   LF          LF_mix_CR LF_nul &&\n+\tcheck_files_in_repo input \"lf\"    LF LF   LF          LF_mix_CR LF_nul\n+'\n+\n+test_expect_success 'check file in repo crlf' '\n+\tcheck_files_in_repo false \"crlf\"  LF LF   LF          LF_mix_CR LF_nul &&\n+\tcheck_files_in_repo true  \"crlf\"  LF LF   LF          LF_mix_CR LF_nul &&\n+\tcheck_files_in_repo input \"crlf\"  LF LF   LF          LF_mix_CR LF_nul\n+'\n+\n ################################################################################\n # Check how files in the repo are changed when they are checked out\n # How to read the table below:\n@@ -199,8 +256,8 @@ test_expect_success 'commit -text' '\n # - parameter $8 : reference for a file with CRLF and a NUL (should be handled as binary when auto)\n \n #                                            What we have in the repo:\n-#                \t\t\t\t\t\t\t\t\t\t\t\t\t\t ----------------- EOL in repo ----------------\n-#                \t\t\t\t\t\t\t\t\t\t\t\t\t\t LF    CRLF  CRLF_mix_LF  LF_mix_CR    CRLF_nul\n+#                                            ----------------- EOL in repo ----------------\n+#                                            LF    CRLF  CRLF_mix_LF  LF_mix_CR    CRLF_nul\n #                   settings with checkout:\n #                   core.   core.   .gitattr\n #                    eol     acrlf\n-- \n1.9.1.dirty\n"},{"id":"252307","messageId":"xmqqr3wx1oth.fsf@gitster.dls.corp.google.com","threadId":"38018","inReplyTo":"546E5D26.8030109@web.de","subject":"Re: [PATCH RFC] t0027: check the eol conversion warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-11-20T22:37:14Z","receivedAt":"2014-11-20T22:37:14Z","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> Add tests to check the warnings when adding file with eol=lf and eol=crlf.\n>\n> Add a function check_warning() to check the warnings on stderr\n> \"CRLF will be replaced...\" or \"LF will be replaced...\"\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n\nAt a glance it is very hard to see what we might be _losing_ with this\nchange that claims to \"add\" new kinds of tests on top of existing ones.\n\nI am guessing that add-check-warn roughly corresponds to the old\ncreate-file-in-repo but they have different calling conventions, or\nsomething?\n\nPerhaps split it into two patches (or more), each of which does one\nthing and one thing well?  I suspect that even with a two-patch\nsplit (e.g. the first of which only renames the function without\nadding the new \"grep in error messages that could be localized and\ngive false failures\" code, and the second adds the lf/crlf stuff)\nmight make this at least readable.\n\nI dunno.\n\n>  t/t0027-auto-crlf.sh | 103 +++++++++++++++++++++++++++++++++++++++------------\n>  1 file changed, 80 insertions(+), 23 deletions(-)\n>\n> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\n> index 2a4a6c1..9570947 100755\n> --- a/t/t0027-auto-crlf.sh\n> +++ b/t/t0027-auto-crlf.sh\n> @@ -55,16 +55,36 @@ create_gitattributes () {\n>  \tesac\n>  }\n>  \n> -create_file_in_repo () {\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*) test_cmp /dev/null $2;;\n> +\tesac\n> +}\n> +\n> +add_check_warn () {\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}_LF_mix_CR.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,50 +160,87 @@ 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> +\tadd_check_warn false \"\"     \"\"        \"\"        \"\"        \"\"        \"\" &&\n> +\tadd_check_warn true  \"\"     \"LF_CRLF\" \"\"        \"\"        \"\"        \"\" &&\n> +\tadd_check_warn input \"\"     \"\"        \"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=auto' '\n> +\tadd_check_warn false \"auto\" \"\"        \"CRLF_LF\" \"\"        \"\"        \"\" &&\n> +\tadd_check_warn true  \"auto\" \"LF_CRLF\" \"\"        \"\"        \"\"        \"\" &&\n> +\tadd_check_warn input \"auto\" \"\"        \"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=text' '\n> +\tadd_check_warn false \"text\" \"\"        \"CRLF_LF\" \"\"        \"\"        \"CRLF_LF\" &&\n> +\tadd_check_warn true  \"text\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"        &&\n> +\tadd_check_warn input \"text\" \"\"        \"CRLF_LF\" \"\"        \"\"        \"CRLF_LF\"\n> +'\n> +\n> +test_expect_success 'add files attr=-text' '\n> +\tadd_check_warn false \"-text\" \"\"       \"\"        \"\"        \"\"        \"\" &&\n> +\tadd_check_warn true  \"-text\" \"\"       \"\"        \"\"        \"\"        \"\" &&\n> +\tadd_check_warn input \"-text\" \"\"       \"\"        \"\"        \"\"        \"\"\n> +'\n> +\n> +test_expect_success 'add files attr=lf' '\n> +\tadd_check_warn false \"lf\"    \"\"       \"CRLF_LF\" \"\"         \"\"       \"CRLF_LF\" &&\n> +\tadd_check_warn true  \"lf\"    \"\"       \"CRLF_LF\" \"\"         \"\"       \"CRLF_LF\" &&\n> +\tadd_check_warn input \"lf\"    \"\"       \"CRLF_LF\" \"\"         \"\"       \"CRLF_LF\"\n> +'\n> +\n> +test_expect_success 'add files attr=crlf' '\n> +\tadd_check_warn false \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\" &&\n> +\tadd_check_warn true  \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\" &&\n> +\tadd_check_warn input \"crlf\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"\n> +'\n> +\n> +test_expect_success 'create files cleanup' '\n>  \trm -f *.txt &&\n>  \tgit reset --hard\n>  '\n>  \n> -test_expect_success 'commit empty gitattribues' '\n> +test_expect_success 'check file in repo empty gitattribues' '\n>  \tcheck_files_in_repo false \"\"      LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&\n>  \tcheck_files_in_repo true  \"\"      LF LF   LF          LF_mix_CR CRLF_nul &&\n>  \tcheck_files_in_repo input \"\"      LF LF   LF          LF_mix_CR CRLF_nul\n>  '\n>  \n> -test_expect_success 'commit text=auto' '\n> +test_expect_success 'check file in repo text=auto' '\n>  \tcheck_files_in_repo false \"auto\"  LF LF   LF          LF_mix_CR CRLF_nul &&\n>  \tcheck_files_in_repo true  \"auto\"  LF LF   LF          LF_mix_CR CRLF_nul &&\n>  \tcheck_files_in_repo input \"auto\"  LF LF   LF          LF_mix_CR CRLF_nul\n>  '\n>  \n> -test_expect_success 'commit text' '\n> +test_expect_success 'check file in repo text' '\n>  \tcheck_files_in_repo false \"text\"  LF LF   LF          LF_mix_CR LF_nul &&\n>  \tcheck_files_in_repo true  \"text\"  LF LF   LF          LF_mix_CR LF_nul &&\n>  \tcheck_files_in_repo input \"text\"  LF LF   LF          LF_mix_CR LF_nul\n>  '\n>  \n> -test_expect_success 'commit -text' '\n> +test_expect_success 'check file in repo -text' '\n>  \tcheck_files_in_repo false \"-text\" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&\n>  \tcheck_files_in_repo true  \"-text\" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&\n>  \tcheck_files_in_repo input \"-text\" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul\n>  '\n>  \n> +test_expect_success 'check file in repo lf' '\n> +\tcheck_files_in_repo false \"lf\"    LF LF   LF          LF_mix_CR LF_nul &&\n> +\tcheck_files_in_repo true  \"lf\"    LF LF   LF          LF_mix_CR LF_nul &&\n> +\tcheck_files_in_repo input \"lf\"    LF LF   LF          LF_mix_CR LF_nul\n> +'\n> +\n> +test_expect_success 'check file in repo crlf' '\n> +\tcheck_files_in_repo false \"crlf\"  LF LF   LF          LF_mix_CR LF_nul &&\n> +\tcheck_files_in_repo true  \"crlf\"  LF LF   LF          LF_mix_CR LF_nul &&\n> +\tcheck_files_in_repo input \"crlf\"  LF LF   LF          LF_mix_CR LF_nul\n> +'\n> +\n>  ################################################################################\n>  # Check how files in the repo are changed when they are checked out\n>  # How to read the table below:\n> @@ -199,8 +256,8 @@ test_expect_success 'commit -text' '\n>  # - parameter $8 : reference for a file with CRLF and a NUL (should be handled as binary when auto)\n>  \n>  #                                            What we have in the repo:\n> -#                \t\t\t\t\t\t\t\t\t\t\t\t\t\t ----------------- EOL in repo ----------------\n> -#                \t\t\t\t\t\t\t\t\t\t\t\t\t\t LF    CRLF  CRLF_mix_LF  LF_mix_CR    CRLF_nul\n> +#                                            ----------------- EOL in repo ----------------\n> +#                                            LF    CRLF  CRLF_mix_LF  LF_mix_CR    CRLF_nul\n>  #                   settings with checkout:\n>  #                   core.   core.   .gitattr\n>  #                    eol     acrlf\n"},{"id":"252332","messageId":"546F31F1.5050701@web.de","threadId":"38018","inReplyTo":"xmqqr3wx1oth.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH RFC] t0027: check the eol conversion warnings","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-11-21T12:37:05Z","receivedAt":"2014-11-21T12:37:05Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"\nOn 20.11.14 23:37, Junio C Hamano wrote:\n>\n> ---\n> At a glance it is very hard to see what we might be _losing_ with this\n> change that claims to \"add\" new kinds of tests on top of existing ones.\n>\n> I am guessing that add-check-warn roughly corresponds to the old\n> create-file-in-repo but they have different calling conventions, or\n> something?\n>\n> Perhaps split it into two patches (or more), each of which does one\n> thing and one thing well?  I suspect that even with a two-patch\n> split (e.g. the first of which only renames the function without\n> adding the new \"grep in error messages that could be localized and\n> give false failures\" code, and the second adds the lf/crlf stuff)\n> might make this at least readable.\n>\n> I dunno.\n>\nWe shouldn't loose anything.\nThe diff is hard to read, as some code\nis re-defined and re-used (and a diff side-by-side looks nicer than the patch)\n\nI will come back with a new commit message, which should explain things better\n( or a 2-stepped patch)\n\nThe long term idea is to improve the gray areas in convert.c, and to do that we need a reliable\ntest frame work, to see what is improved or broken.\n"}]}