3 test_description
='test conversion filters on large files'
7 test_when_finished
'rm -f .gitattributes' &&
8 echo "* $*" >.gitattributes
12 git read-tree
--empty &&
13 git add small large
&&
14 git cat-file blob
:small
>small.index
&&
15 git cat-file blob
:large |
head -n 1 >large.index
&&
16 test_cmp small.index large.index
21 git checkout small large
&&
22 head -n 1 large
>large.
head &&
23 test_cmp small large.
head
26 test_expect_success
'setup input tests' '
27 printf "\$Id: foo\$\\r\\n" >small &&
28 cat small small >large &&
29 git config core.bigfilethreshold 20 &&
30 git config filter.test.clean "sed s/.*/CLEAN/"
33 test_expect_success
'autocrlf=true converts on input' '
34 test_config core.autocrlf true &&
38 test_expect_success
'eol=crlf converts on input' '
43 test_expect_success
'ident converts on input' '
48 test_expect_success
'user-defined filters convert on input' '
49 set_attr filter=test &&
53 test_expect_success
'setup output tests' '
54 echo "\$Id\$" >small &&
55 cat small small >large &&
56 git add small large &&
57 git config core.bigfilethreshold 7 &&
58 git config filter.test.smudge "sed s/.*/SMUDGE/"
61 test_expect_success
'autocrlf=true converts on output' '
62 test_config core.autocrlf true &&
66 test_expect_success
'eol=crlf converts on output' '
71 test_expect_success
'user-defined filters convert on output' '
72 set_attr filter=test &&
76 test_expect_success
'ident converts on output' '
79 git checkout small large &&
80 sed -n "s/Id: .*/Id: SHA/p" <small >small.clean &&
81 head -n 1 large >large.head &&
82 sed -n "s/Id: .*/Id: SHA/p" <large.head >large.clean &&
83 test_cmp small.clean large.clean
86 # This smudge filter prepends 5GB of zeros to the file it checks out. This
87 # ensures that smudging doesn't mangle large files on 64-bit Windows.
88 test_expect_success EXPENSIVE
,SIZE_T_IS_64BIT
,!LONG_IS_64BIT \
89 'files over 4GB convert on output' '
90 test_commit test small "a small file" &&
91 small_size=$(test_file_size small) &&
92 test_config filter.makelarge.smudge \
93 "test-tool genzeros $((5*1024*1024*1024)) && cat" &&
94 echo "small filter=makelarge" >.gitattributes &&
96 git checkout -- small &&
97 size=$(test_file_size small) &&
98 test "$size" -eq $((5 * 1024 * 1024 * 1024 + $small_size))
101 # This clean filter writes down the size of input it receives. By checking against
102 # the actual size, we ensure that cleaning doesn't mangle large files on 64-bit Windows.
103 test_expect_success EXPENSIVE
,SIZE_T_IS_64BIT
,!LONG_IS_64BIT \
104 'files over 4GB convert on input' '
105 test-tool genzeros $((5*1024*1024*1024)) >big &&
106 test_config filter.checklarge.clean "wc -c >big.size" &&
107 echo "big filter=checklarge" >.gitattributes &&
109 test $(test_file_size big) -eq $(cat big.size)