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