]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1051-large-conversion.sh
Merge branch 'jk/clone-allow-bare-and-o-together'
[thirdparty/git.git] / t / t1051-large-conversion.sh
CommitLineData
4f22b101
JK
1#!/bin/sh
2
3test_description='test conversion filters on large files'
27472b51
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
4f22b101
JK
6. ./test-lib.sh
7
8set_attr() {
9 test_when_finished 'rm -f .gitattributes' &&
10 echo "* $*" >.gitattributes
11}
12
13check_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
19}
20
21check_output() {
22 rm -f small large &&
23 git checkout small large &&
24 head -n 1 large >large.head &&
25 test_cmp small large.head
26}
27
28test_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/"
33'
34
35test_expect_success 'autocrlf=true converts on input' '
36 test_config core.autocrlf true &&
37 check_input
38'
39
40test_expect_success 'eol=crlf converts on input' '
41 set_attr eol=crlf &&
42 check_input
43'
44
45test_expect_success 'ident converts on input' '
46 set_attr ident &&
47 check_input
48'
49
50test_expect_success 'user-defined filters convert on input' '
51 set_attr filter=test &&
52 check_input
53'
54
55test_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/"
61'
62
63test_expect_success 'autocrlf=true converts on output' '
64 test_config core.autocrlf true &&
65 check_output
66'
67
68test_expect_success 'eol=crlf converts on output' '
69 set_attr eol=crlf &&
70 check_output
71'
72
73test_expect_success 'user-defined filters convert on output' '
74 set_attr filter=test &&
75 check_output
76'
77
78test_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
86'
87
b79541af
MC
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.
e9aa762c 90test_expect_success EXPENSIVE,SIZE_T_IS_64BIT,!LONG_IS_64BIT \
b79541af
MC
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))
101'
102
596b5e77
MC
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.
105test_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)
112'
113
4f22b101 114test_done