(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'CRLF conversion'>)} spids: [4] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShFunction name: has_cr body: (BraceGroup children: [ (command.Pipeline children: [ (command.Simple words: [{<tr>} {(SQ <'\\015'>)} {<Q>}] redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {(DQ ($ Id.VSub_Number '$1'))} ) ] do_fork: T ) (command.Simple words: [{<grep>} {<Q>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<'/dev/null'>} ) ] do_fork: T ) ] negated: F ) ] ) ) (C {<test_expect_success>} {<setup>} { (SQ <'\n'> <'\n'> <'\tgit config core.autocrlf false &&\n'> <'\n'> <'\tfor w in Hello world how are you; do echo $w; done >LFonly &&\n'> <'\tfor w in I am very very fine thank you; do echo ${w}Q; done | q_to_cr >CRLFonly &&\n'> < '\tfor w in Oh here is a QNUL byte how alarming; do echo ${w}; done | q_to_nul >LFwithNUL &&\n' > <'\tgit add . &&\n'> <'\n'> <'\tgit commit -m initial &&\n'> <'\n'> <'\tLFonly=$(git rev-parse HEAD:LFonly) &&\n'> <'\tCRLFonly=$(git rev-parse HEAD:CRLFonly) &&\n'> <'\tLFwithNUL=$(git rev-parse HEAD:LFwithNUL) &&\n'> <'\n'> <'\techo happy.\n'> ) } ) (C {<test_expect_success>} {(SQ <'default settings cause no changes'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\t! has_cr LFonly &&\n'> <'\thas_cr CRLFonly &&\n'> <'\tLFonlydiff=$(git diff LFonly) &&\n'> <'\tCRLFonlydiff=$(git diff CRLFonly) &&\n'> <'\tLFwithNULdiff=$(git diff LFwithNUL) &&\n'> <'\ttest -z "$LFonlydiff" -a -z "$CRLFonlydiff" -a -z "$LFwithNULdiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'crlf=true causes a CRLF file to be normalized'>)} { (SQ <'\n'> <'\n'> <'\t# Backwards compatibility check\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\techo "CRLFonly crlf" > .gitattributes &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\t# Note, "normalized" means that git will normalize it if added\n'> <'\thas_cr CRLFonly &&\n'> <'\tCRLFonlydiff=$(git diff CRLFonly) &&\n'> <'\ttest -n "$CRLFonlydiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'text=true causes a CRLF file to be normalized'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\techo "CRLFonly text" > .gitattributes &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\t# Note, "normalized" means that git will normalize it if added\n'> <'\thas_cr CRLFonly &&\n'> <'\tCRLFonlydiff=$(git diff CRLFonly) &&\n'> <'\ttest -n "$CRLFonlydiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'eol=crlf gives a normalized file CRLFs with autocrlf=false'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\tgit config core.autocrlf false &&\n'> <'\techo "LFonly eol=crlf" > .gitattributes &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\thas_cr LFonly &&\n'> <'\tLFonlydiff=$(git diff LFonly) &&\n'> <'\ttest -z "$LFonlydiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'eol=crlf gives a normalized file CRLFs with autocrlf=input'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\tgit config core.autocrlf input &&\n'> <'\techo "LFonly eol=crlf" > .gitattributes &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\thas_cr LFonly &&\n'> <'\tLFonlydiff=$(git diff LFonly) &&\n'> <'\ttest -z "$LFonlydiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'eol=lf gives a normalized file LFs with autocrlf=true'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\tgit config core.autocrlf true &&\n'> <'\techo "LFonly eol=lf" > .gitattributes &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\t! has_cr LFonly &&\n'> <'\tLFonlydiff=$(git diff LFonly) &&\n'> <'\ttest -z "$LFonlydiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'autocrlf=true does not normalize CRLF files'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\tgit config core.autocrlf true &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\thas_cr LFonly &&\n'> <'\thas_cr CRLFonly &&\n'> <'\tLFonlydiff=$(git diff LFonly) &&\n'> <'\tCRLFonlydiff=$(git diff CRLFonly) &&\n'> <'\tLFwithNULdiff=$(git diff LFwithNUL) &&\n'> <'\ttest -z "$LFonlydiff" -a -z "$CRLFonlydiff" -a -z "$LFwithNULdiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'text=auto, autocrlf=true does not normalize CRLF files'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\tgit config core.autocrlf true &&\n'> <'\techo "* text=auto" > .gitattributes &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\thas_cr LFonly &&\n'> <'\thas_cr CRLFonly &&\n'> <'\tLFonlydiff=$(git diff LFonly) &&\n'> <'\tCRLFonlydiff=$(git diff CRLFonly) &&\n'> <'\tLFwithNULdiff=$(git diff LFwithNUL) &&\n'> <'\ttest -z "$LFonlydiff" -a -z "$CRLFonlydiff" -a -z "$LFwithNULdiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'text=auto, autocrlf=true does not normalize binary files'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\tgit config core.autocrlf true &&\n'> <'\techo "* text=auto" > .gitattributes &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\t! has_cr LFwithNUL &&\n'> <'\tLFwithNULdiff=$(git diff LFwithNUL) &&\n'> <'\ttest -z "$LFwithNULdiff"\n'> ) } ) (C {<test_expect_success>} {(SQ <'eol=crlf _does_ normalize binary files'>)} { (SQ <'\n'> <'\n'> <'\trm -f .gitattributes tmp LFonly CRLFonly LFwithNUL &&\n'> <'\techo "LFwithNUL eol=crlf" > .gitattributes &&\n'> <'\tgit read-tree --reset -u HEAD &&\n'> <'\n'> <'\thas_cr LFwithNUL &&\n'> <'\tLFwithNULdiff=$(git diff LFwithNUL) &&\n'> <'\ttest -z "$LFwithNULdiff"\n'> ) } ) (C {<test_done>}) ] )