submodule--helper: fix initialization of warn_if_uninitialized
[git.git] / t / t1051-large-conversion.sh
blob042b0e442929b427d48049610e89810a495903bb
1 #!/bin/sh
3 test_description='test conversion filters on large files'
4 . ./test-lib.sh
6 set_attr() {
7 test_when_finished 'rm -f .gitattributes' &&
8 echo "* $*" >.gitattributes
11 check_input() {
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
19 check_output() {
20 rm -f small large &&
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 &&
35 check_input
38 test_expect_success 'eol=crlf converts on input' '
39 set_attr eol=crlf &&
40 check_input
43 test_expect_success 'ident converts on input' '
44 set_attr ident &&
45 check_input
48 test_expect_success 'user-defined filters convert on input' '
49 set_attr filter=test &&
50 check_input
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 &&
63 check_output
66 test_expect_success 'eol=crlf converts on output' '
67 set_attr eol=crlf &&
68 check_output
71 test_expect_success 'user-defined filters convert on output' '
72 set_attr filter=test &&
73 check_output
76 test_expect_success 'ident converts on output' '
77 set_attr ident &&
78 rm -f small large &&
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 &&
95 rm small &&
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 &&
108 git add big &&
109 test $(test_file_size big) -eq $(cat big.size)
112 test_done