{"thread":{"id":"41251","subject":"[PATCH v2] t0027: Add tests for get_stream_filter()","startedAt":"2016-01-24T07:55:43Z","lastAt":"2016-02-23T20:52:22Z","messageCount":47,"participants":["tboegi@web.de","Junio C Hamano","Torsten Bögershausen","Eric Sunshine"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"276617","messageId":"1453622143-22038-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v2] t0027: Add tests for get_stream_filter()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-01-24T07:55:43Z","receivedAt":"2016-01-24T07:55:43Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen a filter is configured, a different code-path is used in\nconvert.c and entry.c via get_stream_filter(), but there are no test cases yet.\n\nAdd tests for the filter API by configuring the ident filter.\nThe result of the SHA1 conversion is not checked, this is already\ndone in other TC.\n\nAdd a parameter to checkout_files() in t0027.\nWhile changing the signature, add another parameter for the eol= attribute.\nThis is currently unused, tests for e.g.\n\"* text=auto eol=lf\" will be added in a separate commit.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n- This needs to go on top of  tb/ls-files-eol\nchanges since v1:\n- minor type, add signoff (Thanks Eric)\n- Can not use sed as intended:\n  Non-Gnu sed like Mac OS needs \"lines\" to have a LF at the end,\n  otherwise they add one. Use tr instead.\n  \nt/t0027-auto-crlf.sh | 262 ++++++++++++++++++++++++++++-----------------------\n 1 file changed, 146 insertions(+), 116 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 504e5a0..f830243 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -21,32 +21,45 @@ compare_ws_file () {\n \tpfx=$1\n \texp=$2.expect\n \tact=$pfx.actual.$3\n-\ttr '\\015\\000' QN <\"$2\" >\"$exp\" &&\n-\ttr '\\015\\000' QN <\"$3\" >\"$act\" &&\n+\ttr '\\015\\000abcdef01234567890' QN00000000000000000 <\"$2\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef01234567890' QN00000000000000000 <\"$3\" >\"$act\" &&\n \ttest_cmp $exp $act &&\n \trm $exp $act\n }\n \n create_gitattributes () {\n \tattr=$1\n+\tident=$2\n+\tcase \"$2\" in\n+\t\t\"\")\n+\t\t\t>.gitattributes\n+\t\t\t;;\n+\t\ti)\n+\t\t\techo \"* ident\" >.gitattributes\n+\t\t\t;;\n+\t\t*)\n+\t\t\techo >&2 invalid ident: $2\n+\t\t\texit 1\n+\tesac\n+\n \tcase \"$attr\" in\n \t\tauto)\n-\t\techo \"*.txt text=auto\" >.gitattributes\n+\t\techo \"*.txt text=auto\" >>.gitattributes\n \t\t;;\n \t\ttext)\n-\t\techo \"*.txt text\" >.gitattributes\n+\t\techo \"*.txt text\" >>.gitattributes\n \t\t;;\n \t\t-text)\n-\t\techo \"*.txt -text\" >.gitattributes\n+\t\techo \"*.txt -text\" >>.gitattributes\n \t\t;;\n \t\tcrlf)\n-\t\techo \"*.txt eol=crlf\" >.gitattributes\n+\t\techo \"*.txt eol=crlf\" >>.gitattributes\n \t\t;;\n \t\tlf)\n-\t\techo \"*.txt eol=lf\" >.gitattributes\n+\t\techo \"*.txt eol=lf\" >>.gitattributes\n \t\t;;\n \t\t\"\")\n-\t\techo >.gitattributes\n+\t\t#echo >.gitattributes\n \t\t;;\n \t\t*)\n \t\techo >&2 invalid attribute: $attr\n@@ -90,7 +103,7 @@ commit_check_warn () {\n \tlfmixcr=$6\n \tcrlfnul=$7\n \tpfx=crlf_${crlf}_attr_${attr}\n-\tcreate_gitattributes \"$attr\" &&\n+\tcreate_gitattributes \"$attr\" \"\" &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul\n \tdo\n \t\tfname=${pfx}_$f.txt &&\n@@ -115,7 +128,7 @@ commit_chk_wrnNNO () {\n \tcrlfnul=$7\n \tpfx=NNO_${crlf}_attr_${attr}\n \t#Commit files on top of existing file\n-\tcreate_gitattributes \"$attr\" &&\n+\tcreate_gitattributes \"$attr\" \"\" &&\n \tfor f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul\n \tdo\n \t\tfname=${pfx}_$f.txt &&\n@@ -208,28 +221,30 @@ check_in_repo_NNO () {\n }\n \n checkout_files () {\n-\teol=$1\n-\tcrlf=$2\n-\tattr=$3\n-\tlfname=$4\n-\tcrlfname=$5\n-\tlfmixcrlf=$6\n-\tlfmixcr=$7\n-\tcrlfnul=$8\n-\tcreate_gitattributes $attr &&\n+\tattr=$1 ; shift\n+\tident=$1; shift\n+\taeol=$1 ; shift\n+\tcrlf=$1 ; shift\n+\tceol=$1 ; shift\n+\tlfname=$1 ; shift\n+\tcrlfname=$1 ; shift\n+\tlfmixcrlf=$1 ; shift\n+\tlfmixcr=$1 ; shift\n+\tcrlfnul=$1 ; shift\n+\tcreate_gitattributes \"$attr\" \"$ident\" &&\n \tgit config core.autocrlf $crlf &&\n-\tpfx=eol_${eol}_crlf_${crlf}_attr_${attr}_ &&\n+\tpfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul\n \tdo\n \t\trm crlf_false_attr__$f.txt &&\n-\t\tif test -z \"$eol\"; then\n+\t\tif test -z \"$ceol\"; then\n \t\t\tgit checkout crlf_false_attr__$f.txt\n \t\telse\n-\t\t\tgit -c core.eol=$eol checkout crlf_false_attr__$f.txt\n+\t\t\tgit -c core.eol=$ceol checkout crlf_false_attr__$f.txt\n \t\tfi\n \tdone\n \n-\ttest_expect_success \"ls-files --eol $lfname ${pfx}LF.txt\" '\n+\ttest_expect_success \"ls-files --eol i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n \t\ttest_when_finished \"rm expect actual\" &&\n \t\tsort <<-EOF >expect &&\n \t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n@@ -244,19 +259,19 @@ checkout_files () {\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF\" \"\n \t\tcompare_ws_file $pfx $lfname    crlf_false_attr__LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF\" \"\n \t\tcompare_ws_file $pfx $crlfname  crlf_false_attr__CRLF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF_mix_LF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF\" \"\n \t\tcompare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_mix_CR\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR\" \"\n \t\tcompare_ws_file $pfx $lfmixcr   crlf_false_attr__LF_mix_CR.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_nul\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul\" \"\n \t\tcompare_ws_file $pfx $crlfnul   crlf_false_attr__LF_nul.txt\n \t\"\n }\n@@ -301,14 +316,13 @@ test_expect_success 'setup master' '\n \tgit checkout -b master &&\n \tgit add .gitattributes &&\n \tgit commit -m \"add .gitattributes\" \"\" &&\n-\tprintf \"line1\\nline2\\nline3\"     >LF &&\n-\tprintf \"line1\\r\\nline2\\r\\nline3\" >CRLF &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >repoMIX &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >CRLF_mix_LF &&\n-\tprintf \"line1\\nline2\\rline3\"     >LF_mix_CR &&\n-\tprintf \"line1\\r\\nline2\\rline3\"   >CRLF_mix_CR &&\n-\tprintf \"line1Q\\r\\nline2\\r\\nline3\" | q_to_nul >CRLF_nul &&\n-\tprintf \"line1Q\\nline2\\nline3\" | q_to_nul >LF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\nLINETHREE\"     >LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\r\\nLINETHREE\" >CRLF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\r\\nLINETWO\\nLINETHREE\"   >CRLF_mix_LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\rLINETHREE\"     >LF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\rLINETHREE\"   >CRLF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONEQ\\r\\nLINETWO\\r\\nLINETHREE\" | q_to_nul >CRLF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONEQ\\nLINETWO\\nLINETHREE\" | q_to_nul >LF_nul &&\n \tcreate_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&\n \tgit -c core.autocrlf=false add NNO_*.txt &&\n \tgit commit -m \"mixed line endings\" &&\n@@ -449,23 +463,18 @@ check_in_repo_NNO input \"-text\" LF        CRLF      CRLF_mix_LF  LF_mix_CR \tCRLF\n # How to read the table below:\n # - checkout_files will check multiple files with a combination of settings\n #   and attributes (core.autocrlf=input is forbidden with core.eol=crlf)\n-# - parameter $1 : core.eol               lf | crlf\n-# - parameter $2 : core.autocrlf          false | true | input\n-# - parameter $3 : text in .gitattributs  \"\" (empty) | auto | text | -text\n-# - parameter $4 : reference for a file with only LF in the repo\n-# - parameter $5 : reference for a file with only CRLF in the repo\n-# - parameter $6 : reference for a file with mixed LF and CRLF in the repo\n-# - parameter $7 : reference for a file with LF and CR in the repo (does somebody uses this ?)\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-#                                            ----------------- 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-#                                            ----------------------------------------------\n-#                                            What we want to have in the working tree:\n+#\n+# - parameter $1 \t: text in .gitattributs  \"\" (empty) | auto | text | -text\n+# - parameter $2 \t: ident                  \"\" | i (i == ident)\n+# - parameter $3 \t: eol in .gitattributs   \"\" (empty) | lf | crlf\n+# - parameter $4 \t: core.autocrlf          false | true | input\n+# - parameter $5 \t: core.eol               \"\" | lf | crlf | \"native\"\n+# - parameter $6 \t: reference for a file with only LF in the repo\n+# - parameter $7 \t: reference for a file with only CRLF in the repo\n+# - parameter $8 \t: reference for a file with mixed LF and CRLF in the repo\n+# - parameter $9 \t: reference for a file with LF and CR in the repo\n+# - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)\n+\n if test_have_prereq NATIVE_CRLF\n then\n MIX_CRLF_LF=CRLF\n@@ -480,69 +489,90 @@ LFNUL=LF_nul\n fi\n export CRLF_MIX_LF_CR MIX NL\n \n-checkout_files    lf      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    lf      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    crlf    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    \"\"      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    \"\"      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    native  false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    native  true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    native  false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    native  true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+checkout_files \"\"      \"\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   crlf     CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   lf       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   native   CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   \"\"       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   lf       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   native   CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\n+for id in \"\" i;\n+do\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+done\n \n # Should be the last test case: remove some files from the worktree\n test_expect_success 'ls-files --eol -d -z' '\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"276849","messageId":"xmqqio2fa5uc.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1453622143-22038-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v2] t0027: Add tests for get_stream_filter()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-01-27T06:34:19Z","receivedAt":"2016-01-27T06:34:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> When a filter is configured, a different code-path is used in\n> convert.c and entry.c via get_stream_filter(), but there are no test cases yet.\n>\n> Add tests for the filter API by configuring the ident filter.\n> The result of the SHA1 conversion is not checked, this is already\n> done in other TC.\n>\n> Add a parameter to checkout_files() in t0027.\n> While changing the signature, add another parameter for the eol= attribute.\n> This is currently unused, tests for e.g.\n> \"* text=auto eol=lf\" will be added in a separate commit.\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n> - This needs to go on top of  tb/ls-files-eol\n\nWith missing \"separate commit\", I am having a hard time to decide if\nthis is something I should pick up at this moment, or I should wait\nuntil that separate commit materializes.  What is your intention?\n\nThanks.\n"},{"id":"276876","messageId":"56A8884D.3060605@web.de","threadId":"41251","inReplyTo":"xmqqio2fa5uc.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] t0027: Add tests for get_stream_filter()","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2016-01-27T09:05:17Z","receivedAt":"2016-01-27T09:05:17Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"\n- This needs to go on top of  tb/ls-files-eol\n\n> With missing \"separate commit\", I am having a hard time to decide if\n> this is something I should pick up at this moment, or I should wait\n> until that separate commit materializes.  What is your intention?\n>\nI send a serious including this patch the next days.\nIf there are more review comments, they are welcome.\n"},{"id":"276891","messageId":"1453907725-31536-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v1 1/6] t0027: Add tests for get_stream_filter()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-01-27T15:15:25Z","receivedAt":"2016-01-27T15:15:25Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen a filter is configured, a different code-path is used in convert.c\nand entry.c via get_stream_filter(), but there are no test cases yet.\n\nAdd tests for the filter API by configuring the ident filter.\nThe result of the SHA1 conversion is not checked, this is already\ndone in other TC.\n\nAdd a parameter to checkout_files() in t0027.\nWhile changing the signature, add another parameter for the eol= attribute.\nThis is currently unused, tests for e.g.\n\"* text=auto eol=lf\" will be added in a separate commit.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n t/t0027-auto-crlf.sh | 262 ++++++++++++++++++++++++++++-----------------------\n 1 file changed, 146 insertions(+), 116 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 504e5a0..08fe6a5 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -21,32 +21,45 @@ compare_ws_file () {\n \tpfx=$1\n \texp=$2.expect\n \tact=$pfx.actual.$3\n-\ttr '\\015\\000' QN <\"$2\" >\"$exp\" &&\n-\ttr '\\015\\000' QN <\"$3\" >\"$act\" &&\n+\ttr '\\015\\000abcdef01234567890' QN00000000000000000 <\"$2\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef01234567890' QN00000000000000000 <\"$3\" >\"$act\" &&\n \ttest_cmp $exp $act &&\n \trm $exp $act\n }\n \n create_gitattributes () {\n \tattr=$1\n+\tident=$2\n+\tcase \"$2\" in\n+\t\t\"\")\n+\t\t\t>.gitattributes\n+\t\t\t;;\n+\t\ti)\n+\t\t\techo \"* ident\" >.gitattributes\n+\t\t\t;;\n+\t\t*)\n+\t\t\techo >&2 invalid ident: $2\n+\t\t\texit 1\n+\tesac\n+\t\t \n \tcase \"$attr\" in\n \t\tauto)\n-\t\techo \"*.txt text=auto\" >.gitattributes\n+\t\techo \"*.txt text=auto\" >>.gitattributes\n \t\t;;\n \t\ttext)\n-\t\techo \"*.txt text\" >.gitattributes\n+\t\techo \"*.txt text\" >>.gitattributes\n \t\t;;\n \t\t-text)\n-\t\techo \"*.txt -text\" >.gitattributes\n+\t\techo \"*.txt -text\" >>.gitattributes\n \t\t;;\n \t\tcrlf)\n-\t\techo \"*.txt eol=crlf\" >.gitattributes\n+\t\techo \"*.txt eol=crlf\" >>.gitattributes\n \t\t;;\n \t\tlf)\n-\t\techo \"*.txt eol=lf\" >.gitattributes\n+\t\techo \"*.txt eol=lf\" >>.gitattributes\n \t\t;;\n \t\t\"\")\n-\t\techo >.gitattributes\n+\t\t#echo >.gitattributes\n \t\t;;\n \t\t*)\n \t\techo >&2 invalid attribute: $attr\n@@ -90,7 +103,7 @@ commit_check_warn () {\n \tlfmixcr=$6\n \tcrlfnul=$7\n \tpfx=crlf_${crlf}_attr_${attr}\n-\tcreate_gitattributes \"$attr\" &&\n+\tcreate_gitattributes \"$attr\" \"\" &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul\n \tdo\n \t\tfname=${pfx}_$f.txt &&\n@@ -115,7 +128,7 @@ commit_chk_wrnNNO () {\n \tcrlfnul=$7\n \tpfx=NNO_${crlf}_attr_${attr}\n \t#Commit files on top of existing file\n-\tcreate_gitattributes \"$attr\" &&\n+\tcreate_gitattributes \"$attr\" \"\" &&\n \tfor f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul\n \tdo\n \t\tfname=${pfx}_$f.txt &&\n@@ -208,28 +221,30 @@ check_in_repo_NNO () {\n }\n \n checkout_files () {\n-\teol=$1\n-\tcrlf=$2\n-\tattr=$3\n-\tlfname=$4\n-\tcrlfname=$5\n-\tlfmixcrlf=$6\n-\tlfmixcr=$7\n-\tcrlfnul=$8\n-\tcreate_gitattributes $attr &&\n+\tattr=$1 ; shift\n+\tident=$1; shift\n+\taeol=$1 ; shift\n+\tcrlf=$1 ; shift\n+\tceol=$1 ; shift\n+\tlfname=$1 ; shift\n+\tcrlfname=$1 ; shift\n+\tlfmixcrlf=$1 ; shift\n+\tlfmixcr=$1 ; shift\n+\tcrlfnul=$1 ; shift\n+\tcreate_gitattributes \"$attr\" \"$ident\" &&\n \tgit config core.autocrlf $crlf &&\n-\tpfx=eol_${eol}_crlf_${crlf}_attr_${attr}_ &&\n+\tpfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul\n \tdo\n \t\trm crlf_false_attr__$f.txt &&\n-\t\tif test -z \"$eol\"; then\n+\t\tif test -z \"$ceol\"; then\n \t\t\tgit checkout crlf_false_attr__$f.txt\n \t\telse\n-\t\t\tgit -c core.eol=$eol checkout crlf_false_attr__$f.txt\n+\t\t\tgit -c core.eol=$ceol checkout crlf_false_attr__$f.txt\n \t\tfi\n \tdone\n \n-\ttest_expect_success \"ls-files --eol $lfname ${pfx}LF.txt\" '\n+\ttest_expect_success \"ls-files --eol attr=$attr i=$ident $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n \t\ttest_when_finished \"rm expect actual\" &&\n \t\tsort <<-EOF >expect &&\n \t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n@@ -244,19 +259,19 @@ checkout_files () {\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF\" \"\n \t\tcompare_ws_file $pfx $lfname    crlf_false_attr__LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF\" \"\n \t\tcompare_ws_file $pfx $crlfname  crlf_false_attr__CRLF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF_mix_LF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF\" \"\n \t\tcompare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_mix_CR\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR\" \"\n \t\tcompare_ws_file $pfx $lfmixcr   crlf_false_attr__LF_mix_CR.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_nul\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul\" \"\n \t\tcompare_ws_file $pfx $crlfnul   crlf_false_attr__LF_nul.txt\n \t\"\n }\n@@ -301,14 +316,13 @@ test_expect_success 'setup master' '\n \tgit checkout -b master &&\n \tgit add .gitattributes &&\n \tgit commit -m \"add .gitattributes\" \"\" &&\n-\tprintf \"line1\\nline2\\nline3\"     >LF &&\n-\tprintf \"line1\\r\\nline2\\r\\nline3\" >CRLF &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >repoMIX &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >CRLF_mix_LF &&\n-\tprintf \"line1\\nline2\\rline3\"     >LF_mix_CR &&\n-\tprintf \"line1\\r\\nline2\\rline3\"   >CRLF_mix_CR &&\n-\tprintf \"line1Q\\r\\nline2\\r\\nline3\" | q_to_nul >CRLF_nul &&\n-\tprintf \"line1Q\\nline2\\nline3\" | q_to_nul >LF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\nLINETHREE\"     >LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\r\\nLINETHREE\" >CRLF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\r\\nLINETWO\\nLINETHREE\"   >CRLF_mix_LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\rLINETHREE\"     >LF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\rLINETHREE\"   >CRLF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONEQ\\r\\nLINETWO\\r\\nLINETHREE\" | q_to_nul >CRLF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONEQ\\nLINETWO\\nLINETHREE\" | q_to_nul >LF_nul &&\n \tcreate_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&\n \tgit -c core.autocrlf=false add NNO_*.txt &&\n \tgit commit -m \"mixed line endings\" &&\n@@ -449,23 +463,18 @@ check_in_repo_NNO input \"-text\" LF        CRLF      CRLF_mix_LF  LF_mix_CR \tCRLF\n # How to read the table below:\n # - checkout_files will check multiple files with a combination of settings\n #   and attributes (core.autocrlf=input is forbidden with core.eol=crlf)\n-# - parameter $1 : core.eol               lf | crlf\n-# - parameter $2 : core.autocrlf          false | true | input\n-# - parameter $3 : text in .gitattributs  \"\" (empty) | auto | text | -text\n-# - parameter $4 : reference for a file with only LF in the repo\n-# - parameter $5 : reference for a file with only CRLF in the repo\n-# - parameter $6 : reference for a file with mixed LF and CRLF in the repo\n-# - parameter $7 : reference for a file with LF and CR in the repo (does somebody uses this ?)\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-#                                            ----------------- 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-#                                            ----------------------------------------------\n-#                                            What we want to have in the working tree:\n+#\n+# - parameter $1 \t: text in .gitattributs  \"\" (empty) | auto | text | -text\n+# - parameter $2 \t: ident                  \"\" | i (i == ident)\n+# - parameter $3 \t: eol in .gitattributs   \"\" (empty) | lf | crlf\n+# - parameter $4 \t: core.autocrlf          false | true | input\n+# - parameter $5 \t: core.eol               \"\" | lf | crlf | \"native\"\n+# - parameter $6 \t: reference for a file with only LF in the repo\n+# - parameter $7 \t: reference for a file with only CRLF in the repo\n+# - parameter $8 \t: reference for a file with mixed LF and CRLF in the repo\n+# - parameter $9 \t: reference for a file with LF and CR in the repo\n+# - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)\n+\n if test_have_prereq NATIVE_CRLF\n then\n MIX_CRLF_LF=CRLF\n@@ -480,69 +489,90 @@ LFNUL=LF_nul\n fi\n export CRLF_MIX_LF_CR MIX NL\n \n-checkout_files    lf      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    lf      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    crlf    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    \"\"      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    \"\"      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    native  false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    native  true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    native  false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    native  true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+checkout_files \"\"      \"\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   crlf     CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   lf       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   native   CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   \"\"       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   lf       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   native   CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\n+for id in \"\" i;\n+do\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+done\n \n # Should be the last test case: remove some files from the worktree\n test_expect_success 'ls-files --eol -d -z' '\n-- \n2.7.0.303.g2c4f448.dirty\n\n\nFrom e6124e6a186c736cf030c13b1073a66f43cc5841 Mon Sep 17 00:00:00 2001\nIn-Reply-To: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nReferences: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nFrom: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= <tboegi@web.de>\nDate: Sat, 2 Jan 2016 22:35:36 +0100\nSubject: [PATCH v1 2/6] convert.c: Remove path when not needed\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nSome functions get a parameter path, but don't use it.\nRemove the unused parameter.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 19 +++++++++----------\n 1 file changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 4bb4ec1..a24c2a2 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -696,7 +696,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,\n \treturn 1;\n }\n \n-static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_check *check)\n+static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -713,7 +713,7 @@ static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_ch\n \treturn CRLF_GUESS;\n }\n \n-static enum eol git_path_check_eol(const char *path, struct git_attr_check *check)\n+static enum eol git_path_check_eol(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -726,8 +726,7 @@ static enum eol git_path_check_eol(const char *path, struct git_attr_check *chec\n \treturn EOL_UNSET;\n }\n \n-static struct convert_driver *git_path_check_convert(const char *path,\n-\t\t\t\t\t     struct git_attr_check *check)\n+static struct convert_driver *git_path_check_convert(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \tstruct convert_driver *drv;\n@@ -740,7 +739,7 @@ static struct convert_driver *git_path_check_convert(const char *path,\n \treturn NULL;\n }\n \n-static int git_path_check_ident(const char *path, struct git_attr_check *check)\n+static int git_path_check_ident(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -783,12 +782,12 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 4);\n+\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n-\t\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 0);\n-\t\tca->ident = git_path_check_ident(path, ccheck + 1);\n-\t\tca->drv = git_path_check_convert(path, ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(path, ccheck + 3);\n+\t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->ident = git_path_check_ident(ccheck + 1);\n+\t\tca->drv = git_path_check_convert(ccheck + 2);\n+\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-- \n2.7.0.303.g2c4f448.dirty\n\n\nFrom 2183b7fe810a6567adba8d95dbf4a582d1d92521 Mon Sep 17 00:00:00 2001\nIn-Reply-To: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nReferences: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nFrom: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= <tboegi@web.de>\nDate: Sun, 3 Jan 2016 22:22:35 +0100\nSubject: [PATCH v1 3/6] convert.c: Remove input_crlf_action()\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nIntegrate the code of input_crlf_action() into convert_attrs(),\nso that ca.crlf_action is aleays valid after calling convert_attrs().\nKeep a copy of crlf_action in attr_action, this is needed for\nget_convert_attr_ascii().\n\nRemove eol_attr from struct conv_attrs, as it is now used temporally.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 35 +++++++++++++----------------------\n 1 file changed, 13 insertions(+), 22 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex a24c2a2..bca3d0c 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -746,21 +746,10 @@ static int git_path_check_ident(struct git_attr_check *check)\n \treturn !!ATTR_TRUE(value);\n }\n \n-static enum crlf_action input_crlf_action(enum crlf_action text_attr, enum eol eol_attr)\n-{\n-\tif (text_attr == CRLF_BINARY)\n-\t\treturn CRLF_BINARY;\n-\tif (eol_attr == EOL_LF)\n-\t\treturn CRLF_INPUT;\n-\tif (eol_attr == EOL_CRLF)\n-\t\treturn CRLF_CRLF;\n-\treturn text_attr;\n-}\n-\n struct conv_attrs {\n \tstruct convert_driver *drv;\n-\tenum crlf_action crlf_action;\n-\tenum eol eol_attr;\n+\tenum crlf_action attr_action; /* What attr says */\n+\tenum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */\n \tint ident;\n };\n \n@@ -782,16 +771,23 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n+\t\tenum eol eol_attr;\n \t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n \t\tca->drv = git_path_check_convert(ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (ca->crlf_action == CRLF_BINARY)\n+\t\t\treturn;\n+\t\teol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (eol_attr == EOL_LF)\n+\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\telse if (eol_attr == EOL_CRLF)\n+\t\t\tca->crlf_action = CRLF_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-\t\tca->eol_attr = EOL_UNSET;\n \t\tca->ident = 0;\n \t}\n }\n@@ -818,11 +814,9 @@ int would_convert_to_git_filter_fd(const char *path)\n const char *get_convert_attr_ascii(const char *path)\n {\n \tstruct conv_attrs ca;\n-\tenum crlf_action crlf_action;\n \n \tconvert_attrs(&ca, path);\n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n-\tswitch (crlf_action) {\n+\tswitch (ca.attr_action) {\n \tcase CRLF_GUESS:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n@@ -861,7 +855,6 @@ int convert_to_git(const char *path, const char *src, size_t len,\n \t\tsrc = dst->buf;\n \t\tlen = dst->len;\n \t}\n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tret |= crlf_to_git(path, src, len, dst, ca.crlf_action, checksafe);\n \tif (ret && dst) {\n \t\tsrc = dst->buf;\n@@ -882,7 +875,6 @@ void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,\n \tif (!apply_filter(path, NULL, 0, fd, dst, ca.drv->clean))\n \t\tdie(\"%s: clean filter '%s' failed\", path, ca.drv->name);\n \n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tcrlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);\n \tident_to_git(path, dst->buf, dst->len, dst, ca.ident);\n }\n@@ -912,7 +904,6 @@ static int convert_to_working_tree_internal(const char *path, const char *src,\n \t * is a smudge filter.  The filter might expect CRLFs.\n \t */\n \tif (filter || !normalizing) {\n-\t\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \t\tret |= crlf_to_worktree(path, src, len, dst, ca.crlf_action);\n \t\tif (ret) {\n \t\t\tsrc = dst->buf;\n@@ -1381,7 +1372,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \tif (ca.ident)\n \t\tfilter = ident_filter(sha1);\n \n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n+\tcrlf_action = ca.crlf_action;\n \n \tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n-- \n2.7.0.303.g2c4f448.dirty\n\n\nFrom 4b0a119f136ff1b4711cd2e588c8ce183ffd2e8e Mon Sep 17 00:00:00 2001\nIn-Reply-To: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nReferences: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nFrom: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= <tboegi@web.de>\nDate: Mon, 4 Jan 2016 22:06:11 +0100\nSubject: [PATCH v1 4/6] convert.c: Use text_eol_is_crlf()\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nAdd a helper function to find out, which line endings\ntext files should get at checkout, depending on\ncore.autocrlf and core.eol\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 25 +++++++++++++++++--------\n 1 file changed, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex bca3d0c..a5701a1 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -149,6 +149,19 @@ const char *get_wt_convert_stats_ascii(const char *path)\n \treturn ret;\n }\n \n+static int text_eol_is_crlf(void)\n+{\n+\tif (auto_crlf == AUTO_CRLF_TRUE)\n+\t\treturn 1;\n+\telse if (auto_crlf == AUTO_CRLF_INPUT)\n+\t\treturn 0;\n+\tif (core_eol == EOL_CRLF)\n+\t\treturn 1;\n+\tif (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n static enum eol output_eol(enum crlf_action crlf_action)\n {\n \tswitch (crlf_action) {\n@@ -164,12 +177,7 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \t\t/* fall through */\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n-\t\tif (auto_crlf == AUTO_CRLF_TRUE)\n-\t\t\treturn EOL_CRLF;\n-\t\telse if (auto_crlf == AUTO_CRLF_INPUT)\n-\t\t\treturn EOL_LF;\n-\t\telse if (core_eol == EOL_UNSET)\n-\t\t\treturn EOL_NATIVE;\n+\t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n \treturn core_eol;\n }\n@@ -1378,8 +1386,9 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n-\telse if (output_eol(crlf_action) == EOL_CRLF &&\n-\t\t !(crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\t\t;\n+\telse if (output_eol(crlf_action) == EOL_CRLF)\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n \n \treturn filter;\n-- \n2.7.0.303.g2c4f448.dirty\n\n\nFrom e6345a0f0972ae5b7c58a00c476a7e2544e6eda8 Mon Sep 17 00:00:00 2001\nIn-Reply-To: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nReferences: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nFrom: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= <tboegi@web.de>\nDate: Tue, 5 Jan 2016 21:50:15 +0100\nSubject: [PATCH v1 5/6] convert: auto_crlf=false and no attributes set: same\n as binary\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nWhen core.autocrlf is set to false, and no attributes are set, the file\nis treated as binary.\nSimplify the logic and remove duplicated code when dealing with\n(crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) by setting\ncrlf_action=CRLF_BINARY already in convert_attrs().\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex a5701a1..50bdc42 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -235,7 +235,6 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tchar *dst;\n \n \tif (crlf_action == CRLF_BINARY ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) ||\n \t    (src && !len))\n \t\treturn 0;\n \n@@ -798,6 +797,8 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\tca->crlf_action = CRLF_GUESS;\n \t\tca->ident = 0;\n \t}\n+\tif (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n+\t\tca->crlf_action = CRLF_BINARY;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -1382,8 +1383,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \n \tcrlf_action = ca.crlf_action;\n \n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n+\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n \telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n-- \n2.7.0.303.g2c4f448.dirty\n\n\nFrom 44aae1e1e06f7e16e2e8f2db83bfa130f0b89f34 Mon Sep 17 00:00:00 2001\nIn-Reply-To: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nReferences: <Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de>\nFrom: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= <tboegi@web.de>\nDate: Wed, 27 Jan 2016 15:48:04 +0100\nSubject: [PATCH v1 6/6] convert.c: Refactor crlf_action\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nRefactor the determination and usage of crlf_action.\nToday, when no attributes are set on a file,  crlf_action is set to CRLF_GUESS,\nand later, CRLF_GUESS is used as an indication that core.autocrlf is not false\nand that some automatic eol conversion is needed.\nMake more clear, what is what, by defining:\n\n- CRLF_UNDEFINED : No attributes set. Temparally used, until core.autocrlf and\n                   core.eol is evaluated and one\n                   CRLF_BINARY, CRLF_AUTO_INPUT or CRLF_AUTO_CRLF is selected\n- CRLF_BINARY    : No processing of line endings.\n- CRLF_TEXT      : attribute \"text\" is set, line endings are processed.\n- CRLF_TEXT_LF   : attribute \"input\" or \"eol=lf\" is set. This implies text.\n- CRLF_TEXT_CRLF : attribute \"eol=crlf\" is set. This implies text.\n- CRLF_AUTO      : attribute \"auto\" is set.\n- CRLF_AUTO_INPUT: No attributes, core.autocrlf=input\n- CRLF_AUTO_CRLF : No attributes, core.autocrlf=true\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 77 ++++++++++++++++++++++++++++++++++++++-------------------------\n 1 file changed, 46 insertions(+), 31 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 50bdc42..84fe714 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -19,12 +19,14 @@\n #define CONVERT_STAT_BITS_BIN       0x4\n \n enum crlf_action {\n-\tCRLF_GUESS = -1,\n-\tCRLF_BINARY = 0,\n+\tCRLF_UNDEFINED,\n+\tCRLF_BINARY,\n \tCRLF_TEXT,\n-\tCRLF_INPUT,\n-\tCRLF_CRLF,\n-\tCRLF_AUTO\n+\tCRLF_TEXT_LF,\n+\tCRLF_TEXT_CRLF,\n+\tCRLF_AUTO,\n+\tCRLF_AUTO_INPUT,\n+\tCRLF_AUTO_CRLF\n };\n \n struct text_stat {\n@@ -167,18 +169,19 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \tswitch (crlf_action) {\n \tcase CRLF_BINARY:\n \t\treturn EOL_UNSET;\n-\tcase CRLF_CRLF:\n+\tcase CRLF_TEXT_CRLF:\n \t\treturn EOL_CRLF;\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_LF:\n \t\treturn EOL_LF;\n-\tcase CRLF_GUESS:\n-\t\tif (!auto_crlf)\n-\t\t\treturn EOL_UNSET;\n-\t\t/* fall through */\n+\tcase CRLF_UNDEFINED:\n+\tcase CRLF_AUTO_CRLF:\n+\tcase CRLF_AUTO_INPUT:\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n+\t\t/* fall through */\n \t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n+\twarning(\"Illegal crlf_action %d\\n\", (int)crlf_action);\n \treturn core_eol;\n }\n \n@@ -247,11 +250,11 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \n \tgather_stats(src, len, &stats);\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\tif (convert_is_binary(len, &stats))\n \t\t\treturn 0;\n \n-\t\tif (crlf_action == CRLF_GUESS) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/*\n \t\t\t * If the file in the index has any CR in it, do not convert.\n \t\t\t * This is the new safer autocrlf handling.\n@@ -278,7 +281,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tif (strbuf_avail(buf) + buf->len < len)\n \t\tstrbuf_grow(buf, len - buf->len);\n \tdst = buf->buf;\n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t/*\n \t\t * If we guessed, we already know we rejected a file with\n \t\t * lone CR, and we can strip a CR without looking at what\n@@ -319,8 +322,8 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tif (stats.lf == stats.crlf)\n \t\treturn 0;\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n-\t\tif (crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/* If we have any CR or CRLF line endings, we do not touch it */\n \t\t\t/* This is the new safer autocrlf-handling */\n \t\t\tif (stats.cr > 0 || stats.crlf > 0)\n@@ -708,16 +711,16 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n \tconst char *value = check->value;\n \n \tif (ATTR_TRUE(value))\n-\t\treturn CRLF_TEXT;\n+\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_LF;\n \telse if (ATTR_FALSE(value))\n \t\treturn CRLF_BINARY;\n \telse if (ATTR_UNSET(value))\n \t\t;\n \telse if (!strcmp(value, \"input\"))\n-\t\treturn CRLF_INPUT;\n+\t\treturn CRLF_TEXT_LF;\n \telse if (!strcmp(value, \"auto\"))\n \t\treturn CRLF_AUTO;\n-\treturn CRLF_GUESS;\n+\treturn CRLF_UNDEFINED;\n }\n \n static enum eol git_path_check_eol(struct git_attr_check *check)\n@@ -780,7 +783,7 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n \t\tenum eol eol_attr;\n \t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n-\t\tif (ca->crlf_action == CRLF_GUESS)\n+\t\tif (ca->crlf_action == CRLF_UNDEFINED)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n \t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n@@ -789,16 +792,22 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\t\treturn;\n \t\teol_attr = git_path_check_eol(ccheck + 3);\n \t\tif (eol_attr == EOL_LF)\n-\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\t\tca->crlf_action = CRLF_TEXT_LF;\n \t\telse if (eol_attr == EOL_CRLF)\n-\t\t\tca->crlf_action = CRLF_CRLF;\n+\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n-\t\tca->crlf_action = CRLF_GUESS;\n+\t\tca->crlf_action = CRLF_UNDEFINED;\n \t\tca->ident = 0;\n \t}\n-\tif (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n+\tif (ca->crlf_action == CRLF_TEXT)\n+\t\tca->crlf_action = text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_LF;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_FALSE)\n \t\tca->crlf_action = CRLF_BINARY;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_TRUE)\n+\t\tca->crlf_action = CRLF_AUTO_CRLF;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_INPUT)\n+\t\tca->crlf_action = CRLF_AUTO_INPUT;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -826,18 +835,22 @@ const char *get_convert_attr_ascii(const char *path)\n \n \tconvert_attrs(&ca, path);\n \tswitch (ca.attr_action) {\n-\tcase CRLF_GUESS:\n+\tcase CRLF_UNDEFINED:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n \t\treturn \"-text\";\n \tcase CRLF_TEXT:\n \t\treturn \"text\";\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_LF:\n \t\treturn \"text eol=lf\";\n-\tcase CRLF_CRLF:\n-\t\treturn \"text=auto eol=crlf\";\n+\tcase CRLF_TEXT_CRLF:\n+\t\treturn \"text eol=crlf\";\n \tcase CRLF_AUTO:\n \t\treturn \"text=auto\";\n+\tcase CRLF_AUTO_CRLF:\n+\t\treturn \"text=auto eol=crlf\"; /* This is not supported yet */\n+\tcase CRLF_AUTO_INPUT:\n+\t\treturn \"text=auto eol=lf\"; /* This is not supported yet */\n \t}\n \treturn \"\";\n }\n@@ -1382,11 +1395,13 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \t\tfilter = ident_filter(sha1);\n \n \tcrlf_action = ca.crlf_action;\n-\n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT))\n+\tif ((crlf_action == CRLF_BINARY) ||\n+\t\t\t(crlf_action == CRLF_TEXT_LF))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n-\telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\telse if ((crlf_action == CRLF_AUTO ||\n+\t\t\t\t\t\tcrlf_action == CRLF_AUTO_INPUT ||\n+\t\t\t\t\t\tcrlf_action == CRLF_AUTO_CRLF))\n \t\t;\n \telse if (output_eol(crlf_action) == EOL_CRLF)\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277243","messageId":"1454431988-1941-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v1 1/6] t0027: Add tests for get_stream_filter()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-02T16:53:08Z","receivedAt":"2016-02-02T16:53:08Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen a filter is configured, a different code-path is used in convert.c\nand entry.c via get_stream_filter(), but there are no test cases yet.\n\nAdd tests for the filter API by configuring the ident filter.\nThe result of the SHA1 conversion is not checked, this is already\ndone in other TC.\n\nAdd a parameter to checkout_files() in t0027.\nWhile changing the signature, add another parameter for the eol= attribute.\nThis is currently unused, tests for e.g.\n\"* text=auto eol=lf\" will be added in a separate commit.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n t/t0027-auto-crlf.sh | 262 ++++++++++++++++++++++++++++-----------------------\n 1 file changed, 146 insertions(+), 116 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 504e5a0..681f0c5 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -21,32 +21,45 @@ compare_ws_file () {\n \tpfx=$1\n \texp=$2.expect\n \tact=$pfx.actual.$3\n-\ttr '\\015\\000' QN <\"$2\" >\"$exp\" &&\n-\ttr '\\015\\000' QN <\"$3\" >\"$act\" &&\n+\ttr '\\015\\000abcdef01234567890' QN00000000000000000 <\"$2\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef01234567890' QN00000000000000000 <\"$3\" >\"$act\" &&\n \ttest_cmp $exp $act &&\n \trm $exp $act\n }\n \n create_gitattributes () {\n \tattr=$1\n+\tident=$2\n+\tcase \"$2\" in\n+\t\t\"\")\n+\t\t\t>.gitattributes\n+\t\t\t;;\n+\t\ti)\n+\t\t\techo \"* ident\" >.gitattributes\n+\t\t\t;;\n+\t\t*)\n+\t\t\techo >&2 invalid ident: $2\n+\t\t\texit 1\n+\tesac\n+\n \tcase \"$attr\" in\n \t\tauto)\n-\t\techo \"*.txt text=auto\" >.gitattributes\n+\t\techo \"*.txt text=auto\" >>.gitattributes\n \t\t;;\n \t\ttext)\n-\t\techo \"*.txt text\" >.gitattributes\n+\t\techo \"*.txt text\" >>.gitattributes\n \t\t;;\n \t\t-text)\n-\t\techo \"*.txt -text\" >.gitattributes\n+\t\techo \"*.txt -text\" >>.gitattributes\n \t\t;;\n \t\tcrlf)\n-\t\techo \"*.txt eol=crlf\" >.gitattributes\n+\t\techo \"*.txt eol=crlf\" >>.gitattributes\n \t\t;;\n \t\tlf)\n-\t\techo \"*.txt eol=lf\" >.gitattributes\n+\t\techo \"*.txt eol=lf\" >>.gitattributes\n \t\t;;\n \t\t\"\")\n-\t\techo >.gitattributes\n+\t\t#echo >.gitattributes\n \t\t;;\n \t\t*)\n \t\techo >&2 invalid attribute: $attr\n@@ -90,7 +103,7 @@ commit_check_warn () {\n \tlfmixcr=$6\n \tcrlfnul=$7\n \tpfx=crlf_${crlf}_attr_${attr}\n-\tcreate_gitattributes \"$attr\" &&\n+\tcreate_gitattributes \"$attr\" \"\" &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul\n \tdo\n \t\tfname=${pfx}_$f.txt &&\n@@ -115,7 +128,7 @@ commit_chk_wrnNNO () {\n \tcrlfnul=$7\n \tpfx=NNO_${crlf}_attr_${attr}\n \t#Commit files on top of existing file\n-\tcreate_gitattributes \"$attr\" &&\n+\tcreate_gitattributes \"$attr\" \"\" &&\n \tfor f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul\n \tdo\n \t\tfname=${pfx}_$f.txt &&\n@@ -208,28 +221,30 @@ check_in_repo_NNO () {\n }\n \n checkout_files () {\n-\teol=$1\n-\tcrlf=$2\n-\tattr=$3\n-\tlfname=$4\n-\tcrlfname=$5\n-\tlfmixcrlf=$6\n-\tlfmixcr=$7\n-\tcrlfnul=$8\n-\tcreate_gitattributes $attr &&\n+\tattr=$1 ; shift\n+\tident=$1; shift\n+\taeol=$1 ; shift\n+\tcrlf=$1 ; shift\n+\tceol=$1 ; shift\n+\tlfname=$1 ; shift\n+\tcrlfname=$1 ; shift\n+\tlfmixcrlf=$1 ; shift\n+\tlfmixcr=$1 ; shift\n+\tcrlfnul=$1 ; shift\n+\tcreate_gitattributes \"$attr\" \"$ident\" &&\n \tgit config core.autocrlf $crlf &&\n-\tpfx=eol_${eol}_crlf_${crlf}_attr_${attr}_ &&\n+\tpfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul\n \tdo\n \t\trm crlf_false_attr__$f.txt &&\n-\t\tif test -z \"$eol\"; then\n+\t\tif test -z \"$ceol\"; then\n \t\t\tgit checkout crlf_false_attr__$f.txt\n \t\telse\n-\t\t\tgit -c core.eol=$eol checkout crlf_false_attr__$f.txt\n+\t\t\tgit -c core.eol=$ceol checkout crlf_false_attr__$f.txt\n \t\tfi\n \tdone\n \n-\ttest_expect_success \"ls-files --eol $lfname ${pfx}LF.txt\" '\n+\ttest_expect_success \"ls-files --eol attr=$attr i=$ident $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n \t\ttest_when_finished \"rm expect actual\" &&\n \t\tsort <<-EOF >expect &&\n \t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n@@ -244,19 +259,19 @@ checkout_files () {\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF\" \"\n \t\tcompare_ws_file $pfx $lfname    crlf_false_attr__LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF\" \"\n \t\tcompare_ws_file $pfx $crlfname  crlf_false_attr__CRLF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF_mix_LF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF\" \"\n \t\tcompare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_mix_CR\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR\" \"\n \t\tcompare_ws_file $pfx $lfmixcr   crlf_false_attr__LF_mix_CR.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_nul\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul\" \"\n \t\tcompare_ws_file $pfx $crlfnul   crlf_false_attr__LF_nul.txt\n \t\"\n }\n@@ -301,14 +316,13 @@ test_expect_success 'setup master' '\n \tgit checkout -b master &&\n \tgit add .gitattributes &&\n \tgit commit -m \"add .gitattributes\" \"\" &&\n-\tprintf \"line1\\nline2\\nline3\"     >LF &&\n-\tprintf \"line1\\r\\nline2\\r\\nline3\" >CRLF &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >repoMIX &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >CRLF_mix_LF &&\n-\tprintf \"line1\\nline2\\rline3\"     >LF_mix_CR &&\n-\tprintf \"line1\\r\\nline2\\rline3\"   >CRLF_mix_CR &&\n-\tprintf \"line1Q\\r\\nline2\\r\\nline3\" | q_to_nul >CRLF_nul &&\n-\tprintf \"line1Q\\nline2\\nline3\" | q_to_nul >LF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\nLINETHREE\"     >LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\r\\nLINETHREE\" >CRLF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\r\\nLINETWO\\nLINETHREE\"   >CRLF_mix_LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\rLINETHREE\"     >LF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\rLINETHREE\"   >CRLF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONEQ\\r\\nLINETWO\\r\\nLINETHREE\" | q_to_nul >CRLF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONEQ\\nLINETWO\\nLINETHREE\" | q_to_nul >LF_nul &&\n \tcreate_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&\n \tgit -c core.autocrlf=false add NNO_*.txt &&\n \tgit commit -m \"mixed line endings\" &&\n@@ -449,23 +463,18 @@ check_in_repo_NNO input \"-text\" LF        CRLF      CRLF_mix_LF  LF_mix_CR \tCRLF\n # How to read the table below:\n # - checkout_files will check multiple files with a combination of settings\n #   and attributes (core.autocrlf=input is forbidden with core.eol=crlf)\n-# - parameter $1 : core.eol               lf | crlf\n-# - parameter $2 : core.autocrlf          false | true | input\n-# - parameter $3 : text in .gitattributs  \"\" (empty) | auto | text | -text\n-# - parameter $4 : reference for a file with only LF in the repo\n-# - parameter $5 : reference for a file with only CRLF in the repo\n-# - parameter $6 : reference for a file with mixed LF and CRLF in the repo\n-# - parameter $7 : reference for a file with LF and CR in the repo (does somebody uses this ?)\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-#                                            ----------------- 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-#                                            ----------------------------------------------\n-#                                            What we want to have in the working tree:\n+#\n+# - parameter $1 \t: text in .gitattributs  \"\" (empty) | auto | text | -text\n+# - parameter $2 \t: ident                  \"\" | i (i == ident)\n+# - parameter $3 \t: eol in .gitattributs   \"\" (empty) | lf | crlf\n+# - parameter $4 \t: core.autocrlf          false | true | input\n+# - parameter $5 \t: core.eol               \"\" | lf | crlf | \"native\"\n+# - parameter $6 \t: reference for a file with only LF in the repo\n+# - parameter $7 \t: reference for a file with only CRLF in the repo\n+# - parameter $8 \t: reference for a file with mixed LF and CRLF in the repo\n+# - parameter $9 \t: reference for a file with LF and CR in the repo\n+# - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)\n+\n if test_have_prereq NATIVE_CRLF\n then\n MIX_CRLF_LF=CRLF\n@@ -480,69 +489,90 @@ LFNUL=LF_nul\n fi\n export CRLF_MIX_LF_CR MIX NL\n \n-checkout_files    lf      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    lf      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    crlf    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    \"\"      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    \"\"      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    native  false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    native  true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    native  false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    native  true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+checkout_files \"\"      \"\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   crlf     CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   lf       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   native   CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   \"\"       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   lf       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   native   CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\n+for id in \"\" i;\n+do\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+done\n \n # Should be the last test case: remove some files from the worktree\n test_expect_success 'ls-files --eol -d -z' '\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277245","messageId":"1454431990-1980-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v1 2/6] convert.c: Remove path when not needed","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-02T16:53:10Z","receivedAt":"2016-02-02T16:53:10Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nSome functions get a parameter path, but don't use it.\nRemove the unused parameter.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 19 +++++++++----------\n 1 file changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 4bb4ec1..a24c2a2 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -696,7 +696,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,\n \treturn 1;\n }\n \n-static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_check *check)\n+static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -713,7 +713,7 @@ static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_ch\n \treturn CRLF_GUESS;\n }\n \n-static enum eol git_path_check_eol(const char *path, struct git_attr_check *check)\n+static enum eol git_path_check_eol(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -726,8 +726,7 @@ static enum eol git_path_check_eol(const char *path, struct git_attr_check *chec\n \treturn EOL_UNSET;\n }\n \n-static struct convert_driver *git_path_check_convert(const char *path,\n-\t\t\t\t\t     struct git_attr_check *check)\n+static struct convert_driver *git_path_check_convert(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \tstruct convert_driver *drv;\n@@ -740,7 +739,7 @@ static struct convert_driver *git_path_check_convert(const char *path,\n \treturn NULL;\n }\n \n-static int git_path_check_ident(const char *path, struct git_attr_check *check)\n+static int git_path_check_ident(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -783,12 +782,12 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 4);\n+\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n-\t\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 0);\n-\t\tca->ident = git_path_check_ident(path, ccheck + 1);\n-\t\tca->drv = git_path_check_convert(path, ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(path, ccheck + 3);\n+\t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->ident = git_path_check_ident(ccheck + 1);\n+\t\tca->drv = git_path_check_convert(ccheck + 2);\n+\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277246","messageId":"1454431992-2019-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v1 3/6] convert.c: Remove input_crlf_action()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-02T16:53:12Z","receivedAt":"2016-02-02T16:53:12Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nIntegrate the code of input_crlf_action() into convert_attrs(),\nso that ca.crlf_action is aleays valid after calling convert_attrs().\nKeep a copy of crlf_action in attr_action, this is needed for\nget_convert_attr_ascii().\n\nRemove eol_attr from struct conv_attrs, as it is now used temporally.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 35 +++++++++++++----------------------\n 1 file changed, 13 insertions(+), 22 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex a24c2a2..bca3d0c 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -746,21 +746,10 @@ static int git_path_check_ident(struct git_attr_check *check)\n \treturn !!ATTR_TRUE(value);\n }\n \n-static enum crlf_action input_crlf_action(enum crlf_action text_attr, enum eol eol_attr)\n-{\n-\tif (text_attr == CRLF_BINARY)\n-\t\treturn CRLF_BINARY;\n-\tif (eol_attr == EOL_LF)\n-\t\treturn CRLF_INPUT;\n-\tif (eol_attr == EOL_CRLF)\n-\t\treturn CRLF_CRLF;\n-\treturn text_attr;\n-}\n-\n struct conv_attrs {\n \tstruct convert_driver *drv;\n-\tenum crlf_action crlf_action;\n-\tenum eol eol_attr;\n+\tenum crlf_action attr_action; /* What attr says */\n+\tenum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */\n \tint ident;\n };\n \n@@ -782,16 +771,23 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n+\t\tenum eol eol_attr;\n \t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n \t\tca->drv = git_path_check_convert(ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (ca->crlf_action == CRLF_BINARY)\n+\t\t\treturn;\n+\t\teol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (eol_attr == EOL_LF)\n+\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\telse if (eol_attr == EOL_CRLF)\n+\t\t\tca->crlf_action = CRLF_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-\t\tca->eol_attr = EOL_UNSET;\n \t\tca->ident = 0;\n \t}\n }\n@@ -818,11 +814,9 @@ int would_convert_to_git_filter_fd(const char *path)\n const char *get_convert_attr_ascii(const char *path)\n {\n \tstruct conv_attrs ca;\n-\tenum crlf_action crlf_action;\n \n \tconvert_attrs(&ca, path);\n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n-\tswitch (crlf_action) {\n+\tswitch (ca.attr_action) {\n \tcase CRLF_GUESS:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n@@ -861,7 +855,6 @@ int convert_to_git(const char *path, const char *src, size_t len,\n \t\tsrc = dst->buf;\n \t\tlen = dst->len;\n \t}\n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tret |= crlf_to_git(path, src, len, dst, ca.crlf_action, checksafe);\n \tif (ret && dst) {\n \t\tsrc = dst->buf;\n@@ -882,7 +875,6 @@ void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,\n \tif (!apply_filter(path, NULL, 0, fd, dst, ca.drv->clean))\n \t\tdie(\"%s: clean filter '%s' failed\", path, ca.drv->name);\n \n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tcrlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);\n \tident_to_git(path, dst->buf, dst->len, dst, ca.ident);\n }\n@@ -912,7 +904,6 @@ static int convert_to_working_tree_internal(const char *path, const char *src,\n \t * is a smudge filter.  The filter might expect CRLFs.\n \t */\n \tif (filter || !normalizing) {\n-\t\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \t\tret |= crlf_to_worktree(path, src, len, dst, ca.crlf_action);\n \t\tif (ret) {\n \t\t\tsrc = dst->buf;\n@@ -1381,7 +1372,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \tif (ca.ident)\n \t\tfilter = ident_filter(sha1);\n \n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n+\tcrlf_action = ca.crlf_action;\n \n \tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277248","messageId":"1454431993-2058-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v1 4/6] convert.c: Use text_eol_is_crlf()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-02T16:53:13Z","receivedAt":"2016-02-02T16:53:13Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nAdd a helper function to find out, which line endings\ntext files should get at checkout, depending on\ncore.autocrlf and core.eol\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 25 +++++++++++++++++--------\n 1 file changed, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex bca3d0c..a5701a1 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -149,6 +149,19 @@ const char *get_wt_convert_stats_ascii(const char *path)\n \treturn ret;\n }\n \n+static int text_eol_is_crlf(void)\n+{\n+\tif (auto_crlf == AUTO_CRLF_TRUE)\n+\t\treturn 1;\n+\telse if (auto_crlf == AUTO_CRLF_INPUT)\n+\t\treturn 0;\n+\tif (core_eol == EOL_CRLF)\n+\t\treturn 1;\n+\tif (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n static enum eol output_eol(enum crlf_action crlf_action)\n {\n \tswitch (crlf_action) {\n@@ -164,12 +177,7 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \t\t/* fall through */\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n-\t\tif (auto_crlf == AUTO_CRLF_TRUE)\n-\t\t\treturn EOL_CRLF;\n-\t\telse if (auto_crlf == AUTO_CRLF_INPUT)\n-\t\t\treturn EOL_LF;\n-\t\telse if (core_eol == EOL_UNSET)\n-\t\t\treturn EOL_NATIVE;\n+\t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n \treturn core_eol;\n }\n@@ -1378,8 +1386,9 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n-\telse if (output_eol(crlf_action) == EOL_CRLF &&\n-\t\t !(crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\t\t;\n+\telse if (output_eol(crlf_action) == EOL_CRLF)\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n \n \treturn filter;\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277247","messageId":"1454431994-2097-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v1 5/6] convert: auto_crlf=false and no attributes set: same as binary","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-02T16:53:14Z","receivedAt":"2016-02-02T16:53:14Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen core.autocrlf is set to false, and no attributes are set, the file\nis treated as binary.\nSimplify the logic and remove duplicated code when dealing with\n(crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) by setting\ncrlf_action=CRLF_BINARY already in convert_attrs().\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex a5701a1..50bdc42 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -235,7 +235,6 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tchar *dst;\n \n \tif (crlf_action == CRLF_BINARY ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) ||\n \t    (src && !len))\n \t\treturn 0;\n \n@@ -798,6 +797,8 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\tca->crlf_action = CRLF_GUESS;\n \t\tca->ident = 0;\n \t}\n+\tif (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n+\t\tca->crlf_action = CRLF_BINARY;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -1382,8 +1383,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \n \tcrlf_action = ca.crlf_action;\n \n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n+\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n \telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277244","messageId":"1454431996-2136-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v1 6/6] convert.c: Refactor crlf_action","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-02T16:53:16Z","receivedAt":"2016-02-02T16:53:16Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nRefactor the determination and usage of crlf_action.\nToday, when no attributes are set on a file,\ncrlf_action is set to CRLF_GUESS, and later, CRLF_GUESS is used as an\nindication that core.autocrlf is not false and that some automatic eol\nconversion is needed.\nMake more clear, what is what, by defining:\n\n- CRLF_UNDEFINED : No attributes set. Temparally used, until core.autocrlf\n                   and core.eol is evaluated and one of CRLF_BINARY,\n                   CRLF_AUTO_INPUT or CRLF_AUTO_CRLF is selected\n- CRLF_BINARY    : No processing of line endings.\n- CRLF_TEXT      : attribute \"text\" is set, line endings are processed.\n- CRLF_TEXT_INPUT: attribute \"input\" or \"eol=lf\" is set. This implies text.\n- CRLF_TEXT_CRLF : attribute \"eol=crlf\" is set. This implies text.\n- CRLF_AUTO      : attribute \"auto\" is set.\n- CRLF_AUTO_INPUT: No attributes, core.autocrlf=input\n- CRLF_AUTO_CRLF : No attributes, core.autocrlf=true\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 77 ++++++++++++++++++++++++++++++++++++++-------------------------\n 1 file changed, 46 insertions(+), 31 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 50bdc42..f6ad9d6 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -19,12 +19,14 @@\n #define CONVERT_STAT_BITS_BIN       0x4\n \n enum crlf_action {\n-\tCRLF_GUESS = -1,\n-\tCRLF_BINARY = 0,\n+\tCRLF_UNDEFINED,\n+\tCRLF_BINARY,\n \tCRLF_TEXT,\n-\tCRLF_INPUT,\n-\tCRLF_CRLF,\n-\tCRLF_AUTO\n+\tCRLF_TEXT_INPUT,\n+\tCRLF_TEXT_CRLF,\n+\tCRLF_AUTO,\n+\tCRLF_AUTO_INPUT,\n+\tCRLF_AUTO_CRLF\n };\n \n struct text_stat {\n@@ -167,18 +169,19 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \tswitch (crlf_action) {\n \tcase CRLF_BINARY:\n \t\treturn EOL_UNSET;\n-\tcase CRLF_CRLF:\n+\tcase CRLF_TEXT_CRLF:\n \t\treturn EOL_CRLF;\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_INPUT:\n \t\treturn EOL_LF;\n-\tcase CRLF_GUESS:\n-\t\tif (!auto_crlf)\n-\t\t\treturn EOL_UNSET;\n-\t\t/* fall through */\n+\tcase CRLF_UNDEFINED:\n+\tcase CRLF_AUTO_CRLF:\n+\tcase CRLF_AUTO_INPUT:\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n+\t\t/* fall through */\n \t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n+\twarning(\"Illegal crlf_action %d\\n\", (int)crlf_action);\n \treturn core_eol;\n }\n \n@@ -247,11 +250,11 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \n \tgather_stats(src, len, &stats);\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\tif (convert_is_binary(len, &stats))\n \t\t\treturn 0;\n \n-\t\tif (crlf_action == CRLF_GUESS) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/*\n \t\t\t * If the file in the index has any CR in it, do not convert.\n \t\t\t * This is the new safer autocrlf handling.\n@@ -278,7 +281,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tif (strbuf_avail(buf) + buf->len < len)\n \t\tstrbuf_grow(buf, len - buf->len);\n \tdst = buf->buf;\n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t/*\n \t\t * If we guessed, we already know we rejected a file with\n \t\t * lone CR, and we can strip a CR without looking at what\n@@ -319,8 +322,8 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tif (stats.lf == stats.crlf)\n \t\treturn 0;\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n-\t\tif (crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/* If we have any CR or CRLF line endings, we do not touch it */\n \t\t\t/* This is the new safer autocrlf-handling */\n \t\t\tif (stats.cr > 0 || stats.crlf > 0)\n@@ -708,16 +711,16 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n \tconst char *value = check->value;\n \n \tif (ATTR_TRUE(value))\n-\t\treturn CRLF_TEXT;\n+\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n \telse if (ATTR_FALSE(value))\n \t\treturn CRLF_BINARY;\n \telse if (ATTR_UNSET(value))\n \t\t;\n \telse if (!strcmp(value, \"input\"))\n-\t\treturn CRLF_INPUT;\n+\t\treturn CRLF_TEXT_INPUT;\n \telse if (!strcmp(value, \"auto\"))\n \t\treturn CRLF_AUTO;\n-\treturn CRLF_GUESS;\n+\treturn CRLF_UNDEFINED;\n }\n \n static enum eol git_path_check_eol(struct git_attr_check *check)\n@@ -780,7 +783,7 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n \t\tenum eol eol_attr;\n \t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n-\t\tif (ca->crlf_action == CRLF_GUESS)\n+\t\tif (ca->crlf_action == CRLF_UNDEFINED)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n \t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n@@ -789,16 +792,22 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\t\treturn;\n \t\teol_attr = git_path_check_eol(ccheck + 3);\n \t\tif (eol_attr == EOL_LF)\n-\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n \t\telse if (eol_attr == EOL_CRLF)\n-\t\t\tca->crlf_action = CRLF_CRLF;\n+\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n-\t\tca->crlf_action = CRLF_GUESS;\n+\t\tca->crlf_action = CRLF_UNDEFINED;\n \t\tca->ident = 0;\n \t}\n-\tif (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n+\tif (ca->crlf_action == CRLF_TEXT)\n+\t\tca->crlf_action = text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_FALSE)\n \t\tca->crlf_action = CRLF_BINARY;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_TRUE)\n+\t\tca->crlf_action = CRLF_AUTO_CRLF;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_INPUT)\n+\t\tca->crlf_action = CRLF_AUTO_INPUT;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -826,18 +835,22 @@ const char *get_convert_attr_ascii(const char *path)\n \n \tconvert_attrs(&ca, path);\n \tswitch (ca.attr_action) {\n-\tcase CRLF_GUESS:\n+\tcase CRLF_UNDEFINED:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n \t\treturn \"-text\";\n \tcase CRLF_TEXT:\n \t\treturn \"text\";\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_INPUT:\n \t\treturn \"text eol=lf\";\n-\tcase CRLF_CRLF:\n-\t\treturn \"text=auto eol=crlf\";\n+\tcase CRLF_TEXT_CRLF:\n+\t\treturn \"text eol=crlf\";\n \tcase CRLF_AUTO:\n \t\treturn \"text=auto\";\n+\tcase CRLF_AUTO_CRLF:\n+\t\treturn \"text=auto eol=crlf\"; /* This is not supported yet */\n+\tcase CRLF_AUTO_INPUT:\n+\t\treturn \"text=auto eol=lf\"; /* This is not supported yet */\n \t}\n \treturn \"\";\n }\n@@ -1382,11 +1395,13 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \t\tfilter = ident_filter(sha1);\n \n \tcrlf_action = ca.crlf_action;\n-\n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT))\n+\tif ((crlf_action == CRLF_BINARY) ||\n+\t\t\t(crlf_action == CRLF_TEXT_INPUT))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n-\telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\telse if ((crlf_action == CRLF_AUTO ||\n+\t\t\t\t\t\tcrlf_action == CRLF_AUTO_INPUT ||\n+\t\t\t\t\t\tcrlf_action == CRLF_AUTO_CRLF))\n \t\t;\n \telse if (output_eol(crlf_action) == EOL_CRLF)\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277278","messageId":"xmqqk2mmretb.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1454431988-1941-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v1 1/6] t0027: Add tests for get_stream_filter()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-02T21:18:56Z","receivedAt":"2016-02-02T21:18:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> When a filter is configured, a different code-path is used in convert.c\n> and entry.c via get_stream_filter(), but there are no test cases yet.\n>\n> Add tests for the filter API by configuring the ident filter.\n> The result of the SHA1 conversion is not checked, this is already\n> done in other TC.\n>\n> Add a parameter to checkout_files() in t0027.\n> While changing the signature, add another parameter for the eol= attribute.\n> This is currently unused, tests for e.g.\n> \"* text=auto eol=lf\" will be added in a separate commit.\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>  t/t0027-auto-crlf.sh | 262 ++++++++++++++++++++++++++++-----------------------\n>  1 file changed, 146 insertions(+), 116 deletions(-)\n>\n> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\n> index 504e5a0..681f0c5 100755\n> --- a/t/t0027-auto-crlf.sh\n> +++ b/t/t0027-auto-crlf.sh\n> @@ -21,32 +21,45 @@ compare_ws_file () {\n>  \tpfx=$1\n>  \texp=$2.expect\n>  \tact=$pfx.actual.$3\n> -\ttr '\\015\\000' QN <\"$2\" >\"$exp\" &&\n> -\ttr '\\015\\000' QN <\"$3\" >\"$act\" &&\n> +\ttr '\\015\\000abcdef01234567890' QN00000000000000000 <\"$2\" >\"$exp\" &&\n> +\ttr '\\015\\000abcdef01234567890' QN00000000000000000 <\"$3\" >\"$act\" &&\n\n'0' is listed twice on purpose?\n\n>  \ttest_cmp $exp $act &&\n>  \trm $exp $act\n\nAs we are not forcing all the future callers of this helper\nfunctions to feed only non problematic pathnames, we should quote\nthese variable references, but this is not a new issue this patch\nintroduces.\n\n>  }\n>  \n>  create_gitattributes () {\n>  \tattr=$1\n> +\tident=$2\n> +\tcase \"$2\" in\n> +\t\t\"\")\n> +\t\t\t>.gitattributes\n> +\t\t\t;;\n> +\t\ti)\n> +\t\t\techo \"* ident\" >.gitattributes\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\techo >&2 invalid ident: $2\n> +\t\t\texit 1\n\nThis is overindented.  Case arms align with case/esac, and their\nbodies indent one level down, i.e.\n\n\tcase \"$2\" in\n        \"\")\n        \t>.gitattributes\n                ;;\n\tesac\n\nBy the way, I somehow find it hard to follow to assign magic\nmeanings \"clear\" and \"prepare ident for everybody\" to a short\nand cryptic \"\" (empty string) and \"i\".  If you were taking advantage\nof the fact that all existing uses of this helper function pass only\none argument to it and you will get $ident=\"\" automatically from the\nones that you did not touch, that might be a reasonable way to reduce\npatch noise, but because you are doing things like this\n\n> -\tcreate_gitattributes \"$attr\" &&\n> +\tcreate_gitattributes \"$attr\" \"\" &&\n\nanyway, it may make sense to be slightly more verbose and readable.\n\n> +\tesac\n> +\n>  \tcase \"$attr\" in\n>  \t\tauto)\n> -\t\techo \"*.txt text=auto\" >.gitattributes\n> +\t\techo \"*.txt text=auto\" >>.gitattributes\n>  \t\t;;\n>  \t\t...\n>  \t\t;;\n>  \t\t*)\n>  \t\techo >&2 invalid attribute: $attr\n\nAs you are touching this helper to emit more than one thing into the\nfile, I'd consider doing \n\n\t{\n                case \"$2\" in\n                clear)\t;;\n                ident)\techo '* ident' ;;\n                ...\n                esac &&\n                case \"$1\" in\n                auto)\techo '*.txt auto' ;;\n                ...\n                esac\n\t} >.gitattributes\n\nor even\n\n\t{\n                while test \"$#\" != 1\n                do\n                        printf \"%s\\n\" \"$1\"\n                        shift\n                done &&\n                case \"$1\" in\n                auto)\techo '*.txt auto' ;;\n                ...\n                esac &&\n\t} >.gitattributes\n\nanticipating that we may want more things added to the output in the\nfuture.  The latter form allows your callers to say things like\n\n\tcreate_gitattributes \"auto\" \"* ident\" \"*.bin binary\" \n\nwithout having to touch the helper function.\n"},{"id":"277279","messageId":"xmqqfuxare5x.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1454431990-1980-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v1 2/6] convert.c: Remove path when not needed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-02T21:32:58Z","receivedAt":"2016-02-02T21:32:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n\n> Subject: Re: [PATCH v1 2/6] convert.c: Remove path when not needed\n\nAt least s/: Remove/: remove/, but I think\n\ns/: Remove.*/: remove unused parameter 'path'/\n\nwould be easier to read.\n\nAll of these functions seem to have \"path\" in their name, sounding\nas if they meant to ask \"What is the crlf-ness for THIS PATH?\"  Is\nit still sensible to have \"path\" in their names?\n\nThe necessary information that is specific to the path was already\ngathered when we prepared the 'check' thing, so they are still\nasking and answering their questions specific to the path by\naccepting 'check', but it still feels somewhat funny.\n\nWith or without \"path\" in their names, they are horribly misnamed\n(e.g. \"check crlf---are we asking if the file has crlf?  if the\nfile must be written out with crlf?  something else?\").\n\nYour later patches seem to refactor and reorganize this internal\ncalling mess in some way, so let's read on and see how the whole\nthing improves ;-)\n\n> -static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_check *check)\n> +static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n>  {\n>  \tconst char *value = check->value;\n>  \n> @@ -713,7 +713,7 @@ static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_ch\n>  \treturn CRLF_GUESS;\n>  }\n>  \n> -static enum eol git_path_check_eol(const char *path, struct git_attr_check *check)\n> +static enum eol git_path_check_eol(struct git_attr_check *check)\n>  {\n>  \tconst char *value = check->value;\n>  \n> @@ -726,8 +726,7 @@ static enum eol git_path_check_eol(const char *path, struct git_attr_check *chec\n>  \treturn EOL_UNSET;\n>  }\n>  \n> -static struct convert_driver *git_path_check_convert(const char *path,\n> -\t\t\t\t\t     struct git_attr_check *check)\n> +static struct convert_driver *git_path_check_convert(struct git_attr_check *check)\n>  {\n>  \tconst char *value = check->value;\n>  \tstruct convert_driver *drv;\n> @@ -740,7 +739,7 @@ static struct convert_driver *git_path_check_convert(const char *path,\n>  \treturn NULL;\n>  }\n>  \n> -static int git_path_check_ident(const char *path, struct git_attr_check *check)\n> +static int git_path_check_ident(struct git_attr_check *check)\n>  {\n>  \tconst char *value = check->value;\n>  \n> @@ -783,12 +782,12 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n>  \t}\n>  \n>  \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n> -\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 4);\n> +\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n>  \t\tif (ca->crlf_action == CRLF_GUESS)\n> -\t\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 0);\n> -\t\tca->ident = git_path_check_ident(path, ccheck + 1);\n> -\t\tca->drv = git_path_check_convert(path, ccheck + 2);\n> -\t\tca->eol_attr = git_path_check_eol(path, ccheck + 3);\n> +\t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n> +\t\tca->ident = git_path_check_ident(ccheck + 1);\n> +\t\tca->drv = git_path_check_convert(ccheck + 2);\n> +\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n>  \t} else {\n>  \t\tca->drv = NULL;\n>  \t\tca->crlf_action = CRLF_GUESS;\n"},{"id":"277280","messageId":"xmqqbn7yrdm9.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1454431992-2019-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v1 3/6] convert.c: Remove input_crlf_action()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-02T21:44:46Z","receivedAt":"2016-02-02T21:44:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> Integrate the code of input_crlf_action() into convert_attrs(),\n> so that ca.crlf_action is aleays valid after calling convert_attrs().\n\ns/aleays/always/\n\n> Keep a copy of crlf_action in attr_action, this is needed for\n> get_convert_attr_ascii().\n>\n> Remove eol_attr from struct conv_attrs, as it is now used temporally.\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>  convert.c | 35 +++++++++++++----------------------\n>  1 file changed, 13 insertions(+), 22 deletions(-)\n>\n> diff --git a/convert.c b/convert.c\n> index a24c2a2..bca3d0c 100644\n> --- a/convert.c\n> +++ b/convert.c\n> @@ -746,21 +746,10 @@ static int git_path_check_ident(struct git_attr_check *check)\n>  \treturn !!ATTR_TRUE(value);\n>  }\n>  \n> -static enum crlf_action input_crlf_action(enum crlf_action text_attr, enum eol eol_attr)\n> -{\n> -\tif (text_attr == CRLF_BINARY)\n> -\t\treturn CRLF_BINARY;\n> -\tif (eol_attr == EOL_LF)\n> -\t\treturn CRLF_INPUT;\n> -\tif (eol_attr == EOL_CRLF)\n> -\t\treturn CRLF_CRLF;\n> -\treturn text_attr;\n> -}\n> -\n>  struct conv_attrs {\n>  \tstruct convert_driver *drv;\n> -\tenum crlf_action crlf_action;\n> -\tenum eol eol_attr;\n> +\tenum crlf_action attr_action; /* What attr says */\n> +\tenum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */\n>  \tint ident;\n>  };\n>  \n> @@ -782,16 +771,23 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n>  \t}\n>  \n>  \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n> +\t\tenum eol eol_attr;\n>  \t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n\nI guess this extra SP after opening paren was a misconversion from\nthe previous step...\n\n>  \t\tif (ca->crlf_action == CRLF_GUESS)\n>  \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n> +\t\tca->attr_action = ca->crlf_action;\n>  \t\tca->ident = git_path_check_ident(ccheck + 1);\n>  \t\tca->drv = git_path_check_convert(ccheck + 2);\n> -\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n> +\t\tif (ca->crlf_action == CRLF_BINARY)\n> +\t\t\treturn;\n> +\t\teol_attr = git_path_check_eol(ccheck + 3);\n> +\t\tif (eol_attr == EOL_LF)\n> +\t\t\tca->crlf_action = CRLF_INPUT;\n> +\t\telse if (eol_attr == EOL_CRLF)\n> +\t\t\tca->crlf_action = CRLF_CRLF;\n>  \t} else {\n>  \t\tca->drv = NULL;\n>  \t\tca->crlf_action = CRLF_GUESS;\n> -\t\tca->eol_attr = EOL_UNSET;\n>  \t\tca->ident = 0;\n>  \t}\n>  }\n> @@ -818,11 +814,9 @@ int would_convert_to_git_filter_fd(const char *path)\n>  const char *get_convert_attr_ascii(const char *path)\n>  {\n>  \tstruct conv_attrs ca;\n> -\tenum crlf_action crlf_action;\n>  \n>  \tconvert_attrs(&ca, path);\n> -\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n> -\tswitch (crlf_action) {\n> +\tswitch (ca.attr_action) {\n>  \tcase CRLF_GUESS:\n>  \t\treturn \"\";\n>  \tcase CRLF_BINARY:\n> @@ -861,7 +855,6 @@ int convert_to_git(const char *path, const char *src, size_t len,\n>  \t\tsrc = dst->buf;\n>  \t\tlen = dst->len;\n>  \t}\n> -\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n>  \tret |= crlf_to_git(path, src, len, dst, ca.crlf_action, checksafe);\n>  \tif (ret && dst) {\n>  \t\tsrc = dst->buf;\n> @@ -882,7 +875,6 @@ void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,\n>  \tif (!apply_filter(path, NULL, 0, fd, dst, ca.drv->clean))\n>  \t\tdie(\"%s: clean filter '%s' failed\", path, ca.drv->name);\n>  \n> -\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n>  \tcrlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);\n>  \tident_to_git(path, dst->buf, dst->len, dst, ca.ident);\n>  }\n> @@ -912,7 +904,6 @@ static int convert_to_working_tree_internal(const char *path, const char *src,\n>  \t * is a smudge filter.  The filter might expect CRLFs.\n>  \t */\n>  \tif (filter || !normalizing) {\n> -\t\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n>  \t\tret |= crlf_to_worktree(path, src, len, dst, ca.crlf_action);\n>  \t\tif (ret) {\n>  \t\t\tsrc = dst->buf;\n> @@ -1381,7 +1372,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n>  \tif (ca.ident)\n>  \t\tfilter = ident_filter(sha1);\n>  \n> -\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n> +\tcrlf_action = ca.crlf_action;\n>  \n>  \tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n>  \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n\nSo the idea is that the code before this prepared eol_attr and\ncrlf_action fields in convert_attrs() and consumers of these fields\ncalled input_crlf_action() with them as parameters to choose one of\nCRLF_X, but with this change, that is precomputed and left in the\nnew field crlf_action.\n\nI didn't find a code where ca.eol_attr is redefined after\nconvert_attrs() returned, and all the codepaths that redefine\nca.crlf_action do so by assigning the result of the call to\ninput_crlf_action(), _and_ they do not use the value before doing\nso.  So it appears that this should not change any behaviour.\n\nOK.\n"},{"id":"277439","messageId":"1454608188-5300-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v2 1/7] t0027: Add tests for get_stream_filter()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-04T17:49:48Z","receivedAt":"2016-02-04T17:49:48Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen a filter is configured, a different code-path is used in convert.c\nand entry.c via get_stream_filter(), but there are no test cases yet.\n\nAdd tests for the filter API by configuring the ident filter.\nThe result of the SHA1 conversion is not checked, this is already\ndone in other TC.\n\nAdd a parameter to checkout_files() in t0027.\nWhile changing the signature, add another parameter for the eol= attribute.\nThis is currently unused, tests for e.g.\n\"* text=auto eol=lf\" will be added in a separate commit.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n Changes since v1:\n - t0027: Comments from Junio, create_gitattributes() and others\n - convert.c: Minor whitespace fixes, changed the commit message\n - Added 7/7: convert.c: simplify text_stat from the TODO stack\nt/t0027-auto-crlf.sh | 281 ++++++++++++++++++++++++++-------------------------\n 1 file changed, 146 insertions(+), 135 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 504e5a0..1d84ed3 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -21,38 +21,32 @@ compare_ws_file () {\n \tpfx=$1\n \texp=$2.expect\n \tact=$pfx.actual.$3\n-\ttr '\\015\\000' QN <\"$2\" >\"$exp\" &&\n-\ttr '\\015\\000' QN <\"$3\" >\"$act\" &&\n-\ttest_cmp $exp $act &&\n-\trm $exp $act\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$3\" >\"$act\" &&\n+\ttest_cmp \"$exp\" \"$act\" &&\n+\trm \"$exp\" \"$act\"\n }\n \n create_gitattributes () {\n-\tattr=$1\n-\tcase \"$attr\" in\n-\t\tauto)\n-\t\techo \"*.txt text=auto\" >.gitattributes\n-\t\t;;\n-\t\ttext)\n-\t\techo \"*.txt text\" >.gitattributes\n-\t\t;;\n-\t\t-text)\n-\t\techo \"*.txt -text\" >.gitattributes\n-\t\t;;\n-\t\tcrlf)\n-\t\techo \"*.txt eol=crlf\" >.gitattributes\n-\t\t;;\n-\t\tlf)\n-\t\techo \"*.txt eol=lf\" >.gitattributes\n-\t\t;;\n-\t\t\"\")\n-\t\techo >.gitattributes\n-\t\t;;\n-\t\t*)\n-\t\techo >&2 invalid attribute: $attr\n-\t\texit 1\n-\t\t;;\n-\tesac\n+\t{\n+\t\twhile test \"$#\" != 0\n+\t\tdo\n+\t\t\tcase \"$1\" in\n+\t\t\t\tauto)\t echo '*.txt text=auto' ;;\n+\t\t\t\ti)     echo '* ident' ;;\n+\t\t\t\ttext)\t echo '*.txt text' ;;\n+\t\t\t\t-text) echo '*.txt -text' ;;\n+\t\t\t\tcrlf)  echo '*.txt eol=crlf' ;;\n+\t\t\t\tlf)    echo '*.txt eol=lf' ;;\n+\t\t\t\t\"\") echo '' ;;\n+\t\t\t\t*)\n+\t\t\t\techo >&2 invalid attribute: $attr\n+\t\t\t\texit 1\n+\t\t\t\t;;\n+\t\t\tesac &&\n+\t\t\tshift\n+\t\tdone\n+\t} >.gitattributes\n }\n \n create_NNO_files () {\n@@ -208,28 +202,30 @@ check_in_repo_NNO () {\n }\n \n checkout_files () {\n-\teol=$1\n-\tcrlf=$2\n-\tattr=$3\n-\tlfname=$4\n-\tcrlfname=$5\n-\tlfmixcrlf=$6\n-\tlfmixcr=$7\n-\tcrlfnul=$8\n-\tcreate_gitattributes $attr &&\n+\tattr=$1 ; shift\n+\tident=$1; shift\n+\taeol=$1 ; shift\n+\tcrlf=$1 ; shift\n+\tceol=$1 ; shift\n+\tlfname=$1 ; shift\n+\tcrlfname=$1 ; shift\n+\tlfmixcrlf=$1 ; shift\n+\tlfmixcr=$1 ; shift\n+\tcrlfnul=$1 ; shift\n+\tcreate_gitattributes \"$attr\" \"$ident\" &&\n \tgit config core.autocrlf $crlf &&\n-\tpfx=eol_${eol}_crlf_${crlf}_attr_${attr}_ &&\n+\tpfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul\n \tdo\n \t\trm crlf_false_attr__$f.txt &&\n-\t\tif test -z \"$eol\"; then\n+\t\tif test -z \"$ceol\"; then\n \t\t\tgit checkout crlf_false_attr__$f.txt\n \t\telse\n-\t\t\tgit -c core.eol=$eol checkout crlf_false_attr__$f.txt\n+\t\t\tgit -c core.eol=$ceol checkout crlf_false_attr__$f.txt\n \t\tfi\n \tdone\n \n-\ttest_expect_success \"ls-files --eol $lfname ${pfx}LF.txt\" '\n+\ttest_expect_success \"ls-files --eol attr=$attr i=$ident $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n \t\ttest_when_finished \"rm expect actual\" &&\n \t\tsort <<-EOF >expect &&\n \t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n@@ -244,19 +240,19 @@ checkout_files () {\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF\" \"\n \t\tcompare_ws_file $pfx $lfname    crlf_false_attr__LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF\" \"\n \t\tcompare_ws_file $pfx $crlfname  crlf_false_attr__CRLF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF_mix_LF\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF\" \"\n \t\tcompare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_mix_CR\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR\" \"\n \t\tcompare_ws_file $pfx $lfmixcr   crlf_false_attr__LF_mix_CR.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_nul\" \"\n+\ttest_expect_success \"checkout i=$ident attributes=$attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul\" \"\n \t\tcompare_ws_file $pfx $crlfnul   crlf_false_attr__LF_nul.txt\n \t\"\n }\n@@ -301,14 +297,13 @@ test_expect_success 'setup master' '\n \tgit checkout -b master &&\n \tgit add .gitattributes &&\n \tgit commit -m \"add .gitattributes\" \"\" &&\n-\tprintf \"line1\\nline2\\nline3\"     >LF &&\n-\tprintf \"line1\\r\\nline2\\r\\nline3\" >CRLF &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >repoMIX &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >CRLF_mix_LF &&\n-\tprintf \"line1\\nline2\\rline3\"     >LF_mix_CR &&\n-\tprintf \"line1\\r\\nline2\\rline3\"   >CRLF_mix_CR &&\n-\tprintf \"line1Q\\r\\nline2\\r\\nline3\" | q_to_nul >CRLF_nul &&\n-\tprintf \"line1Q\\nline2\\nline3\" | q_to_nul >LF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\nLINETHREE\"     >LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\r\\nLINETHREE\" >CRLF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\r\\nLINETWO\\nLINETHREE\"   >CRLF_mix_LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\rLINETHREE\"     >LF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\rLINETHREE\"   >CRLF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONEQ\\r\\nLINETWO\\r\\nLINETHREE\" | q_to_nul >CRLF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONEQ\\nLINETWO\\nLINETHREE\" | q_to_nul >LF_nul &&\n \tcreate_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&\n \tgit -c core.autocrlf=false add NNO_*.txt &&\n \tgit commit -m \"mixed line endings\" &&\n@@ -449,23 +444,18 @@ check_in_repo_NNO input \"-text\" LF        CRLF      CRLF_mix_LF  LF_mix_CR \tCRLF\n # How to read the table below:\n # - checkout_files will check multiple files with a combination of settings\n #   and attributes (core.autocrlf=input is forbidden with core.eol=crlf)\n-# - parameter $1 : core.eol               lf | crlf\n-# - parameter $2 : core.autocrlf          false | true | input\n-# - parameter $3 : text in .gitattributs  \"\" (empty) | auto | text | -text\n-# - parameter $4 : reference for a file with only LF in the repo\n-# - parameter $5 : reference for a file with only CRLF in the repo\n-# - parameter $6 : reference for a file with mixed LF and CRLF in the repo\n-# - parameter $7 : reference for a file with LF and CR in the repo (does somebody uses this ?)\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-#                                            ----------------- 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-#                                            ----------------------------------------------\n-#                                            What we want to have in the working tree:\n+#\n+# - parameter $1 \t: text in .gitattributs  \"\" (empty) | auto | text | -text\n+# - parameter $2 \t: ident                  \"\" | i (i == ident)\n+# - parameter $3 \t: eol in .gitattributs   \"\" (empty) | lf | crlf\n+# - parameter $4 \t: core.autocrlf          false | true | input\n+# - parameter $5 \t: core.eol               \"\" | lf | crlf | \"native\"\n+# - parameter $6 \t: reference for a file with only LF in the repo\n+# - parameter $7 \t: reference for a file with only CRLF in the repo\n+# - parameter $8 \t: reference for a file with mixed LF and CRLF in the repo\n+# - parameter $9 \t: reference for a file with LF and CR in the repo\n+# - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)\n+\n if test_have_prereq NATIVE_CRLF\n then\n MIX_CRLF_LF=CRLF\n@@ -480,69 +470,90 @@ LFNUL=LF_nul\n fi\n export CRLF_MIX_LF_CR MIX NL\n \n-checkout_files    lf      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    lf      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    crlf    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    \"\"      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    \"\"      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    native  false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    native  true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    native  false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    native  true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+checkout_files \"\"      \"\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   crlf     CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   lf       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \"\"    true   native   CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      i  \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   \"\"       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   lf       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \"\"    true   native   CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  i  \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\n+for id in \"\" i;\n+do\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+done\n \n # Should be the last test case: remove some files from the worktree\n test_expect_success 'ls-files --eol -d -z' '\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277437","messageId":"1454608191-5339-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v2 2/7] convert.c: remove unused parameter 'path'","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-04T17:49:51Z","receivedAt":"2016-02-04T17:49:51Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nSome functions get a parameter path, but don't use it.\nRemove the unused parameter.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 19 +++++++++----------\n 1 file changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 4bb4ec1..a24c2a2 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -696,7 +696,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,\n \treturn 1;\n }\n \n-static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_check *check)\n+static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -713,7 +713,7 @@ static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_ch\n \treturn CRLF_GUESS;\n }\n \n-static enum eol git_path_check_eol(const char *path, struct git_attr_check *check)\n+static enum eol git_path_check_eol(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -726,8 +726,7 @@ static enum eol git_path_check_eol(const char *path, struct git_attr_check *chec\n \treturn EOL_UNSET;\n }\n \n-static struct convert_driver *git_path_check_convert(const char *path,\n-\t\t\t\t\t     struct git_attr_check *check)\n+static struct convert_driver *git_path_check_convert(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \tstruct convert_driver *drv;\n@@ -740,7 +739,7 @@ static struct convert_driver *git_path_check_convert(const char *path,\n \treturn NULL;\n }\n \n-static int git_path_check_ident(const char *path, struct git_attr_check *check)\n+static int git_path_check_ident(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -783,12 +782,12 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 4);\n+\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n-\t\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 0);\n-\t\tca->ident = git_path_check_ident(path, ccheck + 1);\n-\t\tca->drv = git_path_check_convert(path, ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(path, ccheck + 3);\n+\t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->ident = git_path_check_ident(ccheck + 1);\n+\t\tca->drv = git_path_check_convert(ccheck + 2);\n+\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277440","messageId":"1454608193-5378-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v2 3/7] convert.c: Remove input_crlf_action()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-04T17:49:53Z","receivedAt":"2016-02-04T17:49:53Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nIntegrate the code of input_crlf_action() into convert_attrs(),\nso that ca.crlf_action is always valid after calling convert_attrs().\nKeep a copy of crlf_action in attr_action, this is needed for\nget_convert_attr_ascii().\n\nRemove eol_attr from struct conv_attrs, as it is now used temporally.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 37 ++++++++++++++-----------------------\n 1 file changed, 14 insertions(+), 23 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex a24c2a2..d0c8c66 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -746,21 +746,10 @@ static int git_path_check_ident(struct git_attr_check *check)\n \treturn !!ATTR_TRUE(value);\n }\n \n-static enum crlf_action input_crlf_action(enum crlf_action text_attr, enum eol eol_attr)\n-{\n-\tif (text_attr == CRLF_BINARY)\n-\t\treturn CRLF_BINARY;\n-\tif (eol_attr == EOL_LF)\n-\t\treturn CRLF_INPUT;\n-\tif (eol_attr == EOL_CRLF)\n-\t\treturn CRLF_CRLF;\n-\treturn text_attr;\n-}\n-\n struct conv_attrs {\n \tstruct convert_driver *drv;\n-\tenum crlf_action crlf_action;\n-\tenum eol eol_attr;\n+\tenum crlf_action attr_action; /* What attr says */\n+\tenum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */\n \tint ident;\n };\n \n@@ -782,16 +771,23 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n+\t\tenum eol eol_attr;\n+\t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n \t\tca->drv = git_path_check_convert(ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (ca->crlf_action == CRLF_BINARY)\n+\t\t\treturn;\n+\t\teol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (eol_attr == EOL_LF)\n+\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\telse if (eol_attr == EOL_CRLF)\n+\t\t\tca->crlf_action = CRLF_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-\t\tca->eol_attr = EOL_UNSET;\n \t\tca->ident = 0;\n \t}\n }\n@@ -818,11 +814,9 @@ int would_convert_to_git_filter_fd(const char *path)\n const char *get_convert_attr_ascii(const char *path)\n {\n \tstruct conv_attrs ca;\n-\tenum crlf_action crlf_action;\n \n \tconvert_attrs(&ca, path);\n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n-\tswitch (crlf_action) {\n+\tswitch (ca.attr_action) {\n \tcase CRLF_GUESS:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n@@ -861,7 +855,6 @@ int convert_to_git(const char *path, const char *src, size_t len,\n \t\tsrc = dst->buf;\n \t\tlen = dst->len;\n \t}\n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tret |= crlf_to_git(path, src, len, dst, ca.crlf_action, checksafe);\n \tif (ret && dst) {\n \t\tsrc = dst->buf;\n@@ -882,7 +875,6 @@ void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,\n \tif (!apply_filter(path, NULL, 0, fd, dst, ca.drv->clean))\n \t\tdie(\"%s: clean filter '%s' failed\", path, ca.drv->name);\n \n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tcrlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);\n \tident_to_git(path, dst->buf, dst->len, dst, ca.ident);\n }\n@@ -912,7 +904,6 @@ static int convert_to_working_tree_internal(const char *path, const char *src,\n \t * is a smudge filter.  The filter might expect CRLFs.\n \t */\n \tif (filter || !normalizing) {\n-\t\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \t\tret |= crlf_to_worktree(path, src, len, dst, ca.crlf_action);\n \t\tif (ret) {\n \t\t\tsrc = dst->buf;\n@@ -1381,7 +1372,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \tif (ca.ident)\n \t\tfilter = ident_filter(sha1);\n \n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n+\tcrlf_action = ca.crlf_action;\n \n \tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277441","messageId":"1454608194-5417-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v2 4/7] convert.c: Use text_eol_is_crlf()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-04T17:49:54Z","receivedAt":"2016-02-04T17:49:54Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nAdd a helper function to find out, which line endings\ntext files should get at checkout, depending on\ncore.autocrlf and core.eol\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 25 +++++++++++++++++--------\n 1 file changed, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex d0c8c66..9ffd043 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -149,6 +149,19 @@ const char *get_wt_convert_stats_ascii(const char *path)\n \treturn ret;\n }\n \n+static int text_eol_is_crlf(void)\n+{\n+\tif (auto_crlf == AUTO_CRLF_TRUE)\n+\t\treturn 1;\n+\telse if (auto_crlf == AUTO_CRLF_INPUT)\n+\t\treturn 0;\n+\tif (core_eol == EOL_CRLF)\n+\t\treturn 1;\n+\tif (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n static enum eol output_eol(enum crlf_action crlf_action)\n {\n \tswitch (crlf_action) {\n@@ -164,12 +177,7 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \t\t/* fall through */\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n-\t\tif (auto_crlf == AUTO_CRLF_TRUE)\n-\t\t\treturn EOL_CRLF;\n-\t\telse if (auto_crlf == AUTO_CRLF_INPUT)\n-\t\t\treturn EOL_LF;\n-\t\telse if (core_eol == EOL_UNSET)\n-\t\t\treturn EOL_NATIVE;\n+\t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n \treturn core_eol;\n }\n@@ -1378,8 +1386,9 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n-\telse if (output_eol(crlf_action) == EOL_CRLF &&\n-\t\t !(crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\t\t;\n+\telse if (output_eol(crlf_action) == EOL_CRLF)\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n \n \treturn filter;\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277442","messageId":"1454608197-5456-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v2 5/7] convert: auto_crlf=false and no attributes set: same as binary","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-04T17:49:57Z","receivedAt":"2016-02-04T17:49:57Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen core.autocrlf is set to false, and no attributes are set, the file\nis treated as binary.\nSimplify the logic and remove duplicated code when dealing with\n(crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) by setting\ncrlf_action=CRLF_BINARY already in convert_attrs().\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 9ffd043..4e33db1 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -235,7 +235,6 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tchar *dst;\n \n \tif (crlf_action == CRLF_BINARY ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) ||\n \t    (src && !len))\n \t\treturn 0;\n \n@@ -798,6 +797,8 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\tca->crlf_action = CRLF_GUESS;\n \t\tca->ident = 0;\n \t}\n+\tif (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n+\t\tca->crlf_action = CRLF_BINARY;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -1382,8 +1383,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \n \tcrlf_action = ca.crlf_action;\n \n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n+\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n \telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277438","messageId":"1454608198-5495-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v2 6/7] convert.c: Refactor crlf_action","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-04T17:49:58Z","receivedAt":"2016-02-04T17:49:58Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nRefactor the determination and usage of crlf_action.\nToday, when no attributes are set on a file,\ncrlf_action is set to CRLF_GUESS, and later, CRLF_GUESS is used as an\nindication that core.autocrlf is not false and that some automatic eol\nconversion is needed.\nMake more clear, what is what, by defining:\n\n- CRLF_UNDEFINED : No attributes set. Temparally used, until core.autocrlf\n                   and core.eol is evaluated and one of CRLF_BINARY,\n                   CRLF_AUTO_INPUT or CRLF_AUTO_CRLF is selected\n- CRLF_BINARY    : No processing of line endings.\n- CRLF_TEXT      : attribute \"text\" is set, line endings are processed.\n- CRLF_TEXT_INPUT: attribute \"input\" or \"eol=lf\" is set. This implies text.\n- CRLF_TEXT_CRLF : attribute \"eol=crlf\" is set. This implies text.\n- CRLF_AUTO      : attribute \"auto\" is set.\n- CRLF_AUTO_INPUT: No attributes, core.autocrlf=input\n- CRLF_AUTO_CRLF : No attributes, core.autocrlf=true\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 77 ++++++++++++++++++++++++++++++++++++++-------------------------\n 1 file changed, 46 insertions(+), 31 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 4e33db1..dd9646a 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -19,12 +19,14 @@\n #define CONVERT_STAT_BITS_BIN       0x4\n \n enum crlf_action {\n-\tCRLF_GUESS = -1,\n-\tCRLF_BINARY = 0,\n+\tCRLF_UNDEFINED,\n+\tCRLF_BINARY,\n \tCRLF_TEXT,\n-\tCRLF_INPUT,\n-\tCRLF_CRLF,\n-\tCRLF_AUTO\n+\tCRLF_TEXT_INPUT,\n+\tCRLF_TEXT_CRLF,\n+\tCRLF_AUTO,\n+\tCRLF_AUTO_INPUT,\n+\tCRLF_AUTO_CRLF\n };\n \n struct text_stat {\n@@ -167,18 +169,19 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \tswitch (crlf_action) {\n \tcase CRLF_BINARY:\n \t\treturn EOL_UNSET;\n-\tcase CRLF_CRLF:\n+\tcase CRLF_TEXT_CRLF:\n \t\treturn EOL_CRLF;\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_INPUT:\n \t\treturn EOL_LF;\n-\tcase CRLF_GUESS:\n-\t\tif (!auto_crlf)\n-\t\t\treturn EOL_UNSET;\n-\t\t/* fall through */\n+\tcase CRLF_UNDEFINED:\n+\tcase CRLF_AUTO_CRLF:\n+\tcase CRLF_AUTO_INPUT:\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n+\t\t/* fall through */\n \t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n+\twarning(\"Illegal crlf_action %d\\n\", (int)crlf_action);\n \treturn core_eol;\n }\n \n@@ -247,11 +250,11 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \n \tgather_stats(src, len, &stats);\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\tif (convert_is_binary(len, &stats))\n \t\t\treturn 0;\n \n-\t\tif (crlf_action == CRLF_GUESS) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/*\n \t\t\t * If the file in the index has any CR in it, do not convert.\n \t\t\t * This is the new safer autocrlf handling.\n@@ -278,7 +281,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tif (strbuf_avail(buf) + buf->len < len)\n \t\tstrbuf_grow(buf, len - buf->len);\n \tdst = buf->buf;\n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t/*\n \t\t * If we guessed, we already know we rejected a file with\n \t\t * lone CR, and we can strip a CR without looking at what\n@@ -319,8 +322,8 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tif (stats.lf == stats.crlf)\n \t\treturn 0;\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n-\t\tif (crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/* If we have any CR or CRLF line endings, we do not touch it */\n \t\t\t/* This is the new safer autocrlf-handling */\n \t\t\tif (stats.cr > 0 || stats.crlf > 0)\n@@ -708,16 +711,16 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n \tconst char *value = check->value;\n \n \tif (ATTR_TRUE(value))\n-\t\treturn CRLF_TEXT;\n+\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n \telse if (ATTR_FALSE(value))\n \t\treturn CRLF_BINARY;\n \telse if (ATTR_UNSET(value))\n \t\t;\n \telse if (!strcmp(value, \"input\"))\n-\t\treturn CRLF_INPUT;\n+\t\treturn CRLF_TEXT_INPUT;\n \telse if (!strcmp(value, \"auto\"))\n \t\treturn CRLF_AUTO;\n-\treturn CRLF_GUESS;\n+\treturn CRLF_UNDEFINED;\n }\n \n static enum eol git_path_check_eol(struct git_attr_check *check)\n@@ -780,7 +783,7 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n \t\tenum eol eol_attr;\n \t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n-\t\tif (ca->crlf_action == CRLF_GUESS)\n+\t\tif (ca->crlf_action == CRLF_UNDEFINED)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n \t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n@@ -789,16 +792,22 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\t\treturn;\n \t\teol_attr = git_path_check_eol(ccheck + 3);\n \t\tif (eol_attr == EOL_LF)\n-\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n \t\telse if (eol_attr == EOL_CRLF)\n-\t\t\tca->crlf_action = CRLF_CRLF;\n+\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n-\t\tca->crlf_action = CRLF_GUESS;\n+\t\tca->crlf_action = CRLF_UNDEFINED;\n \t\tca->ident = 0;\n \t}\n-\tif (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n+\tif (ca->crlf_action == CRLF_TEXT)\n+\t\tca->crlf_action = text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_FALSE)\n \t\tca->crlf_action = CRLF_BINARY;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_TRUE)\n+\t\tca->crlf_action = CRLF_AUTO_CRLF;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_INPUT)\n+\t\tca->crlf_action = CRLF_AUTO_INPUT;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -826,18 +835,22 @@ const char *get_convert_attr_ascii(const char *path)\n \n \tconvert_attrs(&ca, path);\n \tswitch (ca.attr_action) {\n-\tcase CRLF_GUESS:\n+\tcase CRLF_UNDEFINED:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n \t\treturn \"-text\";\n \tcase CRLF_TEXT:\n \t\treturn \"text\";\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_INPUT:\n \t\treturn \"text eol=lf\";\n-\tcase CRLF_CRLF:\n-\t\treturn \"text=auto eol=crlf\";\n+\tcase CRLF_TEXT_CRLF:\n+\t\treturn \"text eol=crlf\";\n \tcase CRLF_AUTO:\n \t\treturn \"text=auto\";\n+\tcase CRLF_AUTO_CRLF:\n+\t\treturn \"text=auto eol=crlf\"; /* This is not supported yet */\n+\tcase CRLF_AUTO_INPUT:\n+\t\treturn \"text=auto eol=lf\"; /* This is not supported yet */\n \t}\n \treturn \"\";\n }\n@@ -1382,11 +1395,13 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \t\tfilter = ident_filter(sha1);\n \n \tcrlf_action = ca.crlf_action;\n-\n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT))\n+\tif ((crlf_action == CRLF_BINARY) ||\n+\t\t\t(crlf_action == CRLF_TEXT_INPUT))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n-\telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\telse if ((crlf_action == CRLF_AUTO ||\n+\t\t\t\t\t\tcrlf_action == CRLF_AUTO_INPUT ||\n+\t\t\t\t\t\tcrlf_action == CRLF_AUTO_CRLF))\n \t\t;\n \telse if (output_eol(crlf_action) == EOL_CRLF)\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277443","messageId":"1454608200-5535-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v2 7/7] convert.c: simplify text_stat","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-04T17:50:00Z","receivedAt":"2016-02-04T17:50:00Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nSimplify the statistics:\nlonecr counts the CR which is not followed by a LF,\nlonelf counts the LF which is not preceded by a CR,\ncrlf counts CRLF combinations.\nThis simplifies the evaluation of the statistics.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 58 +++++++++++++++++++++++++++-------------------------------\n 1 file changed, 27 insertions(+), 31 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex dd9646a..ebf4d0e 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -31,7 +31,7 @@ enum crlf_action {\n \n struct text_stat {\n \t/* NUL, CR, LF and CRLF counts */\n-\tunsigned nul, cr, lf, crlf;\n+\tunsigned nul, lonecr, lonelf, crlf;\n \n \t/* These are just approximations! */\n \tunsigned printable, nonprintable;\n@@ -46,13 +46,15 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n \tfor (i = 0; i < size; i++) {\n \t\tunsigned char c = buf[i];\n \t\tif (c == '\\r') {\n-\t\t\tstats->cr++;\n-\t\t\tif (i+1 < size && buf[i+1] == '\\n')\n+\t\t\tif (i+1 < size && buf[i+1] == '\\n') {\n \t\t\t\tstats->crlf++;\n+\t\t\t\ti++;\n+\t\t\t} else\n+\t\t\t\tstats->lonecr++;\n \t\t\tcontinue;\n \t\t}\n \t\tif (c == '\\n') {\n-\t\t\tstats->lf++;\n+\t\t\tstats->lonelf++;\n \t\t\tcontinue;\n \t\t}\n \t\tif (c == 127)\n@@ -86,7 +88,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n  */\n static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n {\n-\tif (stats->cr != stats->crlf)\n+\tif (stats->lonecr)\n \t\treturn 1;\n \tif (stats->nul)\n \t\treturn 1;\n@@ -98,19 +100,18 @@ static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n static unsigned int gather_convert_stats(const char *data, unsigned long size)\n {\n \tstruct text_stat stats;\n+\tint ret = 0;\n \tif (!data || !size)\n-\t\treturn 0;\n+\t\treturn ret;\n \tgather_stats(data, size, &stats);\n \tif (convert_is_binary(size, &stats))\n-\t\treturn CONVERT_STAT_BITS_BIN;\n-\telse if (stats.crlf && stats.crlf == stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_CRLF;\n-\telse if (stats.crlf && stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_CRLF | CONVERT_STAT_BITS_TXT_LF;\n-\telse if (stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_LF;\n-\telse\n-\t\treturn 0;\n+\t\tret |= CONVERT_STAT_BITS_BIN;\n+\tif (stats.crlf)\n+\t\tret |= CONVERT_STAT_BITS_TXT_CRLF;\n+\tif (stats.lonelf)\n+\t\tret |=  CONVERT_STAT_BITS_TXT_LF;\n+\n+\treturn ret;\n }\n \n static const char *gather_convert_stats_ascii(const char *data, unsigned long size)\n@@ -207,7 +208,7 @@ static void check_safe_crlf(const char *path, enum crlf_action crlf_action,\n \t\t * CRLFs would be added by checkout:\n \t\t * check if we have \"naked\" LFs\n \t\t */\n-\t\tif (stats->lf != stats->crlf) {\n+\t\tif (stats->lonelf) {\n \t\t\tif (checksafe == SAFE_CRLF_WARN)\n \t\t\t\twarning(\"LF will be replaced by CRLF in %s.\\nThe file will have its original line endings in your working directory.\", path);\n \t\t\telse /* i.e. SAFE_CRLF_FAIL */\n@@ -266,8 +267,8 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \n \tcheck_safe_crlf(path, crlf_action, &stats, checksafe);\n \n-\t/* Optimization: No CR? Nothing to convert, regardless. */\n-\tif (!stats.cr)\n+\t/* Optimization: No CRLF? Nothing to convert, regardless. */\n+\tif (!stats.crlf)\n \t\treturn 0;\n \n \t/*\n@@ -315,21 +316,16 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tgather_stats(src, len, &stats);\n \n \t/* No LF? Nothing to convert, regardless. */\n-\tif (!stats.lf)\n-\t\treturn 0;\n-\n-\t/* Was it already in CRLF format? */\n-\tif (stats.lf == stats.crlf)\n+\tif (!stats.lonelf)\n \t\treturn 0;\n \n+\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n+\t\t/* If we have any CRLF line endings, we do not touch it */\n+\t\t/* This is the new safer autocrlf-handling */\n+\t\tif (stats.crlf)\n+\t\t\treturn 0;\n+\t}\n \tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n-\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n-\t\t\t/* If we have any CR or CRLF line endings, we do not touch it */\n-\t\t\t/* This is the new safer autocrlf-handling */\n-\t\t\tif (stats.cr > 0 || stats.crlf > 0)\n-\t\t\t\treturn 0;\n-\t\t}\n-\n \t\tif (convert_is_binary(len, &stats))\n \t\t\treturn 0;\n \t}\n@@ -338,7 +334,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tif (src == buf->buf)\n \t\tto_free = strbuf_detach(buf, NULL);\n \n-\tstrbuf_grow(buf, len + stats.lf - stats.crlf);\n+\tstrbuf_grow(buf, len + stats.crlf);\n \tfor (;;) {\n \t\tconst char *nl = memchr(src, '\\n', len);\n \t\tif (!nl)\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277454","messageId":"xmqqpowcgsnt.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1454608188-5300-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v2 1/7] t0027: Add tests for get_stream_filter()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-04T19:52:06Z","receivedAt":"2016-02-04T19:52:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> +\t\twhile test \"$#\" != 0\n> +\t\tdo\n> +\t\t\tcase \"$1\" in\n> +\t\t\t\tauto)\t echo '*.txt text=auto' ;;\n> +\t\t\t\ti)     echo '* ident' ;;\n> +\t\t\t\ttext)\t echo '*.txt text' ;;\n> +\t\t\t\t-text) echo '*.txt -text' ;;\n> +\t\t\t\tcrlf)  echo '*.txt eol=crlf' ;;\n> +\t\t\t\tlf)    echo '*.txt eol=lf' ;;\n> +\t\t\t\t\"\") echo '' ;;\n> +\t\t\t\t*)\n> +\t\t\t\techo >&2 invalid attribute: $attr\n> +\t\t\t\texit 1\n> +\t\t\t\t;;\n\nPerhaps use the right style as you are rewriting pretty much\neverything in this helper function?  case/esac aligns with the\nlabels of case arms, and commands under each arm are indented one\nlevel down, i.e.\n\n\tcase \"$var\" in\n        $arm1)\t... do short thing ...;;\n        $arm2)\n        \t... do a lot of\n                ... things\n                ;;\n\tesac\n\n\nI still do not see the value of accepting a cryptic 'i' (or an empty\nstring) to this thing, though.  Also what $attr does the error\nmessage refer to now?  Perhaps it wants to refer to \"$1\" (quoted)\ninstead?\n"},{"id":"277456","messageId":"xmqqlh70groz.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1454608194-5417-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v2 4/7] convert.c: Use text_eol_is_crlf()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-04T20:13:00Z","receivedAt":"2016-02-04T20:13:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> Add a helper function to find out, which line endings\n> text files should get at checkout, depending on\n> core.autocrlf and core.eol\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>  convert.c | 25 +++++++++++++++++--------\n>  1 file changed, 17 insertions(+), 8 deletions(-)\n>\n> diff --git a/convert.c b/convert.c\n> index d0c8c66..9ffd043 100644\n> --- a/convert.c\n> +++ b/convert.c\n> @@ -149,6 +149,19 @@ const char *get_wt_convert_stats_ascii(const char *path)\n>  \treturn ret;\n>  }\n>  \n> +static int text_eol_is_crlf(void)\n> +{\n> +\tif (auto_crlf == AUTO_CRLF_TRUE)\n> +\t\treturn 1;\n> +\telse if (auto_crlf == AUTO_CRLF_INPUT)\n> +\t\treturn 0;\n> +\tif (core_eol == EOL_CRLF)\n> +\t\treturn 1;\n> +\tif (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)\n> +\t\treturn 1;\n> +\treturn 0;\n> +}\n> +\n>  static enum eol output_eol(enum crlf_action crlf_action)\n>  {\n>  \tswitch (crlf_action) {\n> @@ -164,12 +177,7 @@ static enum eol output_eol(enum crlf_action crlf_action)\n>  \t\t/* fall through */\n>  \tcase CRLF_TEXT:\n>  \tcase CRLF_AUTO:\n> -\t\tif (auto_crlf == AUTO_CRLF_TRUE)\n> -\t\t\treturn EOL_CRLF;\n> -\t\telse if (auto_crlf == AUTO_CRLF_INPUT)\n> -\t\t\treturn EOL_LF;\n> -\t\telse if (core_eol == EOL_UNSET)\n> -\t\t\treturn EOL_NATIVE;\n> +\t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n>  \t}\n>  \treturn core_eol;\n>  }\n> @@ -1378,8 +1386,9 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n>  \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n>  \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n>  \n> -\telse if (output_eol(crlf_action) == EOL_CRLF &&\n> -\t\t !(crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n> +\telse if ((crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n> +\t\t;\n> +\telse if (output_eol(crlf_action) == EOL_CRLF)\n>  \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n>  \n>  \treturn filter;\n\nI am a bit slow today so let me talk this change through aloud.\n\nThe condition under which we called cascade_filter() used to be that\noutput_eol(crlf_action) yields EOL_CRLF and crlf_action is not set\nto one of these two values.  Now, we say if crlf_action is one of\nthese two values, we wouldn't call it, and then we check\noutput_eol().\n\nSo they do the same thing, even though it smells that this change is\noutside the scope of \"Add a helper and use it\" theme of the patch.\n\nWhile I do not think this new \"split\" conditions particularly easier\nto read compared to the previous one, if you plan to do something\ndifferent in later patches when crlf_action is set to specific\nvalues, ignoring what output_eol() says, a patch to implement such a\nchange would become easier to understand what is going on with this\npreparatory rewrite.  So if such a preparatory rewrite is coming (I\nhaven't checked 5-7/7 yet), perhaps have this hunk as a single patch\nthat is separate from \"add a helper text_eol_is_crlf()\" patch.\n\nBy the way, your new 1/7 has s/: Remove/: remove/ applied to the\nsubject, but not other ones like this one.  Intended, or you forgot\nto do s/: Use/: use/ here?\n"},{"id":"277459","messageId":"xmqqh9hogqkw.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1454608200-5535-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v2 7/7] convert.c: simplify text_stat","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-04T20:37:03Z","receivedAt":"2016-02-04T20:37:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n>  static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n>  {\n> -\tif (stats->cr != stats->crlf)\n> +\tif (stats->lonecr)\n>  \t\treturn 1;\n\nThis is an equivalent conversion, but...\n\n> @@ -266,8 +267,8 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n>  \n>  \tcheck_safe_crlf(path, crlf_action, &stats, checksafe);\n>  \n> -\t/* Optimization: No CR? Nothing to convert, regardless. */\n> -\tif (!stats.cr)\n> +\t/* Optimization: No CRLF? Nothing to convert, regardless. */\n> +\tif (!stats.crlf)\n>  \t\treturn 0;\n\n... this is not.  In fact this is even better, as we used to try the\nremainder of the function when we saw a lone CR, but we no longer\ndo.  I am of course assuming that the original turned into a no-op\nif we had a lone CR in the input--otherwise this patch changes the\nbehaviour.\n\nHowever, I see this comment after the function returns with the\nabove optimization:\n\n       /*\n        * If we guessed, we already know we rejected a file with\n        * lone CR, and we can strip a CR without looking at what\n        * follow it.\n        */\n\nSo the code around there used to have a reason to worry about a lone\nCR (i.e. it didn't want to lose them).  With the change in this hunk\nfor the \"optimization\", it no longer is necessary to do so, i.e. we\nknow we do not have a lone CR so every CR can be stripped because it\nmust be followed by LF, isn't it?\n\nBut I do not see a matching change to simplify that here.  Am I\nfollowing the current code incorrectly or something?\n\nPuzzled...\n\n>  \t/*\n> @@ -315,21 +316,16 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n>  \tgather_stats(src, len, &stats);\n>  \n>  \t/* No LF? Nothing to convert, regardless. */\n> -\tif (!stats.lf)\n> -\t\treturn 0;\n> -\n> -\t/* Was it already in CRLF format? */\n> -\tif (stats.lf == stats.crlf)\n> +\tif (!stats.lonelf)\n\nDoesn't the comment above need adjustment?\n\n>  \t\treturn 0;\n\nOtherwise, the output side looks correct to me.\n"},{"id":"277545","messageId":"1454688800-20714-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v3 1/7] t0027: Add tests for get_stream_filter()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-05T16:13:20Z","receivedAt":"2016-02-05T16:13:20Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen a filter is configured, a different code-path is used in convert.c\nand entry.c via get_stream_filter(), but there are no test cases yet.\n\nAdd tests for the filter API by configuring the ident filter.\nThe result of the SHA1 conversion is not checked, this is already\ndone in other TC.\n\nAdd a parameter to checkout_files() in t0027.\nWhile changing the signature, add another parameter for the eol= attribute.\nThis is currently unused, tests for e.g.\n\"* text=auto eol=lf\" will be added in a separate commit.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\nChanges since v2:\n1/7 t0027 uses ident instead of i (the empty \"\" is still there)\n    better ident of case..esac (thanks for the patience)\n    (And again the question, if there is an official init.el, please)\n4/7 don't change the logic which stream filter to use    \n7/7 had been broken (wrong bufferlen) , should be OK now\n\n\nt/t0027-auto-crlf.sh | 281 ++++++++++++++++++++++++++-------------------------\n 1 file changed, 146 insertions(+), 135 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 504e5a0..fc4c628 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -21,38 +21,32 @@ compare_ws_file () {\n \tpfx=$1\n \texp=$2.expect\n \tact=$pfx.actual.$3\n-\ttr '\\015\\000' QN <\"$2\" >\"$exp\" &&\n-\ttr '\\015\\000' QN <\"$3\" >\"$act\" &&\n-\ttest_cmp $exp $act &&\n-\trm $exp $act\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$3\" >\"$act\" &&\n+\ttest_cmp \"$exp\" \"$act\" &&\n+\trm \"$exp\" \"$act\"\n }\n \n create_gitattributes () {\n-\tattr=$1\n-\tcase \"$attr\" in\n-\t\tauto)\n-\t\techo \"*.txt text=auto\" >.gitattributes\n-\t\t;;\n-\t\ttext)\n-\t\techo \"*.txt text\" >.gitattributes\n-\t\t;;\n-\t\t-text)\n-\t\techo \"*.txt -text\" >.gitattributes\n-\t\t;;\n-\t\tcrlf)\n-\t\techo \"*.txt eol=crlf\" >.gitattributes\n-\t\t;;\n-\t\tlf)\n-\t\techo \"*.txt eol=lf\" >.gitattributes\n-\t\t;;\n-\t\t\"\")\n-\t\techo >.gitattributes\n-\t\t;;\n-\t\t*)\n-\t\techo >&2 invalid attribute: $attr\n-\t\texit 1\n-\t\t;;\n-\tesac\n+\t{\n+\t\twhile test \"$#\" != 0\n+\t\tdo\n+\t\t\tcase \"$1\" in\n+\t\t\tauto)\t echo '*.txt text=auto' ;;\n+\t\t\tident) echo '*.txt ident' ;;\n+\t\t\ttext)\t echo '*.txt text' ;;\n+\t\t\t-text) echo '*.txt -text' ;;\n+\t\t\tcrlf)  echo '*.txt eol=crlf' ;;\n+\t\t\tlf)    echo '*.txt eol=lf' ;;\n+\t\t\t\"\") ;;\n+\t\t\t*)\n+\t\t\t\techo >&2 invalid attribute: \"$1\"\n+\t\t\t\texit 1\n+\t\t\t\t;;\n+\t\t\tesac &&\n+\t\t\tshift\n+\t\tdone\n+\t} >.gitattributes\n }\n \n create_NNO_files () {\n@@ -208,28 +202,30 @@ check_in_repo_NNO () {\n }\n \n checkout_files () {\n-\teol=$1\n-\tcrlf=$2\n-\tattr=$3\n-\tlfname=$4\n-\tcrlfname=$5\n-\tlfmixcrlf=$6\n-\tlfmixcr=$7\n-\tcrlfnul=$8\n-\tcreate_gitattributes $attr &&\n+\tattr=$1 ; shift\n+\tident=$1; shift\n+\taeol=$1 ; shift\n+\tcrlf=$1 ; shift\n+\tceol=$1 ; shift\n+\tlfname=$1 ; shift\n+\tcrlfname=$1 ; shift\n+\tlfmixcrlf=$1 ; shift\n+\tlfmixcr=$1 ; shift\n+\tcrlfnul=$1 ; shift\n+\tcreate_gitattributes \"$attr\" \"$ident\" &&\n \tgit config core.autocrlf $crlf &&\n-\tpfx=eol_${eol}_crlf_${crlf}_attr_${attr}_ &&\n+\tpfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul\n \tdo\n \t\trm crlf_false_attr__$f.txt &&\n-\t\tif test -z \"$eol\"; then\n+\t\tif test -z \"$ceol\"; then\n \t\t\tgit checkout crlf_false_attr__$f.txt\n \t\telse\n-\t\t\tgit -c core.eol=$eol checkout crlf_false_attr__$f.txt\n+\t\t\tgit -c core.eol=$ceol checkout crlf_false_attr__$f.txt\n \t\tfi\n \tdone\n \n-\ttest_expect_success \"ls-files --eol $lfname ${pfx}LF.txt\" '\n+\ttest_expect_success \"ls-files --eol attr=$attr $ident $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n \t\ttest_when_finished \"rm expect actual\" &&\n \t\tsort <<-EOF >expect &&\n \t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n@@ -244,19 +240,19 @@ checkout_files () {\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF\" \"\n \t\tcompare_ws_file $pfx $lfname    crlf_false_attr__LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF\" \"\n \t\tcompare_ws_file $pfx $crlfname  crlf_false_attr__CRLF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF_mix_LF\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF\" \"\n \t\tcompare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_mix_CR\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR\" \"\n \t\tcompare_ws_file $pfx $lfmixcr   crlf_false_attr__LF_mix_CR.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_nul\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul\" \"\n \t\tcompare_ws_file $pfx $crlfnul   crlf_false_attr__LF_nul.txt\n \t\"\n }\n@@ -301,14 +297,13 @@ test_expect_success 'setup master' '\n \tgit checkout -b master &&\n \tgit add .gitattributes &&\n \tgit commit -m \"add .gitattributes\" \"\" &&\n-\tprintf \"line1\\nline2\\nline3\"     >LF &&\n-\tprintf \"line1\\r\\nline2\\r\\nline3\" >CRLF &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >repoMIX &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >CRLF_mix_LF &&\n-\tprintf \"line1\\nline2\\rline3\"     >LF_mix_CR &&\n-\tprintf \"line1\\r\\nline2\\rline3\"   >CRLF_mix_CR &&\n-\tprintf \"line1Q\\r\\nline2\\r\\nline3\" | q_to_nul >CRLF_nul &&\n-\tprintf \"line1Q\\nline2\\nline3\" | q_to_nul >LF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\nLINETHREE\"     >LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\r\\nLINETHREE\" >CRLF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\r\\nLINETWO\\nLINETHREE\"   >CRLF_mix_LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\rLINETHREE\"     >LF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\rLINETHREE\"   >CRLF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONEQ\\r\\nLINETWO\\r\\nLINETHREE\" | q_to_nul >CRLF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONEQ\\nLINETWO\\nLINETHREE\" | q_to_nul >LF_nul &&\n \tcreate_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&\n \tgit -c core.autocrlf=false add NNO_*.txt &&\n \tgit commit -m \"mixed line endings\" &&\n@@ -449,23 +444,18 @@ check_in_repo_NNO input \"-text\" LF        CRLF      CRLF_mix_LF  LF_mix_CR \tCRLF\n # How to read the table below:\n # - checkout_files will check multiple files with a combination of settings\n #   and attributes (core.autocrlf=input is forbidden with core.eol=crlf)\n-# - parameter $1 : core.eol               lf | crlf\n-# - parameter $2 : core.autocrlf          false | true | input\n-# - parameter $3 : text in .gitattributs  \"\" (empty) | auto | text | -text\n-# - parameter $4 : reference for a file with only LF in the repo\n-# - parameter $5 : reference for a file with only CRLF in the repo\n-# - parameter $6 : reference for a file with mixed LF and CRLF in the repo\n-# - parameter $7 : reference for a file with LF and CR in the repo (does somebody uses this ?)\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-#                                            ----------------- 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-#                                            ----------------------------------------------\n-#                                            What we want to have in the working tree:\n+#\n+# - parameter $1 \t: text in .gitattributs  \"\" (empty) | auto | text | -text\n+# - parameter $2 \t: ident                  \"\" | i (i == ident)\n+# - parameter $3 \t: eol in .gitattributs   \"\" (empty) | lf | crlf\n+# - parameter $4 \t: core.autocrlf          false | true | input\n+# - parameter $5 \t: core.eol               \"\" | lf | crlf | \"native\"\n+# - parameter $6 \t: reference for a file with only LF in the repo\n+# - parameter $7 \t: reference for a file with only CRLF in the repo\n+# - parameter $8 \t: reference for a file with mixed LF and CRLF in the repo\n+# - parameter $9 \t: reference for a file with LF and CR in the repo\n+# - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)\n+\n if test_have_prereq NATIVE_CRLF\n then\n MIX_CRLF_LF=CRLF\n@@ -480,69 +470,90 @@ LFNUL=LF_nul\n fi\n export CRLF_MIX_LF_CR MIX NL\n \n-checkout_files    lf      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    lf      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    crlf    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    \"\"      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    \"\"      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    native  false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    native  true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    native  false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    native  true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+checkout_files \"\"      \"\" \t \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    true   crlf     CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    true   lf       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    true   native   CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    false  crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    true   \"\"       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    true   crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    true   lf       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    true   native   CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\n+for id in \"\" ident;\n+do\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+done\n \n # Should be the last test case: remove some files from the worktree\n test_expect_success 'ls-files --eol -d -z' '\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277547","messageId":"1454688802-20753-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v3 2/7] convert.c: remove unused parameter 'path'","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-05T16:13:22Z","receivedAt":"2016-02-05T16:13:22Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nSome functions get a parameter path, but don't use it.\nRemove the unused parameter.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 19 +++++++++----------\n 1 file changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 4bb4ec1..a24c2a2 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -696,7 +696,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,\n \treturn 1;\n }\n \n-static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_check *check)\n+static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -713,7 +713,7 @@ static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_ch\n \treturn CRLF_GUESS;\n }\n \n-static enum eol git_path_check_eol(const char *path, struct git_attr_check *check)\n+static enum eol git_path_check_eol(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -726,8 +726,7 @@ static enum eol git_path_check_eol(const char *path, struct git_attr_check *chec\n \treturn EOL_UNSET;\n }\n \n-static struct convert_driver *git_path_check_convert(const char *path,\n-\t\t\t\t\t     struct git_attr_check *check)\n+static struct convert_driver *git_path_check_convert(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \tstruct convert_driver *drv;\n@@ -740,7 +739,7 @@ static struct convert_driver *git_path_check_convert(const char *path,\n \treturn NULL;\n }\n \n-static int git_path_check_ident(const char *path, struct git_attr_check *check)\n+static int git_path_check_ident(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -783,12 +782,12 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 4);\n+\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n-\t\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 0);\n-\t\tca->ident = git_path_check_ident(path, ccheck + 1);\n-\t\tca->drv = git_path_check_convert(path, ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(path, ccheck + 3);\n+\t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->ident = git_path_check_ident(ccheck + 1);\n+\t\tca->drv = git_path_check_convert(ccheck + 2);\n+\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277550","messageId":"1454688803-20792-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v3 3/7] convert.c: Remove input_crlf_action()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-05T16:13:23Z","receivedAt":"2016-02-05T16:13:23Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nIntegrate the code of input_crlf_action() into convert_attrs(),\nso that ca.crlf_action is always valid after calling convert_attrs().\nKeep a copy of crlf_action in attr_action, this is needed for\nget_convert_attr_ascii().\n\nRemove eol_attr from struct conv_attrs, as it is now used temporally.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 37 ++++++++++++++-----------------------\n 1 file changed, 14 insertions(+), 23 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex a24c2a2..d0c8c66 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -746,21 +746,10 @@ static int git_path_check_ident(struct git_attr_check *check)\n \treturn !!ATTR_TRUE(value);\n }\n \n-static enum crlf_action input_crlf_action(enum crlf_action text_attr, enum eol eol_attr)\n-{\n-\tif (text_attr == CRLF_BINARY)\n-\t\treturn CRLF_BINARY;\n-\tif (eol_attr == EOL_LF)\n-\t\treturn CRLF_INPUT;\n-\tif (eol_attr == EOL_CRLF)\n-\t\treturn CRLF_CRLF;\n-\treturn text_attr;\n-}\n-\n struct conv_attrs {\n \tstruct convert_driver *drv;\n-\tenum crlf_action crlf_action;\n-\tenum eol eol_attr;\n+\tenum crlf_action attr_action; /* What attr says */\n+\tenum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */\n \tint ident;\n };\n \n@@ -782,16 +771,23 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n+\t\tenum eol eol_attr;\n+\t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n \t\tca->drv = git_path_check_convert(ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (ca->crlf_action == CRLF_BINARY)\n+\t\t\treturn;\n+\t\teol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (eol_attr == EOL_LF)\n+\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\telse if (eol_attr == EOL_CRLF)\n+\t\t\tca->crlf_action = CRLF_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-\t\tca->eol_attr = EOL_UNSET;\n \t\tca->ident = 0;\n \t}\n }\n@@ -818,11 +814,9 @@ int would_convert_to_git_filter_fd(const char *path)\n const char *get_convert_attr_ascii(const char *path)\n {\n \tstruct conv_attrs ca;\n-\tenum crlf_action crlf_action;\n \n \tconvert_attrs(&ca, path);\n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n-\tswitch (crlf_action) {\n+\tswitch (ca.attr_action) {\n \tcase CRLF_GUESS:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n@@ -861,7 +855,6 @@ int convert_to_git(const char *path, const char *src, size_t len,\n \t\tsrc = dst->buf;\n \t\tlen = dst->len;\n \t}\n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tret |= crlf_to_git(path, src, len, dst, ca.crlf_action, checksafe);\n \tif (ret && dst) {\n \t\tsrc = dst->buf;\n@@ -882,7 +875,6 @@ void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,\n \tif (!apply_filter(path, NULL, 0, fd, dst, ca.drv->clean))\n \t\tdie(\"%s: clean filter '%s' failed\", path, ca.drv->name);\n \n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tcrlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);\n \tident_to_git(path, dst->buf, dst->len, dst, ca.ident);\n }\n@@ -912,7 +904,6 @@ static int convert_to_working_tree_internal(const char *path, const char *src,\n \t * is a smudge filter.  The filter might expect CRLFs.\n \t */\n \tif (filter || !normalizing) {\n-\t\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \t\tret |= crlf_to_worktree(path, src, len, dst, ca.crlf_action);\n \t\tif (ret) {\n \t\t\tsrc = dst->buf;\n@@ -1381,7 +1372,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \tif (ca.ident)\n \t\tfilter = ident_filter(sha1);\n \n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n+\tcrlf_action = ca.crlf_action;\n \n \tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277551","messageId":"1454688805-20832-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v3 4/7] convert.c: use text_eol_is_crlf()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-05T16:13:25Z","receivedAt":"2016-02-05T16:13:25Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nAdd a helper function to find out, which line endings\ntext files should get at checkout, depending on\ncore.autocrlf and core.eol\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 20 ++++++++++++++------\n 1 file changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex d0c8c66..557e574 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -149,6 +149,19 @@ const char *get_wt_convert_stats_ascii(const char *path)\n \treturn ret;\n }\n \n+static int text_eol_is_crlf(void)\n+{\n+\tif (auto_crlf == AUTO_CRLF_TRUE)\n+\t\treturn 1;\n+\telse if (auto_crlf == AUTO_CRLF_INPUT)\n+\t\treturn 0;\n+\tif (core_eol == EOL_CRLF)\n+\t\treturn 1;\n+\tif (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n static enum eol output_eol(enum crlf_action crlf_action)\n {\n \tswitch (crlf_action) {\n@@ -164,12 +177,7 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \t\t/* fall through */\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n-\t\tif (auto_crlf == AUTO_CRLF_TRUE)\n-\t\t\treturn EOL_CRLF;\n-\t\telse if (auto_crlf == AUTO_CRLF_INPUT)\n-\t\t\treturn EOL_LF;\n-\t\telse if (core_eol == EOL_UNSET)\n-\t\t\treturn EOL_NATIVE;\n+\t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n \treturn core_eol;\n }\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277549","messageId":"1454688807-20871-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v3 5/7] convert: auto_crlf=false and no attributes set: same as binary","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-05T16:13:27Z","receivedAt":"2016-02-05T16:13:27Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen core.autocrlf is set to false, and no attributes are set, the file\nis treated as binary.\nSimplify the logic and remove duplicated code when dealing with\n(crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) by setting\ncrlf_action=CRLF_BINARY already in convert_attrs().\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 557e574..e9c9448 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -235,7 +235,6 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tchar *dst;\n \n \tif (crlf_action == CRLF_BINARY ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) ||\n \t    (src && !len))\n \t\treturn 0;\n \n@@ -798,6 +797,8 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\tca->crlf_action = CRLF_GUESS;\n \t\tca->ident = 0;\n \t}\n+\tif (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n+\t\tca->crlf_action = CRLF_BINARY;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -1382,8 +1383,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \n \tcrlf_action = ca.crlf_action;\n \n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n+\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n \telse if (output_eol(crlf_action) == EOL_CRLF &&\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277546","messageId":"1454688808-20910-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v3 6/7] convert.c: refactor crlf_action","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-05T16:13:28Z","receivedAt":"2016-02-05T16:13:28Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nRefactor the determination and usage of crlf_action.\nToday, when no attributes are set on a file,\ncrlf_action is set to CRLF_GUESS, and later, CRLF_GUESS is used as an\nindication that core.autocrlf is not false and that some automatic eol\nconversion is needed.\nMake more clear, what is what, by defining:\n\n- CRLF_UNDEFINED : No attributes set. Temparally used, until core.autocrlf\n                   and core.eol is evaluated and one of CRLF_BINARY,\n                   CRLF_AUTO_INPUT or CRLF_AUTO_CRLF is selected\n- CRLF_BINARY    : No processing of line endings.\n- CRLF_TEXT      : attribute \"text\" is set, line endings are processed.\n- CRLF_TEXT_INPUT: attribute \"input\" or \"eol=lf\" is set. This implies text.\n- CRLF_TEXT_CRLF : attribute \"eol=crlf\" is set. This implies text.\n- CRLF_AUTO      : attribute \"auto\" is set.\n- CRLF_AUTO_INPUT: No attributes, core.autocrlf=input\n- CRLF_AUTO_CRLF : No attributes, core.autocrlf=true\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 75 ++++++++++++++++++++++++++++++++++++++-------------------------\n 1 file changed, 45 insertions(+), 30 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex e9c9448..e4e2877 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -19,12 +19,14 @@\n #define CONVERT_STAT_BITS_BIN       0x4\n \n enum crlf_action {\n-\tCRLF_GUESS = -1,\n-\tCRLF_BINARY = 0,\n+\tCRLF_UNDEFINED,\n+\tCRLF_BINARY,\n \tCRLF_TEXT,\n-\tCRLF_INPUT,\n-\tCRLF_CRLF,\n-\tCRLF_AUTO\n+\tCRLF_TEXT_INPUT,\n+\tCRLF_TEXT_CRLF,\n+\tCRLF_AUTO,\n+\tCRLF_AUTO_INPUT,\n+\tCRLF_AUTO_CRLF\n };\n \n struct text_stat {\n@@ -167,18 +169,19 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \tswitch (crlf_action) {\n \tcase CRLF_BINARY:\n \t\treturn EOL_UNSET;\n-\tcase CRLF_CRLF:\n+\tcase CRLF_TEXT_CRLF:\n \t\treturn EOL_CRLF;\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_INPUT:\n \t\treturn EOL_LF;\n-\tcase CRLF_GUESS:\n-\t\tif (!auto_crlf)\n-\t\t\treturn EOL_UNSET;\n-\t\t/* fall through */\n+\tcase CRLF_UNDEFINED:\n+\tcase CRLF_AUTO_CRLF:\n+\tcase CRLF_AUTO_INPUT:\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n+\t\t/* fall through */\n \t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n+\twarning(\"Illegal crlf_action %d\\n\", (int)crlf_action);\n \treturn core_eol;\n }\n \n@@ -247,11 +250,11 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \n \tgather_stats(src, len, &stats);\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\tif (convert_is_binary(len, &stats))\n \t\t\treturn 0;\n \n-\t\tif (crlf_action == CRLF_GUESS) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/*\n \t\t\t * If the file in the index has any CR in it, do not convert.\n \t\t\t * This is the new safer autocrlf handling.\n@@ -278,7 +281,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tif (strbuf_avail(buf) + buf->len < len)\n \t\tstrbuf_grow(buf, len - buf->len);\n \tdst = buf->buf;\n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t/*\n \t\t * If we guessed, we already know we rejected a file with\n \t\t * lone CR, and we can strip a CR without looking at what\n@@ -319,8 +322,8 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tif (stats.lf == stats.crlf)\n \t\treturn 0;\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n-\t\tif (crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/* If we have any CR or CRLF line endings, we do not touch it */\n \t\t\t/* This is the new safer autocrlf-handling */\n \t\t\tif (stats.cr > 0 || stats.crlf > 0)\n@@ -708,16 +711,16 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n \tconst char *value = check->value;\n \n \tif (ATTR_TRUE(value))\n-\t\treturn CRLF_TEXT;\n+\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n \telse if (ATTR_FALSE(value))\n \t\treturn CRLF_BINARY;\n \telse if (ATTR_UNSET(value))\n \t\t;\n \telse if (!strcmp(value, \"input\"))\n-\t\treturn CRLF_INPUT;\n+\t\treturn CRLF_TEXT_INPUT;\n \telse if (!strcmp(value, \"auto\"))\n \t\treturn CRLF_AUTO;\n-\treturn CRLF_GUESS;\n+\treturn CRLF_UNDEFINED;\n }\n \n static enum eol git_path_check_eol(struct git_attr_check *check)\n@@ -780,7 +783,7 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n \t\tenum eol eol_attr;\n \t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n-\t\tif (ca->crlf_action == CRLF_GUESS)\n+\t\tif (ca->crlf_action == CRLF_UNDEFINED)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n \t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n@@ -789,16 +792,22 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\t\treturn;\n \t\teol_attr = git_path_check_eol(ccheck + 3);\n \t\tif (eol_attr == EOL_LF)\n-\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n \t\telse if (eol_attr == EOL_CRLF)\n-\t\t\tca->crlf_action = CRLF_CRLF;\n+\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n-\t\tca->crlf_action = CRLF_GUESS;\n+\t\tca->crlf_action = CRLF_UNDEFINED;\n \t\tca->ident = 0;\n \t}\n-\tif (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n+\tif (ca->crlf_action == CRLF_TEXT)\n+\t\tca->crlf_action = text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_FALSE)\n \t\tca->crlf_action = CRLF_BINARY;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_TRUE)\n+\t\tca->crlf_action = CRLF_AUTO_CRLF;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_INPUT)\n+\t\tca->crlf_action = CRLF_AUTO_INPUT;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -826,18 +835,22 @@ const char *get_convert_attr_ascii(const char *path)\n \n \tconvert_attrs(&ca, path);\n \tswitch (ca.attr_action) {\n-\tcase CRLF_GUESS:\n+\tcase CRLF_UNDEFINED:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n \t\treturn \"-text\";\n \tcase CRLF_TEXT:\n \t\treturn \"text\";\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_INPUT:\n \t\treturn \"text eol=lf\";\n-\tcase CRLF_CRLF:\n-\t\treturn \"text=auto eol=crlf\";\n+\tcase CRLF_TEXT_CRLF:\n+\t\treturn \"text eol=crlf\";\n \tcase CRLF_AUTO:\n \t\treturn \"text=auto\";\n+\tcase CRLF_AUTO_CRLF:\n+\t\treturn \"text=auto eol=crlf\"; /* This is not supported yet */\n+\tcase CRLF_AUTO_INPUT:\n+\t\treturn \"text=auto eol=lf\"; /* This is not supported yet */\n \t}\n \treturn \"\";\n }\n@@ -1383,11 +1396,13 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \n \tcrlf_action = ca.crlf_action;\n \n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT))\n+\tif ((crlf_action == CRLF_BINARY) ||\n+\t\t\tcrlf_action == CRLF_AUTO_INPUT ||\n+\t\t\t(crlf_action == CRLF_TEXT_INPUT))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n \telse if (output_eol(crlf_action) == EOL_CRLF &&\n-\t\t !(crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\t\t !(crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_CRLF))\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n \n \treturn filter;\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277548","messageId":"1454688810-20949-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v3 7/7] convert.c: simplify text_stat","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-05T16:13:30Z","receivedAt":"2016-02-05T16:13:30Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nSimplify the statistics:\nlonecr counts the CR which is not followed by a LF,\nlonelf counts the LF which is not preceded by a CR,\ncrlf counts CRLF combinations.\nThis simplifies the evaluation of the statistics.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 47 ++++++++++++++++++++++-------------------------\n 1 file changed, 22 insertions(+), 25 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex e4e2877..18af685 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -31,7 +31,7 @@ enum crlf_action {\n \n struct text_stat {\n \t/* NUL, CR, LF and CRLF counts */\n-\tunsigned nul, cr, lf, crlf;\n+\tunsigned nul, lonecr, lonelf, crlf;\n \n \t/* These are just approximations! */\n \tunsigned printable, nonprintable;\n@@ -46,13 +46,15 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n \tfor (i = 0; i < size; i++) {\n \t\tunsigned char c = buf[i];\n \t\tif (c == '\\r') {\n-\t\t\tstats->cr++;\n-\t\t\tif (i+1 < size && buf[i+1] == '\\n')\n+\t\t\tif (i+1 < size && buf[i+1] == '\\n') {\n \t\t\t\tstats->crlf++;\n+\t\t\t\ti++;\n+\t\t\t} else\n+\t\t\t\tstats->lonecr++;\n \t\t\tcontinue;\n \t\t}\n \t\tif (c == '\\n') {\n-\t\t\tstats->lf++;\n+\t\t\tstats->lonelf++;\n \t\t\tcontinue;\n \t\t}\n \t\tif (c == 127)\n@@ -86,7 +88,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n  */\n static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n {\n-\tif (stats->cr != stats->crlf)\n+\tif (stats->lonecr)\n \t\treturn 1;\n \tif (stats->nul)\n \t\treturn 1;\n@@ -98,19 +100,18 @@ static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n static unsigned int gather_convert_stats(const char *data, unsigned long size)\n {\n \tstruct text_stat stats;\n+\tint ret = 0;\n \tif (!data || !size)\n \t\treturn 0;\n \tgather_stats(data, size, &stats);\n \tif (convert_is_binary(size, &stats))\n-\t\treturn CONVERT_STAT_BITS_BIN;\n-\telse if (stats.crlf && stats.crlf == stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_CRLF;\n-\telse if (stats.crlf && stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_CRLF | CONVERT_STAT_BITS_TXT_LF;\n-\telse if (stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_LF;\n-\telse\n-\t\treturn 0;\n+\t\tret |= CONVERT_STAT_BITS_BIN;\n+\tif (stats.crlf)\n+\t\tret |= CONVERT_STAT_BITS_TXT_CRLF;\n+\tif (stats.lonelf)\n+\t\tret |=  CONVERT_STAT_BITS_TXT_LF;\n+\n+\treturn ret;\n }\n \n static const char *gather_convert_stats_ascii(const char *data, unsigned long size)\n@@ -207,7 +208,7 @@ static void check_safe_crlf(const char *path, enum crlf_action crlf_action,\n \t\t * CRLFs would be added by checkout:\n \t\t * check if we have \"naked\" LFs\n \t\t */\n-\t\tif (stats->lf != stats->crlf) {\n+\t\tif (stats->lonelf) {\n \t\t\tif (checksafe == SAFE_CRLF_WARN)\n \t\t\t\twarning(\"LF will be replaced by CRLF in %s.\\nThe file will have its original line endings in your working directory.\", path);\n \t\t\telse /* i.e. SAFE_CRLF_FAIL */\n@@ -266,8 +267,8 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \n \tcheck_safe_crlf(path, crlf_action, &stats, checksafe);\n \n-\t/* Optimization: No CR? Nothing to convert, regardless. */\n-\tif (!stats.cr)\n+\t/* Optimization: No CRLF? Nothing to convert, regardless. */\n+\tif (!stats.crlf)\n \t\treturn 0;\n \n \t/*\n@@ -314,19 +315,15 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \n \tgather_stats(src, len, &stats);\n \n-\t/* No LF? Nothing to convert, regardless. */\n-\tif (!stats.lf)\n-\t\treturn 0;\n-\n-\t/* Was it already in CRLF format? */\n-\tif (stats.lf == stats.crlf)\n+\t/* No \"naked\" LF? Nothing to convert, regardless. */\n+\tif (!stats.lonelf)\n \t\treturn 0;\n \n \tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/* If we have any CR or CRLF line endings, we do not touch it */\n \t\t\t/* This is the new safer autocrlf-handling */\n-\t\t\tif (stats.cr > 0 || stats.crlf > 0)\n+\t\t\tif (stats.lonecr || stats.crlf )\n \t\t\t\treturn 0;\n \t\t}\n \n@@ -338,7 +335,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tif (src == buf->buf)\n \t\tto_free = strbuf_detach(buf, NULL);\n \n-\tstrbuf_grow(buf, len + stats.lf - stats.crlf);\n+\tstrbuf_grow(buf, len + stats.lonelf);\n \tfor (;;) {\n \t\tconst char *nl = memchr(src, '\\n', len);\n \t\tif (!nl)\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277749","messageId":"xmqq60xz9j79.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1454688800-20714-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v3 1/7] t0027: Add tests for get_stream_filter()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-08T17:59:38Z","receivedAt":"2016-02-08T17:59:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> From: Torsten Bögershausen <tboegi@web.de>\n> Subject: Re: [PATCH v3 1/7] t0027: Add tests for get_stream_filter()\n\ns/: Add/: add/ (no need to resend this)\n\n> When a filter is configured, a different code-path is used in convert.c\n> and entry.c via get_stream_filter(), but there are no test cases yet.\n>\n> Add tests for the filter API by configuring the ident filter.\n> The result of the SHA1 conversion is not checked, this is already\n> done in other TC.\n>\n> Add a parameter to checkout_files() in t0027.\n> While changing the signature, add another parameter for the eol= attribute.\n> This is currently unused, tests for e.g.\n> \"* text=auto eol=lf\" will be added in a separate commit.\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n> Changes since v2:\n> 1/7 t0027 uses ident instead of i (the empty \"\" is still there)\n\nThanks, much easier to understand with that spelled out.\n\nAnd making \"\" a noop makes sense given the way this helper is called\n(i.e. it is fed \"$ident\" and \"$attr\" quoted in dq, and they could\nbecome empty string--it is not worth doing ${ident:+\"$ident\"} there).\n"},{"id":"277750","messageId":"xmqqzivb83d1.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1454688807-20871-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v3 5/7] convert: auto_crlf=false and no attributes set: same as binary","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-08T18:27:06Z","receivedAt":"2016-02-08T18:27:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> When core.autocrlf is set to false, and no attributes are set, the file\n> is treated as binary.\n\nThis, and also on the title, I know by \"binary\" you mean \"no\nconversion is attempted\", and it is the word used in the code around\nthere, but it still makes my heart skip a beat every time I read\nthis sentence--it is not like we do not treat the contents as text\nafter all.\n\nIn any case, I take the above sentence the statement of the fact,\ndescribing how the world currently is, not declaring a new world\norder.\n\n> Simplify the logic and remove duplicated code when dealing with\n> (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) by\n> setting crlf_action=CRLF_BINARY already in convert_attrs().\n\nI looked at all the places where CRLF_BINARY is checked.  The ones\nthat are in this patch are clearly where \"Is it BINARY?\" and \"Is\nAUTO_CRLF_FALSE and CRLF_GUESS both true?\" mean the same thing, so\nthis is a correct simplification to these places.\n\nIt is not easy to see what the effect of this change to the other\nplaces that use CRLF_BINARY, though.\n\n * output_eol() used to return EOL_UNSET when auto_crlf is not in\n   effect and CRLF_GUESS is.  The function will see CRLF_BINARY with\n   this patch in such a case, and returns EOL_UNSET.  So there is no\n   change to the function and its callers.\n\n * convert_attrs() has \"If BINARY don't do anything and return\".\n   Will the patch change behaviour for the \"not-autocrlf,\n   CRLF_GUESS\" case in this codepath?  I think ca->crlf_action used\n   to be left as CRLF_GUESS here before the patch, and now by the\n   time the control flow reaches here it is already CRLF_BINARY.\n   Would it affect the callers, and if so how?\n\n * get_convert_attr_ascii() would change the behaviour, right?  It\n   runs convert_attrs(), and with this change a path without\n   attribute when autocrlf is not in effect would get BINARY and\n   would show \"-text\", while the code before this change would give\n   an empty string.  Am I misreading the code, or is the change\n   intended?\n\nThanks.\n"},{"id":"277800","messageId":"56B9F90E.2030304@web.de","threadId":"41251","inReplyTo":"xmqqzivb83d1.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v3 5/7] convert: auto_crlf=false and no attributes set: same as binary","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2016-02-09T14:34:54Z","receivedAt":"2016-02-09T14:34:54Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 02/08/2016 07:27 PM, Junio C Hamano wrote:\n> tboegi@web.de writes:\n>\n>> From: Torsten Bögershausen <tboegi@web.de>\n>>\n>> When core.autocrlf is set to false, and no attributes are set, the file\n>> is treated as binary.\n> This, and also on the title, I know by \"binary\" you mean \"no\n> conversion is attempted\", and it is the word used in the code around\n> there, but it still makes my heart skip a beat every time I read\n> this sentence--it is not like we do not treat the contents as text\n> after all.\n>\n> In any case, I take the above sentence the statement of the fact,\n> describing how the world currently is, not declaring a new world\n> order.\nThe word binary is indeed not ideal here: no eol conversion is done.\n(And the commit message could use \"-text\")\n>> Simplify the logic and remove duplicated code when dealing with\n>> (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) by\n>> setting crlf_action=CRLF_BINARY already in convert_attrs().\n> I looked at all the places where CRLF_BINARY is checked.  The ones\n> that are in this patch are clearly where \"Is it BINARY?\" and \"Is\n> AUTO_CRLF_FALSE and CRLF_GUESS both true?\" mean the same thing, so\n> this is a correct simplification to these places.\n>\n> It is not easy to see what the effect of this change to the other\n> places that use CRLF_BINARY, though.\n>\n>  * output_eol() used to return EOL_UNSET when auto_crlf is not in\n>    effect and CRLF_GUESS is.  The function will see CRLF_BINARY with\n>    this patch in such a case, and returns EOL_UNSET.  So there is no\n>    change to the function and its callers.\nOK\n>  * convert_attrs() has \"If BINARY don't do anything and return\".\n>    Will the patch change behaviour for the \"not-autocrlf,\n>    CRLF_GUESS\" case in this codepath?  I think ca->crlf_action used\n>    to be left as CRLF_GUESS here before the patch, and now by the\n>    time the control flow reaches here it is already CRLF_BINARY.\n>    Would it affect the callers, and if so how?\nNot sure if I fully understand the question:\n\nThe old CRLF_GUESS could mean (a) core.autocrlf=true,\n(b) core.autocrlf=input or (c) core.autocrlf=false.\nThe callers had to look at the core.autocrlf them self.\nThis patch removes (c), the next (or over next) (a) and (b)\n\n    if (ca->crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE)\n        ca->crlf_action = CRLF_BINARY;\n}\nThe next patch 6/7 removes \"GUESS\" completely.\n\n\n\n>  * get_convert_attr_ascii() would change the behaviour, right?  It\n>    runs convert_attrs(), and with this change a path without\n>    attribute when autocrlf is not in effect would get BINARY and\n>    would show \"-text\", while the code before this change would give\n>    an empty string.  Am I misreading the code, or is the change\n>    intended?\n>\n> Thanks.\n(That happened in my first (not published) version,\ntoday we have this:)\nstruct conv_attrs {\n    struct convert_driver *drv;\n    enum crlf_action attr_action; /* What attr says */\n    enum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */\n    int ident;\n};\n\nThe idea is (after this and the next commit 6/7) is\nthat once we had run  convert_attrs() there is a clear picture\nwhat should be done with the eols, and it is stored in crlf_action.\n\nNo further check with core.autocrlf in any calling party should be needed.\n\nIn a future series it should be possible to set\n*text=auto\n*eol=clrf\nto behave exactly as if core.autocrlf=true.\nBut that is a change in behavior, and needs a separate series.\nThis series should not change the behavior, so a critical review is appreciated.\n\n\nDoes this answers the questions ?\nIs a local amend possible ?\n"},{"id":"277808","messageId":"xmqqh9hh4v2v.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"56B9F90E.2030304@web.de","subject":"Re: [PATCH v3 5/7] convert: auto_crlf=false and no attributes set: same as binary","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-09T18:06:32Z","receivedAt":"2016-02-09T18:06:32Z","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>>  * convert_attrs() has \"If BINARY don't do anything and return\".\n>>    Will the patch change behaviour for the \"not-autocrlf,\n>>    CRLF_GUESS\" case in this codepath?  I think ca->crlf_action used\n>>    to be left as CRLF_GUESS here before the patch, and now by the\n>>    time the control flow reaches here it is already CRLF_BINARY.\n>>    Would it affect the callers, and if so how?\n> Not sure if I fully understand the question:\n>\n> The old CRLF_GUESS could mean (a) core.autocrlf=true,\n> (b) core.autocrlf=input or (c) core.autocrlf=false.\n> The callers had to look at the core.autocrlf them self.\n> This patch removes (c), the next (or over next) (a) and (b)\n\nThat part I understand and fully agree.\n\nIf a function that appears much later in the control flow depends\non seeing CRLF_GUESS to do certain things, and showing CRLF_BINARY\nto the code would make it behave differently, that would make this\npatch incorrect.\n\nThat is, if some function that you did not touch (hence did not\nappear in the context of this patch) did this:\n\n\tif (CRLF_GUESS)\n        \tdo the \"guess thing\"\n\telse if (CRLF_BINARY)\n        \tdo the \"binary thing\"\n\telse\n        \tdo other things\n\nthen depending on how 'guess thing' and 'binary thing' work\ndifferently, this patch would change the outcome.  If the\n\"guess thing\" had\n\n\t\tif (!AUTOCRLF) goto \"binary thing\"\n\nupfront, then it obviously is OK, though ;-)\n\nIf the _ONLY_ way all the code that use CRLF_GUESS is\n\n\tif ((CRLF_GUESS && !AUTOCRLF) || CRLF_BINARY)\n        \tdo the \"binary thing\"\n\nthen the conversion done by the patch is perfectly fine.  It was\nunclear from the patch text and the proposed log message if you made\nsure that is the case.  And with your response, it still isn't clear\nto me.\n"},{"id":"277872","messageId":"1455121474-16273-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v4 1/6] t0027: add tests for get_stream_filter()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-10T16:24:34Z","receivedAt":"2016-02-10T16:24:34Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nWhen a filter is configured, a different code-path is used in convert.c\nand entry.c via get_stream_filter(), but there are no test cases yet.\n\nAdd tests for the filter API by configuring the ident filter.\nThe result of the SHA1 conversion is not checked, this is already\ndone in other TC.\n\nAdd a parameter to checkout_files() in t0027.\nWhile changing the signature, add another parameter for the eol= attribute.\nThis is currently unused, tests for e.g.\n\"* text=auto eol=lf\" will be added in a separate commit.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\nChanges against tb/conversion:\n- 1..4 unchanged\n- Merged together 5/7 6/7 into 5/6, improved the commit message 1%\n- 7/7 becomes 6/6\n\n t/t0027-auto-crlf.sh | 281 ++++++++++++++++++++++++++-------------------------\n 1 file changed, 146 insertions(+), 135 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 504e5a0..fc4c628 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -21,38 +21,32 @@ compare_ws_file () {\n \tpfx=$1\n \texp=$2.expect\n \tact=$pfx.actual.$3\n-\ttr '\\015\\000' QN <\"$2\" >\"$exp\" &&\n-\ttr '\\015\\000' QN <\"$3\" >\"$act\" &&\n-\ttest_cmp $exp $act &&\n-\trm $exp $act\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$3\" >\"$act\" &&\n+\ttest_cmp \"$exp\" \"$act\" &&\n+\trm \"$exp\" \"$act\"\n }\n \n create_gitattributes () {\n-\tattr=$1\n-\tcase \"$attr\" in\n-\t\tauto)\n-\t\techo \"*.txt text=auto\" >.gitattributes\n-\t\t;;\n-\t\ttext)\n-\t\techo \"*.txt text\" >.gitattributes\n-\t\t;;\n-\t\t-text)\n-\t\techo \"*.txt -text\" >.gitattributes\n-\t\t;;\n-\t\tcrlf)\n-\t\techo \"*.txt eol=crlf\" >.gitattributes\n-\t\t;;\n-\t\tlf)\n-\t\techo \"*.txt eol=lf\" >.gitattributes\n-\t\t;;\n-\t\t\"\")\n-\t\techo >.gitattributes\n-\t\t;;\n-\t\t*)\n-\t\techo >&2 invalid attribute: $attr\n-\t\texit 1\n-\t\t;;\n-\tesac\n+\t{\n+\t\twhile test \"$#\" != 0\n+\t\tdo\n+\t\t\tcase \"$1\" in\n+\t\t\tauto)\t echo '*.txt text=auto' ;;\n+\t\t\tident) echo '*.txt ident' ;;\n+\t\t\ttext)\t echo '*.txt text' ;;\n+\t\t\t-text) echo '*.txt -text' ;;\n+\t\t\tcrlf)  echo '*.txt eol=crlf' ;;\n+\t\t\tlf)    echo '*.txt eol=lf' ;;\n+\t\t\t\"\") ;;\n+\t\t\t*)\n+\t\t\t\techo >&2 invalid attribute: \"$1\"\n+\t\t\t\texit 1\n+\t\t\t\t;;\n+\t\t\tesac &&\n+\t\t\tshift\n+\t\tdone\n+\t} >.gitattributes\n }\n \n create_NNO_files () {\n@@ -208,28 +202,30 @@ check_in_repo_NNO () {\n }\n \n checkout_files () {\n-\teol=$1\n-\tcrlf=$2\n-\tattr=$3\n-\tlfname=$4\n-\tcrlfname=$5\n-\tlfmixcrlf=$6\n-\tlfmixcr=$7\n-\tcrlfnul=$8\n-\tcreate_gitattributes $attr &&\n+\tattr=$1 ; shift\n+\tident=$1; shift\n+\taeol=$1 ; shift\n+\tcrlf=$1 ; shift\n+\tceol=$1 ; shift\n+\tlfname=$1 ; shift\n+\tcrlfname=$1 ; shift\n+\tlfmixcrlf=$1 ; shift\n+\tlfmixcr=$1 ; shift\n+\tcrlfnul=$1 ; shift\n+\tcreate_gitattributes \"$attr\" \"$ident\" &&\n \tgit config core.autocrlf $crlf &&\n-\tpfx=eol_${eol}_crlf_${crlf}_attr_${attr}_ &&\n+\tpfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&\n \tfor f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul\n \tdo\n \t\trm crlf_false_attr__$f.txt &&\n-\t\tif test -z \"$eol\"; then\n+\t\tif test -z \"$ceol\"; then\n \t\t\tgit checkout crlf_false_attr__$f.txt\n \t\telse\n-\t\t\tgit -c core.eol=$eol checkout crlf_false_attr__$f.txt\n+\t\t\tgit -c core.eol=$ceol checkout crlf_false_attr__$f.txt\n \t\tfi\n \tdone\n \n-\ttest_expect_success \"ls-files --eol $lfname ${pfx}LF.txt\" '\n+\ttest_expect_success \"ls-files --eol attr=$attr $ident $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n \t\ttest_when_finished \"rm expect actual\" &&\n \t\tsort <<-EOF >expect &&\n \t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n@@ -244,19 +240,19 @@ checkout_files () {\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF\" \"\n \t\tcompare_ws_file $pfx $lfname    crlf_false_attr__LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF\" \"\n \t\tcompare_ws_file $pfx $crlfname  crlf_false_attr__CRLF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF_mix_LF\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=CRLF_mix_LF\" \"\n \t\tcompare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_mix_CR\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_mix_CR\" \"\n \t\tcompare_ws_file $pfx $lfmixcr   crlf_false_attr__LF_mix_CR.txt\n \t\"\n-\ttest_expect_success \"checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_nul\" \"\n+\ttest_expect_success \"checkout $ident $attr $aeol core.autocrlf=$crlf core.eol=$ceol file=LF_nul\" \"\n \t\tcompare_ws_file $pfx $crlfnul   crlf_false_attr__LF_nul.txt\n \t\"\n }\n@@ -301,14 +297,13 @@ test_expect_success 'setup master' '\n \tgit checkout -b master &&\n \tgit add .gitattributes &&\n \tgit commit -m \"add .gitattributes\" \"\" &&\n-\tprintf \"line1\\nline2\\nline3\"     >LF &&\n-\tprintf \"line1\\r\\nline2\\r\\nline3\" >CRLF &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >repoMIX &&\n-\tprintf \"line1\\r\\nline2\\nline3\"   >CRLF_mix_LF &&\n-\tprintf \"line1\\nline2\\rline3\"     >LF_mix_CR &&\n-\tprintf \"line1\\r\\nline2\\rline3\"   >CRLF_mix_CR &&\n-\tprintf \"line1Q\\r\\nline2\\r\\nline3\" | q_to_nul >CRLF_nul &&\n-\tprintf \"line1Q\\nline2\\nline3\" | q_to_nul >LF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\nLINETHREE\"     >LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\r\\nLINETHREE\" >CRLF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\r\\nLINETWO\\nLINETHREE\"   >CRLF_mix_LF &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONE\\nLINETWO\\rLINETHREE\"     >LF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONE\\r\\nLINETWO\\rLINETHREE\"   >CRLF_mix_CR &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\r\\nLINEONEQ\\r\\nLINETWO\\r\\nLINETHREE\" | q_to_nul >CRLF_nul &&\n+\tprintf \"\\$Id: 0000000000000000000000000000000000000000 \\$\\nLINEONEQ\\nLINETWO\\nLINETHREE\" | q_to_nul >LF_nul &&\n \tcreate_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&\n \tgit -c core.autocrlf=false add NNO_*.txt &&\n \tgit commit -m \"mixed line endings\" &&\n@@ -449,23 +444,18 @@ check_in_repo_NNO input \"-text\" LF        CRLF      CRLF_mix_LF  LF_mix_CR \tCRLF\n # How to read the table below:\n # - checkout_files will check multiple files with a combination of settings\n #   and attributes (core.autocrlf=input is forbidden with core.eol=crlf)\n-# - parameter $1 : core.eol               lf | crlf\n-# - parameter $2 : core.autocrlf          false | true | input\n-# - parameter $3 : text in .gitattributs  \"\" (empty) | auto | text | -text\n-# - parameter $4 : reference for a file with only LF in the repo\n-# - parameter $5 : reference for a file with only CRLF in the repo\n-# - parameter $6 : reference for a file with mixed LF and CRLF in the repo\n-# - parameter $7 : reference for a file with LF and CR in the repo (does somebody uses this ?)\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-#                                            ----------------- 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-#                                            ----------------------------------------------\n-#                                            What we want to have in the working tree:\n+#\n+# - parameter $1 \t: text in .gitattributs  \"\" (empty) | auto | text | -text\n+# - parameter $2 \t: ident                  \"\" | i (i == ident)\n+# - parameter $3 \t: eol in .gitattributs   \"\" (empty) | lf | crlf\n+# - parameter $4 \t: core.autocrlf          false | true | input\n+# - parameter $5 \t: core.eol               \"\" | lf | crlf | \"native\"\n+# - parameter $6 \t: reference for a file with only LF in the repo\n+# - parameter $7 \t: reference for a file with only CRLF in the repo\n+# - parameter $8 \t: reference for a file with mixed LF and CRLF in the repo\n+# - parameter $9 \t: reference for a file with LF and CR in the repo\n+# - parameter $10 : reference for a file with CRLF and a NUL (should be handled as binary when auto)\n+\n if test_have_prereq NATIVE_CRLF\n then\n MIX_CRLF_LF=CRLF\n@@ -480,69 +470,90 @@ LFNUL=LF_nul\n fi\n export CRLF_MIX_LF_CR MIX NL\n \n-checkout_files    lf      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    lf      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    lf      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    lf      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    crlf    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    crlf    false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    crlf    true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    \"\"      false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"auto\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    \"\"      true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"text\"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      input \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    \"\"      false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    \"\"      input \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-\n-checkout_files    native  false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"auto\"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n-checkout_files    native  true  \"auto\"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n-checkout_files    native  false \"text\"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n-checkout_files    native  true  \"text\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  false \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"-text\"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  true  \"lf\"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n-checkout_files    native  false \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n-checkout_files    native  true  \"crlf\"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+checkout_files \"\"      \"\" \t \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    true   \"\"       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    true   crlf     CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    true   lf       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      \"\" \t \"\"    true   native   CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"\"      ident \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    false  crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    true   \"\"       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    true   crlf     CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    true   lf       CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  \"\" \t \"\"    true   native   CRLF  CRLF  CRLF         LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+checkout_files \"auto\"  ident \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\n+for id in \"\" ident;\n+do\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    false  native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    input  lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"crlf\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"lf\"    \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  \"\"       $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    false  native   $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   \"\"       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   crlf     CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   lf       CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"text\"  \"$id\" \"\"    true   native   CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    false  native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    input  lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   \"\"       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   crlf     LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   lf       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+\tcheckout_files \"-text\" \"$id\" \"\"    true   native   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul\n+done\n \n # Should be the last test case: remove some files from the worktree\n test_expect_success 'ls-files --eol -d -z' '\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277871","messageId":"1455121477-16312-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v4 2/6] convert.c: remove unused parameter 'path'","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-10T16:24:37Z","receivedAt":"2016-02-10T16:24:37Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nSome functions get a parameter path, but don't use it.\nRemove the unused parameter.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 19 +++++++++----------\n 1 file changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 4bb4ec1..a24c2a2 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -696,7 +696,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,\n \treturn 1;\n }\n \n-static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_check *check)\n+static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -713,7 +713,7 @@ static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_ch\n \treturn CRLF_GUESS;\n }\n \n-static enum eol git_path_check_eol(const char *path, struct git_attr_check *check)\n+static enum eol git_path_check_eol(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -726,8 +726,7 @@ static enum eol git_path_check_eol(const char *path, struct git_attr_check *chec\n \treturn EOL_UNSET;\n }\n \n-static struct convert_driver *git_path_check_convert(const char *path,\n-\t\t\t\t\t     struct git_attr_check *check)\n+static struct convert_driver *git_path_check_convert(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \tstruct convert_driver *drv;\n@@ -740,7 +739,7 @@ static struct convert_driver *git_path_check_convert(const char *path,\n \treturn NULL;\n }\n \n-static int git_path_check_ident(const char *path, struct git_attr_check *check)\n+static int git_path_check_ident(struct git_attr_check *check)\n {\n \tconst char *value = check->value;\n \n@@ -783,12 +782,12 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 4);\n+\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n-\t\t\tca->crlf_action = git_path_check_crlf(path, ccheck + 0);\n-\t\tca->ident = git_path_check_ident(path, ccheck + 1);\n-\t\tca->drv = git_path_check_convert(path, ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(path, ccheck + 3);\n+\t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->ident = git_path_check_ident(ccheck + 1);\n+\t\tca->drv = git_path_check_convert(ccheck + 2);\n+\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277873","messageId":"1455121478-16351-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v4 3/6] convert.c: remove input_crlf_action()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-10T16:24:38Z","receivedAt":"2016-02-10T16:24:38Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nIntegrate the code of input_crlf_action() into convert_attrs(),\nso that ca.crlf_action is always valid after calling convert_attrs().\nKeep a copy of crlf_action in attr_action, this is needed for\nget_convert_attr_ascii().\n\nRemove eol_attr from struct conv_attrs, as it is now used temporally.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 37 ++++++++++++++-----------------------\n 1 file changed, 14 insertions(+), 23 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex a24c2a2..d0c8c66 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -746,21 +746,10 @@ static int git_path_check_ident(struct git_attr_check *check)\n \treturn !!ATTR_TRUE(value);\n }\n \n-static enum crlf_action input_crlf_action(enum crlf_action text_attr, enum eol eol_attr)\n-{\n-\tif (text_attr == CRLF_BINARY)\n-\t\treturn CRLF_BINARY;\n-\tif (eol_attr == EOL_LF)\n-\t\treturn CRLF_INPUT;\n-\tif (eol_attr == EOL_CRLF)\n-\t\treturn CRLF_CRLF;\n-\treturn text_attr;\n-}\n-\n struct conv_attrs {\n \tstruct convert_driver *drv;\n-\tenum crlf_action crlf_action;\n-\tenum eol eol_attr;\n+\tenum crlf_action attr_action; /* What attr says */\n+\tenum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */\n \tint ident;\n };\n \n@@ -782,16 +771,23 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tca->crlf_action = git_path_check_crlf( ccheck + 4);\n+\t\tenum eol eol_attr;\n+\t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_GUESS)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n+\t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n \t\tca->drv = git_path_check_convert(ccheck + 2);\n-\t\tca->eol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (ca->crlf_action == CRLF_BINARY)\n+\t\t\treturn;\n+\t\teol_attr = git_path_check_eol(ccheck + 3);\n+\t\tif (eol_attr == EOL_LF)\n+\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\telse if (eol_attr == EOL_CRLF)\n+\t\t\tca->crlf_action = CRLF_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_GUESS;\n-\t\tca->eol_attr = EOL_UNSET;\n \t\tca->ident = 0;\n \t}\n }\n@@ -818,11 +814,9 @@ int would_convert_to_git_filter_fd(const char *path)\n const char *get_convert_attr_ascii(const char *path)\n {\n \tstruct conv_attrs ca;\n-\tenum crlf_action crlf_action;\n \n \tconvert_attrs(&ca, path);\n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n-\tswitch (crlf_action) {\n+\tswitch (ca.attr_action) {\n \tcase CRLF_GUESS:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n@@ -861,7 +855,6 @@ int convert_to_git(const char *path, const char *src, size_t len,\n \t\tsrc = dst->buf;\n \t\tlen = dst->len;\n \t}\n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tret |= crlf_to_git(path, src, len, dst, ca.crlf_action, checksafe);\n \tif (ret && dst) {\n \t\tsrc = dst->buf;\n@@ -882,7 +875,6 @@ void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,\n \tif (!apply_filter(path, NULL, 0, fd, dst, ca.drv->clean))\n \t\tdie(\"%s: clean filter '%s' failed\", path, ca.drv->name);\n \n-\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \tcrlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);\n \tident_to_git(path, dst->buf, dst->len, dst, ca.ident);\n }\n@@ -912,7 +904,6 @@ static int convert_to_working_tree_internal(const char *path, const char *src,\n \t * is a smudge filter.  The filter might expect CRLFs.\n \t */\n \tif (filter || !normalizing) {\n-\t\tca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n \t\tret |= crlf_to_worktree(path, src, len, dst, ca.crlf_action);\n \t\tif (ret) {\n \t\t\tsrc = dst->buf;\n@@ -1381,7 +1372,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \tif (ca.ident)\n \t\tfilter = ident_filter(sha1);\n \n-\tcrlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);\n+\tcrlf_action = ca.crlf_action;\n \n \tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n \t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277876","messageId":"1455121480-16390-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v4 4/6] convert.c: use text_eol_is_crlf()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-10T16:24:40Z","receivedAt":"2016-02-10T16:24:40Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nAdd a helper function to find out, which line endings text files\nshould get at checkout, depending on core.autocrlf and core.eol\nconfiguration variables.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n convert.c | 20 ++++++++++++++------\n 1 file changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex d0c8c66..557e574 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -149,6 +149,19 @@ const char *get_wt_convert_stats_ascii(const char *path)\n \treturn ret;\n }\n \n+static int text_eol_is_crlf(void)\n+{\n+\tif (auto_crlf == AUTO_CRLF_TRUE)\n+\t\treturn 1;\n+\telse if (auto_crlf == AUTO_CRLF_INPUT)\n+\t\treturn 0;\n+\tif (core_eol == EOL_CRLF)\n+\t\treturn 1;\n+\tif (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n static enum eol output_eol(enum crlf_action crlf_action)\n {\n \tswitch (crlf_action) {\n@@ -164,12 +177,7 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \t\t/* fall through */\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n-\t\tif (auto_crlf == AUTO_CRLF_TRUE)\n-\t\t\treturn EOL_CRLF;\n-\t\telse if (auto_crlf == AUTO_CRLF_INPUT)\n-\t\t\treturn EOL_LF;\n-\t\telse if (core_eol == EOL_UNSET)\n-\t\t\treturn EOL_NATIVE;\n+\t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n \treturn core_eol;\n }\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277875","messageId":"1455121481-16429-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v4 5/6] convert.c: refactor crlf_action","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-10T16:24:41Z","receivedAt":"2016-02-10T16:24:41Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nRefactor the determination and usage of crlf_action.\nToday, when no \"crlf\" attribute are set on a file, crlf_action is set to\nCRLF_GUESS. Use CRLF_UNDEFINED instead, and search for \"text\" or \"eol\" as\nbefore.\nAfter searching for line ending attributes, save the value in\nstruct conv_attrs.crlf_action attr_action,\nso that get_convert_attr_ascii() is able report the attributes.\n\nReplace the old CRLF_GUESS usage:\nCRLF_GUESS && core.autocrlf=true -> CRLF_AUTO_CRLF\nCRLF_GUESS && core.autocrlf=false -> CRLF_BINARY\nCRLF_GUESS && core.autocrlf=input -> CRLF_AUTO_INPUT\n\nSave the action in conv_attrs.crlf_action (as before) and change\nall callers.\n\nMake more clear, what is what, by defining:\n\n- CRLF_UNDEFINED : No attributes set. Temparally used, until core.autocrlf\n                   and core.eol is evaluated and one of CRLF_BINARY,\n                   CRLF_AUTO_INPUT or CRLF_AUTO_CRLF is selected\n- CRLF_BINARY    : No processing of line endings.\n- CRLF_TEXT      : attribute \"text\" is set, line endings are processed.\n- CRLF_TEXT_INPUT: attribute \"input\" or \"eol=lf\" is set. This implies text.\n- CRLF_TEXT_CRLF : attribute \"eol=crlf\" is set. This implies text.\n- CRLF_AUTO      : attribute \"auto\" is set.\n- CRLF_AUTO_INPUT: core.autocrlf=input (no attributes)\n- CRLF_AUTO_CRLF : core.autocrlf=true  (no attributes)\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 77 ++++++++++++++++++++++++++++++++++++++-------------------------\n 1 file changed, 46 insertions(+), 31 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 557e574..e4e2877 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -19,12 +19,14 @@\n #define CONVERT_STAT_BITS_BIN       0x4\n \n enum crlf_action {\n-\tCRLF_GUESS = -1,\n-\tCRLF_BINARY = 0,\n+\tCRLF_UNDEFINED,\n+\tCRLF_BINARY,\n \tCRLF_TEXT,\n-\tCRLF_INPUT,\n-\tCRLF_CRLF,\n-\tCRLF_AUTO\n+\tCRLF_TEXT_INPUT,\n+\tCRLF_TEXT_CRLF,\n+\tCRLF_AUTO,\n+\tCRLF_AUTO_INPUT,\n+\tCRLF_AUTO_CRLF\n };\n \n struct text_stat {\n@@ -167,18 +169,19 @@ static enum eol output_eol(enum crlf_action crlf_action)\n \tswitch (crlf_action) {\n \tcase CRLF_BINARY:\n \t\treturn EOL_UNSET;\n-\tcase CRLF_CRLF:\n+\tcase CRLF_TEXT_CRLF:\n \t\treturn EOL_CRLF;\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_INPUT:\n \t\treturn EOL_LF;\n-\tcase CRLF_GUESS:\n-\t\tif (!auto_crlf)\n-\t\t\treturn EOL_UNSET;\n-\t\t/* fall through */\n+\tcase CRLF_UNDEFINED:\n+\tcase CRLF_AUTO_CRLF:\n+\tcase CRLF_AUTO_INPUT:\n \tcase CRLF_TEXT:\n \tcase CRLF_AUTO:\n+\t\t/* fall through */\n \t\treturn text_eol_is_crlf() ? EOL_CRLF : EOL_LF;\n \t}\n+\twarning(\"Illegal crlf_action %d\\n\", (int)crlf_action);\n \treturn core_eol;\n }\n \n@@ -235,7 +238,6 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tchar *dst;\n \n \tif (crlf_action == CRLF_BINARY ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) ||\n \t    (src && !len))\n \t\treturn 0;\n \n@@ -248,11 +250,11 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \n \tgather_stats(src, len, &stats);\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\tif (convert_is_binary(len, &stats))\n \t\t\treturn 0;\n \n-\t\tif (crlf_action == CRLF_GUESS) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/*\n \t\t\t * If the file in the index has any CR in it, do not convert.\n \t\t\t * This is the new safer autocrlf handling.\n@@ -279,7 +281,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \tif (strbuf_avail(buf) + buf->len < len)\n \t\tstrbuf_grow(buf, len - buf->len);\n \tdst = buf->buf;\n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t/*\n \t\t * If we guessed, we already know we rejected a file with\n \t\t * lone CR, and we can strip a CR without looking at what\n@@ -320,8 +322,8 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tif (stats.lf == stats.crlf)\n \t\treturn 0;\n \n-\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS) {\n-\t\tif (crlf_action == CRLF_GUESS) {\n+\tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n+\t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/* If we have any CR or CRLF line endings, we do not touch it */\n \t\t\t/* This is the new safer autocrlf-handling */\n \t\t\tif (stats.cr > 0 || stats.crlf > 0)\n@@ -709,16 +711,16 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n \tconst char *value = check->value;\n \n \tif (ATTR_TRUE(value))\n-\t\treturn CRLF_TEXT;\n+\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n \telse if (ATTR_FALSE(value))\n \t\treturn CRLF_BINARY;\n \telse if (ATTR_UNSET(value))\n \t\t;\n \telse if (!strcmp(value, \"input\"))\n-\t\treturn CRLF_INPUT;\n+\t\treturn CRLF_TEXT_INPUT;\n \telse if (!strcmp(value, \"auto\"))\n \t\treturn CRLF_AUTO;\n-\treturn CRLF_GUESS;\n+\treturn CRLF_UNDEFINED;\n }\n \n static enum eol git_path_check_eol(struct git_attr_check *check)\n@@ -781,7 +783,7 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n \t\tenum eol eol_attr;\n \t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n-\t\tif (ca->crlf_action == CRLF_GUESS)\n+\t\tif (ca->crlf_action == CRLF_UNDEFINED)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n \t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n@@ -790,14 +792,22 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\t\treturn;\n \t\teol_attr = git_path_check_eol(ccheck + 3);\n \t\tif (eol_attr == EOL_LF)\n-\t\t\tca->crlf_action = CRLF_INPUT;\n+\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n \t\telse if (eol_attr == EOL_CRLF)\n-\t\t\tca->crlf_action = CRLF_CRLF;\n+\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n \t} else {\n \t\tca->drv = NULL;\n-\t\tca->crlf_action = CRLF_GUESS;\n+\t\tca->crlf_action = CRLF_UNDEFINED;\n \t\tca->ident = 0;\n \t}\n+\tif (ca->crlf_action == CRLF_TEXT)\n+\t\tca->crlf_action = text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_FALSE)\n+\t\tca->crlf_action = CRLF_BINARY;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_TRUE)\n+\t\tca->crlf_action = CRLF_AUTO_CRLF;\n+\tif (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_INPUT)\n+\t\tca->crlf_action = CRLF_AUTO_INPUT;\n }\n \n int would_convert_to_git_filter_fd(const char *path)\n@@ -825,18 +835,22 @@ const char *get_convert_attr_ascii(const char *path)\n \n \tconvert_attrs(&ca, path);\n \tswitch (ca.attr_action) {\n-\tcase CRLF_GUESS:\n+\tcase CRLF_UNDEFINED:\n \t\treturn \"\";\n \tcase CRLF_BINARY:\n \t\treturn \"-text\";\n \tcase CRLF_TEXT:\n \t\treturn \"text\";\n-\tcase CRLF_INPUT:\n+\tcase CRLF_TEXT_INPUT:\n \t\treturn \"text eol=lf\";\n-\tcase CRLF_CRLF:\n-\t\treturn \"text=auto eol=crlf\";\n+\tcase CRLF_TEXT_CRLF:\n+\t\treturn \"text eol=crlf\";\n \tcase CRLF_AUTO:\n \t\treturn \"text=auto\";\n+\tcase CRLF_AUTO_CRLF:\n+\t\treturn \"text=auto eol=crlf\"; /* This is not supported yet */\n+\tcase CRLF_AUTO_INPUT:\n+\t\treturn \"text=auto eol=lf\"; /* This is not supported yet */\n \t}\n \treturn \"\";\n }\n@@ -1382,12 +1396,13 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \n \tcrlf_action = ca.crlf_action;\n \n-\tif ((crlf_action == CRLF_BINARY) || (crlf_action == CRLF_INPUT) ||\n-\t    (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))\n+\tif ((crlf_action == CRLF_BINARY) ||\n+\t\t\tcrlf_action == CRLF_AUTO_INPUT ||\n+\t\t\t(crlf_action == CRLF_TEXT_INPUT))\n \t\tfilter = cascade_filter(filter, &null_filter_singleton);\n \n \telse if (output_eol(crlf_action) == EOL_CRLF &&\n-\t\t !(crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS))\n+\t\t !(crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_CRLF))\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\n \n \treturn filter;\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"277874","messageId":"1455121483-16470-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH v4 6/6] convert.c: simplify text_stat","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-10T16:24:43Z","receivedAt":"2016-02-10T16:24:43Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nSimplify the statistics:\nlonecr counts the CR which is not followed by a LF,\nlonelf counts the LF which is not preceded by a CR,\ncrlf counts CRLF combinations.\nThis simplifies the evaluation of the statistics.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c | 47 ++++++++++++++++++++++-------------------------\n 1 file changed, 22 insertions(+), 25 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex e4e2877..18af685 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -31,7 +31,7 @@ enum crlf_action {\n \n struct text_stat {\n \t/* NUL, CR, LF and CRLF counts */\n-\tunsigned nul, cr, lf, crlf;\n+\tunsigned nul, lonecr, lonelf, crlf;\n \n \t/* These are just approximations! */\n \tunsigned printable, nonprintable;\n@@ -46,13 +46,15 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n \tfor (i = 0; i < size; i++) {\n \t\tunsigned char c = buf[i];\n \t\tif (c == '\\r') {\n-\t\t\tstats->cr++;\n-\t\t\tif (i+1 < size && buf[i+1] == '\\n')\n+\t\t\tif (i+1 < size && buf[i+1] == '\\n') {\n \t\t\t\tstats->crlf++;\n+\t\t\t\ti++;\n+\t\t\t} else\n+\t\t\t\tstats->lonecr++;\n \t\t\tcontinue;\n \t\t}\n \t\tif (c == '\\n') {\n-\t\t\tstats->lf++;\n+\t\t\tstats->lonelf++;\n \t\t\tcontinue;\n \t\t}\n \t\tif (c == 127)\n@@ -86,7 +88,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n  */\n static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n {\n-\tif (stats->cr != stats->crlf)\n+\tif (stats->lonecr)\n \t\treturn 1;\n \tif (stats->nul)\n \t\treturn 1;\n@@ -98,19 +100,18 @@ static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n static unsigned int gather_convert_stats(const char *data, unsigned long size)\n {\n \tstruct text_stat stats;\n+\tint ret = 0;\n \tif (!data || !size)\n \t\treturn 0;\n \tgather_stats(data, size, &stats);\n \tif (convert_is_binary(size, &stats))\n-\t\treturn CONVERT_STAT_BITS_BIN;\n-\telse if (stats.crlf && stats.crlf == stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_CRLF;\n-\telse if (stats.crlf && stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_CRLF | CONVERT_STAT_BITS_TXT_LF;\n-\telse if (stats.lf)\n-\t\treturn CONVERT_STAT_BITS_TXT_LF;\n-\telse\n-\t\treturn 0;\n+\t\tret |= CONVERT_STAT_BITS_BIN;\n+\tif (stats.crlf)\n+\t\tret |= CONVERT_STAT_BITS_TXT_CRLF;\n+\tif (stats.lonelf)\n+\t\tret |=  CONVERT_STAT_BITS_TXT_LF;\n+\n+\treturn ret;\n }\n \n static const char *gather_convert_stats_ascii(const char *data, unsigned long size)\n@@ -207,7 +208,7 @@ static void check_safe_crlf(const char *path, enum crlf_action crlf_action,\n \t\t * CRLFs would be added by checkout:\n \t\t * check if we have \"naked\" LFs\n \t\t */\n-\t\tif (stats->lf != stats->crlf) {\n+\t\tif (stats->lonelf) {\n \t\t\tif (checksafe == SAFE_CRLF_WARN)\n \t\t\t\twarning(\"LF will be replaced by CRLF in %s.\\nThe file will have its original line endings in your working directory.\", path);\n \t\t\telse /* i.e. SAFE_CRLF_FAIL */\n@@ -266,8 +267,8 @@ static int crlf_to_git(const char *path, const char *src, size_t len,\n \n \tcheck_safe_crlf(path, crlf_action, &stats, checksafe);\n \n-\t/* Optimization: No CR? Nothing to convert, regardless. */\n-\tif (!stats.cr)\n+\t/* Optimization: No CRLF? Nothing to convert, regardless. */\n+\tif (!stats.crlf)\n \t\treturn 0;\n \n \t/*\n@@ -314,19 +315,15 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \n \tgather_stats(src, len, &stats);\n \n-\t/* No LF? Nothing to convert, regardless. */\n-\tif (!stats.lf)\n-\t\treturn 0;\n-\n-\t/* Was it already in CRLF format? */\n-\tif (stats.lf == stats.crlf)\n+\t/* No \"naked\" LF? Nothing to convert, regardless. */\n+\tif (!stats.lonelf)\n \t\treturn 0;\n \n \tif (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\tif (crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {\n \t\t\t/* If we have any CR or CRLF line endings, we do not touch it */\n \t\t\t/* This is the new safer autocrlf-handling */\n-\t\t\tif (stats.cr > 0 || stats.crlf > 0)\n+\t\t\tif (stats.lonecr || stats.crlf )\n \t\t\t\treturn 0;\n \t\t}\n \n@@ -338,7 +335,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \tif (src == buf->buf)\n \t\tto_free = strbuf_detach(buf, NULL);\n \n-\tstrbuf_grow(buf, len + stats.lf - stats.crlf);\n+\tstrbuf_grow(buf, len + stats.lonelf);\n \tfor (;;) {\n \t\tconst char *nl = memchr(src, '\\n', len);\n \t\tif (!nl)\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"278831","messageId":"1456117898-30357-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"Message-Id=1453558101-6858-1-git-send-email-tboegi@web.de","subject":"[PATCH 1/1] convert.c: correct attr_action","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-22T05:11:38Z","receivedAt":"2016-02-22T05:11:38Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nCommit \"convert.c: refactor crlf_action\" unified the crlf_handling\nand introdused a bug for \"git ls-files --eol\".\nThe \"text\" attribute was shown as \"text eol=lf\" or \"text eol=crlf\",\ndepending on core.autocrlf or core.eol.\nCorrect this and add test cases in t0027.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\nThis fix needs to go on top of tb/conversion\nconvert.c            |  3 ++-\n t/t0027-auto-crlf.sh | 47 ++++++++++++++++++++++++++++++++++++++++-------\n 2 files changed, 42 insertions(+), 8 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 18af685..0bc32ec 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -708,7 +708,7 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n \tconst char *value = check->value;\n \n \tif (ATTR_TRUE(value))\n-\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n+\t\treturn CRLF_TEXT;\n \telse if (ATTR_FALSE(value))\n \t\treturn CRLF_BINARY;\n \telse if (ATTR_UNSET(value))\n@@ -792,6 +792,7 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n \t\telse if (eol_attr == EOL_CRLF)\n \t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n+\t\tca->attr_action = ca->crlf_action;\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_UNDEFINED;\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex fc4c628..f9c92c6 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -159,6 +159,39 @@ stats_ascii () {\n \n }\n \n+attr_ascii () {\n+\tcase \"$1\" in\n+\t\"-text\") echo \"-text\"\t;;\n+\tlf)\techo \"text eol=lf\" ;;\n+\tcrlf)\techo \"text eol=crlf\" ;;\n+\ttext)\n+\t\tcase \"$2\" in\n+\t\t\"\")\techo \"text\" ;;\n+\t\tlf)\techo \"text eol=lf\" ;;\n+\t\tcrlf)\techo \"text eol=crlf\" ;;\n+\t\t*) echo invalid_attr2 \"$2\" ;;\n+\t\tesac\n+\t\t;;\n+\tauto)\n+\t\tcase \"$2\" in\n+\t\t\"\")\techo \"text=auto\" ;;\n+\t\tlf)\techo \"text=auto eol=lf\" ;;\n+\t\tcrlf)\techo \"text=auto eol=crlf\" ;;\n+\t\t*) echo invalid_attr2 \"$2\"\t;;\n+\t\tesac\n+\t\t;;\n+\t\"\")\n+\t\tcase \"$2\" in\n+\t\t\"\")\techo \"\" ;;\n+\t\tlf)\techo \"text eol=lf\" ;;\n+\t\tcrlf)\techo \"text eol=crlf\" ;;\n+\t\t*) echo invalid_attr2 \"$2\" ;;\n+\t\tesac\n+\t\t;;\n+\t*)echo invalid_attr1 \"$1\"\t;;\n+\tesac\n+}\n+\n check_files_in_repo () {\n \tcrlf=$1\n \tattr=$2\n@@ -228,15 +261,15 @@ checkout_files () {\n \ttest_expect_success \"ls-files --eol attr=$attr $ident $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n \t\ttest_when_finished \"rm expect actual\" &&\n \t\tsort <<-EOF >expect &&\n-\t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n-\t\ti/mixed w/$(stats_ascii $lfmixcrlf) crlf_false_attr__CRLF_mix_LF.txt\n-\t\ti/lf w/$(stats_ascii $lfname) crlf_false_attr__LF.txt\n-\t\ti/-text w/$(stats_ascii $lfmixcr) crlf_false_attr__LF_mix_CR.txt\n-\t\ti/-text w/$(stats_ascii $crlfnul) crlf_false_attr__CRLF_nul.txt\n-\t\ti/-text w/$(stats_ascii $crlfnul) crlf_false_attr__LF_nul.txt\n+\t\ti/crlf w/$(stats_ascii $crlfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF.txt\n+\t\ti/mixed w/$(stats_ascii $lfmixcrlf) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_mix_LF.txt\n+\t\ti/lf w/$(stats_ascii $lfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF.txt\n+\t\ti/-text w/$(stats_ascii $lfmixcr) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_mix_CR.txt\n+\t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt\n+\t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt\n \t\tEOF\n \t\tgit ls-files --eol crlf_false_attr__* |\n-\t\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"278832","messageId":"CAPig+cSr8uXfsiMivKjMjdRM1et58+w_FB4s5EfoDJTXTqjb4A@mail.gmail.com","threadId":"41251","inReplyTo":"1456117898-30357-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH 1/1] convert.c: correct attr_action","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-02-22T05:34:45Z","receivedAt":"2016-02-22T05:34:45Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Feb 22, 2016 at 12:11 AM,  <tboegi@web.de> wrote:\n> Commit \"convert.c: refactor crlf_action\" unified the crlf_handling\n> and introdused a bug for \"git ls-files --eol\".\n\ns/introdused/introduced/\n\n> The \"text\" attribute was shown as \"text eol=lf\" or \"text eol=crlf\",\n> depending on core.autocrlf or core.eol.\n> Correct this and add test cases in t0027.\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n"},{"id":"278843","messageId":"xmqqd1rp893e.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1456117898-30357-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH 1/1] convert.c: correct attr_action","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-22T08:04:05Z","receivedAt":"2016-02-22T08:04:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\n> index fc4c628..f9c92c6 100755\n> --- a/t/t0027-auto-crlf.sh\n> +++ b/t/t0027-auto-crlf.sh\n> @@ -159,6 +159,39 @@ stats_ascii () {\n>  \n>  }\n>  \n> +attr_ascii () {\n> +\tcase \"$1\" in\n> +\t\"-text\") echo \"-text\"\t;;\n\n - I do not think you need to quote the case label.\n\n - Why the excessive trailing whitespaces before double-semicolons?\n\n> +\tlf)\techo \"text eol=lf\" ;;\n> +\tcrlf)\techo \"text eol=crlf\" ;;\n> +\ttext)\n> +\t\tcase \"$2\" in\n> +\t\t\"\")\techo \"text\" ;;\n> +\t\tlf)\techo \"text eol=lf\" ;;\n> +\t\tcrlf)\techo \"text eol=crlf\" ;;\n> +\t\t*) echo invalid_attr2 \"$2\" ;;\n> +\t\tesac\n> +\t\t;;\n> +\tauto)\n> +\t\tcase \"$2\" in\n> +\t\t\"\")\techo \"text=auto\" ;;\n> +\t\tlf)\techo \"text=auto eol=lf\" ;;\n> +\t\tcrlf)\techo \"text=auto eol=crlf\" ;;\n> +\t\t*) echo invalid_attr2 \"$2\"\t;;\n> +\t\tesac\n> +\t\t;;\n> +\t\"\")\n> +\t\tcase \"$2\" in\n> +\t\t\"\")\techo \"\" ;;\n> +\t\tlf)\techo \"text eol=lf\" ;;\n> +\t\tcrlf)\techo \"text eol=crlf\" ;;\n> +\t\t*) echo invalid_attr2 \"$2\" ;;\n> +\t\tesac\n> +\t\t;;\n\nI wonder if the above is easier to read if written like this:\n\n\tcase \"$1,$2\" in\n        \"-text,*\")\t\techo \"-text\" ;;\n        lf,*)   \t        echo text eol=lf\" ;;\n\t...\n\tauto,)\t\t\techo \"text=auto\" ;;\n\tauto,lf | auto,crlf)\techo \"text=auto eol=$2\" ;;\n\tauto,*)\t\t\techo invalid_attr2 \"$2\" ;;\n\t...\n        esac\n\nas $1 and $2 are not arbitrary words, but you know exactly from what\nvocabulary they are taken.\n"},{"id":"278845","messageId":"xmqq8u2d88ce.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1456117898-30357-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH 1/1] convert.c: correct attr_action","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-22T08:20:17Z","receivedAt":"2016-02-22T08:20:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> diff --git a/convert.c b/convert.c\n> index 18af685..0bc32ec 100644\n> --- a/convert.c\n> +++ b/convert.c\n> @@ -708,7 +708,7 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n>  \tconst char *value = check->value;\n>  \n>  \tif (ATTR_TRUE(value))\n> -\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n> +\t\treturn CRLF_TEXT;\n>  \telse if (ATTR_FALSE(value))\n>  \t\treturn CRLF_BINARY;\n>  \telse if (ATTR_UNSET(value))\n\nHmph, this function has exactly two callers, and they call it like\nthis:\n\n\tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n\t\tenum eol eol_attr;\n\t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n\t\tif (ca->crlf_action == CRLF_UNDEFINED)\n\t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n\t\tca->attr_action = ca->crlf_action;\n\nwhere ccheck+0 refers to \"crlf\" and ccheck+4 refers to \"text\".\n\nSo, we say \"first check 'text' attribute, and if it is true we say\nCRLF_TEXT and stop.\"  We also say \"first check 'text', and if it is\nnot there, the first call returns undef, in which case we check 'crlf'\nattribute, and if it is true we say CRLF_TEXT\".\n\nAnd ca->attr_action retains this value.\n\nHowever, immediately after this assignment to ca->attr_action, we\nhave this:\n\n\t\tca->ident = git_path_check_ident(ccheck + 1);\n\t\tca->drv = git_path_check_convert(ccheck + 2);\n\t\tif (ca->crlf_action == CRLF_BINARY)\n\t\t\treturn;\n\t\teol_attr = git_path_check_eol(ccheck + 3);\n\t\tif (eol_attr == EOL_LF)\n\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n\t\telse if (eol_attr == EOL_CRLF)\n\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n\t\tca->attr_action = ca->crlf_action;\n\nWe check ident (ccheck+1) and filter (ccheck+2); if the value of\nca->crlf_action (which was determined by checking 'text' and then\n'crlf') is not CRLF_BINARY, we further check eol (ccheck+3) and\nupdate ca->crlf_action based on it.  And ca->attr_action gets\nupdated again.\n\nThis feels unnecessarily convoluted.  Perhaps if you get rid of the\nearly return for CRLF_BINARY, the flow may become a lot clearer,\ni.e.\n\n\tca->crlf_action = check 'text';\n        if (ca->crlf_action == undef)\n        \tca->crlf_action = check 'crlf';\n\t// DO NOT ASSIGN ca->attr_action HERE YET\n        ca->ident = check 'ident';\n        ca->drv = check 'filter';\n        if (crlf_action != CRLF_BINARY) {\n                eol_attr = check 'eol';\n                if (eol == LF)\n                        ca->crlf_action = ...\n                else if (eol == EOL_CRLF)\n                        ca->crlf_action = ...\n\t}\n        ca->attr_action = ca->crlf_action;\n\nHmm?\n"},{"id":"278967","messageId":"56CBED82.5040400@web.de","threadId":"41251","inReplyTo":"xmqq8u2d88ce.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 1/1] convert.c: correct attr_action","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2016-02-23T05:26:26Z","receivedAt":"2016-02-23T05:26:26Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 02/22/2016 09:20 AM, Junio C Hamano wrote:\nThanks for all the comments,\nI will send a new version the next days.\n"},{"id":"279034","messageId":"1456247239-5988-1-git-send-email-tboegi@web.de","threadId":"41251","inReplyTo":"56CBED82.5040400@web.de","subject":"[PATCH v2 1/1] convert.c: correct attr_action","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2016-02-23T17:07:19Z","receivedAt":"2016-02-23T17:07:19Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nCommit \"convert.c: refactor crlf_action\" unified the crlf_handling\nand introdused a bug for \"git ls-files --eol\".\nThe \"text\" attribute was shown as \"text eol=lf\" or \"text eol=crlf\",\ndepending on core.autpcrlf or core.eol.\nCorrect this and add test cases in t0027.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n convert.c            | 18 +++++++++---------\n t/t0027-auto-crlf.sh | 33 ++++++++++++++++++++++++++-------\n 2 files changed, 35 insertions(+), 16 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 18af685..d8b1f17 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -708,7 +708,7 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n \tconst char *value = check->value;\n \n \tif (ATTR_TRUE(value))\n-\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n+\t\treturn CRLF_TEXT;\n \telse if (ATTR_FALSE(value))\n \t\treturn CRLF_BINARY;\n \telse if (ATTR_UNSET(value))\n@@ -778,20 +778,20 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n \t}\n \n \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n-\t\tenum eol eol_attr;\n \t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n \t\tif (ca->crlf_action == CRLF_UNDEFINED)\n \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n \t\tca->attr_action = ca->crlf_action;\n \t\tca->ident = git_path_check_ident(ccheck + 1);\n \t\tca->drv = git_path_check_convert(ccheck + 2);\n-\t\tif (ca->crlf_action == CRLF_BINARY)\n-\t\t\treturn;\n-\t\teol_attr = git_path_check_eol(ccheck + 3);\n-\t\tif (eol_attr == EOL_LF)\n-\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n-\t\telse if (eol_attr == EOL_CRLF)\n-\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n+\t\tif (ca->crlf_action != CRLF_BINARY) {\n+\t\t\tenum eol eol_attr = git_path_check_eol(ccheck + 3);\n+\t\t\tif (eol_attr == EOL_LF)\n+\t\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n+\t\t\telse if (eol_attr == EOL_CRLF)\n+\t\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n+\t\t}\n+\t\tca->attr_action = ca->crlf_action;\n \t} else {\n \t\tca->drv = NULL;\n \t\tca->crlf_action = CRLF_UNDEFINED;\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex fc4c628..f33962b 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -159,6 +159,25 @@ stats_ascii () {\n \n }\n \n+\n+# contruct the attr/ returned by git ls-files --eol\n+# Take none (=empty), one or two args\n+attr_ascii () {\n+\tcase $1,$2 in\n+\t-text,*)   echo \"-text\" ;;\n+\ttext,)     echo \"text\" ;;\n+\ttext,lf)   echo \"text eol=lf\" ;;\n+\ttext,crlf) echo \"text eol=crlf\" ;;\n+\tauto,)     echo \"text=auto\" ;;\n+\tauto,lf)   echo \"text=auto eol=lf\" ;;\n+\tauto,crlf) echo \"text=auto eol=crlf\" ;;\n+\tlf,)       echo \"text eol=lf\" ;;\n+\tcrlf,)     echo \"text eol=crlf\" ;;\n+\t,) echo \"\" ;;\n+\t*) echo invalid_attr \"$1,$2\" ;;\n+\tesac\n+}\n+\n check_files_in_repo () {\n \tcrlf=$1\n \tattr=$2\n@@ -228,15 +247,15 @@ checkout_files () {\n \ttest_expect_success \"ls-files --eol attr=$attr $ident $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n \t\ttest_when_finished \"rm expect actual\" &&\n \t\tsort <<-EOF >expect &&\n-\t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n-\t\ti/mixed w/$(stats_ascii $lfmixcrlf) crlf_false_attr__CRLF_mix_LF.txt\n-\t\ti/lf w/$(stats_ascii $lfname) crlf_false_attr__LF.txt\n-\t\ti/-text w/$(stats_ascii $lfmixcr) crlf_false_attr__LF_mix_CR.txt\n-\t\ti/-text w/$(stats_ascii $crlfnul) crlf_false_attr__CRLF_nul.txt\n-\t\ti/-text w/$(stats_ascii $crlfnul) crlf_false_attr__LF_nul.txt\n+\t\ti/crlf w/$(stats_ascii $crlfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF.txt\n+\t\ti/mixed w/$(stats_ascii $lfmixcrlf) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_mix_LF.txt\n+\t\ti/lf w/$(stats_ascii $lfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF.txt\n+\t\ti/-text w/$(stats_ascii $lfmixcr) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_mix_CR.txt\n+\t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt\n+\t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt\n \t\tEOF\n \t\tgit ls-files --eol crlf_false_attr__* |\n-\t\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n-- \n2.7.0.303.g2c4f448.dirty\n"},{"id":"279066","messageId":"xmqqpovnyws9.fsf@gitster.mtv.corp.google.com","threadId":"41251","inReplyTo":"1456247239-5988-1-git-send-email-tboegi@web.de","subject":"Re: [PATCH v2 1/1] convert.c: correct attr_action","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-23T20:52:22Z","receivedAt":"2016-02-23T20:52:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> Commit \"convert.c: refactor crlf_action\" unified the crlf_handling\n> and introdused a bug for \"git ls-files --eol\".\n> The \"text\" attribute was shown as \"text eol=lf\" or \"text eol=crlf\",\n> depending on core.autpcrlf or core.eol.\n> Correct this and add test cases in t0027.\n\nSigh.  I think I typofixed this when I queued the previous version\nwhile commenting on it.\n\nDo people not pay attention to what is queued in 'pu' these days?\n\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>  convert.c            | 18 +++++++++---------\n>  t/t0027-auto-crlf.sh | 33 ++++++++++++++++++++++++++-------\n>  2 files changed, 35 insertions(+), 16 deletions(-)\n\nI looked at the interdiff from the previous version; the updated\nparts looked sensible.\n\nThanks, will queue.\n\n>\n> diff --git a/convert.c b/convert.c\n> index 18af685..d8b1f17 100644\n> --- a/convert.c\n> +++ b/convert.c\n> @@ -708,7 +708,7 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)\n>  \tconst char *value = check->value;\n>  \n>  \tif (ATTR_TRUE(value))\n> -\t\treturn text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;\n> +\t\treturn CRLF_TEXT;\n>  \telse if (ATTR_FALSE(value))\n>  \t\treturn CRLF_BINARY;\n>  \telse if (ATTR_UNSET(value))\n> @@ -778,20 +778,20 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)\n>  \t}\n>  \n>  \tif (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {\n> -\t\tenum eol eol_attr;\n>  \t\tca->crlf_action = git_path_check_crlf(ccheck + 4);\n>  \t\tif (ca->crlf_action == CRLF_UNDEFINED)\n>  \t\t\tca->crlf_action = git_path_check_crlf(ccheck + 0);\n>  \t\tca->attr_action = ca->crlf_action;\n>  \t\tca->ident = git_path_check_ident(ccheck + 1);\n>  \t\tca->drv = git_path_check_convert(ccheck + 2);\n> -\t\tif (ca->crlf_action == CRLF_BINARY)\n> -\t\t\treturn;\n> -\t\teol_attr = git_path_check_eol(ccheck + 3);\n> -\t\tif (eol_attr == EOL_LF)\n> -\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n> -\t\telse if (eol_attr == EOL_CRLF)\n> -\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n> +\t\tif (ca->crlf_action != CRLF_BINARY) {\n> +\t\t\tenum eol eol_attr = git_path_check_eol(ccheck + 3);\n> +\t\t\tif (eol_attr == EOL_LF)\n> +\t\t\t\tca->crlf_action = CRLF_TEXT_INPUT;\n> +\t\t\telse if (eol_attr == EOL_CRLF)\n> +\t\t\t\tca->crlf_action = CRLF_TEXT_CRLF;\n> +\t\t}\n> +\t\tca->attr_action = ca->crlf_action;\n>  \t} else {\n>  \t\tca->drv = NULL;\n>  \t\tca->crlf_action = CRLF_UNDEFINED;\n> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\n> index fc4c628..f33962b 100755\n> --- a/t/t0027-auto-crlf.sh\n> +++ b/t/t0027-auto-crlf.sh\n> @@ -159,6 +159,25 @@ stats_ascii () {\n>  \n>  }\n>  \n> +\n> +# contruct the attr/ returned by git ls-files --eol\n> +# Take none (=empty), one or two args\n> +attr_ascii () {\n> +\tcase $1,$2 in\n> +\t-text,*)   echo \"-text\" ;;\n> +\ttext,)     echo \"text\" ;;\n> +\ttext,lf)   echo \"text eol=lf\" ;;\n> +\ttext,crlf) echo \"text eol=crlf\" ;;\n> +\tauto,)     echo \"text=auto\" ;;\n> +\tauto,lf)   echo \"text=auto eol=lf\" ;;\n> +\tauto,crlf) echo \"text=auto eol=crlf\" ;;\n> +\tlf,)       echo \"text eol=lf\" ;;\n> +\tcrlf,)     echo \"text eol=crlf\" ;;\n> +\t,) echo \"\" ;;\n> +\t*) echo invalid_attr \"$1,$2\" ;;\n> +\tesac\n> +}\n> +\n>  check_files_in_repo () {\n>  \tcrlf=$1\n>  \tattr=$2\n> @@ -228,15 +247,15 @@ checkout_files () {\n>  \ttest_expect_success \"ls-files --eol attr=$attr $ident $aeol core.autocrlf=$crlf core.eol=$ceol\" '\n>  \t\ttest_when_finished \"rm expect actual\" &&\n>  \t\tsort <<-EOF >expect &&\n> -\t\ti/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt\n> -\t\ti/mixed w/$(stats_ascii $lfmixcrlf) crlf_false_attr__CRLF_mix_LF.txt\n> -\t\ti/lf w/$(stats_ascii $lfname) crlf_false_attr__LF.txt\n> -\t\ti/-text w/$(stats_ascii $lfmixcr) crlf_false_attr__LF_mix_CR.txt\n> -\t\ti/-text w/$(stats_ascii $crlfnul) crlf_false_attr__CRLF_nul.txt\n> -\t\ti/-text w/$(stats_ascii $crlfnul) crlf_false_attr__LF_nul.txt\n> +\t\ti/crlf w/$(stats_ascii $crlfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF.txt\n> +\t\ti/mixed w/$(stats_ascii $lfmixcrlf) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_mix_LF.txt\n> +\t\ti/lf w/$(stats_ascii $lfname) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF.txt\n> +\t\ti/-text w/$(stats_ascii $lfmixcr) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_mix_CR.txt\n> +\t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt\n> +\t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt\n>  \t\tEOF\n>  \t\tgit ls-files --eol crlf_false_attr__* |\n> -\t\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n> +\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n>  \t\tsort >actual &&\n>  \t\ttest_cmp expect actual\n>  \t'\n"}]}