merge-tree: accept 3 trees as arguments
[git.git] / t / t1051-large-conversion.sh
blobf6709c9f569ec7170d24694b369abf0d6f8518ec
1 #!/bin/sh
3 test_description='test conversion filters on large files'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 set_attr() {
9 test_when_finished 'rm -f .gitattributes' &&
10 echo "* $*" >.gitattributes
13 check_input() {
14 git read-tree --empty &&
15 git add small large &&
16 git cat-file blob :small >small.index &&
17 git cat-file blob :large | head -n 1 >large.index &&
18 test_cmp small.index large.index
21 check_output() {
22 rm -f small large &&
23 git checkout small large &&
24 head -n 1 large >large.head &&
25 test_cmp small large.head
28 test_expect_success 'setup input tests' '
29 printf "\$Id: foo\$\\r\\n" >small &&
30 cat small small >large &&
31 git config core.bigfilethreshold 20 &&
32 git config filter.test.clean "sed s/.*/CLEAN/"
35 test_expect_success 'autocrlf=true converts on input' '
36 test_config core.autocrlf true &&
37 check_input
40 test_expect_success 'eol=crlf converts on input' '
41 set_attr eol=crlf &&
42 check_input
45 test_expect_success 'ident converts on input' '
46 set_attr ident &&
47 check_input
50 test_expect_success 'user-defined filters convert on input' '
51 set_attr filter=test &&
52 check_input
55 test_expect_success 'setup output tests' '
56 echo "\$Id\$" >small &&
57 cat small small >large &&
58 git add small large &&
59 git config core.bigfilethreshold 7 &&
60 git config filter.test.smudge "sed s/.*/SMUDGE/"
63 test_expect_success 'autocrlf=true converts on output' '
64 test_config core.autocrlf true &&
65 check_output
68 test_expect_success 'eol=crlf converts on output' '
69 set_attr eol=crlf &&
70 check_output
73 test_expect_success 'user-defined filters convert on output' '
74 set_attr filter=test &&
75 check_output
78 test_expect_success 'ident converts on output' '
79 set_attr ident &&
80 rm -f small large &&
81 git checkout small large &&
82 sed -n "s/Id: .*/Id: SHA/p" <small >small.clean &&
83 head -n 1 large >large.head &&
84 sed -n "s/Id: .*/Id: SHA/p" <large.head >large.clean &&
85 test_cmp small.clean large.clean
88 # This smudge filter prepends 5GB of zeros to the file it checks out. This
89 # ensures that smudging doesn't mangle large files on 64-bit Windows.
90 test_expect_success EXPENSIVE,SIZE_T_IS_64BIT,!LONG_IS_64BIT \
91 'files over 4GB convert on output' '
92 test_commit test small "a small file" &&
93 small_size=$(test_file_size small) &&
94 test_config filter.makelarge.smudge \
95 "test-tool genzeros $((5*1024*1024*1024)) && cat" &&
96 echo "small filter=makelarge" >.gitattributes &&
97 rm small &&
98 git checkout -- small &&
99 size=$(test_file_size small) &&
100 test "$size" -eq $((5 * 1024 * 1024 * 1024 + $small_size))
103 # This clean filter writes down the size of input it receives. By checking against
104 # the actual size, we ensure that cleaning doesn't mangle large files on 64-bit Windows.
105 test_expect_success EXPENSIVE,SIZE_T_IS_64BIT,!LONG_IS_64BIT \
106 'files over 4GB convert on input' '
107 test-tool genzeros $((5*1024*1024*1024)) >big &&
108 test_config filter.checklarge.clean "wc -c >big.size" &&
109 echo "big filter=checklarge" >.gitattributes &&
110 git add big &&
111 test $(test_file_size big) -eq $(cat big.size)
114 test_done