#!/bin/sh global test_description := ''test conversion filters on large files'' source ./test-lib.sh proc set_attr { test_when_finished 'rm -f .gitattributes' && echo "* $ifsjoin(Argv)" >.gitattributes } proc check_input { git read-tree --empty && git add small large && git cat-file blob :small >small.index && git cat-file blob :large | head -n 1 >large.index && test_cmp small.index large.index } proc check_output { rm -f small large && git checkout small large && head -n 1 large >large.head && test_cmp small large.head } test_expect_success 'setup input tests' ' printf "\$Id: foo\$\\r\\n" >small && cat small small >large && git config core.bigfilethreshold 20 && git config filter.test.clean "sed s/.*/CLEAN/" ' test_expect_success 'autocrlf=true converts on input' ' test_config core.autocrlf true && check_input ' test_expect_success 'eol=crlf converts on input' ' set_attr eol=crlf && check_input ' test_expect_success 'ident converts on input' ' set_attr ident && check_input ' test_expect_success 'user-defined filters convert on input' ' set_attr filter=test && check_input ' test_expect_success 'setup output tests' ' echo "\$Id\$" >small && cat small small >large && git add small large && git config core.bigfilethreshold 7 && git config filter.test.smudge "sed s/.*/SMUDGE/" ' test_expect_success 'autocrlf=true converts on output' ' test_config core.autocrlf true && check_output ' test_expect_success 'eol=crlf converts on output' ' set_attr eol=crlf && check_output ' test_expect_success 'user-defined filters convert on output' ' set_attr filter=test && check_output ' test_expect_success 'ident converts on output' ' set_attr ident && rm -f small large && git checkout small large && sed -n "s/Id: .*/Id: SHA/p" small.clean && head -n 1 large >large.head && sed -n "s/Id: .*/Id: SHA/p" large.clean && test_cmp small.clean large.clean ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"test conversion filters on large files">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: set_attr body: (BraceGroup children: [ (AndOr children: [ (C {(test_when_finished)} {(SQ <"rm -f .gitattributes">)}) (SimpleCommand words: [{(echo)} {(DQ ("* ") ($ VSub_Star "$*"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(.gitattributes)} spids:[37])] ) ] op_id: Op_DAmp ) ] spids: [18] ) spids: [14 17] ) (FuncDef name: check_input body: (BraceGroup children: [ (AndOr children: [ (C {(git)} {(read-tree)} {(--empty)}) (AndOr children: [ (C {(git)} {(add)} {(small)} {(large)}) (AndOr children: [ (SimpleCommand words: [{(git)} {(cat-file)} {(blob)} {(Lit_Other ":") (small)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(small.index)} spids: [79] ) ] ) (AndOr children: [ (Pipeline children: [ (C {(git)} {(cat-file)} {(blob)} {(Lit_Other ":") (large)}) (SimpleCommand words: [{(head)} {(-n)} {(1)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(large.index)} spids: [102] ) ] ) ] negated: False ) (C {(test_cmp)} {(small.index)} {(large.index)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [47] ) spids: [43 46] ) (FuncDef name: check_output body: (BraceGroup children: [ (AndOr children: [ (C {(rm)} {(-f)} {(small)} {(large)}) (AndOr children: [ (C {(git)} {(checkout)} {(small)} {(large)}) (AndOr children: [ (SimpleCommand words: [{(head)} {(-n)} {(1)} {(large)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(large.head)} spids: [154] ) ] ) (C {(test_cmp)} {(small)} {(large.head)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [121] ) spids: [117 120] ) (C {(test_expect_success)} {(SQ <"setup input tests">)} { (SQ <"\n"> <"\tprintf \"\\$Id: foo\\$\\\\r\\\\n\" >small &&\n"> <"\tcat small small >large &&\n"> <"\tgit config core.bigfilethreshold 20 &&\n"> <"\tgit config filter.test.clean \"sed s/.*/CLEAN/\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"autocrlf=true converts on input">)} {(SQ <"\n"> <"\ttest_config core.autocrlf true &&\n"> <"\tcheck_input\n">)} ) (C {(test_expect_success)} {(SQ <"eol=crlf converts on input">)} {(SQ <"\n"> <"\tset_attr eol=crlf &&\n"> <"\tcheck_input\n">)} ) (C {(test_expect_success)} {(SQ <"ident converts on input">)} {(SQ <"\n"> <"\tset_attr ident &&\n"> <"\tcheck_input\n">)} ) (C {(test_expect_success)} {(SQ <"user-defined filters convert on input">)} {(SQ <"\n"> <"\tset_attr filter=test &&\n"> <"\tcheck_input\n">)} ) (C {(test_expect_success)} {(SQ <"setup output tests">)} { (SQ <"\n"> <"\techo \"\\$Id\\$\" >small &&\n"> <"\tcat small small >large &&\n"> <"\tgit add small large &&\n"> <"\tgit config core.bigfilethreshold 7 &&\n"> <"\tgit config filter.test.smudge \"sed s/.*/SMUDGE/\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"autocrlf=true converts on output">)} {(SQ <"\n"> <"\ttest_config core.autocrlf true &&\n"> <"\tcheck_output\n">)} ) (C {(test_expect_success)} {(SQ <"eol=crlf converts on output">)} {(SQ <"\n"> <"\tset_attr eol=crlf &&\n"> <"\tcheck_output\n">)} ) (C {(test_expect_success)} {(SQ <"user-defined filters convert on output">)} {(SQ <"\n"> <"\tset_attr filter=test &&\n"> <"\tcheck_output\n">)} ) (C {(test_expect_success)} {(SQ <"ident converts on output">)} { (SQ <"\n"> <"\tset_attr ident &&\n"> <"\trm -f small large &&\n"> <"\tgit checkout small large &&\n"> <"\tsed -n \"s/Id: .*/Id: SHA/p\" small.clean &&\n"> <"\thead -n 1 large >large.head &&\n"> <"\tsed -n \"s/Id: .*/Id: SHA/p\" large.clean &&\n"> <"\ttest_cmp small.clean large.clean\n"> ) } ) (C {(test_done)}) ] )