t / t0027-auto-crlf.shon commit gettext: add is_utf8_locale() (e8c1672)
   1#!/bin/sh
   2
   3test_description='CRLF conversion all combinations'
   4
   5. ./test-lib.sh
   6
   7if ! test_have_prereq EXPENSIVE
   8then
   9        skip_all="EXPENSIVE not set"
  10        test_done
  11fi
  12
  13compare_files () {
  14        tr '\015\000' QN <"$1" >"$1".expect &&
  15        tr '\015\000' QN <"$2" >"$2".actual &&
  16        test_cmp "$1".expect "$2".actual &&
  17        rm "$1".expect "$2".actual
  18}
  19
  20compare_ws_file () {
  21        pfx=$1
  22        exp=$2.expect
  23        act=$pfx.actual.$3
  24        tr '\015\000' QN <"$2" >"$exp" &&
  25        tr '\015\000' QN <"$3" >"$act" &&
  26        test_cmp $exp $act &&
  27        rm $exp $act
  28}
  29
  30create_gitattributes () {
  31        attr=$1
  32        case "$attr" in
  33                auto)
  34                echo "*.txt text=auto" >.gitattributes
  35                ;;
  36                text)
  37                echo "*.txt text" >.gitattributes
  38                ;;
  39                -text)
  40                echo "*.txt -text" >.gitattributes
  41                ;;
  42                crlf)
  43                echo "*.txt eol=crlf" >.gitattributes
  44                ;;
  45                lf)
  46                echo "*.txt eol=lf" >.gitattributes
  47                ;;
  48                "")
  49                echo >.gitattributes
  50                ;;
  51                *)
  52                echo >&2 invalid attribute: $attr
  53                exit 1
  54                ;;
  55        esac
  56}
  57
  58create_NNO_files () {
  59        for crlf in false true input
  60        do
  61                for attr in "" auto text -text lf crlf
  62                do
  63                        pfx=NNO_${crlf}_attr_${attr} &&
  64                        cp CRLF_mix_LF ${pfx}_LF.txt &&
  65                        cp CRLF_mix_LF ${pfx}_CRLF.txt &&
  66                        cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt &&
  67                        cp CRLF_mix_LF ${pfx}_LF_mix_CR.txt &&
  68                        cp CRLF_mix_LF ${pfx}_CRLF_nul.txt
  69                done
  70        done
  71}
  72
  73check_warning () {
  74        case "$1" in
  75        LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;;
  76        CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;;
  77        '')                                                      >"$2".expect ;;
  78        *) echo >&2 "Illegal 1": "$1" ; return false ;;
  79        esac
  80        grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" | uniq  >"$2".actual
  81        test_cmp "$2".expect "$2".actual
  82}
  83
  84commit_check_warn () {
  85        crlf=$1
  86        attr=$2
  87        lfname=$3
  88        crlfname=$4
  89        lfmixcrlf=$5
  90        lfmixcr=$6
  91        crlfnul=$7
  92        pfx=crlf_${crlf}_attr_${attr}
  93        create_gitattributes "$attr" &&
  94        for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul
  95        do
  96                fname=${pfx}_$f.txt &&
  97                cp $f $fname &&
  98                git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
  99        done &&
 100        git commit -m "core.autocrlf $crlf" &&
 101        check_warning "$lfname" ${pfx}_LF.err &&
 102        check_warning "$crlfname" ${pfx}_CRLF.err &&
 103        check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err &&
 104        check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err &&
 105        check_warning "$crlfnul" ${pfx}_CRLF_nul.err
 106}
 107
 108commit_chk_wrnNNO () {
 109        crlf=$1
 110        attr=$2
 111        lfwarn=$3
 112        crlfwarn=$4
 113        lfmixcrlf=$5
 114        lfmixcr=$6
 115        crlfnul=$7
 116        pfx=NNO_${crlf}_attr_${attr}
 117        #Commit files on top of existing file
 118        create_gitattributes "$attr" &&
 119        for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
 120        do
 121                fname=${pfx}_$f.txt &&
 122                cp $f $fname &&
 123                git -c core.autocrlf=$crlf add $fname 2>/dev/null &&
 124                git -c core.autocrlf=$crlf commit -m "commit_$fname" $fname >"${pfx}_$f.err" 2>&1
 125        done
 126
 127        test_expect_success "commit NNO files crlf=$crlf attr=$attr LF" '
 128                check_warning "$lfwarn" ${pfx}_LF.err
 129        '
 130        test_expect_success "commit NNO files crlf=$crlf attr=$attr CRLF" '
 131                check_warning "$crlfwarn" ${pfx}_CRLF.err
 132        '
 133
 134        test_expect_success "commit NNO files crlf=$crlf attr=$attr CRLF_mix_LF" '
 135                check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err
 136        '
 137
 138        test_expect_success "commit NNO files crlf=$crlf attr=$attr LF_mix_cr" '
 139                check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err
 140        '
 141
 142        test_expect_success "commit NNO files crlf=$crlf attr=$attr CRLF_nul" '
 143                check_warning "$crlfnul" ${pfx}_CRLF_nul.err
 144        '
 145}
 146
 147stats_ascii () {
 148        case "$1" in
 149        LF)
 150                echo lf
 151                ;;
 152        CRLF)
 153                echo crlf
 154                ;;
 155        CRLF_mix_LF)
 156                echo mixed
 157                ;;
 158        LF_mix_CR|CRLF_nul|LF_nul|CRLF_mix_CR)
 159                echo "-text"
 160                ;;
 161        *)
 162                echo error_invalid $1
 163                ;;
 164        esac
 165
 166}
 167
 168check_files_in_repo () {
 169        crlf=$1
 170        attr=$2
 171        lfname=$3
 172        crlfname=$4
 173        lfmixcrlf=$5
 174        lfmixcr=$6
 175        crlfnul=$7
 176        pfx=crlf_${crlf}_attr_${attr}_ &&
 177        compare_files $lfname ${pfx}LF.txt &&
 178        compare_files $crlfname ${pfx}CRLF.txt &&
 179        compare_files $lfmixcrlf ${pfx}CRLF_mix_LF.txt &&
 180        compare_files $lfmixcr ${pfx}LF_mix_CR.txt &&
 181        compare_files $crlfnul ${pfx}CRLF_nul.txt
 182}
 183
 184check_in_repo_NNO () {
 185        crlf=$1
 186        attr=$2
 187        lfname=$3
 188        crlfname=$4
 189        lfmixcrlf=$5
 190        lfmixcr=$6
 191        crlfnul=$7
 192        pfx=NNO_${crlf}_attr_${attr}_
 193        test_expect_success "compare_files $lfname ${pfx}LF.txt" '
 194                compare_files $lfname ${pfx}LF.txt
 195        '
 196        test_expect_success "compare_files $crlfname ${pfx}CRLF.txt" '
 197                compare_files $crlfname ${pfx}CRLF.txt
 198        '
 199        test_expect_success "compare_files $lfmixcrlf ${pfx}CRLF_mix_LF.txt" '
 200                compare_files $lfmixcrlf ${pfx}CRLF_mix_LF.txt
 201        '
 202        test_expect_success "compare_files $lfmixcr ${pfx}LF_mix_CR.txt" '
 203                compare_files $lfmixcr ${pfx}LF_mix_CR.txt
 204        '
 205        test_expect_success "compare_files $crlfnul ${pfx}CRLF_nul.txt" '
 206                compare_files $crlfnul ${pfx}CRLF_nul.txt
 207        '
 208}
 209
 210checkout_files () {
 211        eol=$1
 212        crlf=$2
 213        attr=$3
 214        lfname=$4
 215        crlfname=$5
 216        lfmixcrlf=$6
 217        lfmixcr=$7
 218        crlfnul=$8
 219        create_gitattributes $attr &&
 220        git config core.autocrlf $crlf &&
 221        pfx=eol_${eol}_crlf_${crlf}_attr_${attr}_ &&
 222        for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul
 223        do
 224                rm crlf_false_attr__$f.txt &&
 225                if test -z "$eol"; then
 226                        git checkout crlf_false_attr__$f.txt
 227                else
 228                        git -c core.eol=$eol checkout crlf_false_attr__$f.txt
 229                fi
 230        done
 231
 232        test_expect_success "ls-files --eol $lfname ${pfx}LF.txt" '
 233                test_when_finished "rm expect actual" &&
 234                sort <<-EOF >expect &&
 235                i/crlf w/$(stats_ascii $crlfname) crlf_false_attr__CRLF.txt
 236                i/mixed w/$(stats_ascii $lfmixcrlf) crlf_false_attr__CRLF_mix_LF.txt
 237                i/lf w/$(stats_ascii $lfname) crlf_false_attr__LF.txt
 238                i/-text w/$(stats_ascii $lfmixcr) crlf_false_attr__LF_mix_CR.txt
 239                i/-text w/$(stats_ascii $crlfnul) crlf_false_attr__CRLF_nul.txt
 240                i/-text w/$(stats_ascii $crlfnul) crlf_false_attr__LF_nul.txt
 241                EOF
 242                git ls-files --eol crlf_false_attr__* |
 243                sed -e "s!attr/[^       ]*!!g" -e "s/   / /g" -e "s/  */ /g" |
 244                sort >actual &&
 245                test_cmp expect actual
 246        '
 247        test_expect_success "checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF" "
 248                compare_ws_file $pfx $lfname    crlf_false_attr__LF.txt
 249        "
 250        test_expect_success "checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF" "
 251                compare_ws_file $pfx $crlfname  crlf_false_attr__CRLF.txt
 252        "
 253        test_expect_success "checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF_mix_LF" "
 254                compare_ws_file $pfx $lfmixcrlf crlf_false_attr__CRLF_mix_LF.txt
 255        "
 256        test_expect_success "checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_mix_CR" "
 257                compare_ws_file $pfx $lfmixcr   crlf_false_attr__LF_mix_CR.txt
 258        "
 259        test_expect_success "checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_nul" "
 260                compare_ws_file $pfx $crlfnul   crlf_false_attr__LF_nul.txt
 261        "
 262}
 263
 264# Test control characters
 265# NUL SOH CR EOF==^Z
 266test_expect_success 'ls-files --eol -o Text/Binary' '
 267        test_when_finished "rm expect actual TeBi_*" &&
 268        STRT=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA &&
 269        STR=$STRT$STRT$STRT$STRT &&
 270        printf "${STR}BBB\001" >TeBi_127_S &&
 271        printf "${STR}BBBB\001">TeBi_128_S &&
 272        printf "${STR}BBB\032" >TeBi_127_E &&
 273        printf "\032${STR}BBB" >TeBi_E_127 &&
 274        printf "${STR}BBBB\000">TeBi_128_N &&
 275        printf "${STR}BBB\012">TeBi_128_L &&
 276        printf "${STR}BBB\015">TeBi_127_C &&
 277        printf "${STR}BB\015\012" >TeBi_126_CL &&
 278        printf "${STR}BB\015\012\015" >TeBi_126_CLC &&
 279        sort <<-\EOF >expect &&
 280        i/ w/-text TeBi_127_S
 281        i/ w/none TeBi_128_S
 282        i/ w/none TeBi_127_E
 283        i/ w/-text TeBi_E_127
 284        i/ w/-text TeBi_128_N
 285        i/ w/lf TeBi_128_L
 286        i/ w/-text TeBi_127_C
 287        i/ w/crlf TeBi_126_CL
 288        i/ w/-text TeBi_126_CLC
 289        EOF
 290        git ls-files --eol -o |
 291        sed -n -e "/TeBi_/{s!attr/[     ]*!!g
 292        s!      ! !g
 293        s!  *! !g
 294        p
 295        }" | sort >actual &&
 296        test_cmp expect actual
 297'
 298
 299test_expect_success 'setup master' '
 300        echo >.gitattributes &&
 301        git checkout -b master &&
 302        git add .gitattributes &&
 303        git commit -m "add .gitattributes" "" &&
 304        printf "line1\nline2\nline3"     >LF &&
 305        printf "line1\r\nline2\r\nline3" >CRLF &&
 306        printf "line1\r\nline2\nline3"   >repoMIX &&
 307        printf "line1\r\nline2\nline3"   >CRLF_mix_LF &&
 308        printf "line1\nline2\rline3"     >LF_mix_CR &&
 309        printf "line1\r\nline2\rline3"   >CRLF_mix_CR &&
 310        printf "line1Q\r\nline2\r\nline3" | q_to_nul >CRLF_nul &&
 311        printf "line1Q\nline2\nline3" | q_to_nul >LF_nul &&
 312        create_NNO_files CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF CRLF_mix_LF &&
 313        git -c core.autocrlf=false add NNO_*.txt &&
 314        git commit -m "mixed line endings" &&
 315        test_tick
 316'
 317
 318
 319
 320warn_LF_CRLF="LF will be replaced by CRLF"
 321warn_CRLF_LF="CRLF will be replaced by LF"
 322
 323# WILC stands for "Warn if (this OS) converts LF into CRLF".
 324# WICL: Warn if CRLF becomes LF
 325# WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF
 326if test_have_prereq NATIVE_CRLF
 327then
 328        WILC=LF_CRLF
 329        WICL=
 330        WAMIX=LF_CRLF
 331else
 332        WILC=
 333        WICL=CRLF_LF
 334        WAMIX=CRLF_LF
 335fi
 336
 337#                         attr   LF        CRLF      CRLFmixLF LFmixCR   CRLFNUL
 338test_expect_success 'commit files empty attr' '
 339        commit_check_warn false ""     ""        ""        ""        ""        "" &&
 340        commit_check_warn true  ""     "LF_CRLF" ""        "LF_CRLF" ""        "" &&
 341        commit_check_warn input ""     ""        "CRLF_LF" "CRLF_LF" ""        ""
 342'
 343
 344test_expect_success 'commit files attr=auto' '
 345        commit_check_warn false "auto" "$WILC"   "$WICL"   "$WAMIX"  ""        "" &&
 346        commit_check_warn true  "auto" "LF_CRLF" ""        "LF_CRLF" ""        "" &&
 347        commit_check_warn input "auto" ""        "CRLF_LF" "CRLF_LF" ""        ""
 348'
 349
 350test_expect_success 'commit files attr=text' '
 351        commit_check_warn false "text" "$WILC"   "$WICL"   "$WAMIX"  "$WILC"   "$WICL"   &&
 352        commit_check_warn true  "text" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" ""        &&
 353        commit_check_warn input "text" ""        "CRLF_LF" "CRLF_LF" ""        "CRLF_LF"
 354'
 355
 356test_expect_success 'commit files attr=-text' '
 357        commit_check_warn false "-text" ""       ""        ""        ""        "" &&
 358        commit_check_warn true  "-text" ""       ""        ""        ""        "" &&
 359        commit_check_warn input "-text" ""       ""        ""        ""        ""
 360'
 361
 362test_expect_success 'commit files attr=lf' '
 363        commit_check_warn false "lf"    ""       "CRLF_LF" "CRLF_LF"  ""       "CRLF_LF" &&
 364        commit_check_warn true  "lf"    ""       "CRLF_LF" "CRLF_LF"  ""       "CRLF_LF" &&
 365        commit_check_warn input "lf"    ""       "CRLF_LF" "CRLF_LF"  ""       "CRLF_LF"
 366'
 367
 368test_expect_success 'commit files attr=crlf' '
 369        commit_check_warn false "crlf" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" "" &&
 370        commit_check_warn true  "crlf" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" "" &&
 371        commit_check_warn input "crlf" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" ""
 372'
 373
 374#                       attr   LF        CRLF      CRLFmixLF     LF_mix_CR   CRLFNUL
 375commit_chk_wrnNNO false ""     ""        ""        ""            ""              ""
 376commit_chk_wrnNNO true  ""     "LF_CRLF" ""        ""            ""              ""
 377commit_chk_wrnNNO input ""     ""        ""        ""            ""              ""
 378
 379
 380commit_chk_wrnNNO false "auto" "$WILC"   "$WICL"   "$WAMIX"      ""              ""
 381commit_chk_wrnNNO true  "auto" "LF_CRLF" ""        "LF_CRLF"     ""              ""
 382commit_chk_wrnNNO input "auto" ""        "CRLF_LF" "CRLF_LF"     ""              ""
 383
 384commit_chk_wrnNNO false "text" "$WILC"   "$WICL"   "$WAMIX"      "$WILC"         "$WICL"
 385commit_chk_wrnNNO true  "text" "LF_CRLF" ""        "LF_CRLF"     "LF_CRLF"       ""
 386commit_chk_wrnNNO input "text" ""        "CRLF_LF" "CRLF_LF"     ""              "CRLF_LF"
 387
 388commit_chk_wrnNNO false "-text" ""       ""        ""            ""              ""
 389commit_chk_wrnNNO true  "-text" ""       ""        ""            ""              ""
 390commit_chk_wrnNNO input "-text" ""       ""        ""            ""              ""
 391
 392commit_chk_wrnNNO false "lf"    ""       "CRLF_LF" "CRLF_LF"      ""             "CRLF_LF"
 393commit_chk_wrnNNO true  "lf"    ""       "CRLF_LF" "CRLF_LF"      ""             "CRLF_LF"
 394commit_chk_wrnNNO input "lf"    ""       "CRLF_LF" "CRLF_LF"      ""             "CRLF_LF"
 395
 396commit_chk_wrnNNO false "crlf" "LF_CRLF" ""        "LF_CRLF"     "LF_CRLF"       ""
 397commit_chk_wrnNNO true  "crlf" "LF_CRLF" ""        "LF_CRLF"     "LF_CRLF"       ""
 398commit_chk_wrnNNO input "crlf" "LF_CRLF" ""        "LF_CRLF"     "LF_CRLF"       ""
 399
 400test_expect_success 'create files cleanup' '
 401        rm -f *.txt &&
 402        git -c core.autocrlf=false reset --hard
 403'
 404
 405test_expect_success 'commit empty gitattribues' '
 406        check_files_in_repo false ""      LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
 407        check_files_in_repo true  ""      LF LF   LF          LF_mix_CR CRLF_nul &&
 408        check_files_in_repo input ""      LF LF   LF          LF_mix_CR CRLF_nul
 409'
 410
 411test_expect_success 'commit text=auto' '
 412        check_files_in_repo false "auto"  LF LF   LF          LF_mix_CR CRLF_nul &&
 413        check_files_in_repo true  "auto"  LF LF   LF          LF_mix_CR CRLF_nul &&
 414        check_files_in_repo input "auto"  LF LF   LF          LF_mix_CR CRLF_nul
 415'
 416
 417test_expect_success 'commit text' '
 418        check_files_in_repo false "text"  LF LF   LF          LF_mix_CR LF_nul &&
 419        check_files_in_repo true  "text"  LF LF   LF          LF_mix_CR LF_nul &&
 420        check_files_in_repo input "text"  LF LF   LF          LF_mix_CR LF_nul
 421'
 422
 423test_expect_success 'commit -text' '
 424        check_files_in_repo false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
 425        check_files_in_repo true  "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
 426        check_files_in_repo input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
 427'
 428
 429#                       attr    LF        CRLF      CRLF_mix_LF  LF_mix_CR      CRLFNUL
 430check_in_repo_NNO false ""      LF        CRLF      CRLF_mix_LF  LF_mix_CR      CRLF_nul
 431check_in_repo_NNO true  ""      LF        CRLF      CRLF_mix_LF  LF_mix_CR      CRLF_nul
 432check_in_repo_NNO input ""      LF        CRLF      CRLF_mix_LF  LF_mix_CR      CRLF_nul
 433
 434check_in_repo_NNO false "auto"  LF        LF        LF           LF_mix_CR      CRLF_nul
 435check_in_repo_NNO true  "auto"  LF        LF        LF           LF_mix_CR      CRLF_nul
 436check_in_repo_NNO input "auto"  LF        LF        LF           LF_mix_CR      CRLF_nul
 437
 438check_in_repo_NNO false "text"  LF        LF        LF           LF_mix_CR      LF_nul
 439check_in_repo_NNO true  "text"  LF        LF        LF           LF_mix_CR      LF_nul
 440check_in_repo_NNO input "text"  LF        LF        LF           LF_mix_CR      LF_nul
 441
 442check_in_repo_NNO false "-text" LF        CRLF      CRLF_mix_LF  LF_mix_CR      CRLF_nul
 443check_in_repo_NNO true  "-text" LF        CRLF      CRLF_mix_LF  LF_mix_CR      CRLF_nul
 444check_in_repo_NNO input "-text" LF        CRLF      CRLF_mix_LF  LF_mix_CR      CRLF_nul
 445
 446
 447################################################################################
 448# Check how files in the repo are changed when they are checked out
 449# How to read the table below:
 450# - checkout_files will check multiple files with a combination of settings
 451#   and attributes (core.autocrlf=input is forbidden with core.eol=crlf)
 452# - parameter $1 : core.eol               lf | crlf
 453# - parameter $2 : core.autocrlf          false | true | input
 454# - parameter $3 : text in .gitattributs  "" (empty) | auto | text | -text
 455# - parameter $4 : reference for a file with only LF in the repo
 456# - parameter $5 : reference for a file with only CRLF in the repo
 457# - parameter $6 : reference for a file with mixed LF and CRLF in the repo
 458# - parameter $7 : reference for a file with LF and CR in the repo (does somebody uses this ?)
 459# - parameter $8 : reference for a file with CRLF and a NUL (should be handled as binary when auto)
 460
 461#                                            What we have in the repo:
 462#                                            ----------------- EOL in repo ----------------
 463#                                            LF    CRLF  CRLF_mix_LF  LF_mix_CR    CRLF_nul
 464#                   settings with checkout:
 465#                   core.   core.   .gitattr
 466#                    eol     acrlf
 467#                                            ----------------------------------------------
 468#                                            What we want to have in the working tree:
 469if test_have_prereq NATIVE_CRLF
 470then
 471MIX_CRLF_LF=CRLF
 472MIX_LF_CR=CRLF_mix_CR
 473NL=CRLF
 474LFNUL=CRLF_nul
 475else
 476MIX_CRLF_LF=CRLF_mix_LF
 477MIX_LF_CR=LF_mix_CR
 478NL=LF
 479LFNUL=LF_nul
 480fi
 481export CRLF_MIX_LF_CR MIX NL
 482
 483checkout_files    lf      false  ""       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 484checkout_files    lf      true   ""       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 485checkout_files    lf      input  ""       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 486checkout_files    lf      false "auto"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 487checkout_files    lf      true  "auto"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul
 488checkout_files    lf      input "auto"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 489checkout_files    lf      false "text"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 490checkout_files    lf      true  "text"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 491checkout_files    lf      input "text"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 492checkout_files    lf      false "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 493checkout_files    lf      true  "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 494checkout_files    lf      input "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 495checkout_files    lf      false "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 496checkout_files    lf      true  "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 497checkout_files    lf      input "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 498checkout_files    lf      false "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 499checkout_files    lf      true  "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 500checkout_files    lf      input "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 501
 502checkout_files    crlf    false  ""       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 503checkout_files    crlf    true   ""       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 504checkout_files    crlf    false "auto"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul
 505checkout_files    crlf    true  "auto"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul
 506checkout_files    crlf    false "text"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 507checkout_files    crlf    true  "text"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 508checkout_files    crlf    false "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 509checkout_files    crlf    true  "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 510checkout_files    crlf    false "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 511checkout_files    crlf    true  "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 512checkout_files    crlf    false "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 513checkout_files    crlf    true  "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 514
 515checkout_files    ""      false  ""       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 516checkout_files    ""      true   ""       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 517checkout_files    ""      input  ""       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 518checkout_files    ""      false "auto"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul
 519checkout_files    ""      true  "auto"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul
 520checkout_files    ""      input "auto"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 521checkout_files    ""      false "text"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL
 522checkout_files    ""      true  "text"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 523checkout_files    ""      input "text"    LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 524checkout_files    ""      false "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 525checkout_files    ""      true  "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 526checkout_files    ""      input "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 527checkout_files    ""      false "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 528checkout_files    ""      true  "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 529checkout_files    ""      input "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 530checkout_files    ""      false "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 531checkout_files    ""      true  "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 532checkout_files    ""      input "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 533
 534checkout_files    native  false  ""       LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 535checkout_files    native  true   ""       CRLF  CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 536checkout_files    native  false "auto"    $NL   CRLF  $MIX_CRLF_LF LF_mix_CR    LF_nul
 537checkout_files    native  true  "auto"    CRLF  CRLF  CRLF         LF_mix_CR    LF_nul
 538checkout_files    native  false "text"    $NL   CRLF  $MIX_CRLF_LF $MIX_LF_CR   $LFNUL
 539checkout_files    native  true  "text"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 540checkout_files    native  false "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 541checkout_files    native  true  "-text"   LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 542checkout_files    native  false "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 543checkout_files    native  true  "lf"      LF    CRLF  CRLF_mix_LF  LF_mix_CR    LF_nul
 544checkout_files    native  false "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 545checkout_files    native  true  "crlf"    CRLF  CRLF  CRLF         CRLF_mix_CR  CRLF_nul
 546
 547# Should be the last test case: remove some files from the worktree
 548test_expect_success 'ls-files --eol -d -z' '
 549        rm crlf_false_attr__CRLF.txt crlf_false_attr__CRLF_mix_LF.txt crlf_false_attr__LF.txt .gitattributes &&
 550        cat >expect <<-\EOF &&
 551        i/crlf w/ crlf_false_attr__CRLF.txt
 552        i/lf w/ .gitattributes
 553        i/lf w/ crlf_false_attr__LF.txt
 554        i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
 555        EOF
 556        git ls-files --eol -d |
 557        sed -e "s!attr/[^       ]*!!g" -e "s/   / /g" -e "s/  */ /g" |
 558        sort >actual &&
 559        test_cmp expect actual
 560'
 561
 562test_done